Untitled

Run Settings
LanguageRaku
Language Version
Run Command
#!/usr/bin/env perl6 class RabbitPair { has Int $.age is rw; method BUILD() { $.age = 0; } method grow-up { $.age += 1; } method of-age { return $.age > 0 } method Str { if $.age > 0 { "\c[RABBIT]\c[RABBIT]($.age)" } else { "\c[RABBIT FACE]\c[RABBIT FACE]($.age)" } } } sub MAIN() { my $months = 6; my $growth-rate = 2; my @nursery; my @playpen; @nursery.push: RabbitPair.new(); for 1..$months -> $month { say "month $month:\n\tnursery: @nursery[]\n\tplaypen: @playpen[]"; for @playpen { for ^$growth-rate { @nursery.push: RabbitPair.new() } } my @growing; for @nursery -> $pair { push $pair.of-age ?? @playpen !! @growing, $pair; $pair.grow-up; } @nursery = @growing; } say @nursery.elems + @playpen.elems; }
Editor Settings
Theme
Key bindings
Full width
Lines