Talk:Josephus problem: Difference between revisions

Content added Content deleted
Line 68: Line 68:
:::Please accept my Apologies guys. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 14:11, 31 October 2016 (UTC)
:::Please accept my Apologies guys. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 14:11, 31 October 2016 (UTC)
:::: No problem – happens easily, and easily fixed. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 14:24, 31 October 2016 (UTC)
:::: No problem – happens easily, and easily fixed. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 14:24, 31 October 2016 (UTC)

== Categorisation of solutions ==

The task description only mentions one way of going about solving this problem, but from the solutions given it seem to me that there's at least six different ways to solve it. To help me understand these solutions, I'm trying to make a list of them and what languages show them off in a particularly clear way. Can anyone help me do this?

I've tried to read every solution so far, and it's my understanding that all of the following solutions exist:

*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 matrix 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.
*Solutions 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.


However, there are quite a lot of solutions that I can't understand. I have no idea what approach any of the following have taken. Have I missed a category or two? Or is it just that I can't read the syntax?
*[https://rosettacode.org/wiki/Josephus_problem#AutoHotkey AutoHotkey]
*[https://rosettacode.org/wiki/Josephus_problem#C.23 C#]
*[https://rosettacode.org/wiki/Josephus_problem#Elixir Elixir]
*[https://rosettacode.org/wiki/Josephus_problem#Factor Factor]
*[https://rosettacode.org/wiki/Josephus_problem#Fortran Fotran]
*[https://rosettacode.org/wiki/Josephus_problem#Haskell Haskell]
*[https://rosettacode.org/wiki/Josephus_problem#JavaScript JavaScript]
*[https://rosettacode.org/wiki/Josephus_problem#jq jq]
*[https://rosettacode.org/wiki/Josephus_problem#REBOL REBOL]
*[https://rosettacode.org/wiki/Josephus_problem#Scala Scala]

--[[User:ReeceGoding|ReeceGoding]] ([[User talk:ReeceGoding|talk]]) 13:02, 24 June 2020 (UTC)