about | help | code help+videos | done | prefs |
In the Josephus problem from antiquity, numPeople people are in dire straits and agree to the following strategy to reduce the population. They arrange themselves in a circle (at positions numbered from 0 to numPeople-1) and proceed around the circle, eliminating every elim person until only one person is left. Legend has it that Josephus figured out where to sit to avoid being eliminated. Return where Josephus should sit. josephusQueue(2, 7) → 6 josephusQueue(2, 4) → 0 josephusQueue(3, 41) → 30 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300 Post-solution available
Copyright Nick Parlante 2017 - privacy