0 people like it.

What's My SuperBowl Pool Box Worth?

If I'd entered the same SuperBowl Pool every year, and received the same numbers every year, how much would I have won?

 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: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
65: 
66: 
// Per-quarter points scored for every superbowl - AFC,NFC
let quarterPoints = [
    ([ 0;10; 0; 0],[ 7; 7;14; 7]);
    ([ 0; 7; 0; 7],[ 3;13;10; 7]);
    ([ 0; 7; 6; 3],[ 0; 0; 0; 7]);
    ([ 3;13; 7; 0],[ 0; 0; 7; 0]);
    ([ 0; 6; 0;10],[ 3;10; 0; 0]);
    ([ 0; 3; 0; 0],[ 3; 7; 7; 7]);
    ([ 7; 7; 0; 0],[ 0; 0; 0; 7]);
    ([14; 3; 7; 0],[ 0; 0; 0; 7]);
    ([ 0; 2; 7; 7],[ 0; 0; 0; 6]);
    ([ 7; 0; 0;14],[ 7; 3; 0; 7]);
    ([ 0;16; 3;13],[ 0; 0; 7; 7]);
    ([ 0; 0;10; 0],[10; 3; 7; 7]);
    ([ 7;14; 0;14],[ 7; 7; 3;14]);
    ([ 3; 7; 7;14],[ 7; 6; 6; 0]);
    ([14; 0;10; 3],[ 0; 3; 0; 7]);
    ([ 0; 0; 7;14],[ 7;13; 0; 6]);
    ([ 7;10; 0; 0],[ 0;10; 3;14]);
    ([ 7;14;14; 3],[ 0; 3; 6; 0]);
    ([10; 6; 0; 0],[ 7;21;10; 0]);
    ([ 3; 0; 0; 7],[13;10;21; 2]);
    ([10; 0; 0;10],[ 7; 2;17;13]);
    ([10; 0; 0; 0],[ 0;35; 0; 7]);
    ([ 0; 3;10; 3],[ 3; 0; 3;14]);
    ([ 3; 0; 7; 0],[13;14;14;14]);
    ([ 3; 9; 0; 7],[ 3; 7; 7; 3]);
    ([ 0; 0;10;14],[ 0;17;14; 6]);
    ([ 7; 3; 7; 0],[14;14; 3;21]);
    ([ 3;10; 0; 0],[ 6; 0;14;10]);
    ([ 7; 3; 8; 8],[14;14;14; 7]);
    ([ 0; 7; 0;10],[10; 3; 7; 7]);
    ([14; 0; 7; 0],[10;17; 8; 0]);
    ([ 7;10; 7; 7],[ 7; 7; 3; 7]);
    ([ 7;10; 0;17],[ 3; 3; 0;13]);
    ([ 0; 0; 6;10],[ 3; 6; 7; 7]);
    ([ 7; 3;14;10],[ 0; 0; 7; 0]);
    ([ 0;14; 3; 3],[ 3; 0; 0;14]);
    ([ 3; 0; 6;12],[ 3;17;14;14]);
    ([ 0;14; 0;18],[ 0;10; 0;19]);
    ([ 0; 7; 7;10],[ 0; 7; 7; 7]);
    ([ 0; 7; 7; 7],[ 3; 0; 7; 0]);
    ([ 6;10; 6; 7],[14; 0; 3; 0]);
    ([ 0; 7; 0; 7],[ 3; 0; 0;14]);
    ([ 3;14; 3; 7],[ 0; 7; 0;16]);
    ([10; 0; 7; 0],[ 0; 6;10;15]);
    ([ 0;10; 7; 8],[14; 7; 0;10]);
    ([ 9; 0; 6; 6],[ 0;10; 7; 0]) ]

// Dollars to win at the end of each quarter
let prizes = [| 50; 125; 75; 250 |]

let total points = Seq.scan (fun t p -> t + p) (List.head points) (List.tail points)

let modulo = fun i -> i % 10
let modulos points = Seq.map modulo (total points)
let quarterModulos = Seq.map (fun (afc, nfc) -> modulos afc, modulos nfc) quarterPoints

let payoff : int[,] = Array2D.zeroCreate 10 10

let payQuarter (afc, nfc, prize) = payoff.[nfc,afc] <- payoff.[nfc,afc] + prize
let payGame (afc, nfc) = Seq.iter payQuarter (Seq.zip3 afc nfc prizes)

Seq.iter payGame quarterModulos

payoff
val quarterPoints : (int list * int list) list

Full name: Script.quarterPoints
val prizes : int []

Full name: Script.prizes
val total : points:int list -> seq<int>

Full name: Script.total
val points : int list
module Seq

from Microsoft.FSharp.Collections
val scan : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> seq<'State>

Full name: Microsoft.FSharp.Collections.Seq.scan
val t : int
val p : int
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val head : list:'T list -> 'T

Full name: Microsoft.FSharp.Collections.List.head
val tail : list:'T list -> 'T list

Full name: Microsoft.FSharp.Collections.List.tail
val modulo : i:int -> int

Full name: Script.modulo
val i : int
val modulos : points:int list -> seq<int>

Full name: Script.modulos
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val quarterModulos : seq<seq<int> * seq<int>>

Full name: Script.quarterModulos
val afc : int list
val nfc : int list
val payoff : int [,]

Full name: Script.payoff
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
module Array2D

from Microsoft.FSharp.Collections
val zeroCreate : length1:int -> length2:int -> 'T [,]

Full name: Microsoft.FSharp.Collections.Array2D.zeroCreate
val payQuarter : afc:int * nfc:int * prize:int -> unit

Full name: Script.payQuarter
val afc : int
val nfc : int
val prize : int
val payGame : afc:seq<int> * nfc:seq<int> -> unit

Full name: Script.payGame
val afc : seq<int>
val nfc : seq<int>
val iter : action:('T -> unit) -> source:seq<'T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iter
val zip3 : source1:seq<'T1> -> source2:seq<'T2> -> source3:seq<'T3> -> seq<'T1 * 'T2 * 'T3>

Full name: Microsoft.FSharp.Collections.Seq.zip3
Raw view Test code New version

More information

Link:http://fssnip.net/gF
Posted:11 years ago
Author:Wayne Bradney
Tags: fun