id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

tmhscs@gmail.com josephus

    _____                                          __                           
   /     |                                        /  |                          
   $$$$$ |  ______    _______   ______    ______  $$ |____   __    __   _______ 
      $$ | /      \  /       | /      \  /      \ $$      \ /  |  /  | /       |
 __   $$ |/$$$$$$  |/$$$$$$$/ /$$$$$$  |/$$$$$$  |$$$$$$$  |$$ |  $$ |/$$$$$$$/ 
/  |  $$ |$$ |  $$ |$$      \ $$    $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$      \ 
$$ \__$$ |$$ \__$$ | $$$$$$  |$$$$$$$$/ $$ |__$$ |$$ |  $$ |$$ \__$$ | $$$$$$  |
$$    $$/ $$    $$/ /     $$/ $$       |$$    $$/ $$ |  $$ |$$    $$/ /     $$/ 
 $$$$$$/   $$$$$$/  $$$$$$$/   $$$$$$$/ $$$$$$$/  $$/   $$/  $$$$$$/  $$$$$$$/  
                                        $$ |                                    
                                        $$ |                                    
                                        $$/                                     
 _______                      __        __                                      
/       \                    /  |      /  |                        
$$$$$$$  | ______    ______  $$ |____  $$ |  ______   _____  ____  
$$ |__$$ |/      \  /      \ $$      \ $$ | /      \ /     \/    \ 
$$    $$//$$$$$$  |/$$$$$$  |$$$$$$$  |$$ |/$$$$$$  |$$$$$$ $$$$  |
$$$$$$$/ $$ |  $$/ $$ |  $$ |$$ |  $$ |$$ |$$    $$ |$$ | $$ | $$ |
$$ |     $$ |      $$ \__$$ |$$ |__$$ |$$ |$$$$$$$$/ $$ | $$ | $$ |
$$ |     $$ |      $$    $$/ $$    $$/ $$ |$$       |$$ | $$ | $$ |
$$/      $$/        $$$$$$/  $$$$$$$/  $$/  $$$$$$$/ $$/  $$/  $$/ 

Josephus Flavius was a Jewish general in the Jewish-Roman War in the 1st century. During the war, he and forty of his soldiers became trapped in a cave by Roman soldiers. They decided to choose suicide over capture because they feared torture from their Roman enemies. They believed that suicide is a sin, so they decided stand in a circle, pick a starting spot, and that every third man will be killed by the man nearest him. Because Josephus was a scholar, he was able to mentally calculate what place to stand in the circle to be the lone survivor. Afterwards, he would ask the Romans for mercy.

This set of problems is designed to help you create a solution to the "Josephus Problem" which is a historic math problem that is possibly the predecessor for the game "Duck, Duck, Goose".

Let’s practice using Arrays in Java by creating a program that is given an input number of people and skip amount and calculates the spot number that will be the lone survivor. Your program MUST use a boolean array where every value is initialized to TRUE (meaning alive), and then simulates the game by assigning array elements to FALSE (meaning dead).

Numberphile's Video on the Josephus Problem, explains how to tackle problems and how to solve it by hand.
https://www.youtube.com/watch?v=uCsD3ZGzMgE

Link with an attached PDF you can print and simulate the game by crossing out the numbers.
http://mathletenation.com/content/josephus-problem-counting-puzzle

Let's you type in a number of people and a skip number and calculates surviving spot. Useful for checking your answers.
http://webspace.ship.edu/deensley/mathdl/Joseph.html

Array problems that can help you with the Array Josephus Solver:
array_createFalseArray H  
array_createTrueArray H  
array_numTrue H  
array_onlyOneTrue H  
array_firstTrue H  
array_nextTrue H  

Array Josephus Solver:
array_josephusSolver H  
array_josephusBonus H  

List Josephus Solver:
list_josephusSolver H  
list_josephusBonus H  


Authoring docs

Copyright Nick Parlante 2017 - privacy