zachmitch / josephussurvivor Goto Github PK
View Code? Open in Web Editor NEWFinds the "survivor" of the Josephus Permutation
Finds the "survivor" of the Josephus Permutation
Copyright Zach Mitchell 2017 for implementation However the problem is defined by Giacomo Sorbi @ https://www.codewars.com/kata/555624b601231dc7a400017a - - - - - - - - - - - - You have to correctly return who is the "survivor", ie: the last element of a Josephus permutation. Basically you have to assume that n people are put into a circle and that they are eliminated in steps of k elements, like this: josephus_survivor(7,3) => means 7 people in a circle; one every 3 is eliminated until one remains [1,2,3,4,5,6,7] - initial sequence [1,2,4,5,6,7] => 3 is counted out [1,2,4,5,7] => 6 is counted out [1,4,5,7] => 2 is counted out [1,4,5] => 7 is counted out [1,4] => 5 is counted out [4] => 1 counted out, 4 is the last element - the survivor! The above link about the "base" kata description will give you a more thorough insight about the origin of this kind of permutation, but basically that's all that there is to know to solve this kata. Notes and tips: using the solution to the other kata to check your function may be helpful, but as much larger numbers will be used, using an array/list to compute the number of the survivor may be too slow; you may assume that both n and k will always be >=1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.