Skip to content

Commit 980058b

Browse files
committed
Added a proper arithmetic clockhands solution.
1 parent 252ab2d commit 980058b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

php/clockhands.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22
for ($i = 0 ; $i < 11 ; $i++){
3-
echo gmstrftime("%I:%M:%S\n", ($i + 0.5) * 43200.0/11);
3+
$t = (43200 * $i + 21600) / 11
4+
$h = $t / 3600
5+
$m = $t / 60 % 60
6+
$s = $t % 60
7+
sprintf("%02d:%02d:%02d", $h || 12, $m, $s);
48
}
59
?>

php/clockhands_time.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
for ($i = 0; $i < 11; $i++) {
3+
echo gmstrftime("%I:%M:%S", ($i+0.5) * 43200.0/11) . "\n";
4+
}
5+
?>

0 commit comments

Comments
 (0)