aboutsummaryrefslogtreecommitdiff
path: root/2019/four.nim
diff options
context:
space:
mode:
Diffstat (limited to '2019/four.nim')
-rw-r--r--2019/four.nim37
1 files changed, 0 insertions, 37 deletions
diff --git a/2019/four.nim b/2019/four.nim
deleted file mode 100644
index eb6d933..0000000
--- a/2019/four.nim
+++ /dev/null
@@ -1,37 +0,0 @@
-# Day Four: Secure Container
-import os, strutils, sequtils
-
-let input: string = paramStr(1)
-let bounds: seq[int] = map(split(strip(readFile(input)), '-'), parseInt)
-var valid, details: int = 0
-
-proc criteria(password: int): bool =
- var password: string = $password
- for digit in 0 .. 4:
- if password[digit] > password[digit+1]:
- return false
- for digit in 0 .. 4:
- if password[digit] == password[digit+1]:
- return true
- return false
-
-proc extracriteria(password: int): bool =
- var password: string = $password
- for digit in 0 .. 4:
- if password[digit] > password[digit+1]:
- return false
- for digit in 0 .. 4:
- if password[digit] == password[digit+1]:
- if digit == 0 or password[digit] != password[digit-1]:
- if digit == 4 or password[digit] != password[digit+2]:
- return true
- return false
-
-for password in bounds[0] .. bounds[1]:
- if criteria(password): inc(valid)
-
-for password in bounds[0] .. bounds[1]:
- if extracriteria(password): inc(details)
-
-echo valid
-echo details