On 3/3/19 7:07 PM, Samir via Digitalmars-d-learn wrote:
I am belatedly working my way through the 2018 edition of the Advent of
Code[1] programming challenges using D and am stumped on Problem 3[2].
The challenge requires you to parse a set of lines in the format:
#99 @ 652,39: 24x23
#100 @ 61,13: 15x24
#101 @ 31,646: 16x28
I would like to store each number (match) as an element in an array so
that I can refer to them by index.
There is also std.file.slurp which makes this quite easy:
slurp!(int, int, int, int, int)("03.input", "#%d @ %d,%d: %dx%d");
You can then later expand the matches in a loop and process the claims:
foreach(id, offX, offY, width, height; ...