in reply to two dice question
Output is:#!/usr/bin/perl use strict; use warnings; for (1..6){ print_dice($_); }; sub print_dice{ my $value = shift or die $!; my %diceHash = ( 1 => [0,2,0], 2 => [4,0,1], 3 => [4,2,1], 4 => [5,0,5], 5 => [5,2,5], 6 => [5,5,5] ); print "---------\n"; foreach my $face ($diceHash{$value}){ foreach my $line (@{$face}){ print '| '; my @map = split //, sprintf("%03b",$line); foreach my $dot (@map){ print $dot ? "#":" "," "; } print "|\n"; } } print "---------\n"; };
--------- | | | # | | | --------- --------- | # | | | | # | --------- --------- | # | | # | | # | --------- --------- | # # | | | | # # | --------- --------- | # # | | # | | # # | --------- --------- | # # | | # # | | # # | ---------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: two dice question
by eric256 (Parson) on Jul 20, 2007 at 18:12 UTC |