Skip to content

Instantly share code, notes, and snippets.

@vinniefranco
Created March 2, 2012 06:59
Show Gist options
  • Save vinniefranco/1956353 to your computer and use it in GitHub Desktop.
Save vinniefranco/1956353 to your computer and use it in GitHub Desktop.
# Tiny ass Luhn CC Check
def valid_luhn_cc? cc
a = i = 0
cc.each_char { |c| ((i%2)==0)? a+=c.to_i : (c.to_i*2).divmod(10).each { |j| a+=j }; i+=1 }
a % 10 == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment