Talk:Josephus problem: Difference between revisions

m
Line 76:
 
*Solution 1: Use a circular list. This is the solution typically found in the Lisp approaches. The [https://rosettacode.org/wiki/Josephus_problem#EchoLisp Echo Lisp] solution gives some helpful comments for this.
*Solution 2: Use matrixarray rotation. The [https://rosettacode.org/wiki/Josephus_problem#Ruby Ruby] example keeps this short and sweet.
*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.
331

edits