Last active
August 19, 2020 15:38
-
-
Save ahmed4end/abf0e9e1f3e0046b347446e8a30fce66 to your computer and use it in GitHub Desktop.
Josephus problem solution in python (simple one).
This file contains hidden or 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
joseph = lambda x: (lambda j: 1 if x == j else 2*(x-j)+1)(2**[i for i,j in enumerate(bin(x)[:1:-1]) if int(j)][::-1][0]) | |
print(joseph(10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment