일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- solutions of matrix equation
- 재귀함수
- Big Theta
- 코틀린 Hello World!
- Big-Oh notation
- matrix trnasformations
- recursive algorithms
- nonhomogeneous linear system
- trivial solution
- 이진 탐색
- 빅오 표기법
- NumPy
- python
- 빅세타
- 알고리즘 분석의 실례
- homogeneous linear system
- Big-O 예제
- linear dependence
- matrix-vector product
- Big-Oh 예제
- 배열 섞기
- Big Omega
- 빅오메가
- one-to-one
- itertools
- 랜덤 순서 배열
- 코틀린 시작하기
- matrix fo a linear transformation
- 일차변환
- nontrivial solution
- Today
- Total
코딩 연습
프로젝트 오일러 54번 본문
문제는 다음과 같다.
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:
- High Card: Highest value card.
- One Pair: Two cards of the same value.
- Two Pairs: Two different pairs.
- Three of a Kind: Three cards of the same value.
- Straight: All cards are consecutive values.
- Flush: All cards of the same suit.
- Full House: Three of a kind and a pair.
- Four of a Kind: Four cards of the same value.
- Straight Flush: All cards are consecutive values of same suit.
- Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.
The cards are valued in the order:
2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.
Consider the following five hands dealt to two players:
Hand | Player 1 | Player 2 | Winner | |||
1 | 5H 5C 6S 7S KD Pair of Fives | 2C 3S 8S 8D TD Pair of Eights | Player 2 | |||
2 | 5D 8C 9S JS AC Highest card Ace | 2C 5C 7D 8S QH Highest card Queen | Player 1 | |||
3 | 2D 9C AS AH AC Three Aces | 3D 6D 7D TD QD Flush with Diamonds | Player 2 | |||
4 | 4D 6S 9H QH QC Pair of Queens Highest card Nine | 3D 6D 7H QD QS Pair of Queens Highest card Seven | Player 1 | |||
5 | 2H 2D 4C 4D 4S Full House With Three Fours | 3C 3D 3S 9S 9D Full House with Three Threes | Player 1 |
The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands are valid (no invalid characters or repeated cards), each player's hand is in no specific order, and in each hand there is a clear winner.
How many hands does Player 1 win?
정답은 열심히 노력하셔서 알아 내시고, 본인의 결과가 어디서 잘 못되었는지 확인하기 위해서 승패 결과 자료를 공개하겠다.
포커에 대한 사전 지식이 없어 이 문제를 너무 어렵게 접근했었다.
너무 자세한 승부 판정에 대한 걱정은 하지 않아도 되는 문제다.
문제에서 설명하는 범위에서 모든 승패 판정이 가능하다.
즉, 같은 rank 에서는 highest card만 가지고 승패를 판정할 수 있다.
더 이상 복잡한 결과는 주어진 데이터에 없다.
참고하시길....
'project euler with python' 카테고리의 다른 글
프로젝트 오일러 68번 (0) | 2016.03.15 |
---|---|
프로젝트 오일러 67번 (0) | 2016.03.15 |
프로젝트 오일러 66번 (0) | 2016.03.15 |
프로젝트 오일러 59번 (0) | 2016.03.15 |
프로젝트 오일러 51번 (0) | 2016.03.15 |