Talk:Josephus problem: Difference between revisions

m
Line 79:
*Solution 3: Use nested loops or if statements in a loop that are as good as nested loops. I think that the goal here is to replicate modular arithmetic. I didn't quite understand this until I saw the [https://rosettacode.org/wiki/Josephus_problem#Kotlin Kotlin] and [https://rosettacode.org/wiki/Josephus_problem#Lua Lua] solutions, but once I understood it became quite clear that this is a popular approach. [https://rosettacode.org/wiki/Josephus_problem#REXX REXX] has a well-commented example and so does [https://rosettacode.org/wiki/Josephus_problem#MATLAB MATLAB]. I also think that this is what [https://rosettacode.org/wiki/Josephus_problem#AWK AWK] and the many solutions adapted from it have done, but I'm less sure.
*Solution 4: Use recursion. I've not studied these solutions yet, but there are solutions in [https://rosettacode.org/wiki/Josephus_problem#Erlang Erlang], [https://rosettacode.org/wiki/Josephus_problem#Sidef Sidef] and [https://rosettacode.org/wiki/Josephus_problem#Julia Julia] that are clearly doing this. I suspect that the [https://rosettacode.org/wiki/Josephus_problem#Emacs_Lisp Emacs Lisp] solution is similar.
*SolutionsSolution 5: Use modular arithmetic modulo the decreasing length of the circle. [https://rosettacode.org/wiki/Josephus_problem#Python Python] and [https://rosettacode.org/wiki/Josephus_problem#Visual_Basic_.NET Visual Basic .NET] do a good job of showing how to do this while actually making the circle smaller. [https://rosettacode.org/wiki/Josephus_problem#Rust Rust] shows how to do this without having to recalculate the length of the circle.
*Solution 6: Use modular arithmetic, but treat the circle as if it is growing. This is very much a mathematician's solution, so it's no surprise that [https://rosettacode.org/wiki/Josephus_problem#R R] makes it very concise. I think that [https://rosettacode.org/wiki/Josephus_problem#Ring Ring] takes the same approach.
 
331

edits