This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils, sequtils | |
var sum = 0 | |
for line in lines "src/input.txt": | |
let digits = line.filter isDigit | |
sum += parseInt $digits[0] & $digits[^1] | |
echo sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils | |
var grid = [ | |
[6, 0, 0, 0, 0, 4, 5, 3, 0], | |
[8, 0, 0, 0, 5, 0, 0, 0, 9], | |
[5, 9, 4, 0, 0, 0, 8, 2, 0], | |
[0, 5, 0, 3, 0, 0, 0, 0, 0], | |
[0, 3, 0, 0, 0, 0, 0, 8, 5], | |
[0, 0, 2, 0, 0, 1, 0, 7, 0], | |
[2, 0, 8, 0, 0, 0, 0, 5, 0], |