Skip to main content
deleted 16 characters in body; deleted 2 characters in body
Source Link

PHP, 180162

<?php error_reporting(0);$b=$argv;$b[0]='';foreach;$b=0;while($b as $a$argv[$b])$c[strlen($a$argv[++$b])]++;for($t=1;$t<=max(array_keys($c));$t++){echo $t.'|';if'|'.($c[$t])for?str_repeat($z=0;$z<$c[$t];$z++'#',$c[$t])echo'#';echo"\n";}:'')."\n";

Usage:

php histogram.php Very long strings of words should be just as easy to generate a histogram just as short strings of words are easy to generate a histogram for.
1|##
2|#######
3|#
4|#######
5|###
6|#
7|##
8|##
9|##

PHP, 180

<?php error_reporting(0);$b=$argv;$b[0]='';foreach($b as $a)$c[strlen($a)]++;for($t=1;$t<=max(array_keys($c));$t++){echo $t.'|';if($c[$t])for($z=0;$z<$c[$t];$z++)echo'#';echo"\n";}

Usage:

php histogram.php Very long strings of words should be just as easy to generate a histogram just as short strings of words are easy to generate a histogram for.
1|##
2|#######
3|#
4|#######
5|###
6|#
7|##
8|##
9|##

PHP, 162

<?php error_reporting(0);$b=0;while($argv[$b])$c[strlen($argv[++$b])]++;for($t=1;$t<=max(array_keys($c));$t++)echo $t.'|'.($c[$t]?str_repeat('#',$c[$t]):'')."\n";

Usage:

php histogram.php Very long strings of words should be just as easy to generate a histogram just as short strings of words are easy to generate a histogram for.
1|##
2|#######
3|#
4|#######
5|###
6|#
7|##
8|##
9|##
Source Link

PHP, 180

<?php error_reporting(0);$b=$argv;$b[0]='';foreach($b as $a)$c[strlen($a)]++;for($t=1;$t<=max(array_keys($c));$t++){echo $t.'|';if($c[$t])for($z=0;$z<$c[$t];$z++)echo'#';echo"\n";}

Usage:

php histogram.php Very long strings of words should be just as easy to generate a histogram just as short strings of words are easy to generate a histogram for.
1|##
2|#######
3|#
4|#######
5|###
6|#
7|##
8|##
9|##