brute forced part two
This commit is contained in:
@@ -8,15 +8,25 @@ public class SecretEntrance : IAdventSolution
|
|||||||
|
|
||||||
var current = 50;
|
var current = 50;
|
||||||
var password = 0;
|
var password = 0;
|
||||||
|
var password2 = 0;
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
var direction = line[0] == 'L' ? -1 : 1;
|
var direction = line[0] == 'L' ? -1 : 1;
|
||||||
var distance = int.Parse(line.Substring(1)) * direction;
|
var distance = int.Parse(line.Substring(1));
|
||||||
current += distance;
|
var change = distance * direction;
|
||||||
|
for (var temp = current; distance > 0; distance--)
|
||||||
|
{
|
||||||
|
temp += direction;
|
||||||
|
temp %= 100;
|
||||||
|
if(temp == 0) password2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
current += change;
|
||||||
current %= 100;
|
current %= 100;
|
||||||
if(current == 0) password++;
|
if(current == 0) password++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AdventSolution(password.ToString(), null);
|
return new AdventSolution(password.ToString(), password2.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user