Cut the Cards
08-24-2020, 09:49 PM
Post: #8
 pinkman Senior Member Posts: 403 Joined: Mar 2018
RE: Cut the Cards
Thanks for all those formulas and explanations.

Here is an implementation of the brute force algorithm for the experimental analysis:

Code:
 // Forward declaration CRDS(N); // Main func: // N is the number of cards // L is the number of tests // Returns average number of peeks EXPORT CARDS(N,L) BEGIN  LOCAL I, S := 0;  FOR I FROM 1 TO L DO   S := S + CRDS(N);   END;  RETURN S/L; END; // Peek a card until all cards //   are peeked at least once EXPORT CRDS(N) BEGIN  LOCAL LL, C := 0;  LL:=MAKELIST(0,A,1,N);  WHILE ΠLIST(LL)=0 DO   LL(RANDINT(1,N)):=1;   C := C+1;  END;   RETURN C; END;

Usage:
CARDS(number-of-cards, number-of-analysis)

Example:
CARDS(52, 1000)
Returns: 235.951

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
 « Next Oldest | Next Newest »

 Messages In This Thread Cut the Cards - David Hayden - 07-30-2020, 08:00 PM RE: Cut the Cards - Albert Chan - 07-30-2020, 08:58 PM RE: Cut the Cards - Albert Chan - 08-21-2020, 11:00 PM RE: Cut the Cards - Jim Horn - 07-30-2020, 09:49 PM RE: Cut the Cards - John Keith - 07-31-2020, 12:24 AM RE: Cut the Cards - Gerson W. Barbosa - 08-24-2020, 01:57 PM RE: Cut the Cards - Albert Chan - 08-25-2020, 06:14 PM RE: Cut the Cards - Albert Chan - 07-30-2020, 10:21 PM RE: Cut the Cards - pinkman - 08-24-2020 09:49 PM RE: Cut the Cards - Gerson W. Barbosa - 08-25-2020, 11:41 PM RE: Cut the Cards - Albert Chan - 08-26-2020, 03:06 AM RE: Cut the Cards - Gerson W. Barbosa - 08-26-2020, 08:23 AM RE: Cut the Cards - Albert Chan - 08-26-2020, 02:13 PM RE: Cut the Cards - Gerson W. Barbosa - 08-26-2020, 06:13 PM RE: Cut the Cards - Gerson W. Barbosa - 08-27-2020, 10:07 PM RE: Cut the Cards - Albert Chan - 08-28-2020, 09:26 PM RE: Cut the Cards - Albert Chan - 08-29-2020, 04:02 PM RE: Cut the Cards - Gerson W. Barbosa - 08-28-2020, 11:39 PM RE: Cut the Cards - Albert Chan - 06-23-2021, 12:08 AM

User(s) browsing this thread: 1 Guest(s)