Improved Day 5 Part 1
This commit is contained in:
parent
65c325dc96
commit
4b601b56a5
1 changed files with 10 additions and 8 deletions
16
day5/d5p1.gd
16
day5/d5p1.gd
|
@ -59,7 +59,7 @@ func input_format(input):
|
|||
|
||||
func is_mapped(map, input):
|
||||
for v in map:
|
||||
#if input in range(v[Column.origin], v[Column.origin]+v[Column.range]):
|
||||
#if input in range(v[Column.origin], v[Column.origin]+v[Column.range]): # Fucking Godot runs out of memory when I use this
|
||||
if input >= v[Column.origin] && input <= v[Column.origin]+v[Column.range]:
|
||||
return v[Column.destination] + (input-v[Column.origin])
|
||||
|
||||
|
@ -76,7 +76,7 @@ func map_input(data, seed):
|
|||
func _init():
|
||||
print("Hello!")
|
||||
|
||||
var temp = file_load("res://sample.txt").split("\n\n")
|
||||
var temp = file_load("res://input.txt").split("\n\n")
|
||||
input_clean(temp)
|
||||
|
||||
var input = input_format(temp)
|
||||
|
@ -88,10 +88,12 @@ func _init():
|
|||
var seeds = input[0][0]
|
||||
print(seeds)
|
||||
|
||||
var locations = []
|
||||
for v in seeds:
|
||||
print(v)
|
||||
locations.append(map_input(input, v))
|
||||
var minval = 2**32
|
||||
for seed in seeds:
|
||||
|
||||
print("Answer: %s" % locations.min())
|
||||
var location = map_input(input, seed)
|
||||
|
||||
if location < minval:
|
||||
minval = location
|
||||
|
||||
print("Answer: %s" % minval)
|
||||
|
|
Loading…
Reference in a new issue