Last active
March 28, 2016 09:26
-
-
Save atesgoral/6a0ac4b17dd428da873d to your computer and use it in GitHub Desktop.
Turkish Citizenship ID Validator
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
n=>{a=[].slice.call(n,0,9);a.push(a.reduce((s,d,i)=>{return s+d*(((i+1&1)*8)-1)},0)%10,a.reduce((s,d)=>{return s+1*d},0)%10);return n==a.join('')} |
You may even write (s,d)=>s+1*d
instead of (s,d)=>{return s+1*d}
:
// 137 characters
n=>{a=[].slice.call(n,0,9);a.push(a.reduce((s,d,i)=>{return s+d*(((i+1&1)*8)-1)},0)%10,a.reduce((s,d)=>s+1*d,0)%10);return n==a.join('')}
But my ID doesn't get validated. Any idea why?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
COOL!