Skip to content

Instantly share code, notes, and snippets.

@atesgoral
Last active March 28, 2016 09:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atesgoral/6a0ac4b17dd428da873d to your computer and use it in GitHub Desktop.
Save atesgoral/6a0ac4b17dd428da873d to your computer and use it in GitHub Desktop.
Turkish Citizenship ID Validator
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('')}
@detaybey
Copy link

COOL!

@monoblaine
Copy link

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