# Problems with Q1 Data generator exercise

Output for questions in batch 1 has the wrong size.
Expected (3, 32).
Got (3,).
Output for questions in batch 2 has the wrong size.
Expected (3, 32).
Got (3,).
Wrong output for questions in batch 1.
Expected [[ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 1 1 1
1 1 1 1 1 1 1 1]
[32 33 4 34 6 35 36 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1]
[32 38 4 41 11 42 43 44 45 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1]].
Got [list([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])
list([32, 33, 4, 34, 6, 35, 36, 21, 1, 1, 1, 1, 1, 1, 1, 1])
list([32, 38, 4, 41, 11, 42, 43, 44, 45, 21, 1, 1, 1, 1, 1, 1])].
Wrong output for questions in batch 2.
Expected [[ 4 22 6 23 7 24 8 25 26 11 27 28 7 29 30 16 31 18 19 20 21 1 1 1
1 1 1 1 1 1 1 1]
[30 37 4 38 39 34 6 40 36 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1]
[32 33 4 46 47 43 48 45 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1]].
Got [list([4, 22, 6, 23, 7, 24, 8, 25, 26, 11, 27, 28, 7, 29, 30, 16, 31, 18, 19, 20, 21])
list([30, 37, 4, 38, 39, 34, 6, 40, 36, 21, 1, 1, 1, 1, 1, 1])
list([32, 33, 4, 46, 47, 43, 48, 45, 21, 1, 1, 1, 1, 1, 1, 1])].
Output for questions in batch 1 has the wrong size.
Expected (5, 32).
Got (5,).
Output for questions in batch 2 has the wrong size.
Expected (5, 32).
Got (5,).
Wrong output for questions in batch 1.
Expected [[ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1]
[30 55 56 57 58 59 60 21 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1]
[30 61 6 62 63 64 65 66 67 68 69 70 71 72 73 74 75 21 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1]
[32 33 4 34 6 35 36 21 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1]
[86 87 88 89 90 91 92 93 17 87 94 95 72 96 21 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1]].
Got [list([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])
list([30, 55, 56, 57, 58, 59, 60, 21, -1, -1, -1, -1, -1, -1, -1, -1])
list([30, 61, 6, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 21])
list([32, 33, 4, 34, 6, 35, 36, 21, -1, -1, -1, -1, -1, -1, -1, -1])
list([86, 87, 88, 89, 90, 91, 92, 93, 17, 87, 94, 95, 72, 96, 21, -1])].
Wrong output for questions in batch 2.
Expected [[ 4 22 6 23 7 24 8 25 26 11 27 28 7 29 30 16 31 18
19 20 21 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
[ 30 55 56 57 58 59 21 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
[ 32 76 6 62 63 77 78 71 79 28 80 81 82 39 83 28 80 21
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
[ 30 37 4 38 39 34 6 40 36 21 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
[ 86 38 97 98 90 93 99 33 34 95 100 101 96 21 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]].
Got [list([4, 22, 6, 23, 7, 24, 8, 25, 26, 11, 27, 28, 7, 29, 30, 16, 31, 18, 19, 20, 21])
list([30, 55, 56, 57, 58, 59, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1])
list([32, 76, 6, 62, 63, 77, 78, 71, 79, 28, 80, 81, 82, 39, 83, 28, 80, 21])
list([30, 37, 4, 38, 39, 34, 6, 40, 36, 21, -1, -1, -1, -1, -1, -1])
list([86, 38, 97, 98, 90, 93, 99, 33, 34, 95, 100, 101, 96, 21, -1, -1])].
0 Tests passed
8 Tests failed

The answers to the exercise match perfectly, but the tests fail. Any help will be much appreciated.

I will not be specific but this might help you

The error message suggests that the function is returning the wrong size of output. The expected size of the output is (3, 32) or (5, 32) for batch 1 and batch 2 respectively, but the returned output has the size (3,) or (5,). This means that the function is returning a 1-dimensional array of lists, instead of a 2-dimensional array.

There are several reasons why this error might occur:

• There might be an issue with how the output is being constructed in the function. For example, the function might not be correctly appending the elements to the output array or it might be using the wrong data type (e.g. list instead of numpy array)
• The function might not be handling edge cases correctly, such as when the input has a different size than expected.
• There might be a mistake in the expected output provided in the test case.

It’s recommended to check the implementation of the function and the test case to identify the source of the error. Also, you can check the shape of your output and compare it with the expected shape. It’s also important to check the expected output and compare it with the output generated by the function to understand why it’s not passing the test cases.

Regards
Muhammad John Abbas

Hey @Rama_Mahajanam,
The error is pretty simple. You haven’t performed the padding for `q1` and `q2`. As a result, all the lists are of variable length. And when you try to convert a list of lists (where each individual list has a different length) into a numpy array, it creates a 1D array of lists, instead of a 2D array of integers, as we expect in this case. For more reference, you can check this thread out. I hope this helps.

Cheers,
Elemento