Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Sum-to-100/F-Sharp/sum-to-100-1.fs
Normal file
18
Task/Sum-to-100/F-Sharp/sum-to-100-1.fs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(*
|
||||
Generate the data set
|
||||
Nigel Galloway February 22nd., 2017
|
||||
*)
|
||||
type N = {n:string; g:int}
|
||||
let N = seq {
|
||||
let rec fn n i g e l = seq {
|
||||
match i with
|
||||
|9 -> yield {n=l + "-9"; g=g+e-9}
|
||||
yield {n=l + "+9"; g=g+e+9}
|
||||
yield {n=l + "9"; g=g+e*10+9*n}
|
||||
|_ -> yield! fn -1 (i+1) (g+e) -i (l + string -i)
|
||||
yield! fn 1 (i+1) (g+e) i (l + "+" + string i)
|
||||
yield! fn n (i+1) g (e*10+i*n) (l + string i)
|
||||
}
|
||||
yield! fn 1 2 0 1 "1"
|
||||
yield! fn -1 2 0 -1 "-1"
|
||||
}
|
||||
1
Task/Sum-to-100/F-Sharp/sum-to-100-2.fs
Normal file
1
Task/Sum-to-100/F-Sharp/sum-to-100-2.fs
Normal file
|
|
@ -0,0 +1 @@
|
|||
N |> Seq.filter(fun n->n.g=100) |> Seq.iter(fun n->printfn "%s" n.n)
|
||||
2
Task/Sum-to-100/F-Sharp/sum-to-100-3.fs
Normal file
2
Task/Sum-to-100/F-Sharp/sum-to-100-3.fs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let n,g = N |> Seq.filter(fun n->n.g>=0) |> Seq.countBy(fun n->n.g) |> Seq.maxBy(snd)
|
||||
printfn "%d has %d solutions" n g
|
||||
3
Task/Sum-to-100/F-Sharp/sum-to-100-4.fs
Normal file
3
Task/Sum-to-100/F-Sharp/sum-to-100-4.fs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
match N |> Seq.filter(fun n->n.g>=0) |> Seq.distinctBy(fun n->n.g) |> Seq.sortBy(fun n->n.g) |> Seq.pairwise |> Seq.tryFind(fun n->(snd n).g-(fst n).g > 1) with
|
||||
|Some(n) -> printfn "least non-value is %d" ((fst n).g+1)
|
||||
|None -> printfn "No non-values found"
|
||||
1
Task/Sum-to-100/F-Sharp/sum-to-100-5.fs
Normal file
1
Task/Sum-to-100/F-Sharp/sum-to-100-5.fs
Normal file
|
|
@ -0,0 +1 @@
|
|||
N |> Seq.filter(fun n->n.g>=0) |> Seq.distinctBy(fun n->n.g) |> Seq.sortBy(fun n->(-n.g)) |> Seq.take 10 |> Seq.iter(fun n->printfn "%d" n.g )
|
||||
Loading…
Add table
Add a link
Reference in a new issue