avoid some allocations
2015 was allocating over 2gb memory in small object heap for the md5 byte conversions
This commit is contained in:
parent
f451e0aa77
commit
425acc5de5
|
@ -33,12 +33,12 @@ public sealed class Day04 : Day
|
|||
|
||||
public override object Part2()
|
||||
{
|
||||
var counter = 0;
|
||||
var counter = 9_000_000;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var hash = MD5.HashData(Encoding.ASCII.GetBytes(_key + counter));
|
||||
if (BitConverter.ToString(hash).Replace("-", "").StartsWith("000000"))
|
||||
var hashBytes = MD5.HashData(Encoding.ASCII.GetBytes(_key + counter));
|
||||
if (hashBytes[0] == 0 && hashBytes[1] == 0 && hashBytes[2] == 0)
|
||||
return counter;
|
||||
counter++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue