Cleanup some unnecessary code

This commit is contained in:
Daniel Flanagan 2020-12-03 10:20:02 -06:00
parent fa6c830b81
commit f1f5b2f57c
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
2 changed files with 2 additions and 6 deletions

View file

@ -20,13 +20,11 @@ iterator asPasswordPolicies(s: Stream): (PasswordPolicy, string) =
yield parsePasswordPolicy line
proc part1*(s: Stream): int =
result = 0
for (pp, pw) in asPasswordPolicies(s):
if isValidPassword(pw, pp):
result += 1
proc part2*(s: Stream): int =
result = 0
for (pp, pw) in asPasswordPolicies(s):
if isValidPasswordPart2(pw, pp):
result += 1

View file

@ -1,10 +1,7 @@
import streams
proc sled(s: Stream, velx: int, vely: int): int =
setPosition(s, 0)
result = 0
var xpos = 0
var ypos = 0
var xpos, ypos: int
for line in s.lines():
ypos += 1
if (ypos - 1) mod vely > 0:
@ -19,5 +16,6 @@ proc part1*(s: Stream): int =
proc part2*(s: Stream): int =
result = part1(s)
for vels in [(1, 1), (5, 1), (7, 1), (1, 2)]:
setPosition(s, 0)
let (velx, vely) = vels
result *= sled(s, velx, vely)