private static int SumAllNextMatchingDigits(int[] input) { CircularIntArray unsolvedCaptchaArray = new CircularIntArray(input); int solvedCaptcha = 0; for (int i = 0; i < input.Length; i++) { if (unsolvedCaptchaArray.Current() == unsolvedCaptchaArray.MoveNext()) { solvedCaptcha += unsolvedCaptchaArray.Current(); } } return(solvedCaptcha); }
private static int SkipAndSumMatchingDigits(int[] input, int skipAmount) { CircularIntArray unsolvedCaptchaArray = new CircularIntArray(input); int solvedCaptcha = 0; for (int i = 0; i < input.Length; i++) { if (unsolvedCaptchaArray.Current() == unsolvedCaptchaArray.SkipAndMoveNext(skipAmount)) { solvedCaptcha += unsolvedCaptchaArray.GetValueOfIndex(i); // I can't use .Current() because we are on next digit already :< } } return(solvedCaptcha); }