We can now declare key and value variables inside a loop.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
bbcd99789d
commit
186e5887f6
|
@ -8,9 +8,7 @@ class Program {
|
||||||
'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1};
|
'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1};
|
||||||
|
|
||||||
int $matches;
|
int $matches;
|
||||||
string $roman;
|
foreach(string $roman => int $value in $lookup) {
|
||||||
int $value;
|
|
||||||
foreach($roman => $value in $lookup) {
|
|
||||||
$matches = (int) ($n / $value);
|
$matches = (int) ($n / $value);
|
||||||
$result += str_repeat($roman, $matches);
|
$result += str_repeat($roman, $matches);
|
||||||
$n = $n % $value;
|
$n = $n % $value;
|
||||||
|
|
Loading…
Reference in New Issue