Created
January 21, 2014 06:40
-
-
Save dshafik/8535381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Just run the script and start typing asap. Hit enter to get a calculation. | |
$start = microtime(true); | |
$read = fgets(STDIN); | |
$end = microtime(true); | |
echo substr_count($read, " ") . " words in " . ($end - $start) . " seconds" . PHP_EOL; | |
$interval = $end - $start; | |
if ($interval < 60) { | |
$times = 60 / $interval; | |
} else { | |
$times = $interval / 60; | |
} | |
echo (round(substr_count($read, " ") * $times)) . " words per minute!" . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment