Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,24 @@
func hailstone (n) {
var sequence = [n];
while (n > 1) {
sequence.append(
n.is_even ? n.div!(2)
: n.mul!(3).add!(1)
);
}
return(sequence);
}
# The hailstone sequence for the number 27
var arr = hailstone(var nr = 27);
say "#{nr}: #{arr.first(4).to_s} ... #{arr.last(4).to_s} (#{arr.len})";
# The longest hailstone sequence for a number less than 100,000
var h = [0, 0];
99_999.times { |i|
(var l = hailstone(i).len) > h[1] && (
h = [i, l];
);
}
printf("%d: (%d)\n", h...);