Install a package named bundler using the ruby program gem.
$ gem install bundler
If you get a connection refused error (likely because of the school filter),
run this command instead.
$ gem install bundler --source http://rubygems.org
In your project folder, install the testing packages using bundler.
$ bundle
Run the tests
$ ruby test.rb
Implement the following methods.
Start with the tests, then use them to create your method.
Make a commit after correctly implementing each method.
DO NOT print inside of methods.
-
elevenish?A number is elevenish if it is a multiple of eleven or one greater than a multiple of eleven.
Name Type Notes n intThe number to check Type Value boolean truewhennis elevenish,falseotherwise. -
ice_cream_partyYou are having a party with amounts of ice cream and candy. Return the int outcome of the party encoded as 0=bad, 1=good, or 2=great. A party is good (1) if both ice cream and candy are at least 5. However, if either ice cream or candy is at least double the amount of the other one, the party is great (2). However, in all cases, if either ice cream or candy is less than 5, the party is always bad (0).
Name Type Notes ice_cream intThe amount of ice cream at the party candy intThe amount of candy at the party ####Return
Type Value int0 when the party is bad
1 when the party is good
2 when the party is great -
successful_squirrel_party?When squirrels get together for a party, they like to have nuts. A squirrel party is successful when the number of nuts is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of nuts. Return true if the party with the given values is successful, or false otherwise.
Name Type Notes nuts intThe amount of nuts at the party is_weekend booleantruewhen it is the weekend,falseduring the weekType Value booleantruewhen the party is successful,falsewhen it is not -
ticketYou have a lottery ticket, with ints a, b, and c on it. This makes three pairs, which we'll call ab, bc, and ac. Consider the sum of the numbers in each pair. If any pair sums to exactly 10, the result is 10. Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the result is 5. Otherwise the result is 0.
Determine the parameters and return type of the method yourself from the problem statement.
-
###in_order?
Given three ints, a b c, return true if b is greater than a, and c is greater than b. However, with the exception that if "bOk" is true, b does not need to be greater than a.
Name Type Notes a intAny integer b intAny integer c intAny integer bOK booleantruewhen b is okay,falsewhen it is notType Value booleantruewhen a, b, and c are in ascending order,
unless b is okay then it can be not greater than a.
falseotherwise -
less_by_ten?Given three ints, a b c, return true if one of them is 10 or more less than one of the others.
Determine the parameters and return type of the method yourself from the problem statement.
-
fizz_stringGiven a string str, if the string starts with "f" return "Fizz". If the string ends with "b" return "Buzz". If both the "f" and "b" conditions are true, return "FizzBuzz". In all other cases, return the string unchanged.
Determine the parameters and return type of the method yourself from the problem statement.
-
first_last_six?Given an array of integers, return true if 6 appears as either the first or last element in the array. The array will be length 1 or more.Learn about Ruby Arrays and how they can be used.
Name Type Notes list ArrayAn array of integers,
the length of which is at least 1Type Value booleantruewhen a 6 is the first or last element of the list,falseotherwise -
rotate_leftGiven an array of 3 integers, return an array with the elements "rotated left" so 1, 2, 3 yields 2, 3, 1.
Name Type Notes trio ArrayAn array of 3 integers Type Value ArrayA version of triowith the numbers rotated left one place -
double23?Given an integer array, return true if the array contains 2 twice, or 3 twice. The array will have 0, 1, or 2 elements.
Determine the parameters and return type of the method yourself from the problem statement.