This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Compares weight of 2 items | |
def weigh(item1, item2) | |
$totalWeighings += 1 | |
if item1 > item2 | |
return 0 | |
elsif item2 > item1 | |
return 1 | |
else | |
return 2 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#WARNING! This code is functional but has some redundancy | |
#LEVEL: NIGHTMARE | |
def is_a_number(input) | |
true if Float(input) rescue false | |
end | |
def get_input() | |
puts "Please give me your input:" | |
gets.chomp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a method which returns: | |
# | |
# * "Fizz" if the number is divisible by 3 | |
# * "Buzz" if the number is divisible by 5 | |
# * "FizzBuzz" if the number is divisible by 3 and 5 | |
# * Otherwise, return the number itself | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Find all time entries. | |
SELECT * | |
FROM time_entries; | |
# Results Returned: 500 | |
Find the developer who joined the company most recently. | |
SELECT * | |
FROM developers | |
ORDER BY joined_on DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write two methods: | |
# | |
# * `first_name`: given a name in string, return the first name. | |
# * `last_name`: given a name in string, return the last name. | |
# WRITE YOUR CODE HERE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a method which accepts an array and returns a hash. Each item in the | |
# array will be a string, and the returned hash should have last names as keys | |
# and first names as values. | |
# WRITE YOUR CODE HERE. Name your method `names`. | |
def first_name(name) | |
array = name.to_s.split |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a method which accepts one parameter. The method should return true if | |
# the string passed to it is a palindrome. It should return false if the string | |
# is not a palindrome | |
def palindrome?(string) | |
string.downcase! | |
string = string.gsub(/\W/, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write two classes which inherit from the Vehicle class below. You will also | |
# need to add a method to the Vehicle class during this challenge. | |
class Vehicle | |
def initialize(make, model) | |
@make = make | |
@model = model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
#I somehow overlooked this challenge. Submitting now on 9-21 | |
class Goat | |
attr_reader :name | |
def initialize(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a class which wraps around an array, but only allows odd numbers | |
# to be stored in the array. | |
class OddArray | |
def initialize(numbers) | |
@array = numbers.select{|num| num % 2 == 1} | |
end |
OlderNewer