Skip to main content
added 14 characters in body
Source Link
NestWhile[Rest@RotateLeft@#NestWhile[Rest @ RotateLeft @ # &, Range@10Range @ 10, Length@#Length @ # > 1 &]

{5}

FixedPoint[If[Length@#FixedPoint[If[Length @ # > 1, Rest@RotateLeft[#]Rest @ RotateLeft[#], #] &, Range@10]Range @ 10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted inof killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Note: The direction is important. RotateRight[] will select another victim.

NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Note: The direction is important. RotateRight[] will select another victim.

NestWhile[Rest @ RotateLeft @ # &, Range @ 10, Length @ # > 1 &]

{5}

FixedPoint[If[Length @ # > 1, Rest @ RotateLeft[#], #] &, Range @ 10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted of killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Note: The direction is important. RotateRight[] will select another victim.

added 83 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456
NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Note: The direction is important. RotateRight[] will select another victim.

NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Note: The direction is important. RotateRight[] will select another victim.

added 238 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456
NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]
NestWhile[Rest@RotateLeft@# &, Range@10, Length@# > 1 &]

{5}

FixedPoint[If[Length@# > 1, Rest@RotateLeft[#], #] &, Range@10]

Edit

Historical note: As far as I can remember, Josephus roulette (a plain treason to his companions) consisted in killing every third person.

FixedPoint[If[Length@# != 1, Rest@RotateLeft[#, 2], #] &, Range@10]

{4}

Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456
Loading