Euler Problem 54 Answer Via Python

Euler problem 54, poker hands, https://projecteuler.net/problem=54

With a txt file filled with 1000 lines of poker hands from two players, the question is how many hands does Player 1 win?

I would give the answer at very bottom of this post in case of some guys like to crack it out on their own. My solution is via python program language and wrote the code on Sublime Text 2. Since I am a beginner of codes, my implementation is lousy and crappy, although it’s sure to get correct result. So here is just a way to carry out the problem, if you are unable to work it out, think need help, that my codes would at least are worthy of trying and inspiring.

Oh, no. It is shameful to paste my complete codes here, cause it is too straight and bumpy, even not optimized. Instead of that, I just illustrate the flow chart.

detect poker hands flow chart

detect poker hands flow chart

So I call two functions first, has_flush and has_straight, they are for checking whether a flush or straight exist or not. Combine with that information, I can determine the very highest poker hand each player has. But that’s not enough, cuz there would be chance the result would be a tie. So in that case, I should go for checking second highest poker hands and may continue for next compare and more, think about the situations when two players are all holding high cards and the four highest cards are same. Once finished the competition, return final result and add 1 point to due player win numbers variation. By the way, I have set up a ties variation to record all the ties, but I do not draw it in the chart, you will know the reason.

The challenges of this problem are only two parts, I believe. One is to convert to strings input into something can be calculated, another is to detect the highest poker hands. For them, I created one dictionary and two lists:

suits = {"H":1, "S":2, "D":4, "C":8}
values = ["0","1","2","3","4","5","6","7","8","9","T","J","Q","K","A"]
ranks = ["High Cards", "One Pair", "Two Pair", "Three Of A Kind", "Straight", "Flush", "Full House", "Four Of A Kind", "Straight Flush", "Loyal Flush Straight"]

The dictionary type suits are for bitwise operators to check for same suit cards. The tricks of list type of values and ranks are the index of each item indicate its grade. And meanwhile you can determine the highest poker hand via these storage types.

Ok, now that’s jump to final answer to this problem, are you ready, you’re sure? The final answer is:

The answer of problem 54 of Euler project

The answer of problem 54 of Euler project

Last words. Man, after finished this, you should really consider about making a Texas holdem application online. Of course you still have other works to do, like simple random number generator, but after all, you finished the major part of that game.

Flash Poker Rules And Play Online

Flash poker is another variation of poker, however, it is a very simple version of gambling. It shows some similarities with Texas holdem when count winnings, but it doesn’t need flop, turn or river, just two bets. When I said two bets, actually I mean two sections of bets, the first bet is basic bet before any card dealt, and the second section bet actually is double up part, which can be infinite if you are lucky insanely.

Below are rules of flash poker I played online, if any different with yours, please let me know.
This is the page I played, flash poker at mindjolt.

The Play

At the very beginning, you would get 50 start-up credits.

  1. When it comes to first ante, there are five choices from 1 to 5, it is up to you.
  2. After click your bet, program begins to deal five cards for you.
  3. Hold some cards according to the rules of winnings.
  4. Program discards the cards you don’t want and deal new ones.
  5. Check rules, see if you are lucky guess or losing.
  6. The second section is to double up the money you just won.
  7. Feel free to stop at any guess and retain your triumph.

Be aware of the double-up section, you will lose all(nothing left include your bonus) if you just make one wrong guess. There are two types of double it up, the first one is to guess the color, red or black, the second one is more exciting because it is four times of your current wager if you can make a shot.

The Rules Of Winnings

5 of kinds: 100 credits
Straight flush: 60 credits
4 of kinds: 25 credits
Full house: 5 credits
Straight: 4 credits
Flush: 3 credits
3 of kinds: 2 credits
Two pairs: 1 credit

Below is a crappy cheat sheet image made by me for you.

Flash Poker Rules Cheat Sheet

Flash Poker Cheat Sheet

