Tweak 2021-01 Nim solution
This commit is contained in:
parent
bd93e33ad0
commit
c551f3fad1
1 changed files with 12 additions and 6 deletions
|
@ -5,16 +5,22 @@ proc loadInput(): string =
|
||||||
return readFile("input.txt")
|
return readFile("input.txt")
|
||||||
|
|
||||||
proc parseInput(instr: string): seq[int] =
|
proc parseInput(instr: string): seq[int] =
|
||||||
for item in split(instr, "\n"):
|
result = instr.
|
||||||
if item == "":
|
splitLines.
|
||||||
continue
|
toSeq.
|
||||||
let n = parseInt(item)
|
filter(proc(x: string): bool = x != "").
|
||||||
result.add(n)
|
map(parseInt)
|
||||||
|
|
||||||
|
# for item in split(instr, "\n"):
|
||||||
|
# if item == "":
|
||||||
|
# continue
|
||||||
|
# let n = parseInt(item)
|
||||||
|
# result.add(n)
|
||||||
|
|
||||||
let input = parseInput(loadInput())
|
let input = parseInput(loadInput())
|
||||||
|
|
||||||
proc countIncreases(data: seq[int]): int =
|
proc countIncreases(data: seq[int]): int =
|
||||||
for i in countup(1, data.len()-1):
|
for i in 1..data.high:
|
||||||
if data[i] > data[i-1]:
|
if data[i] > data[i-1]:
|
||||||
result = result + 1
|
result = result + 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue