The goal is to write a program that rotates any two-dimensional list by 45 degrees, it must be able to do this up to 7*45 (at once) before returning the list. The list will not necessarily be square or rectangular. You must include output for the examples in your answer. It must also work for cases that are not in the examples... circles, triangles etc. You cannot use a pre-existing function to do the whole thing.
All lists will have at least one axis of symmetry (N,S,E,W). All sublists are to be assumed as center-aligned. Odd-even lists will shift to the left one to align properly. See example 4 for gaps in the middle of a sublist.
Your program will use a variable named
l containing the list, and a variable named
n specifying the amount the list will be rotated (n*45) (
n will always be less than 7, and can be 0). It will have to accept
l containing sublists of any printable data type (decimal, List, int, String.. etc), but sublists will only contain one data type at a time.
You do not need to accept console input or use stdin. The lines specifying the test values of
n are not included in the character count, but must be included in the submitted code.
Your program must print the list in the correct orientation, NIL can be used to pad lists if you desire, but padding is not necessary (you get a smiley face if they are padded, though). Sub-lists do not have to be indented or separated by newlines as in the examples.
IN l= [[0 , 1 , 2], [3 , 4 , 5], [6 , 7 , 8]] n=1 OUT [ , [3 , 1], [6 , 4 , 2], [7 , 5],  ]
IN l= [[a , b , c , d], [e , f , g , h]] n=2 OUT [[e , a], [f , b], [c , g], [h , d]]
IN l= [[A , B , C , D , E , F], [G , H , I , J], [K , L], [0 , 8], [M , N], [O , P , Q , R], [S , T , U , V , W , X]] n=7 OUT [ [F], [E], [D , J], [C , I], [B , H , L], [A , G , K , 8], [0 , N , R , X], [M , Q , W], [P , V], [O , U], [T], [U] ]
IN l= [[9 , 8 , 7 , 6], , [4 , 3 , 2 , 1],  ] n=3 OUT [ [0 , 4], , [2 , 5 , 9], [1 ,NIL, 8], , , ]
IN l= [ [Q], [X ,NIL, Y], [Z] ] n=2 OUT [ [X], [Z ,NIL, Q], [Y] ]