Second answer, horrible kludge
This commit is contained in:
16
05/e.py
16
05/e.py
@@ -19,6 +19,8 @@ for i in [1, 5, 9, 13, 17, 21, 25, 29, 33]:
|
||||
temp.append(stack_input[l][i])
|
||||
stacks.append(temp)
|
||||
|
||||
stacks2 = [row[:] for row in stacks]
|
||||
|
||||
for move in moves:
|
||||
move = move.split(' ')
|
||||
amount = int(move[1])
|
||||
@@ -30,9 +32,19 @@ for move in moves:
|
||||
moved = stacks[move_from-1].pop()
|
||||
stacks[move_to-1].append(moved)
|
||||
|
||||
res = ''
|
||||
index = len(stacks2[move_from-1])-amount
|
||||
tomove = stacks2[move_from-1][index:]
|
||||
stacks2[move_from-1] = stacks2[move_from-1][:index]
|
||||
stacks2[move_to-1].extend(tomove)
|
||||
|
||||
res = ''
|
||||
for stack in stacks:
|
||||
res += stack[len(stack)-1]
|
||||
|
||||
print(res)
|
||||
print("First answer: " + res)
|
||||
|
||||
res2 = ''
|
||||
for stack in stacks2:
|
||||
res2 += stack[len(stack)-1]
|
||||
|
||||
print("Second answer: " + res2)
|
||||
|
||||
Reference in New Issue
Block a user