Skip to content

Instantly share code, notes, and snippets.

@NaumenkoSergiy
Last active April 13, 2016 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NaumenkoSergiy/6c5f45a7902df36a92e4da76ae458411 to your computer and use it in GitHub Desktop.
Save NaumenkoSergiy/6c5f45a7902df36a92e4da76ae458411 to your computer and use it in GitHub Desktop.
1 ruby tasks

##1 task

###Description:

The company you work for has just been awarded a contract to build a payment gateway. In order to help move things along, you have volunteered to create a function that will take a float and return the amount formatting in dollars and cents.

39.99 becomes $39.99

The rest of your team will make sure that the argument is santized before being passed to your function although you will need to account for adding trailing zeros if they are missing (though you won't have to worry about a dangling period).

Examples:

3 needs to become $3.00

3.1 needs to become $3.10

##2 task

###Description Write a function convert_temp(temp, from_scale, to_scale) converting temperature from one scale to another. Return converted temp value.

Round converted temp value to an integer(!).

Reading: link

possible scale inputs:

    "C"  for Celsius
    "F"  for Fahrenheit
    "K"  for Kelvin
    "R"  for Rankine
    "De" for Delisle
    "N"  for Newton
    "Re" for Réaumur
    "Ro" for Rømer

temp is a number, from_scale and to_scale are strings.

Examples:

convert_temp(   100, "C",  "F") # => 212
convert_temp(    40, "Re", "C") # => 50
convert_temp(    60, "De", "F") # => 140
convert_temp(373.15, "K",  "N") # => 33
convert_temp(   666, "K",  "K") # => 666

##3 task

###Description:

Build a function that will take the length of each side of a triangle and return if it's either an Equilateral, an Isosceles, a Scalene or an invalid triangle.

It has to return a string with the type of triangle. For example:

type_of_triangle(2, 2, 1) --> "Isosceles"

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