Created
January 3, 2018 07:05
-
-
Save texzhichen/b856de7cac23cc4abf77a6481cbd868b to your computer and use it in GitHub Desktop.
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
// Reverse a string, e.g., '321' -> '123' | |
s.split('').reverse().join('') | |
// Give a random number within a range [a,b) | |
Math.random() * (b - a) + a; | |
// XOR swap | |
x = x^y; | |
y = x^y; | |
x = x^y; | |
// Arithmetic swap | |
y = y-x; | |
x = y+x; | |
y = x-y; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment