Created
December 3, 2014 11:52
-
-
Save kvalv/0755bf3fdf512501962d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #(5#%)#Skriv#metoden#new_level#som#tar#inn#en#liste#(endimensjonal#tabell),# | |
| list,#bestående#av#15#heltall#i#tilfeldig#rekkefølge#som#vist#i#figur#3.#Metoden#skal# | |
| returnere#en#4x4Utabell#der#tallene#i#list#er#satt#inn#fortløpende,#radvis,#fra#rad#0,# | |
| kolonne#0,#til#rad#3,#kolonne#2.#Elementet#med#indeks#3,3#skal#ha#verdien#0. | |
| #input: a table with 15 elements, each element is between 1 and 15, all elements are unique | |
| def new_level(table): | |
| a = [[] for i in range(4)] | |
| ctr = 0 | |
| for i in range(4): | |
| for j in range(4): | |
| if ctr != 15: | |
| a[i].append(table[ctr]) | |
| ctr+=1 | |
| a[3].append(0) | |
| return a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment