Cleaned code a bit
This commit is contained in:
parent
a7eafca0a2
commit
f857e8cc24
@ -4,7 +4,7 @@ from pprint import pprint
|
||||
from termcolor import colored
|
||||
|
||||
sys.path.insert(0, '../../')
|
||||
from fred import list2int,get_re,lprint,loadFile,addTuples,grid_valid,bfs,dfs,flood_fill
|
||||
from fred import get_re,loadFile,addTuples,flood_fill
|
||||
start_time = time.time()
|
||||
|
||||
input_f = 'test'
|
||||
@ -46,21 +46,16 @@ def part1():
|
||||
coordinates = {}
|
||||
initial = {}
|
||||
for idx,inst in enumerate(instructions):
|
||||
#inst = [(2,4),(2,-3)]
|
||||
#print(inst)
|
||||
|
||||
#print('Initial state')
|
||||
pos = inst[0]
|
||||
vel = inst[1]
|
||||
if pos not in initial:
|
||||
initial[pos] = 0
|
||||
initial[pos] += 1
|
||||
|
||||
#nprint(grid,pos,'1')
|
||||
length = 100
|
||||
for i in range (0,length):
|
||||
pos = addTuples(pos,vel)
|
||||
#print('After',i+1,'seconds')
|
||||
if pos[0] < 0:
|
||||
pos = (pos[0]+size_c,pos[1])
|
||||
if pos[0] >= size_c:
|
||||
@ -70,39 +65,9 @@ def part1():
|
||||
if pos[1] >= size_r:
|
||||
pos = (pos[0],pos[1]-size_r)
|
||||
|
||||
#print('Position inside grid: ', grid_valid(pos[1],pos[0],grid))
|
||||
#nprint(grid,pos,'1')
|
||||
#print(pos)
|
||||
#input()
|
||||
if pos not in coordinates:
|
||||
coordinates[pos] = 0
|
||||
coordinates[pos] += 1
|
||||
#print('End State')
|
||||
#nprint(grid,pos,'1')
|
||||
#input()
|
||||
|
||||
#pprint(coordinates)
|
||||
# print(instructions)
|
||||
# print()
|
||||
# print(initial)
|
||||
# print()
|
||||
# for r in range(size_r):
|
||||
# for c in range(size_c):
|
||||
# if (c,r) in initial.keys():
|
||||
# print(initial[(c,r)],end='')
|
||||
# else:
|
||||
# print(grid[r][c],end='')
|
||||
# print()
|
||||
# print('----------------------')
|
||||
# print(coordinates)
|
||||
|
||||
# for r in range(size_r):
|
||||
# for c in range(size_c):
|
||||
# if (c,r) in coordinates.keys():
|
||||
# print(coordinates[(c,r)],end='')
|
||||
# else:
|
||||
# print(grid[r][c],end='')
|
||||
# print()
|
||||
|
||||
center = (int((size_r-1)/2),int((size_c-1)/2))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user