aoc2020/day6/part1/main.d

38 lines
461 B
D
Raw Permalink Normal View History

2020-12-08 09:13:05 +01:00
import std.algorithm;
import std.uni;
import std.array;
import std.file;
import std.stdio;
void main()
{
readText("input").calculateTotalNumberOfQuestions.writeln;
}
auto calculateTotalNumberOfQuestions(string input)
{
return input.splitter("\n\n")
.array.map!(group => group.filter!isAlpha.array.sort.uniq.count).sum;
}
unittest
{
auto input = `abc
a
b
c
ab
ac
a
a
a
a
b`;
assert(input.calculateTotalNumberOfQuestions == 11);
}