Project

rypto

0.0
No commit activity in last 3 years
No release in over 3 years
A library that provides an API for solving hands from the Krypto card game. See http://en.wikipedia.org/wiki/Krypto_%28game%29 for a description of Krypto.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 5.5
~> 10.0
>= 0
 Project Readme

Rypto

Gem Version Build Status Dependency Status

A ruby gem library that provides an API for solving hands from the Krypto card game. Read more about Krypto.

Installation

Add this line to your application's Gemfile:

gem 'rypto'

And then execute:

% bundle install

Or install it yourself as:

% gem install rypto

Examples

Deal a hand of Krypto

This example shows creating a deck, dealing a hand of Krypto, and inspecting the possible solutions to the hand.

require 'rypto'

deck = Rypto::Deck.new

#Deal a random hand from the deck (removes dealt cards from deck)
hand = deck.deal_hand

#Print results in infix notation
puts hand.solve.infix

This will output:

(19 + 4 - 23) * 14 + 8 = 8
(19 + 4 - 23) / 14 + 8 = 8
(19 - (23 - 4)) * 14 + 8 = 8
(19 - (23 - 4)) / 14 + 8 = 8
(19 - (23 - 14 + 8)) * 4 = 8
(19 - (23 - 14) - 8) * 4 = 8
(19 - (23 - (14 - 8))) * 4 = 8
19 - (23 - 14) - 8 / 4 = 8
19 - (23 - 14 + 8 / 4) = 8
19 - (23 - (14 - 8 / 4)) = 8
...results truncated...

Solve a specific hand of Krypto

One can create a hand manually to solve a specific Krypto deal.

hand = Rypto::Hand.new [1,2,3,4,5], 6

#Print results in postfix notation
puts hand.solve.postfix

This will output:

1 2 + 3 4 + 5 - * = 6
1 2 3 + 4 - 5 + * = 6
1 2 3 + 4 - * 5 + = 6
1 2 3 + 4 - 5 * + = 6
1 2 3 + 4 - / 5 + = 6
1 2 3 + * 4 - 5 + = 6
1 2 3 * 4 + + 5 - = 6
1 2 3 * + 4 + 5 - = 6
1 2 * 3 + 4 - 5 + = 6
1 2 3 * 4 + 5 - + = 6
...results truncated...

Documentation

API Documentation

License

Copyright (c) 2015 Joe Sortelli

MIT License