Skip to content

Instantly share code, notes, and snippets.

View SolomonHD's full-sized avatar

Solomon Hilliard SolomonHD

  • Emory University
  • Atlanta,GA
View GitHub Profile
def fizzbuzz(fizzbuzz)
if fizzbuzz % 3 == 0 && fizzbuzz % 5 == 0 && fizzbuzz > 0
return "FizzBuzz"
elsif fizzbuzz % 3 == 0
return "Fizz"
elsif fizzbuzz % 5 == 0
return "Buzz"
else
return fizzbuzz
end
@SolomonHD
SolomonHD / name_quiz
Created February 10, 2015 14:22
Name Quiz
require 'minitest/autorun'
require 'minitest/pride'
def first_name(input)
string = []
string << input.split(" ")
output = string[0]
return output
end
@SolomonHD
SolomonHD / palindrome_quiz.rb
Created February 11, 2015 14:21
palindrome quiz
require 'minitest/autorun'
require 'minitest/pride'
def palindrome?(input)
input.downcase!
array = input.split(" ")
array = array.join
input2 = array.to_s
if input2 == input2.reverse
return true
@SolomonHD
SolomonHD / Thurs Quiz
Created February 12, 2015 14:21
Thurs_Quiz
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 names (input)
hash = ["Washington"=>"George", "Adams"=>"John"]
@SolomonHD
SolomonHD / 16FEB15-Quiz-Sol.rb
Created February 17, 2015 01:14
16FEB15 Quiz
require 'minitest/autorun'
require 'minitest/pride'
# Write a method which returns a hash.
# WRITE YOUR CODE HERE. Name your method `get_hash`.
def get_hash
hash= {"Pizza" => "Unhealthy",
"French Fries" => "Okay",
"Broccoli" => "Healthy",
@SolomonHD
SolomonHD / 17FEB14.rb
Created February 17, 2015 14:20
17FEB14 Quiz
require 'minitest/autorun'
require 'minitest/pride'
# Write a series of methods which use the .any, .all, .map, .select, .reject, and
# .reduce methods in Enumerable. Each of your methods should be one line.
# WRITE YOUR CODE HERE. In this challenge, names longer than 5 characters are
# considered long.
def has_even?(array)
array.any? {|n| n % 2 == 0}
@SolomonHD
SolomonHD / sql_statements
Created February 18, 2015 08:05
SQL Statements
#1
SELECT * FROM authors WHERE email = "shakespeare@example.com"
#2
SELECT * FROM authors ORDER BY created_at DESC LIMIT 1;
#3
SELECT question_text, count(*) FROM questions GROUP BY question_type
#4
@SolomonHD
SolomonHD / 18FEB15
Created February 18, 2015 14:23
18FEB15
require 'minitest/autorun'
require 'minitest/pride'
# Write a method which accepts an array as the first paramater and a number
# as the second parameter. Return true if two of the numbers in the array sum
# to the second parameter.
# WRITE YOUR CODE HERE. Name your method `complements?`.
def complements?(array, sum)
if array == nil || array.length < 2
require 'minitest/autorun'
require 'minitest/pride'
require 'prime'
# Write a method which returns the first n primes, where n is provided to the
# method as a parameter.
#
# Remember that the % operator (modulo) is your friend. It returns a zero if one
# number is divisible by another number. In other words, 4 % 2 == 0.
@SolomonHD
SolomonHD / 24FEB15
Created February 24, 2015 16:35
24FEB15
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 names(array)