This file contains hidden or 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
def to_roman(num) | |
numerals = {:I => 1, :V => 5, :X => 10, :L => 50, :C => 100, :D => 500, :M => 1000} | |
largest_less_than_array |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM manipulation with jQuery</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript" src="jquery_example.js"></script> | |
</head> | |
<body> |
This file contains hidden or 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
class BoggleBoard | |
def initialize(dice_grid) | |
@dice_grid = dice_grid # Creates dice_grid instance variable that holds the dice_grid | |
end | |
def create_word(*coords) | |
coords.map { |coord| @dice_grid[coord.first][coord.last]}.join("") # Iterates over coords, locating the index of the first given coordinate and then doing the same for the last coordinate | |
end # returning the element found based on those index positions. It does this for as many coordinates are given, and joins the elements as a string to form a word. |
This file contains hidden or 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
#1 | |
class CreditCard | |
def initialize(credit_card_num) | |
@credit_card_num = credit_card_num.to_s.split('') | |
if @credit_card_num.length != 16 | |
raise ArgumentError.new("Not a valid credit card number") | |
end |
This file contains hidden or 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
def mode(array) | |
counter = Hash.new(0) | |
array.each {|num| counter[num] += 1} | |
counter.sort_by {|k,v| v }.last | |
end |
This file contains hidden or 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
def count_between(array, lower_bound, upper_bound) | |
if array==[] | |
return 0 | |
else | |
array.count {|x| x>=lower_bound && x<=upper_bound} | |
end | |
end |
This file contains hidden or 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
# print_triangle(rows) prints out a right triangle of +rows+ rows consisting | |
# of * characters | |
# | |
# +rows+ is an integer | |
# | |
# For example, print_triangle(4) should print out the following: | |
# * | |
# ** | |
# *** | |
# **** |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset=utf-8> | |
<title></title> | |
</head> | |
<body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> |