Skip to content

Instantly share code, notes, and snippets.

@ga-wolf
Created July 6, 2015 06:33
Show Gist options
  • Save ga-wolf/6d27f68d17f55be6bba9 to your computer and use it in GitHub Desktop.
Save ga-wolf/6d27f68d17f55be6bba9 to your computer and use it in GitHub Desktop.
Phone Number Readme

Normalized Phone Number

Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages.

The rules are as follows:

  • If the phone number is less than 10 digits assume that it is bad number
  • If the phone number is 10 digits assume that it is good
  • If the phone number is 11 digits and the first number is 1, trim the 1 and use the first 10 digits
  • If the phone number is 11 digits and the first number is not 1, then it is a bad number
  • If the phone number is more than 11 digits assume that it is a bad number

We've provided tests, now make them pass.

Hint: Only make one test pass at a time. You can turn off tests by sending the message skip to it:

def test_string_conversion
  skip
  assert_equal 1, "1".to_i
end

Source

Event Manager by JumpstartLab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment