Skip to content

Commit 1b5dd66

Browse files
author
Ngoc Pham
committed
Day 4
1 parent 28d8437 commit 1b5dd66

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

d04.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
function find(string $input, int $leading_zeros_count, int $start = 1)
4+
{
5+
while (1) {
6+
$hash = md5("{$input}{$start}");
7+
8+
if (substr($hash, 0, $leading_zeros_count) === str_pad('', $leading_zeros_count, '0')) {
9+
return $start;
10+
}
11+
12+
$start++;
13+
}
14+
}
15+
16+
$input = 'bgvyzdsv';
17+
18+
$num = find($input, 5);
19+
var_dump($num);
20+
21+
var_dump(find($input, 6, $num));

0 commit comments

Comments
 (0)