I hope I got everything explicit, if you do not follow me or have more details to share, please comment right here or contact me.

What Can We Learn From The One With All The Poker

With the improvement of the standard of living, more and more people tend to pay much attention to their spiritual life. Poker is a good way to enrich people’s life and nurture their souls. Playing poker has become an international game for people all over the world. Although it is quite popular, there is still a must for us to know more about poker. Now let’s learn several poker knowledge points from The One with All the Poker in Friends, a well-known situation comedy.

NO.1 Straight

In The One with All the Poker, the relevant conversation is as follows:

A: So now we draw cards.

B: So I wouldn’t need any. I have a straight.

A: Oh, good for you! Congratulations!

In a poker game, there are 10 hands of cards, namely five of a kind, straight flush, four of a kind, full house, flush, straight, three of a kind, two pair, pair and high card. Straight is ranked the 6th among the poker hands. Then, what is straight? A straight is 5 cards in order, such as 5-6-7-8-9. Although an ace may be considered as high or low, a straight can not wrap around. For example, A-K-Q-J-T is a straight while Q-K-A-2-3 is not a straight.

NO.2 Four of a Kind

The conversation in The One with All the Poker as follows:

A: Don’t need them. I’m going for fours. Chandler, could you?

B: Here we go.

“Fours” in the conversation means four of a kind. In the above paragraphs, we can know that four of a kind is ranked 3rd in the card hands. Do you know what this poker term means? Actually, it is quite simple for people to understand. Four of a kind means four cards of the same rank. The hand with the higher-rank four of a kind wins if there are two or more hands that qualify. Then, how to judge who is high or low when they hold the same four of a kind? When there are two four of a kinds with the same rank, the player who holds the high card outside the four of a kind wins the game.

NO.3 Full House

The short conversation in the situation comedy Friend is in the following.

A: What do you get?

B: Full house.

A: You got me.

In card hands, full house is ranked the 4th. In fact, a full house is a three of a kind and a pair. For example, Q-Q-Q-7-7 belongs to a full house in a poker game. How can we judge who wins the game when poker players hold the same cards with a full house at the same time? As for this, we can compare the three of a kind at the first and then the pair. For example, J-J-J-7-7 beats 9-9-9-7-7. 9-9-9-7-7 beats 9-9-9-5-5. Of course, the rest can be done in the same way.

NO.4 Bluffing

An interesting conversation about bluffing in comedy Friends is listed as follows.

A: I see. You were lying.

B: About what?

A: About how good your cards were.

B: I was bluffing.

A: And what is bluffing?

B: Is it not another word for lying?

Aha! This is quite an interesting conversation in the comedy! The guy uses a good poker skill to make himself look confident in front of other poker players. He pretends that he holds the good hand of cards so that he can have more mental advantages than other players in the game. However, the girl can not be aware of this small poker trick at the first. As a matter of fact, poker is not just a game of chance. It is also a game of psychological battle between poker players.

NO.5 Five-Card Draw

A relevant conversation that talks about five-card draw in The One with All the Poker can be seen in the following.

A: Listen, I’m parked at a meter. Let’s do it. Okay?

B: We’ll start with five-card draw.

Then we’ll go into the studs and he hold ‘ems. I talked to Cousin Nathan.

As a matter of fact, among all the poker hands, five-card draw is thought to be one of the most common hand types. In a formal poker game, each poker player at a poker table is required to deal with five cards. Afterwards, they need to make a bet in the round of the game. In general, in the process of playing cards, every player may discard up to 3 cards and get back from the deck as many playing cards as he or she has discarded in the game. After that, another round of betting follows according to poker rules. Then, hands need to be revealed. In a poker game, it is also called showdown. Finally, the person who has the cards with the highest rank wins at the game.

In addition to the above interesting pokers terms that are presented in The One with All the Poker, there are many other funny poker words and skills. Poker is a very interesting world and it is worth your deeper exploration. If you pay more attention to your life and poker, you will certainly find and learn more about poker.

Best Gift for Dads on Father’ Day in 2015

Father’s love is like the sunrise, open, straightforward and sincere, while mother’s love is the moon, kind, tender and unselfish. However, most of the time, we are inclined to ignore our dad as he is not good at expressing himself. He is always dedicated to the family with heart and soul but in silence. On father’ day, there is a must for us to give him a precious gift to show our gratitude. Fathers’ Day is around the corner! This is a good chance for us to give our sincere regards to dad.

Have you prepared Fathers’ Day gift for your dad yet? I guess you may be in a loss and have no idea. Now, let’s look at the best gift for dad on Father’s Day in 2015.

It is known to us that dad is the hardest work in the world. He needs to work very hard outside to earn money in order to support family. He needs to help do housework inside when he comes back home after work. He needs to be concerned about his babies like mother. There are too many things waiting for busy dad to do everyday. As a result, our dad is in bad need of relaxation and entertainment in their precious free time. In view of this point, out of sincere gratitude and appreciation, we are supposed to prepare a special and funny gift for dad on his day.

In my point of view, compared with many other kinds of parental presents, poker can be considered to be the best gift for dads on this Father’ Day. Although it is a small item, it can make a big difference to you and your dad to an extent. It is not very dear in price but poker is absolutely dear in emotional value. Generally speaking, the values of poker as a Father’ Day selected gift can be embodied in the following aspects.

To begin with, it is a good way for dads to play poker to relax themselves in their spare time or when they are off work. Usually, after a day of hard work, it is very necessary for him to take a good rest and have some fun by means of playing cards. Playing poker needs no excellent skill and much practice. As long as you are devoted to poker game, you can not only make your body and mind relaxed but also help yourselves recover from stressful work very soon. In a sense, it is better for all dads to play poker than other recreational activities.

In the second place, poker can serve as a good communication promoter. It can be a perfect bridge between your dad and family members. At preset, it is quite for people to get together all the time, so there is no much time for family members to communicate with each other. Why do we take the chance to promote communication and strengthen relationships between you and your dad? Through playing card with dad, we can have a better understanding of reserved dad and learn how to communicate with him in a relaxed way. In a poker game, we can not only have fun but also make our hearts closer and closer, no matter how far we are.

In the next place, poker play is a brain developing game. It is beneficial for elder dads to take to poker game in their later life. As we know, the old are prone to many different diseases, such as senile dementia, osteoporosis fracture and autism. To a large extent, the existence of poker is for all old dads in this planet. It can increase dad’s intelligence and slow down aging. In the process of playing poker, dads can keep their brains active and energetic all the time. Moreover, their brains can be as young as possible if they keep playing cards with other people. Of course, it is better for you to have a poker-loving dad. You are able to improve the poker playing skills with each other. If no, it doesn’t matter at all. You can give one pack of playing cards to your dad as a special festival gift and teach him to play poker. Both of you can enjoy the poker fun with one another at home.

Last but not the least, dad has a lot of free time in the later life while as a son or daughter, we can not have enough time to be with him because we have to work and do many other things. Because of this, most dads suffer from autism and live not as happily as before. In my mind, it is a son or daughter’s duty to make dad live with happiness when he is old. Therefore, on Father’s Day, we can prepare a pack of exquisite poker for dad as a gift and go home to play poker with dad. At playing, we can bring him our good news and share our happiness with dad. When we leave, poker can be a good item to help dad spend boring days and enrich his life. With so many attractive features, poker is the best gift for dads on Father’s Day. Love him and give him the best!

Wrote by Miss Lin.

Recommends:

http://www.pokernews.com/news/2006/05/dad-poker-player-fathers-day.htm

a deck of aces as father day's gift

ace poker gift

10 Interesting Family Names About Poker

When poker becomes very popular with the young and the old all over the world, more and more people are curious about the famous people and interesting stories behind poker. Indeed, poker is an interesting game for people in their spare time. It can not only make people happy but also make them rich sometimes. In order to satisfy poker fans’ curiosity, here I will be happy to share 10 interesting family names about poker game with you.

NO.1 Gamble

Gamble is a general term in poker. This is because that poker can not only be considered as a game for amusement but also a gamble for fortune. However, looking up it in a surname dictionary, you will find that gamble is one of English family names. It means old. As said, it is originated from the language of Old Norse in northern Europe. Although Gamble is not a common family name, there are still some famous people who have this surname. Take James Gamble for example. He is one of the founders of P&G, a leader in the mass market cosmetics industry. He set up a P&G in a financial crisis with his brother-in-law William Procter and finally they both made P&G one of the largest and most famous companies specializing in producing goods for everyday consumption.

 

NO.2 Bridge

Bridge is short for contract bridge, which is a kind of poker games. When it comes to poker, people will think of bridge, because bridge is selected as the highest ranking in all kinds of poker games. In terms of surnames, Bridge means a medium between two places. Among a crowd of celebrities, we can discover Wayne Nichael Brdge is a good example. He made his debut in Southampton Academy in 1998 and has played football for Chelsea, Manchester City and Fulham. Besides that, Wayne Nichael Bridge has also made 36 appearances for the English national team. He has once represented England in the World Cup.

 

NO.3 King

In a poker glossary, a king is a playing card with a picture of a king on it. Seeing from poker point, we can know king is a major card. However, King is also an interesting surname for people who speak English. It was evolved from an old English word “cyning”. Its original meaning is a tribal leader and later it is equal to people who have kingship. People love to use it as their last name to show their social status. We can find some famous people who have this interesting surname. For instance, Martin Luther King is a famous American civil right leader, who was graduated from university in 1948 and got a further education between 1948 and 1951. He addressed a famous speech I Have a Dream in 1963. He also won the Nobel Peace Prize in 1964 because of his contributions.

 

NO.4 Jack

In a poker game, a jack is a playing card with a picture of a jack. However, in a surname glossary, it is a popular family name to show a man’s good quality. When it comes to “Jack”, people will think of strength and persistence. As a result, it is a male family name and Jackson is its derivative surname. Among celebrities who contain this surname, Michael Jackson is a typical example. It is known to all of us that he was a famous person who has many titles, such as American singer, songwriter, dancer and performer, pacifist, charity founder, etc. He has initiated electric boogaloo and moonwalk. In 2010, he was awarded Grammy Lifetime Achievement Award.

 

NO.5 Blind

Blind is a common term in a poker gamble. In order to make a game go on smoothly, a banker has to force a man sitting clockwise to make a note (also called small blind) while a man sitting next has to make two notes in the game (called big blind). Just looking around, we can find some people take Blind as their last name. Let’s take Daley Blind for example. He was born in Amsterdam on 9th, March, 1990. Daley Blind is a Dutch football player with a bright future in his football career. At present, he is one member of Dutch national football team. This year, he has represented Netherlands to take part in the World Cup.

NO.6 Stake

As a professional poker player, I think you must be very familiar with this word “stake”. As a matter of fact, stake is a frequently-used word in the game of poker. When a dealer finished dealing cards, all players are required to stake in the round of the gamble. However, in our daily life, Stake is also a very interesting surname for a man. If you are interested in designing, you may know Phillip Stake, a well-known French legendary figure in the designing area. His extraordinary works can be seen from hotels in New York to presidential private residences in France.

 

NO.7 Hand

If you have good luck in a poker game, it often means that you have a good hand of cards. Hand is a common poker term while it is a rare family name for a man in English countries. In fact, it is a main feature for the European to take human organs as their surnames, such as Armstrong, Tongue, Brow and Ear. When it comes to Hand, I think most people will think of Learned Hand at once. He is a notable judge who has put forward a Hand formula in a case, which has established his position in law.

 

NO.8 Queen

In a pack of poker, a queen is a playing card with a classic picture of a queen on it. In the poker point ranking, queen is a major card. However, as a family name, queen is a symbol of a person’s social status. Moreover, it is usually used as a female last name. For this surname, I think Molly Queen is a fit notable person. She is a new star in American acting area. By so far, she has played the leading roles in two well-known TV shows.

 

NO.9 Call

In my point of view, call can be said to be the most common poker term, which may be used by a player more than ten times in a round of a poker game. When we play poker, we can often hear our partner says it is your turn to call. Actually, bid is formal while call is oral. When call is used as a surname, we can find some celebrities who have this interesting last name about poker. Take Brij Mohan Call as an example. He was an Indian army lieutenant general, who had never fought by himself but got crony promotion.

 

NO.10 Card

It is known to us that poker is a card game that has been favored by a large number of people all over the globe. In general, there are 54 cards in one pack of poker while there are 36 cards in a pack of Russian poker. In our daily life, we can discover some people take Card as an interesting surname. For example, Orson Scott Card, a popular science fiction writer in America, has been awarded many important awards in the literary arena. Ender’s Game is his representative works.

Wrote by Miss Lin.

ten poker last names

ten poker last names

Counting Cards Should Be Legal

First of all, here is a news about what we are going to talk about today.

Don’t care about what the society says, the casinos and poker players, just think about all by yourself, with your own logical and rational mind. Ask yourself: “Is card counting legal?”, then start to go through the question in your head. Every normal person will get the same answer with no need to get to the bottom of it. Because this is it, so simple, so sensible, nothing can refute the answer. What is the answer though? It’s legal and make sense, ask rhetorical question to yourself, why can’t I count playing cards, why?  And to the next level, card counting should be legal and legislated, that is casinos have no rights to ask a counter to leave.

What actually is card counter? We should announce it correctly, otherwise there may be loopholes to people who would take advantage of them. To me, a counter is very different to card shark, or poker cheater. Cheating at poker game is obviously illegal, either to casinos or other gamblers. If you play five card draw, you don’t want to lose just because others cheat on you. Those cheaters often use some poker cheating system as help, such as poker analyzers and marked cards system. But card counters don’t, they play poker under the rules, they just use their memory skills to help them win as possible as they can. If using memory is illegal, then what the hell should we remember all the rules of Texas holdem, the royal flush or fours, we just go to buy some lotteries and wait for the luck hit us.

Casinos should open their minds, if they don’t wanna lose, train their dealers to be masters at counting too. After all, memorizing poker cards is not that easy job for everyone. Cheating is intolerable, but counting is just nature. I heart about online gambling, I would like to know what they can do to online counters. I like this answer by ZCT on yahoo, you should check it.

My Slow Win Strategy At Texas Hold’em

Since the first night I played Texas holdem, I played it for few months so far. At the very first beginning, as a newbie, I was like to win some basic money very easily, because I was new to this game, and the old saying says:”The more wit,the less courage”. So it made me continue to involve  and soon, I started to lose money. At that point, I was told that this is the game at which luck is not only angel works. That’s the time I began to read more information about holdem, I knew what is no limit, big and small blind, and call and raise.

When I was much more familiar with this money game, I made a plan to play every day. For the time, I only allow me to spend one hour each day. I played online, so it is not so good for me to stared at computer screen for too long. For money involved, I check the percentage of how money I win or lose, if it is more than 5% either way,  I just stop. The main purpose I play poker cards is not for money, I have a job, that is what I live off, I play poker for fun and recreation.

So everything becomes slow. It turns out to be I am not bad at Texas holdem, I won at most of times. But I think it should be thank to my slow win strategy and my plan. Although it is a just small amount of stake, I am satisfied.

Texas holdem poker

Texas holdem, you fold, you call, and you win.