math/convert_to_decimal/ruby/convert_to_decimal.rb
# Takes a string and a number representing the base that the string is written in (two arguments), and converts it to base 10. Works up to base 16 (Hexadecimal)
Takes a string and a number representing the base that the string is written in (two arguments), and converts it to base 10. Works up to base 16 (Hexadecimal)
Takes a string and a number representing the base that the string is written in ( two arguments ) and converts it to base 10 . Works up to base 16 ( Hexadecimal )
def base_array_to_int(base_array)
  base_array.map! do |item|
    item.downcase!
    if item.match(/\d/) 
      item.to_i 
    elsif item.match(/[a-fA-F]/)
      "abcdef".index(item) + 10
    end
  end
  base_array
end
def base_array_to_int ( base_array ) base_array . map! do | item | item . downcase! if item . match ( / \d / ) item . to_i elsif item . match ( / [a-fA-F] / ) "abcdef" . index ( item ) + 10 end end base_array end
Takes a string and a number representing the base that the string is written in (two arguments), and converts it to base 10.
Takes a string and a number representing the base that the string is written in ( two arguments ) and converts it to base 10 .
base_array