Last active

Practice exercise for Seattle on Rails meetup, Monday February 18th, 2013.

  • Download Gist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
The first Ruby Quiz ( has you implement
Bruce Schneier's Solitaire cipher in Ruby. This hand cipher uses a standard
deck of cards as the encryption key as well as to perform the cipher operations.
Today's exercise is to implement a Deck class representing a physical deck of
cards. It should have the following properties:
It contains an ordered list of 54 cards: numbered 2..10, face cards JQKA, and 2 differentiable jokers
A specific order can be specified when the deck is created
Cards have numeric values:
Clubs A2..10JQK: 1-13
Diamonds A2..10JQK: 14-26
Hearts A2..10JQK: 27-39
Spades A2..10JQK: 40-52
Jokers: 53
It can be shuffled to randomly order the cards
It has methods to determine if a card is:
a particular suit
>, ==, or < a particular value
a face card
a joker
It has methods to
shift cards up or down in the deck, wrapping if necessary
perform a triple cut (see Ruby Quiz)
perform a count cut (see Ruby Quiz)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.