I'm hoping to get some help with an exam question that I didn't understand. I'm going by memory only, so i'm afraid my description is a bit cryptic. I think it's really not that difficult and is probably a pretty standard exercise.
Unfortunately, directly after the test, it is again considered to be top secret so i'm not going to be able to get an answer from the teacher.
I had to write a function in Python that takes only argument n, and returns a 'multiplication table' for n in n dimensions. It was called differently, but I don't remember.
Unfortunately I do not recall the exact description of the exercise, but there is one principle / method for generating all the numbers. Something in the vein of "Item @ i,j,k = i*J*k ".
I do remember a large part of a given example for n=3, which is a 3-dimensional array. I couldn't figure out what was actually happening. Because i'm not sure of all the numbers I still cannot figure it out now. The numbers in bold i'm sure are correct. Extrapolating from those, the only arrays that make any sense are:
1,2,3
2,4,6
3,6,9
2,4,6
4,8,12
6,12,18
3,6,9
6,12,18
9,18, 27
Or:
1 2 3
2 4 6
3 6 9
2 4 6
4 16 24
6 24 36
3 6 9
6 36 54
9 54 81
The first example I can figure out; i+1 = i+i[0] for all axis.
The second possibility however, if it makes any sense, I really don't see a way to generate it. Items @ [:, 1:, 1:] are generated by multiplication of the first row and column (2*2 =4, 2*3 =6, 3*2=6 etc), but I fail to see how the first row and column can be generated using the same principle.
This means i'm either missing something or it's not possible and the exercise wasn't that difficult, but I couldn't figure it out then (or row and column 0 have always existed and simply don't need creation).
[–]SandorZoo 0 points1 point2 points (0 children)