Mercurial > hg > aoc
changeset 17:1b739c382980
day 13: first part
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 15 Dec 2017 12:40:34 -0500 |
parents | 990a4fa2aebe |
children | 70937ca0e7eb |
files | 2017/day14.d |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/2017/day14.d @@ -0,0 +1,18 @@ +import std.stdio; +import std.bitmanip: BitArray; +import std.array: array; +import std.algorithm; +import std.range: iota; +import std.format: format; + +import day10: calcHash, getHash; + +auto countBits(string input) { + return iota(0,128).map!( + i => BitArray(format("%s-%d", input, i).calcHash, 128).bitsSet.array.length + ).sum; +} + +void main(string[] args) { + writeln(args[1].countBits); +}