-
Notifications
You must be signed in to change notification settings - Fork 0
/
Collections.fs
49 lines (44 loc) · 1.51 KB
/
Collections.fs
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
module Collections
open Model
let allPositions = [FarLeft;Left;Centre;Right;FarRight]
let allWomen = [LadyWinslow;DoctorMarcolla;CountessContee;MadamNatsiou;BaronessFinch]
let allColours = [Purple;White;Red;Blue;Green]
let allHeirlooms = [Ring;BirdPendant;Diamond;WarMedal;SnuffTin]
let allDrinks = [Beer;Whiskey;Rum;Absinthe;Wine]
let allHomes = [Dunwall;Dabokva;Baleton;Fraeport;Karnaca]
let allPossibilities =
seq {
yield!
[0..4] |> Seq.collect (fun p ->
[0..4] |> Seq.collect (fun w ->
[0..4] |> Seq.collect (fun c ->
[0..4] |> Seq.collect (fun f ->
[0..4] |> Seq.collect (fun d ->
[0..4] |> Seq.map (fun o ->
{
position = allPositions.[p]
woman = allWomen.[w]
wearing = allColours.[c]
from = allHomes.[f]
drinking = allDrinks.[d]
owns = allHeirlooms.[o]
}))))))
}
let noConflict dx dy =
dx.position <> dy.position
&& dx.woman <> dy.woman
&& dx.wearing <> dy.wearing
&& dx.from <> dy.from
&& dx.drinking <> dy.drinking
&& dx.owns <> dy.owns
let rec distinctGroups group people =
seq {
if Set.count group = 5 then
yield group
else
yield!
people
|> List.filter (fun p -> Seq.forall (noConflict p) group)
|> Seq.collect (fun p ->
distinctGroups (Set.add p group) people)
}