Question 150 Max. score: 6.00 Paul and Lisa are best friends and always love to play…
- User
Question 150
Max. score: 6.00
Paul and Lisa are best friends and always love to play games. Paul gives a Dice to Lisa. But the dice has F number of faces numbered from [ 1, 2 ,.....,F]. To make the game a little challenging Paul restricts the number of throws to N Le Lisa should throw the dice only N times, not less than or greater than N times. And Lisa should find the number of times the sum of faces of N throws is equal to the given sum S.
Example:
N = 2
F = 3
s = 4
The possibilities are
12,2|= 2 + 2 - 4
{1, 3} = 1 + 3 = 4
{3, 1} = 3 + 1 = 4
The total number of possibilities are 3
Note: [1,3] and [31] both are considered
Lisa implemented a function count_ways that takes N, F. S as input and returns the total number of possibilities. But Lisa was stuck at Line 11.
Pseudocode
15
16
17
18
FUNCTION count ways (N, F, S)
IF sum n = 1 to n sin theta \in binomial(n,2) AND S--0
RETURN 1
ELES IF N-0
RETURN Which of the following code snippets will best fit in Line 11 so that function always returns the correct output.
4
Code snippets
1
5
ans ans + count ways (N-1, F-1, S-1)
30
8
ans = ans + count ways (N-1, F, S).
ang and count ways (N-1, F, S-1)
ana ans count ways (N-1, F-1, S)
- Assistant
The problem requires calculating the number of ways to achieve a specific sum using a limited number of dice rolls with a certain number of faces. Let's analyze the task and understand how to best fit the solution.
The function
count_ways(N, F, S)computes the number of ways to obtain the sumSusingNthrows of a dice withFfaces. When thinking about possible solutions, you determine how each face value can contribute to the target sumS.To approach this recursively:
- User
Question 11
Max. score: 6.00
in PySpark, which of these options can be the cause of the following error in the 'main' org.apache.spark.sql.AnalysisException.
Exception:
resolved attribute(s) surname#20 missing from id#0,birthDate#3,name#10.surname#7 in operator Project [Id#0,birthDate#3,name#10,surname#20.UDF(birthDate#3) AS birthDate_cleaned#8).
Options:
- This extor usually happens when there are two data frames and you apply UDF on some columns to transfer, aggregate, and rejoin to add as new lields on a new data frame
2.This errot usually happens when there are two data frames and you apply UDF on some columns to transfer and add new fields on a new data frame.
3.This error usually happens when there are two data frames and you apply UDF on some columns and add new fields on a new data frame.
1
3
4
5
6
7
2
9
10
3
Cannot be determined.
Reset Artwer
12
13
Previous Question
- Assistant
The
org.apache.spark.sql.AnalysisExceptionin Apache Spark typically arises due to issues involving unresolved columns or schema mismatches. This specific error message is indicating that there is a "missing" resolved attributesurname#20that the operationProjectis trying to select, but it's not available in the dataset's current schema.Analyzing the options provided:
-
When dealing with two data frames, if you apply a UDF on some columns to transform, aggregate, and rejoin additional fields into a new data frame, you might encounter issues if the joined fields or columns aren't correctly aligned or resolved.
-
- User
Give only correct answer
- Assistant
The correct answer is:
- This error usually happens when there are two data frames and you apply UDF on some columns to transfer, aggregate, and rejoin to add as new fields on a new data frame.