PROBLEM SET 2 Due: Friday, September 28. Reading: CLRS Chapter 5 & Appendix C; CLR Sections 6.1, 6.2, 6.3, & 6.6;

Similar documents
CS Project 1 Fall 2017

A Case Study. Overview. References. Video poker Poker.Card & Poker.Hand General.dll & game variants

CS Programming Project 1

CS 210 Fundamentals of Programming I Fall 2015 Programming Project 8

Project 2 - Blackjack Due 7/1/12 by Midnight

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 8

{ a, b }, { a, c }, { b, c }

Problem Set 4: Video Poker

3 The multiplication rule/miscellaneous counting problems

Here are two situations involving chance:

Programming Assignment 4

Problem A. Worst Locations

CSC/MTH 231 Discrete Structures II Spring, Homework 5

Chapter 4: Probability

After receiving his initial two cards, the player has four standard options: he can "Hit," "Stand," "Double Down," or "Split a pair.

Ante or ante wager means the initial wager required to be made prior to any cards being dealt in order to participate in the round of play.

FLOP POKER. Rank-- or ranking means the relative position of a card or hand as set forth in Section 5.

Probability & Expectation. Professor Kevin Gold

3 The multiplication rule/miscellaneous counting problems

TEXAS HOLD EM BONUS POKER

Poker Rules Friday Night Poker Club

CSCI 4150 Introduction to Artificial Intelligence, Fall 2004 Assignment 7 (135 points), out Monday November 22, due Thursday December 9

Acing Math (One Deck At A Time!): A Collection of Math Games. Table of Contents

HEADS UP HOLD EM. "Cover card" - means a yellow or green plastic card used during the cut process and then to conceal the bottom card of the deck.


In 2004 the author published a paper on a

13:69E-1.13Z Criss cross poker; physical characteristics

TABLE GAMES RULES OF THE GAME

Pan (7:30am) Juan (8:30am) Juan (9:30am) Allison (10:30am) Allison (11:30am) Mike L. (12:30pm) Mike C. (1:30pm) Grant (2:30pm)

Poker Hand Rankings Highest to Lowest A Poker Hand s Rank determines the winner of the pot!

FOUR CARD POKER. Hand-- means the best four card poker hand that can be formed by each player and the dealer from the cards they are dealt.

Contemporary Mathematics Math 1030 Sample Exam I Chapters Time Limit: 90 Minutes No Scratch Paper Calculator Allowed: Scientific

Poker Hands. Christopher Hayes

Discrete Finite Probability Probability 1

No Flop No Table Limit. Number of

COMP 9 Lab 3: Blackjack revisited

Counting Poker Hands

Maryland State Lottery and Gaming Control Agency Standard Rules Criss Cross Poker

Poker: Further Issues in Probability. Poker I 1/29

Maryland State Lottery and Gaming Control Agency Standard Rules - Double Draw Poker

ULTIMATE TEXAS HOLD EM

Week 1: Probability models and counting

LET IT RIDE POKER. Stub-- means the remaining portion of the deck after all cards in the round of play have been dealt or delivered.

Lecture 1. Permutations and combinations, Pascal s triangle, learning to count

NAME : Math 20. Midterm 1 July 14, Prof. Pantone

1. The chance of getting a flush in a 5-card poker hand is about 2 in 1000.

CATFISH BEND CASINOS RULES OF THE GAME THREE CARD POKER

Math 166: Topics in Contemporary Mathematics II

4.1 Sample Spaces and Events

A Rule-Based Learning Poker Player

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

A. Rules of blackjack, representations, and playing blackjack

Fall 2017 March 13, Written Homework 4

2016 CCSC Eastern Conference Programming Competition

FAST ACTION HOLD EM. Copy hand-- means a five-card hand of a player that is identical in rank to the five-card hand of the dealer.

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 13

The Teachers Circle Mar. 20, 2012 HOW TO GAMBLE IF YOU MUST (I ll bet you $5 that if you give me $10, I ll give you $20.)

Simulations. 1 The Concept

6/24/14. The Poker Manipulation. The Counting Principle. MAFS.912.S-IC.1: Understand and evaluate random processes underlying statistical experiments

9 Video Poker Paytables in 1 Game Ultimate X Triple Play Draw Poker provides a rich selection of the most popular video poker paytables:

The topic for the third and final major portion of the course is Probability. We will aim to make sense of statements such as the following:

The point value of each problem is in the left-hand margin. You must show your work to receive any credit, except on problems 1 & 2. Work neatly.

Homework 8 (for lectures on 10/14,10/16)

Math 2 Proportion & Probability Part 3 Sums of Series, Combinations & Compound Probability

Compound Probability. Set Theory. Basic Definitions

The student will explain and evaluate the financial impact and consequences of gambling.

Independent and Mutually Exclusive Events

Live Casino game rules. 1. Live Baccarat. 2. Live Blackjack. 3. Casino Hold'em. 4. Generic Rulette. 5. Three card Poker

HIGH CARD FLUSH 1. Definitions

Defensive Signals. Attitude Signals

EE 126 Fall 2006 Midterm #1 Thursday October 6, 7 8:30pm DO NOT TURN THIS PAGE OVER UNTIL YOU ARE TOLD TO DO SO

To play the game player has to place a bet on the ANTE bet (initial bet). Optionally player can also place a BONUS bet.

CRISS-CROSS POKER. Community cards Cards which are used by all players to form a five-card Poker hand.

13:69E 1.13Z 5 Card Hi Lo table; physical characteristics. (a) 5 card hi lo shall be played at a table having on one side

For this assignment, your job is to create a program that plays (a simplified version of) blackjack. Name your program blackjack.py.

CHAPTER 649a. THREE CARD POKER

Ch. 670a SIX-CARD FORTUNE PAI GOW POKER a.1. CHAPTER 670a. SIX-CARD FORTUNE PAI GOW POKER

Math-Essentials. Lesson 9-2: Counting Combinations

Problem A: Code Breaking

CSEP 573 Applications of Artificial Intelligence Winter 2011 Assignment 3 Due: Wednesday February 16, 6:30PM

HOW to PLAY TABLE GAMES

Theory of Probability - Brett Bernstein

November 8, Chapter 8: Probability: The Mathematics of Chance

CSE 231 Fall 2012 Programming Project 8

More Probability: Poker Hands and some issues in Counting

CHAPTER 69F RULES OF THE GAMES

CATFISH BEND CASINOS, L.C. RULES OF THE GAME FOUR CARD POKER

Welcome to the Best of Poker Help File.

2. A separate designated betting area at each betting position for the placement of the ante wager;

Activity 1: Play comparison games involving fractions, decimals and/or integers.

FreeCell Puzzle Protocol Document

HOW TO PLAY BLACKJACK

NUMB3RS Activity: A Bit of Basic Blackjack. Episode: Double Down

Name: Exam 1. September 14, 2017

Mathematical Foundations HW 5 By 11:59pm, 12 Dec, 2015

Today s Topics. Sometimes when counting a set, we count the same item more than once

Unit 9: Probability Assignments

Use a tree diagram to find the number of possible outcomes. 2. How many outcomes are there altogether? 2.

The game of poker. Gambling and probability. Poker probability: royal flush. Poker probability: four of a kind

POKER (AN INTRODUCTION TO COUNTING)

Transcription:

CS231 Algorithms Handout #8 Prof Lyn Turbak September 21, 2001 Wellesley College PROBLEM SET 2 Due: Friday, September 28 Reading: CLRS Chapter 5 & Appendix C; CLR Sections 6.1, 6.2, 6.3, & 6.6; Suggested Problems: CLRS C.1-1, C.1-2,C.1-3,C.1-4; C.2-2, C.2-3,C.2-10; C.3-1, C.3-2, C.3-3; 5.4-2, CLR 6.1-1, 6.1-2, 6.1-3, 6.1-4; 6.2-2, 6.2-3, 6.2-4, 6.2-11; 6.3-1, 6.3-2, 6.3-3 ; 6.6-1; 6-2; Problem 1: Let Me Count the Ways... [30] In the following parts,. please show how you derive your answers: a [5] How many ways can 12 students be assigned to the 15 computers in E101? (Assume each student is assigned to one computer.) b [5] Before we started running out of telephone numbers and changes were made to the system, it used to be that a long distance phone number was an area code followed by a 7-digit local number. An area code was a 3-digit number whose middle digit had to be a 0 or 1, whose first digit could not be 0 or 1, and whose last two digits could not be 11. The first 3 digits of the 7- digit local number could not be an area code. Under this scheme, how many long-distance phone numbers were there? c [10] How many terms are there in the expansion of (w + x + y + z) 7? Each term has the form cw e1 x e2 y e3 z e4, where e1 + e2 + e3 + e4 = 7. d [10] How many ways can 100 students be scheduled into 5 different writing classes so that each class has exactly 20 students and each student takes one class? Problem 2: The Infamous Monty Hall Problem [15] Do CLRS C.2-9, p. 1106 (CLR Exercise 6.2-10, p. 110). Justify your answer with a probability tree. It is important to note that the emcee knows where the prize is hidden, and so will always be able to reveal an empty stage behind one of the curtains you have not picked. (This is a classic problem that got national attention a few years back when it appeared in a popular column by Marilyn vos Savant. Many readers of her column, including those with math PhDs, made fools of themselves by adamantly arguing the wrong answer.) 1

