Bit of silliness.
1. What's the next line?
1 1 1 2 1 1 2 1 1 1 1 1 2 2 1
2. Write code to print each line in the pattern (it gets unwieldy).
my $anchor = @ARGV ? '' : '^'; printf "%d\n", $_ = '1'; do { my $new; my ( $n ) = /^(\d)/o; while ( $_ ) { my $c = 0; $c++ while s/$anchor\s?$n\s?//; $new .= "$c $n " if $c; ( $n ) = /^(\d)/o; } print $_ = $new; } until ( <STDIN> =~ /\S/ );
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |