Fixed Day 5 Part 1 edge case
This commit is contained in:
parent
34dc974dd6
commit
65c325dc96
1 changed files with 3 additions and 2 deletions
|
@ -60,7 +60,7 @@ func input_format(input):
|
||||||
func is_mapped(map, input):
|
func is_mapped(map, input):
|
||||||
for v in map:
|
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]):
|
||||||
if input > v[Column.origin] && input < v[Column.origin]+v[Column.range]:
|
if input >= v[Column.origin] && input <= v[Column.origin]+v[Column.range]:
|
||||||
return v[Column.destination] + (input-v[Column.origin])
|
return v[Column.destination] + (input-v[Column.origin])
|
||||||
|
|
||||||
return input
|
return input
|
||||||
|
@ -76,7 +76,7 @@ func map_input(data, seed):
|
||||||
func _init():
|
func _init():
|
||||||
print("Hello!")
|
print("Hello!")
|
||||||
|
|
||||||
var temp = file_load("res://input.txt").split("\n\n")
|
var temp = file_load("res://sample.txt").split("\n\n")
|
||||||
input_clean(temp)
|
input_clean(temp)
|
||||||
|
|
||||||
var input = input_format(temp)
|
var input = input_format(temp)
|
||||||
|
@ -90,6 +90,7 @@ func _init():
|
||||||
|
|
||||||
var locations = []
|
var locations = []
|
||||||
for v in seeds:
|
for v in seeds:
|
||||||
|
print(v)
|
||||||
locations.append(map_input(input, v))
|
locations.append(map_input(input, v))
|
||||||
|
|
||||||
print("Answer: %s" % locations.min())
|
print("Answer: %s" % locations.min())
|
||||||
|
|
Loading…
Reference in a new issue