Problem 3: Randomizing Arrays [15] Many array manipulation algorithms assume that the elements of an input array are randomly permuted. An array of n distinct items is randomly permuted if each of the n! permutations is equally likely. In many cases, the array input to such an algorithm is the output of another process that is decidedly non-random. So it is desirable to find an efficient way to randomly permute a given array. Suppose that: A is a length n array containing all the integers from 1 to n. swap(a, i, j) swaps the values in A[i] and A[j]. random(x, y) is a routine that returns a random integer between x and y, inclusive. For each of the following algorithms, indicate whether the algorithm randomly permutes the input array A. Justify your answer in each case. (Hint: try the algorithms for n = 3, and generalize.) a [5] b [5] c [5] for i <- 1 to n do A[i] <- random(1, n) for i <- 1 to n do swap(a, i, random(1, n)) for i <- 1 to n do swap(a, i, random(i, n)) Problem 4: Coin Flipping [25] We all know that a flip of a fair coin can be used to choose one of two possibilities with equal probability. It is not hard to see that a n flips of a fair coin can choose one of 2 n possibilities with equal probability. But did you know that a fair coin can be used to choose among m possibilities, where m is not a power of 2? In this problem, you will explore the case of m = 3, but the strategy generalizes to any m. Suppose you are given a black-box procedure Flip() that returns one of the symbols H or T, each with a probability of 1/2. a [10] Using Flip(), write pseudocode for a procedure One-Third() that returns one of the symbols A, B, or C, each with a probability of 1/3. (Hints: (1) think of the papertearing exercise from class and (2) make One-Third() recursive!) b [5] Demonstrate that your One-Third() procedure from part a is correct by showing that the probability of returning A is 1/3. (Presumably, the argument for B and C will be similar, so you need not show it.) c [10] Determine the expected number of times that your One-Third() procedure will call Flip() before returning a result. 2

Problem 5: Poker Time! [15] There are many variants of poker; here we describe the form most commonly played on video poker machines. A poker hand is a collection of five cards. We will write cards as a value (2 through 10, J (jack), Q (queen), K (king), or A (ace)) followed by a suit (C (clubs), D (diamonds), H (hearts), S (spades)). We will write a poker hand as comma delimited cards within square brackets, e.g. [2H, 5C, 6H, JS, AD]. The order of cards in a hand does not matter, but by convention we will write them in sorted order from low to high. The order of a card is first determined by its value (2 is lowest, ace is highest); two cards with the same value are order by suit, in the sequence (from low to high) clubs, diamonds, hearts, spades. In the following problems, show your work. a [5] How many distinct poker hands are there? b [10] A poker hand can be classified into several categories; here are two of them (see Extra Credit Problem 2 for the rest): Flush: a hand whose cards are all of the same suit. E.g.: [3C, 5C, 8C, 9C, QC], [8S, 9S, 10S, JS, KS] Straight: a sequence of five consecutive values. Note that for the purposes of a straight, an ace can count as the lowest card as well as the highest. E.g.: [AC, 2H, 3H, 4D, 5S], [4D, 5H, 6D, 7C, 8S], [10H, JH, QH, KC, AH] If you are dealt a poker hand from a fresh deck, is it more likely that you will be dealt a flush or a straight? (Note that a single hand can be both a flush and a straight such a hand is called a straight flush.) Justify your answer. If you would like to explore the probabilities of poker in more detail, do Extra Credit Problem 2. 3

Extra Credit Problem 1: Envelopes [20] (The best probability problem I know of! The following wording comes from Uri Wilensky s MIT Phd thesis) There are two envelopes in front of you. One contains x dollars and the other contains 2x dollars. You choose one, open it, and get $100. You are then offered a switch if you want it. You can take the other envelope instead. Here are two arguments: 1. There were 2 envelopes, one contained x dollars and the other 2x. You got either x or 2x. Each was equally likely, so switching doesn t help. 2. The other envelope contains either $200 or $50. These are equally likely. So the expected value of the other envelope is ($200 + $50)/2 = $125. You should switch. Which if any of these arguments do you believe? What is the bug in the other argument? Extra Credit Problem 2: More Poker Time! [30] This problem extends the analysis of poker from Problem 5. A poker hand can be classified into the following categories; in cases where more than one category applies, the one appearing earliest in the list is chosen: Royal Flush: a ten, jack, queen, king, and ace of the same suit. E.g.: [10H, JH, QH, KH, AH] Straight Flush: a sequence of five consecutive values of the same suit. E.g.: [AC, 2C, 3C, 4C, 5C], [8S, 9S, 10S, JS, QS]. Note that for the purposes of a straight, an ace can count as the lowest card as well as the highest. Four of a Kind: a hand that contains four cards with the same value: E.g.: [6C, 6D, 6H, 6S, 9D], [2S, 3C, 3D, 3H, 3S] Full House: a hand that contains three of one value of card and two of another. E.g.: [7C, 7H, JD, JH, JS], [2C, 2H, 2S, 8D, 8H] Flush: a hand whose cards are all of the same suit. E.g.: [3C, 5C, 8C, 9C, QC], [8S, 9S, 10S, JS, KS] Straight: a sequence of five consecutive values. Note that for the purposes of a straight, an ace can count as the lowest card as well as the highest. E.g.: [AC, 2H, 3H, 4D, 5S], [4D, 5H, 6D, 7C, 8S], [10H, JH, QH, KC, AH] Three of a Kind: a hand that contains three cards with the same value. E.g.: [2C, 2D, 2H, 8C, 10H], [4H, 5C, 5H, 5S, QS], [2S, 7H, JD, JH, JS] Two Pairs: a hand that contains two cards of one value and two cards of another value. E.g.: [3H, 3S. 7C, 7H, QD], [8C, 8H, JD, KC, KS], [6S, 9H, 9S, QC, QH] Pair of Jacks or Better: a hand that contains two cards with the same value that is a Jack or higher. E.g: [JC, JD, QS, KC, AH], [7S, QD, QS, KS, AD], [3H, 9S, JC, JH, KD], [4H, 5C, 10H, AH, AS] 4

Pair of Tens or Less: a hand that contains two cards with the same value that is ten or lower. E.g: [8C, 8S, JC, QD, AC], [4S, 5D, 5H, JS, QH], [4H, 6D, 10C, 10H, JD], [2H, 6D, 7S, 8C, 8H] Nothing: a hand that has no pairs, straights, or flushes. Part a: Below is a table for the number of distinct hands in each category and the probability of getting a hand in each category dealt from a shuffled deck. Fill in the second and third columns by carefully counting the number of each kind of hand. Don't forget that each hand should only be classified into one category. That is, you should only count a straight flush as a straight flush and not as a straight or a flush. Show your derivation of each number. Category Number of Disinct Hands in Category Probability Video Poker Payoff Royal Flush 800:1 Straight Flush 50:1 Four of a Kind 25:1 Full House 9:1 Flush 6:1 Straight 4:1 Three of a Kind 3:1 Two Pairs 2:1 Pair of Jacks or Better 1:1 Pair of Tens or Less 0:1 Nothing 0:1 Total Part b: The fourth column shows a typical video poker payoff schedule. The notation n:1 means that for every dollar bet, n dollars will be one if the hand is in the given category. Given this payoff schedule determine the expected value of a dollar bet for five randomly dealt cards. Note: The expected value will be very low, because it does not model the "draw" aspect of draw poker in a real video poker game. In video poker, the player is first dealt a hand of five cards from a full, shuffled deck. The player is then allowed to discard as many of the cards from the hand as desired; all discarded cards are replaced by new cards drawn from the remaining deck. With the above payoff schedule, playing an optimal strategy in the dyields about a 99.5% return. That is, the perfect player on average will lose one half cent for every dollar bet. Of course, most players are far from perfect, so the casinos rake in quite a bit of money on this game. On the other hand, the laws of probability allow players to sometimes beat the house, which keeps them coming back and serves as good advertising to attract others. There are a few video poker machines with a different payoff schedule that has greater than 100% return for perfect play. These machines are coveted by professional gamblers, who will often play at them for stretches of 24 hours or longer. The key to winning on such a machine is to play until hitting a royal flush, which has a high relative payoff. Why would casinos have such machines? Because they attract customers, and few people can play them optimally. Any deviance from optimal play usually leads to an advantage for the casino. 5

Problem Set Header Page Please make this the first page of your hardcopy submission. CS231 Problem Set 2 Due Friday, September 28, 2001 Name: Date & Time Submitted (only if late): Collaborators (anyone you collaborated with in the process of doing the problem set): In the Time column, please estimate the time you spent on the parts of this problem set. Please try to be as accurate as possible; this information will help me to design future problem sets. I will fill out the Score column when grading your problem set. Part Time Score General Reading Problem 1 [30] Problem 2 [15] Problem 3 [15] Problem 4 [25] Problem 5 [15] Extra Credit 1 [20] Extra Credit 2 [30] Total 6