Created
June 15, 2015 10:43
-
-
Save odaba/48425c8fcc0cf327f37c to your computer and use it in GitHub Desktop.
code warriors 551dd1f424b7a4cdae0001f0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whoIsNext(names, r){ | |
var x = names.length; | |
var pass = ((r - 1)/x) + 1; | |
var cycle = Math.log(pass)/Math.LN2; | |
var grouping = Math.pow(2, Math.floor(cycle)); | |
var cbegin = (grouping - 1) * x; | |
var r_offset = r - cbegin - 1; | |
var r_index = Math.floor(r_offset / grouping); | |
return [x, pass, cycle, grouping, cbegin, r_offset, r_index, names[r_index]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment