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
# Flights, Ruby | |
# | |
# Express the following table as a static structure, | |
# and write a function, find_routes(source, destination) that | |
# efficiently outputs all possible routes. | |
# | |
# Source | Dest | |
# ~~~~~~ ~~~~ | |
# Seattle | LA | |
# LA | Florida |
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
# 6 points for a "touch-down" | |
# 3 points for a "field-goal" | |
# 1 point for an "extra-point"; can only be rewarded after a touch-down. Mutually-exclusive with "two-point conversion" | |
# 2 points for a "two-point conversion"; can only be rewarded after a touch-down. Mutually-exclusive with "extra-point" | |
class Scoring | |
attr_reader :max_number_each, :scoring_values | |
attr_accessor :score, :counter |
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
# Given a deck of n unique cards, cut the deck c cards from the top and perform a perfect shuffle. | |
# A perfect shuffle is where you put down the bottom card from the top portion of the deck followed by the bottom card from the bottom portion of the deck. | |
# This is repeated until one portion is used up. The remaining cards go on top. | |
# We want an algorithm that will determine the number of perfect shuffles that will need to happen before the deck returns to its original order. This can be done in any language. | |
# A successful solution will solve the problem for 1002 cards and a cut size of 101 in under a second even on a slow machine. | |
class Shuffler | |
attr_reader :initial_cards, :cut, :top_cut, :top, :bottom, :extra |