<commit_before># Class Warfare, Validate a Credit Card Number


# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.

# Pseudocode

# Input: 16 digit credit card number
# Output: Returns true or false
# Steps:
# create class called CreditCard
# validate card number length (must be 16 digits)
# initialize way to accept credit card number
# IF number is not 16 digits raise error
# define card_processing method
# starting with the second to last digit, double every other digit until first digit
# sum all of the untouched digits (break apart double digits)
# define new check_card method
# If the total is a multiple of ten, you have received a valid credit card number

#Step 1: 8   5  12   3  18   6   0   1   4   2   0   0   2   9  18   9
#Step 2: 8 + 5 + 1 + 2 + 3 + 1 + 8 + 6 + 0 + 1 + 4 + 2 + 0 + 0 + 2 + 9 + 1 + 8 + 9
#Step 3: 70 (total above) % 10 == 0
#Step 4: Profit

# Initial Solution
# Don't forget to check on initialization for a card length
# of exactly 16 digits

class CreditCard
  def initialize(card_number)
    @card_number = card_number.to_s.scan(/./).map {|i| i.to_i}
    if @card_number != 16
      raise ArgumentError.new("Invalid Credit Card Number")
    end
  end
  def card_check
    p card_number
  end
end
<commit_msg>Updates to Credit Card Assignment<commit_after># Class Warfare, Validate a Credit Card Number


# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.

# Pseudocode

# Input: 16 digit credit card number
# Output: Returns true or false
# Steps:
# create class called CreditCard
# validate card number length (must be 16 digits)
# initialize way to accept credit card number
# IF number is not 16 digits raise error
# define card_processing method
# starting with the second to last digit, double every other digit until first digit
# sum all of the untouched digits (break apart double digits)
# define new check_card method
# If the total is a multiple of ten, you have received a valid credit card number

#Step 1: 8   5  12   3  18   6   0   1   4   2   0   0   2   9  18   9
#Step 2: 8 + 5 + 1 + 2 + 3 + 1 + 8 + 6 + 0 + 1 + 4 + 2 + 0 + 0 + 2 + 9 + 1 + 8 + 9
#Step 3: 70 (total above) % 10 == 0
#Step 4: Profit

# Initial Solution
# Don't forget to check on initialization for a card length
# of exactly 16 digits

class CreditCard
  def initialize(card_number)
    @card_number = card_number
    if @card_number != 16
      raise ArgumentError.new("Invalid Credit Card Number")
    end
  end
  def card_check
    p card_number
  end
end

{'fraction_non_alphanumeric': 0.071484375, 'fraction_numerical': 0.04453125, 'mean_word_length': 3.1041666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4649213', 'n_tokens_mistral': 877, 'n_tokens_neox': 768, 'n_words': 398}