Created
August 29, 2024 16:24
-
-
Save myfonj/8003c60590cd43da9761a20078200349 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
(()=>{ | |
const l = 26 // lower | |
const u = 26 // upper | |
const d = 10 // digits | |
const length = 8 // size | |
const possible = (l + u + d)**length | |
const invalid = | |
(l + d)**length // missing upper | |
+ (u + d)**length // missing lower | |
+ (u + l)**length // missing digit | |
+ (l)**length // missing digit and upper | |
+ (u)**length // missing digit and lower | |
+ (d)**length // missing upper and lower | |
const valid = possible - invalid | |
const f = (new Intl.NumberFormat).format | |
console.table({ | |
'Possible': f(possible), | |
'Invalid': f(invalid), | |
'Valid': f(valid), | |
'Valid / possible': valid / possible, | |
'Invalid = possible %': (invalid / possible) * 100 + '%' | |
}) | |
// https://x.com/BrettLudwig/status/1829071105031852220 | |
})() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment