18
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$.
Rules:
- as matrix you can use any convenient representation you like e.g. a list of lists etc...
- matrix values can be positive and/or negative integer numbers
- \$n\$ and \$m\$ are of course always positive integers between 1 and 10
- \$i\$ can be any valid integer which belongs in the following range: \${0...10^5}\$
- Standard code-golf rules & winning criteria apply but no "winning" answer will be chosen.
EDIT: I had to edit the initial question because for some programming languages it takes too long to compute the result for \$i\in\{0...10^7\}\$. There is a workaround to it but since it's a code-golf just make sure that it simply runs successfully for at least \$i\in\{0...10^5\}\$.
Some test cases:
==== example 1 ====
Input:
5
[[1, 3, 2, 30,],
[4, 9, 7, 10,],
[6, 8, 5, 25 ]]
Expected Output:
[[ 6 4 1],
[ 8 9 3],
[ 5 7 2],
[25 10 30]]
==== example 2 ====
Input:
100
[[1]]
Expected Output:
[[1]]
==== example 3 ====
Input:
15
[[150, 3, 2],
[ 4, -940, 7],
[ 6, 8000, 5]]
Expected Output:
[[ 2 7 5],
[ 3 -940 8000],
[ 150 4 6]]
==== example 4 ====
Input:
40001
[[1, 3, 9]]
Expected Output:
[[1],
[3],
[9]]
```
2
Nice, I really liked that it even works for $i$ of $10^7$. I had to lower that in the requirements because for some languages tio.run wouldn't terminate...
– game0ver – 2019-11-27T23:24:58.3131@game0ver Yeah, APL is generally quite fast when it comes to munging arrays. Even $10^8$ only takes about 20 seconds on TIO. – Adám – 2019-11-27T23:35:02.083
2Wow, the character for transpose and mirror looks suitable – justhalf – 2019-11-29T05:35:16.947
@justhalf Yes, APL is like that. Can you guess what flip-upside-down looks like? – Adám – 2019-11-29T08:32:04.263
Something like this ⦵? – justhalf – 2019-11-29T09:03:06.053
1
@justhalf Basically. Unicode has many homoglyphs. APL prefers the Unicode APL range, so this is
– Adám – 2019-11-29T11:50:12.643⊖