September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,13 +1,6 @@
def main
n = (ARGV[0] || 41).to_i
k = (ARGV[1] || 3).to_i
puts josephus(n,k)
end
n = (ARGV[0] || 41).to_i
k = (ARGV[1] || 3).to_i
def josephus(n, k)
prisoners = (0...n).to_a
prisoners.rotate!(k-1).shift while prisoners.length > 1
return prisoners.first
end
main
prisoners = (0...n).to_a
prisoners.rotate!(k-1).shift while prisoners.length > 1
puts prisoners.first