;; Lab 8 ;; CMPU 145, Spring 2018 #lang racket (include "prob-helper.scm") (header "Lab 8" "YOUR NAME") ;; (problem "0a. Full house probability") ;; (define *num-ways-full-house* ;; (* 13 ;; 13 choices for rank of trips ;; 4 ;; 4-choose-3 ways of choosing suits for trips ;; 12 ;; 12 choices for rank of pair ;; 6)) ;; 4-choose-2 ways of choosing suits for the pair ;; (define *num-5-card-hands* (n-choose-k 52 5)) ;; (define *prob-full-house* ;; (/ *num-ways-full-house* ;; *num-5-card-hands* ;; 1.0)) ;; (tester '*num-ways-full-house*) ;; (tester '*prob-full-house*) ;; (problem "0b. Full house simulation") ;; (define has-full-house? ;; (lambda (cards) ;; (let ((sorted-ranks (sort (map rank cards) <=))) ;; ;; Pattern is either: (X X X Y Y) or (X X Y Y Y) ;; (or (and (= (first sorted-ranks) ;; (third sorted-ranks)) ;; (= (fourth sorted-ranks) ;; (fifth sorted-ranks))) ;; (and (= (first sorted-ranks) ;; (second sorted-ranks)) ;; (= (third sorted-ranks) ;; (fifth sorted-ranks))))))) ;; (tester '(gen-and-test 100000 gen-poker-hand has-full-house?)) ;; (tester '(gen-and-test 100000 gen-poker-hand has-full-house?)) ;; (tester '*prob-full-house*) (problem "1a...") (problem "1b...") (problem "2...")