Created
May 3, 2013 18:09
-
-
Save earino/5512187 to your computer and use it in GitHub Desktop.
column figure outer for sandy
This file contains hidden or 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
#!/usr/bin/env perl | |
# | |
use warnings; | |
use strict; | |
{ | |
print "How many items: "; | |
my $items = <STDIN>; | |
print "How many columns: "; | |
my $columns = <STDIN>; | |
chomp ($items); | |
chomp ($columns); | |
my $base = int($items / $columns); | |
my $leftover = $items % $columns; | |
for my $i ( 1 .. $columns) { | |
my $column_count = $base + ($leftover > 0 ? 1 : 0); | |
$leftover--; | |
print "Column $i has: $column_count items.\n"; | |
} | |
redo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment