I have to say, day three / part two took a long time to finish; I wasn't expecting or looking for integer overflow on the final multiplication and you don't get an exception by default for it in c#, which I don't think I knew.
In case anyone's doing c#, I don't think it's terribly different to a couple of earlier answers:
public int Answer(int r = 3, int d = 1)
{
var inputData = GetInputData().ToArray();
var returnValue = 0;
var lengthOfRow = inputData[0].Length;
var currenthPoz = 0;
for (var currentvPoz = d; currentvPoz < inputData.Length; currentvPoz += d)
{
currenthPoz = (currenthPoz + r) % lengthOfRow;
if (inputData[currentvPoz].ElementAt(currenthPoz) == '#')
returnValue++;
}
return returnValue;
}
I've just caught up to day three...
I have to say, day three / part two took a long time to finish; I wasn't expecting or looking for integer overflow on the final multiplication and you don't get an exception by default for it in c#, which I don't think I knew.
In case anyone's doing c#, I don't think it's terribly different to a couple of earlier answers: