This is Iman Dezfuly test for service Victoria

There are 2 solutions, Java and JavaScript

Both solutions are 100% working and tested (JUnit5 and Jest latest version)

program is main.js, the solution class is josephus.js and the test file is josephus.test.js

josephus solution (printing a complete sequence) is of Order n.

pre-requisits

need to have node.js and npm also a linux-like shell. need Jav (JDK) and eclipse

cloning:

clone the repo using this command:

git clone git@github.com:desphilboy/service-victoria-test.git

Running JavaScript program:

then change directory to the created folder and type the following command:

installation

npm install

run:

npm start

test:

npm test

Best practices used:

functional implementation with a main() runner function using npm package manager, easy to install, easy to run.

100% tested with jest.

static function used as per the request.

complexity order is O(n * (n div k))

memory order is o(n)

Java solution:

Load the repo in eclipse,

run code

run the program ( console app) by righclicking on Josephus class and run it as a java application.

run tests

run test by rightclicking on AllTests.java and run it as a Junit test