Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Josephus-problem/Craft-Basic/josephus-problem.basic
Normal file
28
Task/Josephus-problem/Craft-Basic/josephus-problem.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'using 1 to n
|
||||
|
||||
define prisoners = 0, step = 0, killcount = 0, survivor = 0
|
||||
define fn (josephus) as ( survivor + step ) % killcount
|
||||
|
||||
do
|
||||
|
||||
input "Prisoners", prisoners
|
||||
input "Step", step
|
||||
|
||||
gosub executioner
|
||||
|
||||
loop
|
||||
|
||||
sub executioner
|
||||
|
||||
let killcount = 1
|
||||
|
||||
do
|
||||
|
||||
let killcount = killcount + 1
|
||||
let survivor = (josephus)
|
||||
|
||||
loop killcount < prisoners
|
||||
|
||||
print "survivor = ", survivor
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue