Coder Social home page Coder Social logo

poker_hands's Introduction

PokerHands

Solution to Project Euler Problem #54 - Poker Hands

  • Task was to build an application to determine the winner between two poker hands
  • Given a text file poker.txt with 1000 hands, how many hands does Player 1 win https://projecteuler.net/problem=54

Built with Elixir

Format

Input

  • string
  • Example: 8C TS KC 9H 4S 7D 2S 5D 3S AC
  • First 5 cards are Player 1 cards
  • Last 5 cards are Player 2 cards
  • First character is the value of the card (2 - Two, T - Ten, K - King)
  • Second character denotes the suite (S - Spades, H - Hearts, C - Clubs, D - Diamonds)

Poker Hand Rankings Tiebreakers

https://www.adda52.com/poker/poker-rules/cash-game-rules/tie-breaker-rules

How to run against text file

  • In the command line, enter iex -S mix
  • Then enter PokerHands.count_player_1_wins("poker.txt")

poker_hands's People

Contributors

milevy1 avatar

Watchers

James Cloos avatar  avatar

poker_hands's Issues

Full house

Full House: Three of a kind and a pair.

.full_house?/1

  • Input list of values
  • Returns true if the hand is a full house
  • Else returns false

.ranking for a full house should be 4

High card tie breakers

When No Player Has Even A Pair, Then The Highest Card Wins. When Both Players Have Identical High Cards, The Next Highest Card Wins, And So On Until Five Cards Have Been Used. In The Unusual Circumstance That Two Players Hold The Identical Five Cards, The Pot Would Be Split.

Straight Ties - High card should win

Currently, .winner/1 is not accounting for a tie in rankings where both players have straights but the winner should be the high card between the two

Four of a kind

Four of a Kind: Four cards of the same value.

.four_of_a_kind?/1

Ranking of 3

Ties:

  • Player with higher value set of fours should win
  • If both players have same set of fours, high card should win
  • Same exact hand results in tie

Three of a kind

Three of a Kind: Three cards of the same value.

three_of_a_kind?(values)

.ranking/1 -> 7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.