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
#coding: utf-8 | |
from cStringIO import StringIO | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.header import Header | |
from email import Charset | |
from email.generator import Generator | |
import smtplib | |
# Example address data |
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 is_valid?(number) | |
digits = number.to_s.reverse.chars.map(&:to_i) | |
check_sum = 0 | |
digits.each_slice(2) do |odd, even| | |
check_sum += odd | |
next unless even | |
even *= 2 | |
even = even.divmod(10).inject(:+) if even > 9 | |
check_sum += even |
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
input = ARGV[0] | |
index = 0 | |
numbers = "" | |
File.open(input, 'r') do |f| | |
while line = f.gets | |
if index==0 | |
limit=line.to_i | |
index+=1 | |
next | |
end |
NewerOlder