Skip to content

Instantly share code, notes, and snippets.

@habdenscrimen
Created March 18, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save habdenscrimen/a643be8c60ba11899e16ec287d533f06 to your computer and use it in GitHub Desktop.
Save habdenscrimen/a643be8c60ba11899e16ec287d533f06 to your computer and use it in GitHub Desktop.
Codewars - Defuse the bombs!
// 10
Bomb.diffuse(Bomb.key)
// 9
Bomb.diffuse()
Bomb.diffuse()
Bomb.diffuse()
Bomb.diffuse()
Bomb.diffuse()
// 8
Bomb.diffuse(BombKey)
// 7
const diffuseTheBomb = () => true
Bomb.diffuse()
// 6
Bomb.diffuse('3.14159')
// 5
const date = new Date()
date.setFullYear(2016)
Bomb.diffuse(date)
// 4
Bomb.diffuse(Object.freeze({ key: 43 }))
// 3
const obj = {
valueOf: () => {
if (!this.used) {
this.used = true
return 9
}
return 11
}
}
Bomb.diffuse(obj)
// 2
Math.random = function() {
return {
valueOf: () => {
if (!this.used) {
this.used = true
return 0.5
}
return 1
}
}
}
Bomb.diffuse(42)
// 1
Array.prototype.valueOf = function() {
return this.reduce((sum, cur) => sum + cur)
}
Bomb.diffuse(new Buffer("yes").toString("base64"))
@JasurJunior
Copy link

very clever

@habdenscrimen
Copy link
Author

@JasurJunior thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment