Created
June 8, 2010 18:20
-
-
Save titanous/430430 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
def mask n;n[0,6]+'*'*(n.size-10)+n[-4,4]end |
This is an entry to the Braintree RailsConf Code Golf competition[1]. Credit Card numbers aren't shorter than 10 characters[2].
1 http://codegolf.getbraintree.com/
2 http://en.wikipedia.org/wiki/Bank_card_number#IIN_Ranges_Allocated_to_Issuing_Networks
Ouch, in that case all that checking is quite sub-optimal then isn't it?
How about: http://gist.github.com/431442 ?
Very nicely done.
Thanks, working on that was a great way to wake myself up this morning.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But what about strings smaller than 10 characters?
http://gist.github.com/430895