Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve this question using Haskell : For this question, you will implement functions/methods for evaluating two poker hands and choosing a winner The way each

solve this question using Haskell:

For this question, you will implement functions/methods for evaluating two poker hands and choosing a winner

The way each hand is represented will differ based on which language youre using. If you would like to represent the hands differently, please e-mail me and make a request. I will consider it so long as it doesnt significantly reduce the difficulty of the assignment. You may assume that the hands, when passed into your function, will be formed correctly. That is, you dont have to worry about error checking the data type, the number of cards in each hand, etc.

The rank of each card will be integer. To keep it simple, ace will have a rank of 14. Thus, ranks go from 2 to 14 (11 = Jack, 12 = Queen, 13 = King, 14 = Ace). This way, higher rank is always better.

The suit of each card will be String: H = hearts, D = diamonds, S = spades, C = clubs.

Assume that one hand will always clearly win. Assume that if two hands would be tied in poker, this input would not occur when testing your code. There are tie breaking mechanisms in the actual game of poker - for example, if two hands have the same high card, we check the second highest card, etc. You are not required to consider these cases. Finally, indicate, in some fashion, which hand wins. It can be as simple as returning true if first hand wins, or false otherwise. You can also print a message saying which hand won, etc.

Q:

Represent each hand as a list of pair tuples. Name your function for finding the winning hand winner, and call it as follows: hand1 = [(3, H), (10, S), (4, S), (4, C), (5, C)]

hand2 = [(2, H), (2, S), (5, S), (2, C), (13, C)]

winner hand1 hand2 Your winner function and all associated helper functions should be defined in a module called Poker, in a file Poker.hs. ? note:

When it comes to tie breaking, you only have to consider one "layer" of a tie. Here are some examples:

You program should be able to handle:

If both hands have a pair, the higher pair wins. A pair of Kings beats a pair of 10s, for example.

If both hands have a flush, the flush with the higher card wins. A 10-high flush beats an 8-high flush.

You do NOT have to consider:

If the high hand is a pair, but both hands have the same pair. For example, both hands have a pair of Jacks. In this case, the hand with the higher card outside of the pair would win. However, you do not have to worry about this situation. I won't validate your code on this kind of hand.

Likewise, if the high hand is simply the highest card. If both hands have a King as their high card, the second highest card would win in an actual came of poker.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

ISBN: 0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Question What is a secular trust?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago