Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 616 Bytes

parse_nice_int_from_char_problem.md

File metadata and controls

22 lines (18 loc) · 616 Bytes

Description

You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9.

Write a program that returns the girl's age (0-9) as an integer.

Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number.

My Solution

def get_age(age)
  age[0].to_i
end

Better/Alternative solution from Codewars

def get_age(age)
  age.to_i
end