nimpretty
Signed-off-by: AKU <tom@tdpain.net>
This commit is contained in:
parent
7a1dada319
commit
d87ba9053c
1 changed files with 5 additions and 4 deletions
|
@ -11,7 +11,7 @@ type
|
|||
|
||||
|
||||
proc pointFromString(instr: string): Point =
|
||||
let
|
||||
let
|
||||
parts = instr.split(",")
|
||||
x = parts[0].parseInt
|
||||
y = parts[1].parseInt
|
||||
|
@ -27,7 +27,8 @@ proc parse(instr: string): seq[Line] =
|
|||
|
||||
proc removeDiagonalLines(lines: seq[Line]): seq[Line] =
|
||||
return lines.filter(
|
||||
proc(line: Line): bool = line[0].x == line[1].x or line[0].y == line[1].y,
|
||||
proc(line: Line): bool = line[0].x == line[1].x or line[0].y == line[
|
||||
1].y,
|
||||
)
|
||||
|
||||
iterator iteratePoints(line: Line): Point =
|
||||
|
@ -60,7 +61,7 @@ iterator iteratePoints(line: Line): Point =
|
|||
yield np
|
||||
lastPoint = np
|
||||
|
||||
proc countOverlappingPoints(lines: seq[Line]): int =
|
||||
proc countOverlappingPoints(lines: seq[Line]): int =
|
||||
var areas = initTable[Point, int]()
|
||||
for line in lines:
|
||||
for point in iteratePoints(line):
|
||||
|
@ -80,4 +81,4 @@ proc partOne*(instr: string): int =
|
|||
proc partTwo*(instr: string): int =
|
||||
return instr.
|
||||
parse.
|
||||
countOverlappingPoints
|
||||
countOverlappingPoints
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue