-
-
Save beltiras/e5726f16d05524f42c23b73687519c07 to your computer and use it in GitHub Desktop.
This file contains 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
def user_input_dimentions(): | |
not_correct_input = True | |
while not_correct_input == True: | |
try: | |
boardDimentions = int(input("enter width of board: ")) | |
not_correct_input = False | |
except ValueError: | |
print("please stop being an idiot") | |
return boardDimentions | |
def make_board(boardDimentions): | |
width_list = [] | |
for i in range(boardDimentions): | |
for j in range(boardDimentions): | |
#print(str((j+1)+(i*boardDimentions)) + " ", end='') | |
width_list.append(int((j+1)+(i*boardDimentions))) | |
chunks = [width_list[x:x+boardDimentions] for x in range(0, len(width_list), boardDimentions)] | |
#print(width_list) | |
#print(chunks) | |
return chunks | |
def make_col(a_list_of_lists): | |
columns = [] | |
for i in range(len(a_list_of_lists)): | |
columns.append([l[i] fir l in a_list_of_lists]) | |
return a_list_of_lists | |
""" | |
allColumns = [] | |
for j in range(len(a_list_of_lists)): # hér var list, sem er type, en ekki parameterinn sem þú tókst inn | |
column = [ listi[i][j] for i in range(len(a_list_of_lists)) ] | |
allColumns.append(column) | |
print(column) | |
""" | |
def main(): | |
board_list = make_board(user_input_dimentions()) | |
make_col(board_list) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment