Skip to content

Instantly share code, notes, and snippets.

@darkcris1
Created January 3, 2021 11:28
Show Gist options
  • Save darkcris1/9f2a0db7b85885c23217b4f832281f74 to your computer and use it in GitHub Desktop.
Save darkcris1/9f2a0db7b85885c23217b4f832281f74 to your computer and use it in GitHub Desktop.
Strange Root | SoloLearn
function strangeRoot(n) {
const sqrt = Math.sqrt(n)
.toFixed(3)
.replace(/\.(0{3})$/, '')
return new RegExp(n * n).test(sqrt)
}
console.log(strangeRoot(2)) // true
// Strange Root Visualize
// https://code.sololearn.com/WyEsHZldtkkB/#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment