Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
func calculator({.is_one} ) { 1 }
|
||||
func calculator(n {.is_even}) { n / 2 }
|
||||
func calculator(n ) { 3*n + 1 }
|
||||
|
||||
func succ(this {_{:value}.is_one}, _) {
|
||||
return this
|
||||
}
|
||||
|
||||
func succ(this, get_next) {
|
||||
this{:value} = get_next(this{:value})
|
||||
this{:count}++
|
||||
return this
|
||||
}
|
||||
|
||||
var enviornments = (1..12 -> map {|i| Hash(value => i, count => 0) });
|
||||
|
||||
while (!enviornments.map{ _{:value} }.all { .is_one }) {
|
||||
say enviornments.map {|h| "%4s" % h{:value} }.join;
|
||||
enviornments.range.each { |i|
|
||||
enviornments[i] = succ(enviornments[i], calculator);
|
||||
}
|
||||
}
|
||||
|
||||
say 'Counts';
|
||||
say enviornments.map{ |h| "%4s" % h{:count} }.join;
|
||||
Loading…
Add table
Add a link
Reference in a new issue