initial commit

This commit is contained in:
2025-08-03 20:16:55 -07:00
commit 87a130499d
89 changed files with 10241 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#Ignore thumbnails created by Windows
Thumbs.db
#Ignore files built by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
.vs/
.idea/
#Nuget packages folder
packages/
+16
View File
@@ -0,0 +1,16 @@
$arr = New-Object bool[] 2000000
$arr[0] = $arr[1] = $TRUE
$sum = 0
for ($i=2; $i -lt $arr.Length; $i++)
{
if ($arr[$i] -eq $TRUE)
{
continue
}
for ($j=$i*2; $j -lt $arr.Length; $j += $i)
{
$arr[$j] = $TRUE
}
$sum += $i
write-host "$i, $sum"
}
+54
View File
@@ -0,0 +1,54 @@
module _101
open common
open System
let leGrange points x =
points
|> Seq.mapi (fun j (xj,y) ->
y * (
points
|> Seq.mapi (fun k (xk,_) ->
if (j = k) then 1.0 else
(x - xk) / (xj - xk)
)
|> Seq.fold (*) 1.0
)
)
|> Seq.sum
let rec polynomialGen p x =
if p = 0 then 1L else
let rest = polynomialGen (p-1) x
let this = int64 (Math.Pow(float x, float p))
if p % 2 = 0 then
rest + this
else
rest - this
let poly10 = polynomialGen 10
let cube x =
int64 (Math.Pow(float x,3.0))
let funTup f n = (n, f n)
let sumOfFITsOfBOPs =
let leGrangeTermChecker f seqLimit =
[1..seqLimit]
|> Seq.map (fun n -> (float n, float (f n)))
|> (fun points ->
let nth = points |> Seq.nth (seqLimit - 1) |> snd
let pointsMinusLast = points |> Seq.take (seqLimit - 1)
let nthLegrange = leGrange pointsMinusLast (float seqLimit)
(int64 nth, int64 nthLegrange)
)
allIntegers |> Seq.skip 2
|> Seq.map (leGrangeTermChecker poly10)
|> Seq.take 11
//|> Seq.takeWhile (fun (nth,nthLeGrange) -> .Abs( nth - nthLeGrange) < 2)
|> Seq.toArray
//|> Array.map snd
//|> Array.sum
+57
View File
@@ -0,0 +1,57 @@
module _11
open System
open System.IO
let rightTrans = (0, 1)
let downTrans = (1, 0)
let sidewayRightTrans = (1, 1)
let sidewayLeftTrans = (1, -1)
let len = 4
let maximum max v = if v > max then v else max
let maxProduct =
let getData =
let lines = File.ReadAllLines(@"11.txt")
let convertDataRow(line:string) =
line.Split(' ') |> Array.map int
lines |> Array.map convertDataRow
let rows = getData
let rowLen = rows.Length
let colLen = rows.[0].Length
let getAdjacentCells (r, c) (rInc, cInc) =
if (r + rInc*len > rowLen
|| c + cInc*len > colLen
|| c + cInc*len < 0) then
Seq.empty
else
Seq.init len (fun i -> rows.[r + rInc*i].[c + cInc*i])
seq{
for r in 0..rowLen-1 do
for c in 0..colLen-1 do
let getCells = getAdjacentCells (r, c)
let product = Seq.fold (*) 1
yield getCells rightTrans |> product
yield getCells downTrans |> product
yield getCells sidewayRightTrans |> product
yield getCells sidewayLeftTrans |> product
}
|> Seq.fold maximum -1
(*
for row in rows do
for cell in row do
printf "%u " cell
printf "\n"
*)
+3
View File
@@ -0,0 +1,3 @@
$file = gc 11.txt
$arr = New-Object int[][] 2000000
+20
View File
@@ -0,0 +1,20 @@
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48
+18
View File
@@ -0,0 +1,18 @@
module _112
let bouncy90 =
let bouncy n =
common.numDigits n
|> Seq.pairwise
|> Seq.filter (fun (i,j) -> i <> j)
|> Seq.map (fun (i,j) -> i > j)
|> Seq.distinct
|> Seq.length > 1
common.allIntegers
|> Seq.skip 1
|> Seq.map (fun i -> (i,bouncy i))
|> Seq.scan (fun (t,f) (i,b) ->
if b then (t+1,f) else (t,f+1)) (0,0)
|> Seq.map (fun (t,f) -> if t = 0 then 0.0 else ((float t)/((float t)+(float f))))
|> Seq.findIndex ((<=) 0.99)
+17
View File
@@ -0,0 +1,17 @@
module _12
open System
let fiveDivisorTriangle =
let root (n : int) = int( Math.Sqrt(float(n)) )
// observation: if number has a factor < sqrt(num), then it has a corresponding
// factor > sqrt(num)
let factorCount x = Seq.sum (seq { for i = 1 to root x do if x % i = 0 then yield 2 })
let result =
(1, 0) |> Seq.unfold (fun (num,acc) ->
Some(num + acc, (num + 1, num + acc)))
|> Seq.filter (fun x ->
let factCount = factorCount x
factCount >= 500 )
|> Seq.head
result
+36
View File
@@ -0,0 +1,36 @@
module _13
open System
open System.IO
let getSum =
let numbers = File.ReadAllLines(@"13.txt")
let add i carry =
let sum = carry +
(Seq.sum
(seq
{ for string in numbers
do yield System.Int32.Parse(string.Substring(string.Length - i, 1)) }
)
)
(sum % 10, int(sum / 10))
let unfold (i, carry) =
if i = 51 then
None
else
let (digit, nextCarry) = add i carry
if i <> 50 then
Some(digit.ToString(), (i+1, nextCarry))
else
Some(nextCarry.ToString() + digit.ToString(), (i+1, nextCarry))
let number_string =
Seq.unfold unfold (1, 0)
|> Seq.reduce (fun current next -> next + current)
let hard = number_string.Substring(0, 10)
hard
+100
View File
@@ -0,0 +1,100 @@
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
70386486105843025439939619828917593665686757934951
62176457141856560629502157223196586755079324193331
64906352462741904929101432445813822663347944758178
92575867718337217661963751590579239728245598838407
58203565325359399008402633568948830189458628227828
80181199384826282014278194139940567587151170094390
35398664372827112653829987240784473053190104293586
86515506006295864861532075273371959191420517255829
71693888707715466499115593487603532921714970056938
54370070576826684624621495650076471787294438377604
53282654108756828443191190634694037855217779295145
36123272525000296071075082563815656710885258350721
45876576172410976447339110607218265236877223636045
17423706905851860660448207621209813287860733969412
81142660418086830619328460811191061556940512689692
51934325451728388641918047049293215058642563049483
62467221648435076201727918039944693004732956340691
15732444386908125794514089057706229429197107928209
55037687525678773091862540744969844508330393682126
18336384825330154686196124348767681297534375946515
80386287592878490201521685554828717201219257766954
78182833757993103614740356856449095527097864797581
16726320100436897842553539920931837441497806860984
48403098129077791799088218795327364475675590848030
87086987551392711854517078544161852424320693150332
59959406895756536782107074926966537676326235447210
69793950679652694742597709739166693763042633987085
41052684708299085211399427365734116182760315001271
65378607361501080857009149939512557028198746004375
35829035317434717326932123578154982629742552737307
94953759765105305946966067683156574377167401875275
88902802571733229619176668713819931811048770190271
25267680276078003013678680992525463401061632866526
36270218540497705585629946580636237993140746255962
24074486908231174977792365466257246923322810917141
91430288197103288597806669760892938638285025333403
34413065578016127815921815005561868836468420090470
23053081172816430487623791969842487255036638784583
11487696932154902810424020138335124462181441773470
63783299490636259666498587618221225225512486764533
67720186971698544312419572409913959008952310058822
95548255300263520781532296796249481641953868218774
76085327132285723110424803456124867697064507995236
37774242535411291684276865538926205024910326572967
23701913275725675285653248258265463092207058596522
29798860272258331913126375147341994889534765745501
18495701454879288984856827726077713721403798879715
38298203783031473527721580348144513491373226651381
34829543829199918180278916522431027392251122869539
40957953066405232632538044100059654939159879593635
29746152185502371307642255121183693803580388584903
41698116222072977186158236678424689157993532961922
62467957194401269043877107275048102390895523597457
23189706772547915061505504953922979530901129967519
86188088225875314529584099251203829009407770775672
11306739708304724483816533873502340845647058077308
82959174767140363198008187129011875491310547126581
97623331044818386269515456334926366572897563400500
42846280183517070527831839425882145521227251250327
55121603546981200581762165212827652751691296897789
32238195734329339946437501907836945765883352399886
75506164965184775180738168837861091527357929701337
62177842752192623401942399639168044983993173312731
32924185707147349566916674687634660915035914677504
99518671430235219628894890102423325116913619626622
73267460800591547471830798392868535206946944540724
76841822524674417161514036427982273348055556214818
97142617910342598647204516893989422179826088076852
87783646182799346313767754307809363333018982642090
10848802521674670883215120185883543223812876952786
71329612474782464538636993009049310363619763878039
62184073572399794223406235393808339651327408011116
66627891981488087797941876876144230030984490851411
60661826293682836764744779239180335110989069790714
85786944089552990653640447425576083659976645795096
66024396409905389607120198219976047599490197230297
64913982680032973156037120041377903785566085089252
16730939319872750275468906903707539413042652315011
94809377245048795150954100921645863754710598436791
78639167021187492431995700641917969777599028300699
15368713711936614952811305876380278410754449733078
40789923115535562561142322423255033685442488917353
44889911501440648020369068063960672322193204149535
41503128880339536053299340368006977710650566631954
81234880673210146739058568557934581403627822703280
82616570773948327592232845941706525094512325230608
22918802058777319719839450180888072429661980811197
77158542502016545090413245809786882778948721859617
72107838435069186155435662884062257473692284509516
20849603980134001723930671666823555245252804609722
53503534226472524250874054075591789781264330331690
+15
View File
@@ -0,0 +1,15 @@
module _14
let collatzConjecture n =
match n with
| 0L -> None
| 1L -> Some(1L,0L)
| n -> Some(n,
if n % 2L = 0L then n/2L
else if n % 2L = 1L then 3L*n + 1L
else 1L)
let getLongestChain =
[1L..1000000L]
|> Seq.map (fun i -> (i |> Seq.unfold collatzConjecture |> Seq.length, i))
|> Seq.max
+7
View File
@@ -0,0 +1,7 @@
$assemblyName = gci .\Oyster.IntX.dll | % {$_.FullName }
[System.Reflection.Assembly]::LoadFile($assemblyName)
$num = [Oyster.Math.IntX]::Pow(2,1000) | % {$_.ToString() }
$sum = 0
[char[]]$num | % { $sum += [int][string]$_;}
$sum
+81
View File
@@ -0,0 +1,81 @@
module _17
open System.Text.RegularExpressions
let rec numberToWords i =
let firstDigit number =
int (number.ToString().Substring(0,1))
let remainingDigits number =
int (number.ToString().Substring(1))
let numberHeadTuple i =
(firstDigit i, remainingDigits i)
let concatWith separator s1 s2 =
if not (System.String.IsNullOrEmpty(s2))
then s1 + separator + s2
else
s1
let hyphen = concatWith "-"
let concatAnd = concatWith " and "
match i.ToString().Length with
| 1 ->
match i with
| 1 -> "one"
| 2 -> "two"
| 3 -> "three"
| 4-> "four"
| 5 -> "five"
| 6 -> "six"
| 7 -> "seven"
| 8 -> "eight"
| 9 -> "nine"
| _ -> ""
| 2 ->
match numberHeadTuple i with
| (1,0) -> "ten"
| (1,1) -> "eleven"
| (1,2) -> "twelve"
| (1,3) -> "thirteen"
| (1,4) -> "fourteen"
| (1,5) -> "fifteen"
| (1,8) -> "eighteen"
| (1,j) -> (numberToWords j) + "teen"
| (2,j) -> (numberToWords j) |> hyphen "twenty"
| (3,j) -> (numberToWords j) |> hyphen "thirty"
| (4,j) -> (numberToWords j) |> hyphen "forty"
| (5,j) -> (numberToWords j) |> hyphen "fifty"
| (6,j) -> (numberToWords j) |> hyphen "sixty"
| (7,j) -> (numberToWords j) |> hyphen "seventy"
| (8,j) -> (numberToWords j) |> hyphen "eighty"
| (9,j) -> (numberToWords j) |> hyphen "ninety"
| (_, _) -> "wtf"
| 3 ->
let (first,remaining) = numberHeadTuple i
(numberToWords remaining) |> concatAnd ((numberToWords first) + " hundred")
| 4 ->
let (first,remaining) = numberHeadTuple i
(numberToWords remaining) |> concatAnd ((numberToWords first) + " thousand")
| _ -> "unknown"
let getNumberWords =
let nums = [1..1000]
let numWords = Seq.map numberToWords nums
//printfn "%s" (String.concat "\n" numWords)
let strip s = Regex.Replace(s, "[^a-z]", "")
numWords |> Seq.fold (fun acc elem -> acc + (strip elem).Length) 0
//let getNumberWords =
// let nums = [1..100]
// let strip s = Regex.Replace(s, "[^a-z]", "")
// nums
// |> Seq.map (fun n -> (n, ((numberToWords >> strip) n).Length, numberToWords n))
// |> Seq.toArray
// |> Array.filter (fun (n, l, _) -> n % l = 0)
+18
View File
@@ -0,0 +1,18 @@
module _18
open System.IO
let getTriangleMaxTotal =
let t =
File.ReadAllLines(@"18_67.txt")
|> Array.map (fun line -> line.Split(' ') |> Array.map int)
|> Array.rev
for i in 1 .. t.Length - 1 do
for j in 0 .. t.[i].Length - 1 do
let current = t.[i].[j]
let prev = max t.[i - 1].[j] t.[i - 1].[j + 1]
t.[i].[j] <- current + prev
t.[t.Length - 1].[0]
+15
View File
@@ -0,0 +1,15 @@
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
+100
View File
@@ -0,0 +1,100 @@
59
73 41
52 40 09
26 53 06 34
10 51 87 86 81
61 95 66 57 25 68
90 81 80 38 92 67 73
30 28 51 76 81 18 75 44
84 14 95 87 62 81 17 78 58
21 46 71 58 02 79 62 39 31 09
56 34 35 53 78 31 81 18 90 93 15
78 53 04 21 84 93 32 13 97 11 37 51
45 03 81 79 05 18 78 86 13 30 63 99 95
39 87 96 28 03 38 42 17 82 87 58 07 22 57
06 17 51 17 07 93 09 07 75 97 95 78 87 08 53
67 66 59 60 88 99 94 65 55 77 55 34 27 53 78 28
76 40 41 04 87 16 09 42 75 69 23 97 30 60 10 79 87
12 10 44 26 21 36 32 84 98 60 13 12 36 16 63 31 91 35
70 39 06 05 55 27 38 48 28 22 34 35 62 62 15 14 94 89 86
66 56 68 84 96 21 34 34 34 81 62 40 65 54 62 05 98 03 02 60
38 89 46 37 99 54 34 53 36 14 70 26 02 90 45 13 31 61 83 73 47
36 10 63 96 60 49 41 05 37 42 14 58 84 93 96 17 09 43 05 43 06 59
66 57 87 57 61 28 37 51 84 73 79 15 39 95 88 87 43 39 11 86 77 74 18
54 42 05 79 30 49 99 73 46 37 50 02 45 09 54 52 27 95 27 65 19 45 26 45
71 39 17 78 76 29 52 90 18 99 78 19 35 62 71 19 23 65 93 85 49 33 75 09 02
33 24 47 61 60 55 32 88 57 55 91 54 46 57 07 77 98 52 80 99 24 25 46 78 79 05
92 09 13 55 10 67 26 78 76 82 63 49 51 31 24 68 05 57 07 54 69 21 67 43 17 63 12
24 59 06 08 98 74 66 26 61 60 13 03 09 09 24 30 71 08 88 70 72 70 29 90 11 82 41 34
66 82 67 04 36 60 92 77 91 85 62 49 59 61 30 90 29 94 26 41 89 04 53 22 83 41 09 74 90
48 28 26 37 28 52 77 26 51 32 18 98 79 36 62 13 17 08 19 54 89 29 73 68 42 14 08 16 70 37
37 60 69 70 72 71 09 59 13 60 38 13 57 36 09 30 43 89 30 39 15 02 44 73 05 73 26 63 56 86 12
55 55 85 50 62 99 84 77 28 85 03 21 27 22 19 26 82 69 54 04 13 07 85 14 01 15 70 59 89 95 10 19
04 09 31 92 91 38 92 86 98 75 21 05 64 42 62 84 36 20 73 42 21 23 22 51 51 79 25 45 85 53 03 43 22
75 63 02 49 14 12 89 14 60 78 92 16 44 82 38 30 72 11 46 52 90 27 08 65 78 03 85 41 57 79 39 52 33 48
78 27 56 56 39 13 19 43 86 72 58 95 39 07 04 34 21 98 39 15 39 84 89 69 84 46 37 57 59 35 59 50 26 15 93
42 89 36 27 78 91 24 11 17 41 05 94 07 69 51 96 03 96 47 90 90 45 91 20 50 56 10 32 36 49 04 53 85 92 25 65
52 09 61 30 61 97 66 21 96 92 98 90 06 34 96 60 32 69 68 33 75 84 18 31 71 50 84 63 03 03 19 11 28 42 75 45 45
61 31 61 68 96 34 49 39 05 71 76 59 62 67 06 47 96 99 34 21 32 47 52 07 71 60 42 72 94 56 82 83 84 40 94 87 82 46
01 20 60 14 17 38 26 78 66 81 45 95 18 51 98 81 48 16 53 88 37 52 69 95 72 93 22 34 98 20 54 27 73 61 56 63 60 34 63
93 42 94 83 47 61 27 51 79 79 45 01 44 73 31 70 83 42 88 25 53 51 30 15 65 94 80 44 61 84 12 77 02 62 02 65 94 42 14 94
32 73 09 67 68 29 74 98 10 19 85 48 38 31 85 67 53 93 93 77 47 67 39 72 94 53 18 43 77 40 78 32 29 59 24 06 02 83 50 60 66
32 01 44 30 16 51 15 81 98 15 10 62 86 79 50 62 45 60 70 38 31 85 65 61 64 06 69 84 14 22 56 43 09 48 66 69 83 91 60 40 36 61
92 48 22 99 15 95 64 43 01 16 94 02 99 19 17 69 11 58 97 56 89 31 77 45 67 96 12 73 08 20 36 47 81 44 50 64 68 85 40 81 85 52 09
91 35 92 45 32 84 62 15 19 64 21 66 06 01 52 80 62 59 12 25 88 28 91 50 40 16 22 99 92 79 87 51 21 77 74 77 07 42 38 42 74 83 02 05
46 19 77 66 24 18 05 32 02 84 31 99 92 58 96 72 91 36 62 99 55 29 53 42 12 37 26 58 89 50 66 19 82 75 12 48 24 87 91 85 02 07 03 76 86
99 98 84 93 07 17 33 61 92 20 66 60 24 66 40 30 67 05 37 29 24 96 03 27 70 62 13 04 45 47 59 88 43 20 66 15 46 92 30 04 71 66 78 70 53 99
67 60 38 06 88 04 17 72 10 99 71 07 42 25 54 05 26 64 91 50 45 71 06 30 67 48 69 82 08 56 80 67 18 46 66 63 01 20 08 80 47 07 91 16 03 79 87
18 54 78 49 80 48 77 40 68 23 60 88 58 80 33 57 11 69 55 53 64 02 94 49 60 92 16 35 81 21 82 96 25 24 96 18 02 05 49 03 50 77 06 32 84 27 18 38
68 01 50 04 03 21 42 94 53 24 89 05 92 26 52 36 68 11 85 01 04 42 02 45 15 06 50 04 53 73 25 74 81 88 98 21 67 84 79 97 99 20 95 04 40 46 02 58 87
94 10 02 78 88 52 21 03 88 60 06 53 49 71 20 91 12 65 07 49 21 22 11 41 58 99 36 16 09 48 17 24 52 36 23 15 72 16 84 56 02 99 43 76 81 71 29 39 49 17
64 39 59 84 86 16 17 66 03 09 43 06 64 18 63 29 68 06 23 07 87 14 26 35 17 12 98 41 53 64 78 18 98 27 28 84 80 67 75 62 10 11 76 90 54 10 05 54 41 39 66
43 83 18 37 32 31 52 29 95 47 08 76 35 11 04 53 35 43 34 10 52 57 12 36 20 39 40 55 78 44 07 31 38 26 08 15 56 88 86 01 52 62 10 24 32 05 60 65 53 28 57 99
03 50 03 52 07 73 49 92 66 80 01 46 08 67 25 36 73 93 07 42 25 53 13 96 76 83 87 90 54 89 78 22 78 91 73 51 69 09 79 94 83 53 09 40 69 62 10 79 49 47 03 81 30
71 54 73 33 51 76 59 54 79 37 56 45 84 17 62 21 98 69 41 95 65 24 39 37 62 03 24 48 54 64 46 82 71 78 33 67 09 16 96 68 52 74 79 68 32 21 13 78 96 60 09 69 20 36
73 26 21 44 46 38 17 83 65 98 07 23 52 46 61 97 33 13 60 31 70 15 36 77 31 58 56 93 75 68 21 36 69 53 90 75 25 82 39 50 65 94 29 30 11 33 11 13 96 02 56 47 07 49 02
76 46 73 30 10 20 60 70 14 56 34 26 37 39 48 24 55 76 84 91 39 86 95 61 50 14 53 93 64 67 37 31 10 84 42 70 48 20 10 72 60 61 84 79 69 65 99 73 89 25 85 48 92 56 97 16
03 14 80 27 22 30 44 27 67 75 79 32 51 54 81 29 65 14 19 04 13 82 04 91 43 40 12 52 29 99 07 76 60 25 01 07 61 71 37 92 40 47 99 66 57 01 43 44 22 40 53 53 09 69 26 81 07
49 80 56 90 93 87 47 13 75 28 87 23 72 79 32 18 27 20 28 10 37 59 21 18 70 04 79 96 03 31 45 71 81 06 14 18 17 05 31 50 92 79 23 47 09 39 47 91 43 54 69 47 42 95 62 46 32 85
37 18 62 85 87 28 64 05 77 51 47 26 30 65 05 70 65 75 59 80 42 52 25 20 44 10 92 17 71 95 52 14 77 13 24 55 11 65 26 91 01 30 63 15 49 48 41 17 67 47 03 68 20 90 98 32 04 40 68
90 51 58 60 06 55 23 68 05 19 76 94 82 36 96 43 38 90 87 28 33 83 05 17 70 83 96 93 06 04 78 47 80 06 23 84 75 23 87 72 99 14 50 98 92 38 90 64 61 58 76 94 36 66 87 80 51 35 61 38
57 95 64 06 53 36 82 51 40 33 47 14 07 98 78 65 39 58 53 06 50 53 04 69 40 68 36 69 75 78 75 60 03 32 39 24 74 47 26 90 13 40 44 71 90 76 51 24 36 50 25 45 70 80 61 80 61 43 90 64 11
18 29 86 56 68 42 79 10 42 44 30 12 96 18 23 18 52 59 02 99 67 46 60 86 43 38 55 17 44 93 42 21 55 14 47 34 55 16 49 24 23 29 96 51 55 10 46 53 27 92 27 46 63 57 30 65 43 27 21 20 24 83
81 72 93 19 69 52 48 01 13 83 92 69 20 48 69 59 20 62 05 42 28 89 90 99 32 72 84 17 08 87 36 03 60 31 36 36 81 26 97 36 48 54 56 56 27 16 91 08 23 11 87 99 33 47 02 14 44 73 70 99 43 35 33
90 56 61 86 56 12 70 59 63 32 01 15 81 47 71 76 95 32 65 80 54 70 34 51 40 45 33 04 64 55 78 68 88 47 31 47 68 87 03 84 23 44 89 72 35 08 31 76 63 26 90 85 96 67 65 91 19 14 17 86 04 71 32 95
37 13 04 22 64 37 37 28 56 62 86 33 07 37 10 44 52 82 52 06 19 52 57 75 90 26 91 24 06 21 14 67 76 30 46 14 35 89 89 41 03 64 56 97 87 63 22 34 03 79 17 45 11 53 25 56 96 61 23 18 63 31 37 37 47
77 23 26 70 72 76 77 04 28 64 71 69 14 85 96 54 95 48 06 62 99 83 86 77 97 75 71 66 30 19 57 90 33 01 60 61 14 12 90 99 32 77 56 41 18 14 87 49 10 14 90 64 18 50 21 74 14 16 88 05 45 73 82 47 74 44
22 97 41 13 34 31 54 61 56 94 03 24 59 27 98 77 04 09 37 40 12 26 87 09 71 70 07 18 64 57 80 21 12 71 83 94 60 39 73 79 73 19 97 32 64 29 41 07 48 84 85 67 12 74 95 20 24 52 41 67 56 61 29 93 35 72 69
72 23 63 66 01 11 07 30 52 56 95 16 65 26 83 90 50 74 60 18 16 48 43 77 37 11 99 98 30 94 91 26 62 73 45 12 87 73 47 27 01 88 66 99 21 41 95 80 02 53 23 32 61 48 32 43 43 83 14 66 95 91 19 81 80 67 25 88
08 62 32 18 92 14 83 71 37 96 11 83 39 99 05 16 23 27 10 67 02 25 44 11 55 31 46 64 41 56 44 74 26 81 51 31 45 85 87 09 81 95 22 28 76 69 46 48 64 87 67 76 27 89 31 11 74 16 62 03 60 94 42 47 09 34 94 93 72
56 18 90 18 42 17 42 32 14 86 06 53 33 95 99 35 29 15 44 20 49 59 25 54 34 59 84 21 23 54 35 90 78 16 93 13 37 88 54 19 86 67 68 55 66 84 65 42 98 37 87 56 33 28 58 38 28 38 66 27 52 21 81 15 08 22 97 32 85 27
91 53 40 28 13 34 91 25 01 63 50 37 22 49 71 58 32 28 30 18 68 94 23 83 63 62 94 76 80 41 90 22 82 52 29 12 18 56 10 08 35 14 37 57 23 65 67 40 72 39 93 39 70 89 40 34 07 46 94 22 20 05 53 64 56 30 05 56 61 88 27
23 95 11 12 37 69 68 24 66 10 87 70 43 50 75 07 62 41 83 58 95 93 89 79 45 39 02 22 05 22 95 43 62 11 68 29 17 40 26 44 25 71 87 16 70 85 19 25 59 94 90 41 41 80 61 70 55 60 84 33 95 76 42 63 15 09 03 40 38 12 03 32
09 84 56 80 61 55 85 97 16 94 82 94 98 57 84 30 84 48 93 90 71 05 95 90 73 17 30 98 40 64 65 89 07 79 09 19 56 36 42 30 23 69 73 72 07 05 27 61 24 31 43 48 71 84 21 28 26 65 65 59 65 74 77 20 10 81 61 84 95 08 52 23 70
47 81 28 09 98 51 67 64 35 51 59 36 92 82 77 65 80 24 72 53 22 07 27 10 21 28 30 22 48 82 80 48 56 20 14 43 18 25 50 95 90 31 77 08 09 48 44 80 90 22 93 45 82 17 13 96 25 26 08 73 34 99 06 49 24 06 83 51 40 14 15 10 25 01
54 25 10 81 30 64 24 74 75 80 36 75 82 60 22 69 72 91 45 67 03 62 79 54 89 74 44 83 64 96 66 73 44 30 74 50 37 05 09 97 70 01 60 46 37 91 39 75 75 18 58 52 72 78 51 81 86 52 08 97 01 46 43 66 98 62 81 18 70 93 73 08 32 46 34
96 80 82 07 59 71 92 53 19 20 88 66 03 26 26 10 24 27 50 82 94 73 63 08 51 33 22 45 19 13 58 33 90 15 22 50 36 13 55 06 35 47 82 52 33 61 36 27 28 46 98 14 73 20 73 32 16 26 80 53 47 66 76 38 94 45 02 01 22 52 47 96 64 58 52 39
88 46 23 39 74 63 81 64 20 90 33 33 76 55 58 26 10 46 42 26 74 74 12 83 32 43 09 02 73 55 86 54 85 34 28 23 29 79 91 62 47 41 82 87 99 22 48 90 20 05 96 75 95 04 43 28 81 39 81 01 28 42 78 25 39 77 90 57 58 98 17 36 73 22 63 74 51
29 39 74 94 95 78 64 24 38 86 63 87 93 06 70 92 22 16 80 64 29 52 20 27 23 50 14 13 87 15 72 96 81 22 08 49 72 30 70 24 79 31 16 64 59 21 89 34 96 91 48 76 43 53 88 01 57 80 23 81 90 79 58 01 80 87 17 99 86 90 72 63 32 69 14 28 88 69
37 17 71 95 56 93 71 35 43 45 04 98 92 94 84 96 11 30 31 27 31 60 92 03 48 05 98 91 86 94 35 90 90 08 48 19 33 28 68 37 59 26 65 96 50 68 22 07 09 49 34 31 77 49 43 06 75 17 81 87 61 79 52 26 27 72 29 50 07 98 86 01 17 10 46 64 24 18 56
51 30 25 94 88 85 79 91 40 33 63 84 49 67 98 92 15 26 75 19 82 05 18 78 65 93 61 48 91 43 59 41 70 51 22 15 92 81 67 91 46 98 11 11 65 31 66 10 98 65 83 21 05 56 05 98 73 67 46 74 69 34 08 30 05 52 07 98 32 95 30 94 65 50 24 63 28 81 99 57
19 23 61 36 09 89 71 98 65 17 30 29 89 26 79 74 94 11 44 48 97 54 81 55 39 66 69 45 28 47 13 86 15 76 74 70 84 32 36 33 79 20 78 14 41 47 89 28 81 05 99 66 81 86 38 26 06 25 13 60 54 55 23 53 27 05 89 25 23 11 13 54 59 54 56 34 16 24 53 44 06
13 40 57 72 21 15 60 08 04 19 11 98 34 45 09 97 86 71 03 15 56 19 15 44 97 31 90 04 87 87 76 08 12 30 24 62 84 28 12 85 82 53 99 52 13 94 06 65 97 86 09 50 94 68 69 74 30 67 87 94 63 07 78 27 80 36 69 41 06 92 32 78 37 82 30 05 18 87 99 72 19 99
44 20 55 77 69 91 27 31 28 81 80 27 02 07 97 23 95 98 12 25 75 29 47 71 07 47 78 39 41 59 27 76 13 15 66 61 68 35 69 86 16 53 67 63 99 85 41 56 08 28 33 40 94 76 90 85 31 70 24 65 84 65 99 82 19 25 54 37 21 46 33 02 52 99 51 33 26 04 87 02 08 18 96
54 42 61 45 91 06 64 79 80 82 32 16 83 63 42 49 19 78 65 97 40 42 14 61 49 34 04 18 25 98 59 30 82 72 26 88 54 36 21 75 03 88 99 53 46 51 55 78 22 94 34 40 68 87 84 25 30 76 25 08 92 84 42 61 40 38 09 99 40 23 29 39 46 55 10 90 35 84 56 70 63 23 91 39
52 92 03 71 89 07 09 37 68 66 58 20 44 92 51 56 13 71 79 99 26 37 02 06 16 67 36 52 58 16 79 73 56 60 59 27 44 77 94 82 20 50 98 33 09 87 94 37 40 83 64 83 58 85 17 76 53 02 83 52 22 27 39 20 48 92 45 21 09 42 24 23 12 37 52 28 50 78 79 20 86 62 73 20 59
54 96 80 15 91 90 99 70 10 09 58 90 93 50 81 99 54 38 36 10 30 11 35 84 16 45 82 18 11 97 36 43 96 79 97 65 40 48 23 19 17 31 64 52 65 65 37 32 65 76 99 79 34 65 79 27 55 33 03 01 33 27 61 28 66 08 04 70 49 46 48 83 01 45 19 96 13 81 14 21 31 79 93 85 50 05
92 92 48 84 59 98 31 53 23 27 15 22 79 95 24 76 05 79 16 93 97 89 38 89 42 83 02 88 94 95 82 21 01 97 48 39 31 78 09 65 50 56 97 61 01 07 65 27 21 23 14 15 80 97 44 78 49 35 33 45 81 74 34 05 31 57 09 38 94 07 69 54 69 32 65 68 46 68 78 90 24 28 49 51 45 86 35
41 63 89 76 87 31 86 09 46 14 87 82 22 29 47 16 13 10 70 72 82 95 48 64 58 43 13 75 42 69 21 12 67 13 64 85 58 23 98 09 37 76 05 22 31 12 66 50 29 99 86 72 45 25 10 28 19 06 90 43 29 31 67 79 46 25 74 14 97 35 76 37 65 46 23 82 06 22 30 76 93 66 94 17 96 13 20 72
63 40 78 08 52 09 90 41 70 28 36 14 46 44 85 96 24 52 58 15 87 37 05 98 99 39 13 61 76 38 44 99 83 74 90 22 53 80 56 98 30 51 63 39 44 30 91 91 04 22 27 73 17 35 53 18 35 45 54 56 27 78 48 13 69 36 44 38 71 25 30 56 15 22 73 43 32 69 59 25 93 83 45 11 34 94 44 39 92
12 36 56 88 13 96 16 12 55 54 11 47 19 78 17 17 68 81 77 51 42 55 99 85 66 27 81 79 93 42 65 61 69 74 14 01 18 56 12 01 58 37 91 22 42 66 83 25 19 04 96 41 25 45 18 69 96 88 36 93 10 12 98 32 44 83 83 04 72 91 04 27 73 07 34 37 71 60 59 31 01 54 54 44 96 93 83 36 04 45
30 18 22 20 42 96 65 79 17 41 55 69 94 81 29 80 91 31 85 25 47 26 43 49 02 99 34 67 99 76 16 14 15 93 08 32 99 44 61 77 67 50 43 55 87 55 53 72 17 46 62 25 50 99 73 05 93 48 17 31 70 80 59 09 44 59 45 13 74 66 58 94 87 73 16 14 85 38 74 99 64 23 79 28 71 42 20 37 82 31 23
51 96 39 65 46 71 56 13 29 68 53 86 45 33 51 49 12 91 21 21 76 85 02 17 98 15 46 12 60 21 88 30 92 83 44 59 42 50 27 88 46 86 94 73 45 54 23 24 14 10 94 21 20 34 23 51 04 83 99 75 90 63 60 16 22 33 83 70 11 32 10 50 29 30 83 46 11 05 31 17 86 42 49 01 44 63 28 60 07 78 95 40
44 61 89 59 04 49 51 27 69 71 46 76 44 04 09 34 56 39 15 06 94 91 75 90 65 27 56 23 74 06 23 33 36 69 14 39 05 34 35 57 33 22 76 46 56 10 61 65 98 09 16 69 04 62 65 18 99 76 49 18 72 66 73 83 82 40 76 31 89 91 27 88 17 35 41 35 32 51 32 67 52 68 74 85 80 57 07 11 62 66 47 22 67
65 37 19 97 26 17 16 24 24 17 50 37 64 82 24 36 32 11 68 34 69 31 32 89 79 93 96 68 49 90 14 23 04 04 67 99 81 74 70 74 36 96 68 09 64 39 88 35 54 89 96 58 66 27 88 97 32 14 06 35 78 20 71 06 85 66 57 02 58 91 72 05 29 56 73 48 86 52 09 93 22 57 79 42 12 01 31 68 17 59 63 76 07 77
73 81 14 13 17 20 11 09 01 83 08 85 91 70 84 63 62 77 37 07 47 01 59 95 39 69 39 21 99 09 87 02 97 16 92 36 74 71 90 66 33 73 73 75 52 91 11 12 26 53 05 26 26 48 61 50 90 65 01 87 42 47 74 35 22 73 24 26 56 70 52 05 48 41 31 18 83 27 21 39 80 85 26 08 44 02 71 07 63 22 05 52 19 08 20
17 25 21 11 72 93 33 49 64 23 53 82 03 13 91 65 85 02 40 05 42 31 77 42 05 36 06 54 04 58 07 76 87 83 25 57 66 12 74 33 85 37 74 32 20 69 03 97 91 68 82 44 19 14 89 28 85 85 80 53 34 87 58 98 88 78 48 65 98 40 11 57 10 67 70 81 60 79 74 72 97 59 79 47 30 20 54 80 89 91 14 05 33 36 79 39
60 85 59 39 60 07 57 76 77 92 06 35 15 72 23 41 45 52 95 18 64 79 86 53 56 31 69 11 91 31 84 50 44 82 22 81 41 40 30 42 30 91 48 94 74 76 64 58 74 25 96 57 14 19 03 99 28 83 15 75 99 01 89 85 79 50 03 95 32 67 44 08 07 41 62 64 29 20 14 76 26 55 48 71 69 66 19 72 44 25 14 01 48 74 12 98 07
64 66 84 24 18 16 27 48 20 14 47 69 30 86 48 40 23 16 61 21 51 50 26 47 35 33 91 28 78 64 43 68 04 79 51 08 19 60 52 95 06 68 46 86 35 97 27 58 04 65 30 58 99 12 12 75 91 39 50 31 42 64 70 04 46 07 98 73 98 93 37 89 77 91 64 71 64 65 66 21 78 62 81 74 42 20 83 70 73 95 78 45 92 27 34 53 71 15
30 11 85 31 34 71 13 48 05 14 44 03 19 67 23 73 19 57 06 90 94 72 57 69 81 62 59 68 88 57 55 69 49 13 07 87 97 80 89 05 71 05 05 26 38 40 16 62 45 99 18 38 98 24 21 26 62 74 69 04 85 57 77 35 58 67 91 79 79 57 86 28 66 34 72 51 76 78 36 95 63 90 08 78 47 63 45 31 22 70 52 48 79 94 15 77 61 67 68
23 33 44 81 80 92 93 75 94 88 23 61 39 76 22 03 28 94 32 06 49 65 41 34 18 23 08 47 62 60 03 63 33 13 80 52 31 54 73 43 70 26 16 69 57 87 83 31 03 93 70 81 47 95 77 44 29 68 39 51 56 59 63 07 25 70 07 77 43 53 64 03 94 42 95 39 18 01 66 21 16 97 20 50 90 16 70 10 95 69 29 06 25 61 41 26 15 59 63 35
+15
View File
@@ -0,0 +1,15 @@
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
+62
View File
@@ -0,0 +1,62 @@
module _19
open common
//1 Jan 1900 was a Monday.
//Thirty days has September,
//April, June and November.
//All the rest have thirty-one,
//Saving February alone,
//Which has twenty-eight, rain or shine.
//And on leap years, twenty-nine.
//A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
type day =
Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday
let dayNum d =
match d with
| Sunday -> 0
| Monday -> 1
| Tuesday -> 2
| Wednesday -> 3
| Thursday -> 4
| Friday -> 5
| Saturday -> 6
let numDay n =
match n with
| 0 -> Sunday
| 1 -> Monday
| 2 -> Tuesday
| 3 -> Wednesday
| 4 -> Thursday
| 5 -> Friday
| 6 -> Saturday
| _ -> raise(System.ArgumentException("No!"))
type date =
{ Year : int;
Month : int }
let isLeapYear y =
y % 4 = 0 && (y % 100 <> 0 || y % 400 = 0)
let getDaysInMonth d =
let thirtyMonths = [|9;4;6;11|];
match d with
| date when date.Month = 2 && isLeapYear date.Year -> 29
| date when date.Month = 2 -> 28
| date when Array.exists ((=) date.Month) thirtyMonths -> 30
| _ -> 31
let getNextFirstDay d daysInMonth =
(daysInMonth + (dayNum d)) % 7 |> numDay
let firstSaturdays =
//getNextFirstDay Thursday 30
crossMapList [1900..1999] [1..12]
|> Seq.map (fun (y, m) -> { Year = y; Month = m })
|> Seq.scan (fun (day:day) ym -> getNextFirstDay day (getDaysInMonth ym)) Monday
|> Seq.filter ((=) Sunday)
|> Seq.length
+7
View File
@@ -0,0 +1,7 @@
module _20
let getSum =
let n = [ 1I .. 100I ] |> List.fold (*) 1I
(string n).ToCharArray()
|> Array.map (string >> int)
|> Array.fold (fun acc d -> acc + d) 0
+19
View File
@@ -0,0 +1,19 @@
module _21
let amicalbleNumbers len =
// get divisor sums
let dSums = common.divisors len |> Array.map (List.fold (+) 0)
// find amicable ones
[2..len] |> List.filter (fun i ->
dSums.[i] > 0 &&
dSums.[i] <= len &&
not (i = dSums.[i]) &&
i < dSums.[i] &&
i = dSums.[dSums.[i]]
)
|> List.map (fun i -> (i, dSums.[i]))
let amicalbleSum =
let a = amicalbleNumbers 10000
let all = List.append (a |> List.map fst) (a |> List.map snd)
all |> List.sum
+13
View File
@@ -0,0 +1,13 @@
module _22
open System.IO
let nameScores =
let names =
File.ReadAllLines(@"22_names.txt")
|> Seq.collect (fun l -> l.Split(','))
|> Seq.map (fun w -> w.Substring(1, w.Length - 2))
|> Seq.sort
names
|> Seq.mapi (fun i name -> (i + 1) * common.wordValue name)
|> Seq.sum
+1
View File
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
module _23
let abundantUpperLimit = 28123
let abundantNumbers =
let dSums =
common.divisors abundantUpperLimit
|> Array.mapi (fun i divisors -> (i, List.fold (+) 0 divisors))
dSums |> Array.choose ( fun (i, dSum) ->
match dSum with
| abundant when dSum > i -> Some(i)
| _ -> None
)
let sumNotAbundant =
let a = abundantNumbers
// add all abubundant numbers together
let sums = common.crossMap (+) a a |> Seq.distinct |> Seq.toArray
let sna =
sums
|> Set.ofSeq
|> (-) (Set.ofList [1..abundantUpperLimit])
|> Set.toSeq
//|> Array.rev
sna |> Seq.fold (+) 0
+5
View File
@@ -0,0 +1,5 @@
module _24
let run =
common.permutations ([0..9] |> Set.ofList)
|> Seq.nth 999999
+9
View File
@@ -0,0 +1,9 @@
module _25
let digitCount (d:bigint) =
(string d).Length
let find1000 =
common.fibinoci
|> Seq.findIndex (fun f -> digitCount f = 1000)
|> (+) 1
+30
View File
@@ -0,0 +1,30 @@
module _26
let division d =
let digit = 10 / d
let mutable remainder = 10 % d
let mutable quotient = [(digit, remainder)]
let mutable cycleIndex = None
while remainder <> 0 && cycleIndex = None do
remainder <- remainder * 10
let digit = remainder / d
remainder <- remainder % d
let next = (digit, remainder)
let cycle = quotient |> List.tryFind (fun e -> e = next)
if cycle <> None then
cycleIndex <- Some(
quotient.Length
- (quotient |> List.findIndex (fun e -> e = next))
- 1)
else quotient <- next :: quotient
List.rev quotient |> List.map fst, cycleIndex
let cycleLength d =
match division d with
| (_,None) -> 0
| (q,Some(c)) -> q.Length - c
let longestRecurringCycle =
[2..1000]
|> List.mapi ( fun i d -> (i + 2, cycleLength d))
|> List.maxBy snd
+24
View File
@@ -0,0 +1,24 @@
module _27
open System
let quadraticConsecutivePrimes =
let range = [-1000..1000]
let isPrime = common.isPrimeFunByMax 100000
let primeLength f =
common.allIntegers
|> Seq.map f
|> Seq.takeWhile isPrime
|> Seq.length
let abs = common.crossMap (fun a b -> (a,b)) range range
let quadradic (a,b) n =
n*n + a*n + b
abs
|> Seq.map (fun ab -> (ab, ab |> (quadradic >> primeLength)))
|> Seq.maxBy snd
|> (fun ((a,b),_)-> a * b)
+12
View File
@@ -0,0 +1,12 @@
module _28
let sumNum =
let sideLength count =
seq {
for i in 1..(count/2) do
for l in 1..4 do
yield i * 2
}
sideLength 1001
|> Seq.scan ( fun sum item -> sum + item) 1
|> Seq.sum
+6
View File
@@ -0,0 +1,6 @@
module _29
let getDistinctTerms =
let range = [2..100]
common.crossMap (fun (a:int) b -> bigint.Pow(bigint a,b)) range range
|> Seq.distinct |> Seq.length
+16
View File
@@ -0,0 +1,16 @@
module _30
let sumOfFifth n =
common.numDigits n
|> Seq.map (fun d -> System.Math.Pow(float d, 5.0))
|> Seq.sum
|> int
let isSumOfFifth n =
sumOfFifth n = n
let sumOfSumOfFifthNumbers =
[2..200000]
|> List.map (fun n -> (n,isSumOfFifth n))
|> List.filter (fun r -> snd r)
|> List.sumBy fst
+13
View File
@@ -0,0 +1,13 @@
module _31
let getCurrencyCombos =
let total, coins = 200, [1;2;5;10;20;50;100;200]
let rec count (n, coins) =
match n, coins with
| 0,_ -> 1
| n,_ when n < 0 -> 0
| n,[] when n >= 1 -> 0
| n,coins -> count (n, coins |> List.tail) + count (n - (coins |> List.head),coins)
count (total, coins)
+12
View File
@@ -0,0 +1,12 @@
module _32
open common
let panDigitalProduct =
crossMapList [12..98] [123..987]
|> Seq.append (crossMapList [1..9] [1234..9876])
|> Seq.map (fun (x,y) -> [x;y;x*y])
|> Seq.filter ((List.map unbox) >> isPanDigitalGroup)
|> Seq.map (fun l -> l.[2])
|> Seq.distinct
|> Seq.sum
+37
View File
@@ -0,0 +1,37 @@
module _33
open common
let cancelling =
let nds = seq {
for d in 11..99 do
if d % 10 <> 0 then
for n in 11..(d-1) do
if n % 10 <> 0 then
yield (n,d)
}
let cancelCommonDigits (n,d) =
let nd = numDigits n
let dd = numDigits d
seq {
for ndi in nd do
for ddi in dd do
if ndi = ddi then
let ndmi = Array.filter ((<>) ndi) nd
let ddmi = Array.filter ((<>) ddi) dd
if (ndmi.Length > 0 && ddmi.Length > 0) then
yield (digitsNum ndmi, digitsNum ddmi)
}
nds
|> Seq.collect (fun (n,d) ->
let f = float n/float d
cancelCommonDigits (n,d)
|> Seq.map (fun (cn,cd) -> (float cn/float cd,cn,cd,n,d))
|> Seq.filter (fun (cf,_,_,_,_) -> cf = f)
)
|> Seq.fold (fun (pn, pd) (_,n,d,_,_) -> (pn * n, pd * d)) (1,1)
|> Fraction.reduce
|> snd
+18
View File
@@ -0,0 +1,18 @@
module _34
let numSumDigitFactorials =
let digitFactorials =
[|0..9|]
|> Array.map common.factorial
let digitFactorialSum n =
n
|> common.numDigits
|> Seq.map (Array.get digitFactorials)
|> Seq.sum
[3..1000000]
|> List.map (fun n -> (n, digitFactorialSum n))
|> List.filter (fun n -> fst n = snd n)
|> List.sumBy fst
+26
View File
@@ -0,0 +1,26 @@
module _35
open common
let circularPrime =
let rotations (s:string) =
let len = s.Length
seq {
for n in 0..(len - 1) do
yield s.Substring(len - n)
+ s.Substring(0, len - n)
} |> Seq.toList
let oddOr2 i = i % 2 = 1 || i = 2
let pa =
primeArray 1000000
|> Array.filter (numDigits >> (Array.forall oddOr2))
|> Array.map (string)
let isPrime = isPrimeFunByArray pa
pa
|> Array.map rotations
|> Array.filter (List.forall isPrime)
|> Array.map (Seq.nth 0)
|> Array.length
+12
View File
@@ -0,0 +1,12 @@
module _36
let binary (n:int) =
System.Convert.ToString(n,2)
let palindromicBase10and2Sum =
[1..1000000]
|> List.map (fun n -> (string n, binary n))
|> List.filter (fst >> common.isPalindrome)
|> List.filter (snd >> common.isPalindrome)
|> List.map (fst >> int)
|> List.sum
+26
View File
@@ -0,0 +1,26 @@
module _37
let truncations i =
let s = string i
let len = s.Length
seq {
for n in 0..(len - 1) do
yield s.Substring(0, len - n)
if (n > 0) then
yield s.Substring(len - n)
} |> Seq.distinct |> Seq.toList |> List.map (int)
let truncatablePrimes =
let oddOr2 i = i % 2 = 1 || i = 2
let pa =
common.primeArray 1000000
|> Array.filter (common.numDigits >> (Array.forall oddOr2))
let isPrime n = Array.exists (fun p -> p = n) pa
pa
|> Array.filter ((<) 10)
|> Array.map truncations
|> Array.filter (List.forall isPrime)
|> Array.map (Seq.nth 0)
|> Array.sum
+26
View File
@@ -0,0 +1,26 @@
module _39
let rightTriPerimeter =
let pythagreonTriple m n =
(m * m - n * n, 2 * m * n, m * m + n * n)
let sumTriple (a,b,c) =
a + b + c
let parity a b =
(a + b) % 2 = 1
let multiples lim n =
seq { n .. n .. lim }
common.coprimeArray 33
|> Array.mapi (fun i cp ->
cp
|> Seq.filter (parity i)
|> Seq.map ((pythagreonTriple i) >> sumTriple)
|> Seq.collect (multiples 1000)
)
|> Seq.collect (fun l -> l)
|> Seq.groupBy (fun n -> n)
|> Seq.maxBy (fun g -> Seq.length (snd g))
+28
View File
@@ -0,0 +1,28 @@
function IsPalendrome([string] $str)
{
for ($i = 0; $i -lt $str.Length/2; $i++)
{
if ($str[$i] -ne $str[$str.Length - 1 - $i])
{
return $FALSE;
}
}
return $TRUE;
}
$greatest = [int]::minvalue
for ($j = 999; $j -gt 99; $j--)
{
for ($k = $j; $k -lt 1000; $k++)
{
$mul = $j * $k
if (IsPalendrome $mul)
{
if ($mul -gt $greatest)
{
$greatest = $mul
write-host "$j * $k = $mul"
}
}
}
}
+8
View File
@@ -0,0 +1,8 @@
module _40
let positiveIntegerConcat =
common.allIntegers
|> Seq.collect common.numDigits
|> common.takeIndexes ([1;10;100;1000;10000;100000;1000000]
|> List.map (fun d -> d - 1))
|> Seq.fold (*) 1
+15
View File
@@ -0,0 +1,15 @@
module _41
open common
let panDigital =
// let numListToBigint s =
// s
// |> List.map string
// |> List.fold (+) ""
// |> bigint.Parse
primeArray 7654321
|> arrayToRevSeq
|> Seq.filter isPanDigital
+20
View File
@@ -0,0 +1,20 @@
module _42
open System.IO
let triangleWords =
let words =
File.ReadAllLines(@"42_words.txt")
|> Seq.collect (fun l -> l.Split(','))
|> Seq.map (fun w -> w.Substring(1, w.Length - 2))
let triangleNumbers =
common.allIntegers
|> Seq.map common.triangleNumber
|> Seq.takeWhile ((>) 2000I)
words
|> Seq.map (fun w -> (w, common.wordValue w |> (fun n -> bigint(n))))
|> Seq.toArray
|> Seq.filter (fun wv -> Seq.exists ((=) (snd wv)) triangleNumbers)
|> Seq.length
+1
View File
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
module _43
open System
open common
let pandigitalDivisible =
let comb (i : string) (j : string) =
match i, j with
| i,j when i.[1] = j.[0] && i.[2] = j.[1] -> Some(String.Concat((string i.[0]), j))
| _ -> None
let prMul =
[17;13;11;7;5;3;2]
|> List.map
(
multiples
>> Seq.map string
>> Seq.skipWhile (String.length >> (>) 3)
>> Seq.takeWhile (String.length >> (>) 4)
)
// let lnth i l = List.nth l i
// let lnthDivs i n l = lnth i l >> (%) n >> (=) 0
// [0..9] |> Set.ofSeq |> permutations
// |> Seq.filter (lnth 0 >> (<>) 0)
// |> Seq.filter (lnth 3 >> (%) 2 >> (=) 0)
// //|> Seq.filter (lnth 5 >> (%) 5 >> (=) 0)
// |> Seq.length
+18
View File
@@ -0,0 +1,18 @@
module _45
let triPentHex =
let limit = 100000
let opDict (op : int -> bigint) =
[1..limit]
|> Seq.map (fun n -> (op n, n))
|> dict
let p = opDict common.pentagonalNumber
let h = opDict common.hexagonalNumber
common.allIntegers
|> Seq.skip 284
|> Seq.map (fun i -> (common.triangleNumber i, i))
|> Seq.filter (fst >> (fun t -> p.ContainsKey(t) && h.ContainsKey(t)))
|> Seq.map (fun t -> (snd t, p.Item(fst t), h.Item(fst t), fst t))
|> Seq.take 2
+22
View File
@@ -0,0 +1,22 @@
module _46
let smallestOddCompositeNotSumOfPrimeTwiceSquare =
let ceiling = 10000
let composites =
common.compositeArray ceiling
|> Seq.filter (fun c -> c % 2 = 1)
|> Set.ofSeq
let twiceSquares =
Seq.unfold (fun state -> Some(2 * state * state, state + 1)) 1
let primes = common.primeArray ceiling
let twiceSquareList = twiceSquares |> Seq.take ceiling
let sumOfPrimceTwiceSquare =
common.crossMap (+) primes twiceSquareList
|> Seq.distinct
|> Set.ofSeq
Set.difference composites sumOfPrimceTwiceSquare
+17
View File
@@ -0,0 +1,17 @@
module _47
let consequtivePrimes =
let max = 200000
let count = 4
let d = common.divisors max
let p = common.primeArray ((int)(max/2)) |> Set.ofArray
d
|> Seq.mapi (fun i ds ->
let ds = i::ds |> Set.ofList
let dp = Set.intersect ds p
(i, Set.count dp))
|> Seq.filter (snd >> (=) count)
|> Seq.map fst
|> Seq.windowed count
|> Seq.find (fun ns -> ns.[count - 1] - ns.[0] = count - 1)
+10
View File
@@ -0,0 +1,10 @@
module _48
let series n =
[1..n]
|> List.map (fun d-> System.Numerics.BigInteger.Pow(bigint d, d))
|> List.fold (+) 0I
let seriesEnd =
series 1000
|> common.lastDigits 10
+34
View File
@@ -0,0 +1,34 @@
module _49
open common
let rec insertions x = function
| [] -> [[x]]
| (y :: ys) as l -> (x::l)::(List.map (fun x -> y::x) (insertions x ys))
let rec permutations = function
| [] -> seq [[]]
| x :: xs -> Seq.concat (Seq.map (insertions x) (permutations xs))
let primeSequence =
let primes =
primeArray 10000 |> Seq.skipWhile ((>) 999) |> Array.ofSeq
let isPrime = isPrimeFunByArray primes
primes
|> Seq.map (
numDigits >> List.ofArray >>
permutations >>
Seq.map (Array.ofList >> digitsNum) >>
Seq.filter isPrime >>
Seq.distinct >>
Seq.sort >>
Seq.toArray
)
|> Seq.distinct
|> Seq.collect (List.ofSeq >> combinations 3)
|> Seq.filter (fun a -> a.[2] - a.[1] = a.[1] - a.[0])
|> Seq.map (List.rev >> List.map (numDigits >> Array.map (string) >> Array.fold (+) "") >> List.fold (+) "")
//|> Seq.toArray
+21
View File
@@ -0,0 +1,21 @@
[int64]$num = 20
$i = $num
$answer = 0
while ($answer -eq 0)
{
$answer = $i
for ($j=$num; $j -gt 1; $j--)
{
if ($i%$j -ne 0)
{
$answer = 0
break
}
}
if ($j -lt $num*.75)
{
write-host $i
}
$i += $num
}
$answer
+24
View File
@@ -0,0 +1,24 @@
module _50
let sumOfConsequitivePrimes =
let ceiling = 1000000
let primes = common.primeArray ceiling
let isPrime = common.isPrimeFunByArray primes
let primeSumUnderCeilingIndex =
primes
|> Seq.scan (fun state p -> p + state) 0
|> Seq.findIndex (fun s -> s > ceiling)
|> (+) -1
let indiciesOfDecendingLength max =
seq {
for l in max .. -1 .. 0 do
for o in 0 .. (max - l) do
yield (o, l)
}
indiciesOfDecendingLength primeSumUnderCeilingIndex
|> Seq.map (fun (start,len) -> Array.sub primes start len |> Array.sum)
|> Seq.find isPrime
+24
View File
@@ -0,0 +1,24 @@
module _52
open System
let findSameDigits =
// todo: optimize with combination of available digits
let powerOfTenNums pow =
let b = Math.Pow(10.0, float pow) |> int
seq {1..(b-1)} |> Seq.map ((+) b)
let multiples num =
seq {num*2..num..(num*6) }
let numSet num =
Set (common.numDigits num)
let rec sd pow =
powerOfTenNums pow
|> Seq.filter ( fun n ->
let nDigits = numSet n
multiples n
|> Seq.map (fun m -> numSet m)
|> Seq.forall (fun mDigits -> nDigits = mDigits)
)
|> Seq.map (fun n -> (n, multiples n |> Seq.toArray))
sd 5
+15
View File
@@ -0,0 +1,15 @@
module _53
let combinationGt1M =
let f =
[|0..100|] |> Array.map (fun n -> bigint n) |> Array.map common.factorialI
let combinations (n, r) =
f.[n] / ( f.[r] * f.[n - r] )
[100..-1..0]
|> Seq.sumBy (fun n ->
seq { 1 .. n }
|> Seq.filter (fun r -> combinations (n,r) > 1000000I )
|> Seq.length
)
+200
View File
@@ -0,0 +1,200 @@
module _54
type Suit =
Diamonds | Clubs | Hearts | Spades
type Card =
Jack of Suit | Queen of Suit | King of Suit | Ace of Suit | Value of int * Suit
type Rank =
| HighCard of Card
| OnePair of List<Card>
| TwoPair of List<Card>
| ThreeKind of List<Card>
| Straight of List<Card>
| Flush of List<Card>
| FullHouse of List<Card>
| StraightFlush of List<Card>
| RoyalFlush of List<Card>
let pokerWinner =
let cardValue = function
| Value(v,_) -> v
| Jack(_) -> 11
| Queen(_) -> 12
| King(_) -> 13
| Ace(_) -> 14
let cardSuit = function Value(_,s) | Jack(s) | Queen(s) | King(s) | Ace(s) -> s
let values cards =
cards
|> Seq.groupBy cardValue
let isFlush cards =
cards |> Seq.groupBy cardSuit |> Seq.length = 1
let isStraight cards =
cards |> Seq.map cardValue |> Seq.distinct |> Seq.toArray
|> (fun vs -> Array.length vs = 5 && Array.max vs - Array.min vs = 4)
let isStraightFlush cards =
isStraight cards && isFlush cards
let highCard cards =
cards |> Seq.sortBy cardValue |> Seq.toList |> List.rev |> Seq.nth 0
let isRoyalFlush cards =
let hasAce cards =
cards |> Seq.exists (function | Ace(_) -> true | _ -> false)
isStraightFlush cards && hasAce cards
let multiples cards =
cards
|> Seq.groupBy cardValue |> Seq.map snd
|> Seq.sortBy Seq.length |> Seq.toList |> List.rev
//|> Seq.filter (Seq.length >> ((<) 1))
let rankCards cards =
let multiplesLength cards =
multiples cards
|> List.map Seq.length
|> List.filter ((<) 1)
let flattenMultiples =
multiples cards
|> Seq.collect (fun c -> c)
|> Seq.toList
match cards, multiplesLength cards with
| c,_ when isRoyalFlush c -> RoyalFlush cards
| c,_ when isStraightFlush c -> StraightFlush cards
| _,[3;2] -> FullHouse cards
| c,_ when isFlush c -> Flush cards
| c,_ when isStraight c -> Straight cards
| _,[3] -> ThreeKind flattenMultiples
| _,[2;2] -> TwoPair flattenMultiples
| _,[2] -> OnePair flattenMultiples
| _,_ -> HighCard (highCard cards)
let rankTwoHands (c1,c2) =
(rankCards c1, rankCards c2)
let compareRanks (r1, r2) =
let highCardValue = highCard >> cardValue
let compareHighCard (c1,c2) =
compare (highCardValue c1) (highCardValue c2)
let compareMultiples (c1,c2) =
let rec cm (m1, m2) =
match m1, m2 with
| [],[] -> 0
| h1::_, h2::_ when Seq.length h1 <> Seq.length h2 -> compare (Seq.length h1) (Seq.length h2)
| h1::_, h2::_ when compareHighCard (h1, h2) <> 0 -> compareHighCard (h1, h2)
| _::t1, _::t2 -> cm(t1,t2)
| _,_ -> failwith "huh"
cm (multiples c1, multiples c2)
let r1win, r2win = compare 1 0, compare 0 1
match r1, r2 with
| RoyalFlush(_), RoyalFlush(_) -> 0
| StraightFlush(c1), StraightFlush(c2)
| Flush(c1), Flush(c2)
| Straight(c1), Straight(c2)
-> compareHighCard (c1,c2)
| FullHouse(c1), FullHouse(c2)
| TwoPair(c1), TwoPair(c2)
| OnePair(c1), OnePair(c2)
| ThreeKind(c1), ThreeKind(c2)
-> compareMultiples (c1,c2)
| RoyalFlush(_), _ -> r1win
| _, RoyalFlush(_) -> r2win
| StraightFlush(_), _ -> r1win
| _, StraightFlush(_) -> r2win
| FullHouse(_), _ -> r1win
| _, FullHouse(_) -> r2win
| Flush(_), _ -> r1win
| _, Flush(_) -> r2win
| Straight(_), _ -> r1win
| _, Straight(_) -> r2win
| ThreeKind(_), _ -> r1win
| _, ThreeKind(_) -> r2win
| TwoPair(_), _ -> r1win
| _, TwoPair(_) -> r2win
| OnePair(_), _ -> r1win
| _, OnePair(_) -> r2win
| HighCard(c1), HighCard(c2) -> compare (cardValue c1) (cardValue c2)
let parseCard s =
let parseSuit = function
| 'H' -> Hearts
| 'D' -> Diamonds
| 'C' -> Clubs
| 'S' -> Spades
| _ -> failwith "unknown suit"
if String.length s <> 2 then failwith "wrong length"
let charVal (c:char) = int c - 48
let validVal v = v >= 2 && v <= 9
let suit = parseSuit s.[1]
match s.[0] with
| v when (charVal >> validVal) v -> Value(charVal v, suit)
| 'T' -> Value(10, suit)
| 'J' -> Jack(suit)
| 'Q' -> Queen(suit)
| 'K' -> King(suit)
| 'A' -> Ace(suit)
| _ -> failwith ("unknownCard " + s)
let parseCards (s:string) =
s.Split(' ') |> Array.map parseCard
let parseTwoHands s =
let c = parseCards s
(c.[..4] |> List.ofArray, c.[5..] |> List.ofArray)
// ["5H 5C 6S 7S KD 2C 3S 8S 8D TD";
// "5D 8C 9S JS AC 2C 5C 7D 8S QH";
// "2D 9C AS AH AC 3D 6D 7D TD QD";
// "4D 6S 9H QH QC 3D 6D 7H QD QS";
// "2H 2D 4C 4D 4S 3C 3D 3S 9S 9D"
// ]
System.IO.File.ReadAllLines(@"54_poker.txt")
|> Seq.map (parseTwoHands >> rankTwoHands >> compareRanks) |> Array.ofSeq
|> Seq.filter ((<) 0)
|> Seq.length
//
// ["KD QD JD TD AD"; // royal flush
// "2D 6D 3D 4D 5D"; // straight flush
// "8D TD QD JD 7D"; // flush
// "3D 3S 3H 5D 5H"; // full house
// "KS QD JD TD AD"; // straight
// "3D 3S 3H 5D 6H"; // 3 kind
// "3D 3S 4H 5D 5H"; // 2 pair
// "3D 3S 4H 5D 6H"; // 1 pair
// "KD 3S 4H 5D 6H"; // 1 pair
// ]
// |> Seq.map (parseCards >> Array.toList >> rankCards)
// |> common.crossSelfMapList
// |> Seq.map (
// fun (r1, r2) ->
// let cr = compareRanks (r1, r2)
// sprintf "%A %i %A" r1 cr r2
// )
// |> Array.ofSeq
// |> Seq.map (
// fun c ->
// let pc = parseCards c
// let rf = isRoyalFlush pc
// let s = isStraight pc
// let f = isFlush pc
// let sf = isStraightFlush pc
// let hc = sprintf "%A" (highCard pc)
// let rank = pc |> List.ofArray |> rankCards
// //sprintf "%s RF:%b SF:%b F:%b S:%b HC:%s" c rf sf f s hc
// rank
// )
// |> Seq.toArray
+1000
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
module _55
open System.Numerics
let lynchrels =
let isLynchrel n =
let revInt (n:bigint) =
n
|> (string)
|> common.revString
|> (fun s -> BigInteger.TryParse(s) |> snd)
let rec isLynchrelRec (n:bigint,d) =
match (n + (revInt n)), d with
| _,0 -> true
| n,_ when ((string) >> common.isPalindrome) n -> false
| n,d -> isLynchrelRec (n, d-1)
isLynchrelRec (n,50)
[|1I..10000I|]
|> Array.filter isLynchrel
|> Array.length
+15
View File
@@ -0,0 +1,15 @@
module _56
open System.Numerics
let exponentialDigitSum =
let powDigitSum (a, b) =
BigInteger.Pow(a,b)
|> common.numDigits
|> Seq.sum
let third (_, _, c) = c
common.crossMap (fun a b -> (a,b)) [2I..100I] [2..10]
|> Seq.map (fun (a,b) -> (a,b,powDigitSum (a,b)))
|> Seq.maxBy third
+23
View File
@@ -0,0 +1,23 @@
module _57
open common
open Fraction
open System
open System.Numerics
let sqrtTwoDigits =
let sqrtTwoConvergent d =
let rec sqrtTwo = function
| 1 -> (2I,1I)
| d -> addI (2I,1I) (reciprocalI(sqrtTwo (d - 1)))
addI (1I,1I) (reciprocalI(sqrtTwo d))
let digitCount n =
let d = BigInteger.Log10(n)
Math.Floor d + 1.0 |> int
[1..1000]
|> List.map sqrtTwoConvergent
|> List.map (fun (n,d) -> (digitCount n, digitCount d))
|> List.mapi (fun i (n,d) -> i + 1, n > d)
|> List.filter (snd >> ((=) true))
+33
View File
@@ -0,0 +1,33 @@
module _58
open common
let primeDiagonals =
let isPrime n =
let limit = System.Math.Ceiling(sqrt (float n)) |> int
let rec check i =
i > n/limit || (n % i <> 0 && check (i + 1))
check 2
// let isPrime = isPrimeW [2I;3I]
let sideLengthPrimeCount l = 1 + (l - 1) * 2
let sideLengths =
(2,2) |> Seq.unfold(
fun (l, r) ->
match r with
| 0 -> Some(l, (l + 2, 3))
| _ -> Some(l, (l, r - 1))
)
sideLengths
|> Seq.scan (fun (c,_) l -> (c + (l), l + 1)) (3,3)
|> Seq.scan (fun (p,_) (d,l) ->
let r = isPrime (d)
match r with
| true -> (p + 1, l)
| false -> (p, l)
) (0,0) |> Seq.skip 1
|> Seq.skipWhile (fun (p,l) -> (float p)/(float (sideLengthPrimeCount l)) >= 0.1)
|> Seq.nth 1
+56
View File
@@ -0,0 +1,56 @@
module _59
open System
open System.IO
let cypher =
let encrypted =
File.ReadAllLines(@"59_cipher1.txt")
|> Array.collect (fun line -> line.Split(',') |> Array.map uint16)
let decrypt f message key =
let repeatedKey = seq { while true do yield! key }
Seq.map2 f message repeatedKey
let decryptXor = decrypt (^^^)
let decriptMessage = decryptXor encrypted
let de = encrypted |> Seq.distinct |> Seq.toArray
let filteri f s =
seq {
for i in 0..((s |> Seq.length) - 1) do
let si = Seq.nth i s
if f i si then yield si
}
let validKeys encryptedSymbols =
let lowercase = [97us..122us] |> List.toArray
let validSymbols = [32us..122us] |> List.toArray
let isValidChar i =
Array.exists ((=) i) validSymbols
[0..2]
|> List.map (fun offset ->
lowercase
|> Seq.filter (fun lc ->
encryptedSymbols
|> filteri (fun i e -> i % 3 = offset)
|> Seq.forall (fun e -> (e ^^^ lc) |> isValidChar))
)
let messageToText message =
message
|> Seq.map (char >> string)
|> Seq.fold (fun acc e -> acc + e) ""
validKeys encrypted
|> common.slottedPermutations
|> Seq.map (fun p -> (p, (decriptMessage >> messageToText) p))
|> Seq.find (fun p -> (snd p).Contains(" the "))
|> (fst >> decriptMessage)
|> Seq.map (int)
|> Seq.sum
+1
View File
@@ -0,0 +1 @@
79,59,12,2,79,35,8,28,20,2,3,68,8,9,68,45,0,12,9,67,68,4,7,5,23,27,1,21,79,85,78,79,85,71,38,10,71,27,12,2,79,6,2,8,13,9,1,13,9,8,68,19,7,1,71,56,11,21,11,68,6,3,22,2,14,0,30,79,1,31,6,23,19,10,0,73,79,44,2,79,19,6,28,68,16,6,16,15,79,35,8,11,72,71,14,10,3,79,12,2,79,19,6,28,68,32,0,0,73,79,86,71,39,1,71,24,5,20,79,13,9,79,16,15,10,68,5,10,3,14,1,10,14,1,3,71,24,13,19,7,68,32,0,0,73,79,87,71,39,1,71,12,22,2,14,16,2,11,68,2,25,1,21,22,16,15,6,10,0,79,16,15,10,22,2,79,13,20,65,68,41,0,16,15,6,10,0,79,1,31,6,23,19,28,68,19,7,5,19,79,12,2,79,0,14,11,10,64,27,68,10,14,15,2,65,68,83,79,40,14,9,1,71,6,16,20,10,8,1,79,19,6,28,68,14,1,68,15,6,9,75,79,5,9,11,68,19,7,13,20,79,8,14,9,1,71,8,13,17,10,23,71,3,13,0,7,16,71,27,11,71,10,18,2,29,29,8,1,1,73,79,81,71,59,12,2,79,8,14,8,12,19,79,23,15,6,10,2,28,68,19,7,22,8,26,3,15,79,16,15,10,68,3,14,22,12,1,1,20,28,72,71,14,10,3,79,16,15,10,68,3,14,22,12,1,1,20,28,68,4,14,10,71,1,1,17,10,22,71,10,28,19,6,10,0,26,13,20,7,68,14,27,74,71,89,68,32,0,0,71,28,1,9,27,68,45,0,12,9,79,16,15,10,68,37,14,20,19,6,23,19,79,83,71,27,11,71,27,1,11,3,68,2,25,1,21,22,11,9,10,68,6,13,11,18,27,68,19,7,1,71,3,13,0,7,16,71,28,11,71,27,12,6,27,68,2,25,1,21,22,11,9,10,68,10,6,3,15,27,68,5,10,8,14,10,18,2,79,6,2,12,5,18,28,1,71,0,2,71,7,13,20,79,16,2,28,16,14,2,11,9,22,74,71,87,68,45,0,12,9,79,12,14,2,23,2,3,2,71,24,5,20,79,10,8,27,68,19,7,1,71,3,13,0,7,16,92,79,12,2,79,19,6,28,68,8,1,8,30,79,5,71,24,13,19,1,1,20,28,68,19,0,68,19,7,1,71,3,13,0,7,16,73,79,93,71,59,12,2,79,11,9,10,68,16,7,11,71,6,23,71,27,12,2,79,16,21,26,1,71,3,13,0,7,16,75,79,19,15,0,68,0,6,18,2,28,68,11,6,3,15,27,68,19,0,68,2,25,1,21,22,11,9,10,72,71,24,5,20,79,3,8,6,10,0,79,16,8,79,7,8,2,1,71,6,10,19,0,68,19,7,1,71,24,11,21,3,0,73,79,85,87,79,38,18,27,68,6,3,16,15,0,17,0,7,68,19,7,1,71,24,11,21,3,0,71,24,5,20,79,9,6,11,1,71,27,12,21,0,17,0,7,68,15,6,9,75,79,16,15,10,68,16,0,22,11,11,68,3,6,0,9,72,16,71,29,1,4,0,3,9,6,30,2,79,12,14,2,68,16,7,1,9,79,12,2,79,7,6,2,1,73,79,85,86,79,33,17,10,10,71,6,10,71,7,13,20,79,11,16,1,68,11,14,10,3,79,5,9,11,68,6,2,11,9,8,68,15,6,23,71,0,19,9,79,20,2,0,20,11,10,72,71,7,1,71,24,5,20,79,10,8,27,68,6,12,7,2,31,16,2,11,74,71,94,86,71,45,17,19,79,16,8,79,5,11,3,68,16,7,11,71,13,1,11,6,1,17,10,0,71,7,13,10,79,5,9,11,68,6,12,7,2,31,16,2,11,68,15,6,9,75,79,12,2,79,3,6,25,1,71,27,12,2,79,22,14,8,12,19,79,16,8,79,6,2,12,11,10,10,68,4,7,13,11,11,22,2,1,68,8,9,68,32,0,0,73,79,85,84,79,48,15,10,29,71,14,22,2,79,22,2,13,11,21,1,69,71,59,12,14,28,68,14,28,68,9,0,16,71,14,68,23,7,29,20,6,7,6,3,68,5,6,22,19,7,68,21,10,23,18,3,16,14,1,3,71,9,22,8,2,68,15,26,9,6,1,68,23,14,23,20,6,11,9,79,11,21,79,20,11,14,10,75,79,16,15,6,23,71,29,1,5,6,22,19,7,68,4,0,9,2,28,68,1,29,11,10,79,35,8,11,74,86,91,68,52,0,68,19,7,1,71,56,11,21,11,68,5,10,7,6,2,1,71,7,17,10,14,10,71,14,10,3,79,8,14,25,1,3,79,12,2,29,1,71,0,10,71,10,5,21,27,12,71,14,9,8,1,3,71,26,23,73,79,44,2,79,19,6,28,68,1,26,8,11,79,11,1,79,17,9,9,5,14,3,13,9,8,68,11,0,18,2,79,5,9,11,68,1,14,13,19,7,2,18,3,10,2,28,23,73,79,37,9,11,68,16,10,68,15,14,18,2,79,23,2,10,10,71,7,13,20,79,3,11,0,22,30,67,68,19,7,1,71,8,8,8,29,29,71,0,2,71,27,12,2,79,11,9,3,29,71,60,11,9,79,11,1,79,16,15,10,68,33,14,16,15,10,22,73
View File
+23
View File
@@ -0,0 +1,23 @@
module _63
open System
open common
let powerDigits =
let powDigitCount e n =
let d = Math.Log10(float n) * float e
Math.Floor d + 1.0 |> int
let findNthPowerDigits e =
let pdc = powDigitCount e
allIntegers
|> Seq.map (fun i -> (i, pdc i))
|> Seq.skipWhile (fun (_,n) -> n < e)
|> Seq.takeWhile (fun (_,n) -> n <= e)
|> Seq.toArray
allIntegers |> Seq.skip 1
|> Seq.map findNthPowerDigits
|> Seq.takeWhile (Seq.isEmpty >> not)
|> Seq.collect (fun p -> p)
|> Seq.length
+26
View File
@@ -0,0 +1,26 @@
module _69
open common
let relativePrimeFunc =
let primeDivisorArrayByMax max =
let isPrime = isPrimeFunByMax (int (System.Math.Ceiling(sqrt (float max))))
divisorsInclSelf max |> Array.map (List.filter isPrime)
let totientArrayByMax max =
let pd = primeDivisorArrayByMax max
let productFormula n primes =
let pFunc prime = 1.0 - 1.0/(float prime)
primes
|> List.fold (fun p prime -> p * (pFunc prime)) (float n)
pd
|> Array.mapi productFormula
let indexArray = Array.mapi (fun i e -> (i,e))
totientArrayByMax 1000000
|> indexArray
|> Seq.skip 1
|> Seq.map (fun (i,t) -> (i, (float i)/t))
|> Seq.maxBy snd
+20
View File
@@ -0,0 +1,20 @@
$arr = New-Object bool[] 500000
$arr[0] = $arr[1] = $TRUE
$count = 0
for ($i=2; $i -lt $arr.Length; $i++)
{
if ($arr[$i] -eq $TRUE)
{
continue
}
for ($j=$i*2; $j -lt $arr.Length; $j += $i)
{
$arr[$j] = $TRUE
}
$count ++
write-host "$i is $count"
if ($count -eq 10001)
{
break
}
}
+33
View File
@@ -0,0 +1,33 @@
module _79
open System.IO
let findPasscode =
let logins =
File.ReadAllLines(@"79_keylog.txt")
let preceeds =
logins
|> Seq.collect (fun login -> seq { yield (login.[0], login.[1]); yield (login.[1], login.[2]) })
|> Seq.distinct
let collectTuple (a,b) =
seq { yield a; yield b }
// topographical sort kinda
let rec orderGraph g =
seq {
if Seq.length g = 1 then
yield (collectTuple (Seq.nth 0 g)) |> Seq.toList
else
let allNodes = g |> Seq.collect collectTuple |> Seq.distinct |> Set.ofSeq
let sndNodes = g |> Seq.map snd |> Seq.distinct |> Set.ofSeq
let noPreceedingNodes = allNodes - sndNodes
for n in noPreceedingNodes do
let gMinusN = g |> Seq.filter (fun gi -> not(fst gi = n))
for s in orderGraph gMinusN do
yield n :: s
}
preceeds
|> orderGraph
|> Seq.toArray
+50
View File
@@ -0,0 +1,50 @@
319
680
180
690
129
620
762
689
762
318
368
710
720
710
629
168
160
689
716
731
736
729
316
729
729
710
769
290
719
680
318
389
162
289
162
718
729
319
790
680
890
362
319
760
316
729
380
319
728
716
+24
View File
@@ -0,0 +1,24 @@
$num = gc 8.txt
function product() {
BEGIN {
[int]$prod = 1
}
PROCESS {
#write-host 'prod ' $prod
$prod *= [int][string]$_
#write-host $_ $prod
}
END {
$prod
}
}
$max = 0
for ($i=0; $i -lt $num.length - 5; $i++) {
$curr = $num[$($i)..$($i+4)] | product
if ($curr -gt $max) {
$max = $curr
}
}
$max
+1
View File
@@ -0,0 +1 @@
7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450
+71
View File
@@ -0,0 +1,71 @@
module _81
open common
open System
open System.IO
open System.Collections.Generic
let testMatrix =
[|"131,673,234,103,18";
"201,96,342,965,150";
"630,803,746,422,111";
"537,699,497,121,956";
"805,732,524,37,331"|]
type Direction =
| Down | Right | Init
let coordMod f coord = function
| Down -> (f (fst coord), snd coord)
| Right -> (fst coord, f (snd coord))
| Init -> failwith "Ha"
let coordDeref = coordMod ((-) 1)
let coordRef = coordMod ((+) 1)
let shortestDistance =
let matrix =
//File.ReadAllLines(@"81_matrix.txt")
array2D (testMatrix |> Array.map strSplitInt)
let mLen1, mLen2 = Array2D.length1 matrix, Array2D.length2 matrix
let dist =
Array2D.create mLen1 mLen2 Int32.MaxValue
// let rec listInsert f v l =
// match l with
// | x::xs when f x -> v::x::xs
// | x::xs -> x::listInsert f v xs
// | [] -> [v]
let rec f frontier =
let expand coord =
seq {
let d, r = coordRef coord Down, coordRef coord Right
let inMatrix coord =
fst coord < mLen1 && snd coord < mLen2
let incl c = inMatrix c && dist.[fst c, snd c] = Int32.MaxValue
if incl d then yield d
if incl r then yield r }
match frontier with
| [] -> ()
| (coord,d)::xs ->
dist.[fst coord, snd coord] <- d
xs
|> List.filter (fun ((c),_) -> c <> coord)
|> List.append
(expand coord
|> Seq.map (
fun f ->
let fd = matrix.[fst f, snd f] + d
f,fd)
|> List.ofSeq)
|> List.sortWith (fun (_,d1) (_,d2) -> d1 - d2)
|> f
f [(0,0),matrix.[0,0]]
dist.[mLen1 - 1, mLen2 - 1]
+80
View File
@@ -0,0 +1,80 @@
4445,2697,5115,718,2209,2212,654,4348,3079,6821,7668,3276,8874,4190,3785,2752,9473,7817,9137,496,7338,3434,7152,4355,4552,7917,7827,2460,2350,691,3514,5880,3145,7633,7199,3783,5066,7487,3285,1084,8985,760,872,8609,8051,1134,9536,5750,9716,9371,7619,5617,275,9721,2997,2698,1887,8825,6372,3014,2113,7122,7050,6775,5948,2758,1219,3539,348,7989,2735,9862,1263,8089,6401,9462,3168,2758,3748,5870
1096,20,1318,7586,5167,2642,1443,5741,7621,7030,5526,4244,2348,4641,9827,2448,6918,5883,3737,300,7116,6531,567,5997,3971,6623,820,6148,3287,1874,7981,8424,7672,7575,6797,6717,1078,5008,4051,8795,5820,346,1851,6463,2117,6058,3407,8211,117,4822,1317,4377,4434,5925,8341,4800,1175,4173,690,8978,7470,1295,3799,8724,3509,9849,618,3320,7068,9633,2384,7175,544,6583,1908,9983,481,4187,9353,9377
9607,7385,521,6084,1364,8983,7623,1585,6935,8551,2574,8267,4781,3834,2764,2084,2669,4656,9343,7709,2203,9328,8004,6192,5856,3555,2260,5118,6504,1839,9227,1259,9451,1388,7909,5733,6968,8519,9973,1663,5315,7571,3035,4325,4283,2304,6438,3815,9213,9806,9536,196,5542,6907,2475,1159,5820,9075,9470,2179,9248,1828,4592,9167,3713,4640,47,3637,309,7344,6955,346,378,9044,8635,7466,5036,9515,6385,9230
7206,3114,7760,1094,6150,5182,7358,7387,4497,955,101,1478,7777,6966,7010,8417,6453,4955,3496,107,449,8271,131,2948,6185,784,5937,8001,6104,8282,4165,3642,710,2390,575,715,3089,6964,4217,192,5949,7006,715,3328,1152,66,8044,4319,1735,146,4818,5456,6451,4113,1063,4781,6799,602,1504,6245,6550,1417,1343,2363,3785,5448,4545,9371,5420,5068,4613,4882,4241,5043,7873,8042,8434,3939,9256,2187
3620,8024,577,9997,7377,7682,1314,1158,6282,6310,1896,2509,5436,1732,9480,706,496,101,6232,7375,2207,2306,110,6772,3433,2878,8140,5933,8688,1399,2210,7332,6172,6403,7333,4044,2291,1790,2446,7390,8698,5723,3678,7104,1825,2040,140,3982,4905,4160,2200,5041,2512,1488,2268,1175,7588,8321,8078,7312,977,5257,8465,5068,3453,3096,1651,7906,253,9250,6021,8791,8109,6651,3412,345,4778,5152,4883,7505
1074,5438,9008,2679,5397,5429,2652,3403,770,9188,4248,2493,4361,8327,9587,707,9525,5913,93,1899,328,2876,3604,673,8576,6908,7659,2544,3359,3883,5273,6587,3065,1749,3223,604,9925,6941,2823,8767,7039,3290,3214,1787,7904,3421,7137,9560,8451,2669,9219,6332,1576,5477,6755,8348,4164,4307,2984,4012,6629,1044,2874,6541,4942,903,1404,9125,5160,8836,4345,2581,460,8438,1538,5507,668,3352,2678,6942
4295,1176,5596,1521,3061,9868,7037,7129,8933,6659,5947,5063,3653,9447,9245,2679,767,714,116,8558,163,3927,8779,158,5093,2447,5782,3967,1716,931,7772,8164,1117,9244,5783,7776,3846,8862,6014,2330,6947,1777,3112,6008,3491,1906,5952,314,4602,8994,5919,9214,3995,5026,7688,6809,5003,3128,2509,7477,110,8971,3982,8539,2980,4689,6343,5411,2992,5270,5247,9260,2269,7474,1042,7162,5206,1232,4556,4757
510,3556,5377,1406,5721,4946,2635,7847,4251,8293,8281,6351,4912,287,2870,3380,3948,5322,3840,4738,9563,1906,6298,3234,8959,1562,6297,8835,7861,239,6618,1322,2553,2213,5053,5446,4402,6500,5182,8585,6900,5756,9661,903,5186,7687,5998,7997,8081,8955,4835,6069,2621,1581,732,9564,1082,1853,5442,1342,520,1737,3703,5321,4793,2776,1508,1647,9101,2499,6891,4336,7012,3329,3212,1442,9993,3988,4930,7706
9444,3401,5891,9716,1228,7107,109,3563,2700,6161,5039,4992,2242,8541,7372,2067,1294,3058,1306,320,8881,5756,9326,411,8650,8824,5495,8282,8397,2000,1228,7817,2099,6473,3571,5994,4447,1299,5991,543,7874,2297,1651,101,2093,3463,9189,6872,6118,872,1008,1779,2805,9084,4048,2123,5877,55,3075,1737,9459,4535,6453,3644,108,5982,4437,5213,1340,6967,9943,5815,669,8074,1838,6979,9132,9315,715,5048
3327,4030,7177,6336,9933,5296,2621,4785,2755,4832,2512,2118,2244,4407,2170,499,7532,9742,5051,7687,970,6924,3527,4694,5145,1306,2165,5940,2425,8910,3513,1909,6983,346,6377,4304,9330,7203,6605,3709,3346,970,369,9737,5811,4427,9939,3693,8436,5566,1977,3728,2399,3985,8303,2492,5366,9802,9193,7296,1033,5060,9144,2766,1151,7629,5169,5995,58,7619,7565,4208,1713,6279,3209,4908,9224,7409,1325,8540
6882,1265,1775,3648,4690,959,5837,4520,5394,1378,9485,1360,4018,578,9174,2932,9890,3696,116,1723,1178,9355,7063,1594,1918,8574,7594,7942,1547,6166,7888,354,6932,4651,1010,7759,6905,661,7689,6092,9292,3845,9605,8443,443,8275,5163,7720,7265,6356,7779,1798,1754,5225,6661,1180,8024,5666,88,9153,1840,3508,1193,4445,2648,3538,6243,6375,8107,5902,5423,2520,1122,5015,6113,8859,9370,966,8673,2442
7338,3423,4723,6533,848,8041,7921,8277,4094,5368,7252,8852,9166,2250,2801,6125,8093,5738,4038,9808,7359,9494,601,9116,4946,2702,5573,2921,9862,1462,1269,2410,4171,2709,7508,6241,7522,615,2407,8200,4189,5492,5649,7353,2590,5203,4274,710,7329,9063,956,8371,3722,4253,4785,1194,4828,4717,4548,940,983,2575,4511,2938,1827,2027,2700,1236,841,5760,1680,6260,2373,3851,1841,4968,1172,5179,7175,3509
4420,1327,3560,2376,6260,2988,9537,4064,4829,8872,9598,3228,1792,7118,9962,9336,4368,9189,6857,1829,9863,6287,7303,7769,2707,8257,2391,2009,3975,4993,3068,9835,3427,341,8412,2134,4034,8511,6421,3041,9012,2983,7289,100,1355,7904,9186,6920,5856,2008,6545,8331,3655,5011,839,8041,9255,6524,3862,8788,62,7455,3513,5003,8413,3918,2076,7960,6108,3638,6999,3436,1441,4858,4181,1866,8731,7745,3744,1000
356,8296,8325,1058,1277,4743,3850,2388,6079,6462,2815,5620,8495,5378,75,4324,3441,9870,1113,165,1544,1179,2834,562,6176,2313,6836,8839,2986,9454,5199,6888,1927,5866,8760,320,1792,8296,7898,6121,7241,5886,5814,2815,8336,1576,4314,3109,2572,6011,2086,9061,9403,3947,5487,9731,7281,3159,1819,1334,3181,5844,5114,9898,4634,2531,4412,6430,4262,8482,4546,4555,6804,2607,9421,686,8649,8860,7794,6672
9870,152,1558,4963,8750,4754,6521,6256,8818,5208,5691,9659,8377,9725,5050,5343,2539,6101,1844,9700,7750,8114,5357,3001,8830,4438,199,9545,8496,43,2078,327,9397,106,6090,8181,8646,6414,7499,5450,4850,6273,5014,4131,7639,3913,6571,8534,9703,4391,7618,445,1320,5,1894,6771,7383,9191,4708,9706,6939,7937,8726,9382,5216,3685,2247,9029,8154,1738,9984,2626,9438,4167,6351,5060,29,1218,1239,4785
192,5213,8297,8974,4032,6966,5717,1179,6523,4679,9513,1481,3041,5355,9303,9154,1389,8702,6589,7818,6336,3539,5538,3094,6646,6702,6266,2759,4608,4452,617,9406,8064,6379,444,5602,4950,1810,8391,1536,316,8714,1178,5182,5863,5110,5372,4954,1978,2971,5680,4863,2255,4630,5723,2168,538,1692,1319,7540,440,6430,6266,7712,7385,5702,620,641,3136,7350,1478,3155,2820,9109,6261,1122,4470,14,8493,2095
1046,4301,6082,474,4974,7822,2102,5161,5172,6946,8074,9716,6586,9962,9749,5015,2217,995,5388,4402,7652,6399,6539,1349,8101,3677,1328,9612,7922,2879,231,5887,2655,508,4357,4964,3554,5930,6236,7384,4614,280,3093,9600,2110,7863,2631,6626,6620,68,1311,7198,7561,1768,5139,1431,221,230,2940,968,5283,6517,2146,1646,869,9402,7068,8645,7058,1765,9690,4152,2926,9504,2939,7504,6074,2944,6470,7859
4659,736,4951,9344,1927,6271,8837,8711,3241,6579,7660,5499,5616,3743,5801,4682,9748,8796,779,1833,4549,8138,4026,775,4170,2432,4174,3741,7540,8017,2833,4027,396,811,2871,1150,9809,2719,9199,8504,1224,540,2051,3519,7982,7367,2761,308,3358,6505,2050,4836,5090,7864,805,2566,2409,6876,3361,8622,5572,5895,3280,441,7893,8105,1634,2929,274,3926,7786,6123,8233,9921,2674,5340,1445,203,4585,3837
5759,338,7444,7968,7742,3755,1591,4839,1705,650,7061,2461,9230,9391,9373,2413,1213,431,7801,4994,2380,2703,6161,6878,8331,2538,6093,1275,5065,5062,2839,582,1014,8109,3525,1544,1569,8622,7944,2905,6120,1564,1839,5570,7579,1318,2677,5257,4418,5601,7935,7656,5192,1864,5886,6083,5580,6202,8869,1636,7907,4759,9082,5854,3185,7631,6854,5872,5632,5280,1431,2077,9717,7431,4256,8261,9680,4487,4752,4286
1571,1428,8599,1230,7772,4221,8523,9049,4042,8726,7567,6736,9033,2104,4879,4967,6334,6716,3994,1269,8995,6539,3610,7667,6560,6065,874,848,4597,1711,7161,4811,6734,5723,6356,6026,9183,2586,5636,1092,7779,7923,8747,6887,7505,9909,1792,3233,4526,3176,1508,8043,720,5212,6046,4988,709,5277,8256,3642,1391,5803,1468,2145,3970,6301,7767,2359,8487,9771,8785,7520,856,1605,8972,2402,2386,991,1383,5963
1822,4824,5957,6511,9868,4113,301,9353,6228,2881,2966,6956,9124,9574,9233,1601,7340,973,9396,540,4747,8590,9535,3650,7333,7583,4806,3593,2738,8157,5215,8472,2284,9473,3906,6982,5505,6053,7936,6074,7179,6688,1564,1103,6860,5839,2022,8490,910,7551,7805,881,7024,1855,9448,4790,1274,3672,2810,774,7623,4223,4850,6071,9975,4935,1915,9771,6690,3846,517,463,7624,4511,614,6394,3661,7409,1395,8127
8738,3850,9555,3695,4383,2378,87,6256,6740,7682,9546,4255,6105,2000,1851,4073,8957,9022,6547,5189,2487,303,9602,7833,1628,4163,6678,3144,8589,7096,8913,5823,4890,7679,1212,9294,5884,2972,3012,3359,7794,7428,1579,4350,7246,4301,7779,7790,3294,9547,4367,3549,1958,8237,6758,3497,3250,3456,6318,1663,708,7714,6143,6890,3428,6853,9334,7992,591,6449,9786,1412,8500,722,5468,1371,108,3939,4199,2535
7047,4323,1934,5163,4166,461,3544,2767,6554,203,6098,2265,9078,2075,4644,6641,8412,9183,487,101,7566,5622,1975,5726,2920,5374,7779,5631,3753,3725,2672,3621,4280,1162,5812,345,8173,9785,1525,955,5603,2215,2580,5261,2765,2990,5979,389,3907,2484,1232,5933,5871,3304,1138,1616,5114,9199,5072,7442,7245,6472,4760,6359,9053,7876,2564,9404,3043,9026,2261,3374,4460,7306,2326,966,828,3274,1712,3446
3975,4565,8131,5800,4570,2306,8838,4392,9147,11,3911,7118,9645,4994,2028,6062,5431,2279,8752,2658,7836,994,7316,5336,7185,3289,1898,9689,2331,5737,3403,1124,2679,3241,7748,16,2724,5441,6640,9368,9081,5618,858,4969,17,2103,6035,8043,7475,2181,939,415,1617,8500,8253,2155,7843,7974,7859,1746,6336,3193,2617,8736,4079,6324,6645,8891,9396,5522,6103,1857,8979,3835,2475,1310,7422,610,8345,7615
9248,5397,5686,2988,3446,4359,6634,9141,497,9176,6773,7448,1907,8454,916,1596,2241,1626,1384,2741,3649,5362,8791,7170,2903,2475,5325,6451,924,3328,522,90,4813,9737,9557,691,2388,1383,4021,1609,9206,4707,5200,7107,8104,4333,9860,5013,1224,6959,8527,1877,4545,7772,6268,621,4915,9349,5970,706,9583,3071,4127,780,8231,3017,9114,3836,7503,2383,1977,4870,8035,2379,9704,1037,3992,3642,1016,4303
5093,138,4639,6609,1146,5565,95,7521,9077,2272,974,4388,2465,2650,722,4998,3567,3047,921,2736,7855,173,2065,4238,1048,5,6847,9548,8632,9194,5942,4777,7910,8971,6279,7253,2516,1555,1833,3184,9453,9053,6897,7808,8629,4877,1871,8055,4881,7639,1537,7701,2508,7564,5845,5023,2304,5396,3193,2955,1088,3801,6203,1748,3737,1276,13,4120,7715,8552,3047,2921,106,7508,304,1280,7140,2567,9135,5266
6237,4607,7527,9047,522,7371,4883,2540,5867,6366,5301,1570,421,276,3361,527,6637,4861,2401,7522,5808,9371,5298,2045,5096,5447,7755,5115,7060,8529,4078,1943,1697,1764,5453,7085,960,2405,739,2100,5800,728,9737,5704,5693,1431,8979,6428,673,7540,6,7773,5857,6823,150,5869,8486,684,5816,9626,7451,5579,8260,3397,5322,6920,1879,2127,2884,5478,4977,9016,6165,6292,3062,5671,5968,78,4619,4763
9905,7127,9390,5185,6923,3721,9164,9705,4341,1031,1046,5127,7376,6528,3248,4941,1178,7889,3364,4486,5358,9402,9158,8600,1025,874,1839,1783,309,9030,1843,845,8398,1433,7118,70,8071,2877,3904,8866,6722,4299,10,1929,5897,4188,600,1889,3325,2485,6473,4474,7444,6992,4846,6166,4441,2283,2629,4352,7775,1101,2214,9985,215,8270,9750,2740,8361,7103,5930,8664,9690,8302,9267,344,2077,1372,1880,9550
5825,8517,7769,2405,8204,1060,3603,7025,478,8334,1997,3692,7433,9101,7294,7498,9415,5452,3850,3508,6857,9213,6807,4412,7310,854,5384,686,4978,892,8651,3241,2743,3801,3813,8588,6701,4416,6990,6490,3197,6838,6503,114,8343,5844,8646,8694,65,791,5979,2687,2621,2019,8097,1423,3644,9764,4921,3266,3662,5561,2476,8271,8138,6147,1168,3340,1998,9874,6572,9873,6659,5609,2711,3931,9567,4143,7833,8887
6223,2099,2700,589,4716,8333,1362,5007,2753,2848,4441,8397,7192,8191,4916,9955,6076,3370,6396,6971,3156,248,3911,2488,4930,2458,7183,5455,170,6809,6417,3390,1956,7188,577,7526,2203,968,8164,479,8699,7915,507,6393,4632,1597,7534,3604,618,3280,6061,9793,9238,8347,568,9645,2070,5198,6482,5000,9212,6655,5961,7513,1323,3872,6170,3812,4146,2736,67,3151,5548,2781,9679,7564,5043,8587,1893,4531
5826,3690,6724,2121,9308,6986,8106,6659,2142,1642,7170,2877,5757,6494,8026,6571,8387,9961,6043,9758,9607,6450,8631,8334,7359,5256,8523,2225,7487,1977,9555,8048,5763,2414,4948,4265,2427,8978,8088,8841,9208,9601,5810,9398,8866,9138,4176,5875,7212,3272,6759,5678,7649,4922,5422,1343,8197,3154,3600,687,1028,4579,2084,9467,4492,7262,7296,6538,7657,7134,2077,1505,7332,6890,8964,4879,7603,7400,5973,739
1861,1613,4879,1884,7334,966,2000,7489,2123,4287,1472,3263,4726,9203,1040,4103,6075,6049,330,9253,4062,4268,1635,9960,577,1320,3195,9628,1030,4092,4979,6474,6393,2799,6967,8687,7724,7392,9927,2085,3200,6466,8702,265,7646,8665,7986,7266,4574,6587,612,2724,704,3191,8323,9523,3002,704,5064,3960,8209,2027,2758,8393,4875,4641,9584,6401,7883,7014,768,443,5490,7506,1852,2005,8850,5776,4487,4269
4052,6687,4705,7260,6645,6715,3706,5504,8672,2853,1136,8187,8203,4016,871,1809,1366,4952,9294,5339,6872,2645,6083,7874,3056,5218,7485,8796,7401,3348,2103,426,8572,4163,9171,3176,948,7654,9344,3217,1650,5580,7971,2622,76,2874,880,2034,9929,1546,2659,5811,3754,7096,7436,9694,9960,7415,2164,953,2360,4194,2397,1047,2196,6827,575,784,2675,8821,6802,7972,5996,6699,2134,7577,2887,1412,4349,4380
4629,2234,6240,8132,7592,3181,6389,1214,266,1910,2451,8784,2790,1127,6932,1447,8986,2492,5476,397,889,3027,7641,5083,5776,4022,185,3364,5701,2442,2840,4160,9525,4828,6602,2614,7447,3711,4505,7745,8034,6514,4907,2605,7753,6958,7270,6936,3006,8968,439,2326,4652,3085,3425,9863,5049,5361,8688,297,7580,8777,7916,6687,8683,7141,306,9569,2384,1500,3346,4601,7329,9040,6097,2727,6314,4501,4974,2829
8316,4072,2025,6884,3027,1808,5714,7624,7880,8528,4205,8686,7587,3230,1139,7273,6163,6986,3914,9309,1464,9359,4474,7095,2212,7302,2583,9462,7532,6567,1606,4436,8981,5612,6796,4385,5076,2007,6072,3678,8331,1338,3299,8845,4783,8613,4071,1232,6028,2176,3990,2148,3748,103,9453,538,6745,9110,926,3125,473,5970,8728,7072,9062,1404,1317,5139,9862,6496,6062,3338,464,1600,2532,1088,8232,7739,8274,3873
2341,523,7096,8397,8301,6541,9844,244,4993,2280,7689,4025,4196,5522,7904,6048,2623,9258,2149,9461,6448,8087,7245,1917,8340,7127,8466,5725,6996,3421,5313,512,9164,9837,9794,8369,4185,1488,7210,1524,1016,4620,9435,2478,7765,8035,697,6677,3724,6988,5853,7662,3895,9593,1185,4727,6025,5734,7665,3070,138,8469,6748,6459,561,7935,8646,2378,462,7755,3115,9690,8877,3946,2728,8793,244,6323,8666,4271
6430,2406,8994,56,1267,3826,9443,7079,7579,5232,6691,3435,6718,5698,4144,7028,592,2627,217,734,6194,8156,9118,58,2640,8069,4127,3285,694,3197,3377,4143,4802,3324,8134,6953,7625,3598,3584,4289,7065,3434,2106,7132,5802,7920,9060,7531,3321,1725,1067,3751,444,5503,6785,7937,6365,4803,198,6266,8177,1470,6390,1606,2904,7555,9834,8667,2033,1723,5167,1666,8546,8152,473,4475,6451,7947,3062,3281
2810,3042,7759,1741,2275,2609,7676,8640,4117,1958,7500,8048,1757,3954,9270,1971,4796,2912,660,5511,3553,1012,5757,4525,6084,7198,8352,5775,7726,8591,7710,9589,3122,4392,6856,5016,749,2285,3356,7482,9956,7348,2599,8944,495,3462,3578,551,4543,7207,7169,7796,1247,4278,6916,8176,3742,8385,2310,1345,8692,2667,4568,1770,8319,3585,4920,3890,4928,7343,5385,9772,7947,8786,2056,9266,3454,2807,877,2660
6206,8252,5928,5837,4177,4333,207,7934,5581,9526,8906,1498,8411,2984,5198,5134,2464,8435,8514,8674,3876,599,5327,826,2152,4084,2433,9327,9697,4800,2728,3608,3849,3861,3498,9943,1407,3991,7191,9110,5666,8434,4704,6545,5944,2357,1163,4995,9619,6754,4200,9682,6654,4862,4744,5953,6632,1054,293,9439,8286,2255,696,8709,1533,1844,6441,430,1999,6063,9431,7018,8057,2920,6266,6799,356,3597,4024,6665
3847,6356,8541,7225,2325,2946,5199,469,5450,7508,2197,9915,8284,7983,6341,3276,3321,16,1321,7608,5015,3362,8491,6968,6818,797,156,2575,706,9516,5344,5457,9210,5051,8099,1617,9951,7663,8253,9683,2670,1261,4710,1068,8753,4799,1228,2621,3275,6188,4699,1791,9518,8701,5932,4275,6011,9877,2933,4182,6059,2930,6687,6682,9771,654,9437,3169,8596,1827,5471,8909,2352,123,4394,3208,8756,5513,6917,2056
5458,8173,3138,3290,4570,4892,3317,4251,9699,7973,1163,1935,5477,6648,9614,5655,9592,975,9118,2194,7322,8248,8413,3462,8560,1907,7810,6650,7355,2939,4973,6894,3933,3784,3200,2419,9234,4747,2208,2207,1945,2899,1407,6145,8023,3484,5688,7686,2737,3828,3704,9004,5190,9740,8643,8650,5358,4426,1522,1707,3613,9887,6956,2447,2762,833,1449,9489,2573,1080,4167,3456,6809,2466,227,7125,2759,6250,6472,8089
3266,7025,9756,3914,1265,9116,7723,9788,6805,5493,2092,8688,6592,9173,4431,4028,6007,7131,4446,4815,3648,6701,759,3312,8355,4485,4187,5188,8746,7759,3528,2177,5243,8379,3838,7233,4607,9187,7216,2190,6967,2920,6082,7910,5354,3609,8958,6949,7731,494,8753,8707,1523,4426,3543,7085,647,6771,9847,646,5049,824,8417,5260,2730,5702,2513,9275,4279,2767,8684,1165,9903,4518,55,9682,8963,6005,2102,6523
1998,8731,936,1479,5259,7064,4085,91,7745,7136,3773,3810,730,8255,2705,2653,9790,6807,2342,355,9344,2668,3690,2028,9679,8102,574,4318,6481,9175,5423,8062,2867,9657,7553,3442,3920,7430,3945,7639,3714,3392,2525,4995,4850,2867,7951,9667,486,9506,9888,781,8866,1702,3795,90,356,1483,4200,2131,6969,5931,486,6880,4404,1084,5169,4910,6567,8335,4686,5043,2614,3352,2667,4513,6472,7471,5720,1616
8878,1613,1716,868,1906,2681,564,665,5995,2474,7496,3432,9491,9087,8850,8287,669,823,347,6194,2264,2592,7871,7616,8508,4827,760,2676,4660,4881,7572,3811,9032,939,4384,929,7525,8419,5556,9063,662,8887,7026,8534,3111,1454,2082,7598,5726,6687,9647,7608,73,3014,5063,670,5461,5631,3367,9796,8475,7908,5073,1565,5008,5295,4457,1274,4788,1728,338,600,8415,8535,9351,7750,6887,5845,1741,125
3637,6489,9634,9464,9055,2413,7824,9517,7532,3577,7050,6186,6980,9365,9782,191,870,2497,8498,2218,2757,5420,6468,586,3320,9230,1034,1393,9886,5072,9391,1178,8464,8042,6869,2075,8275,3601,7715,9470,8786,6475,8373,2159,9237,2066,3264,5000,679,355,3069,4073,494,2308,5512,4334,9438,8786,8637,9774,1169,1949,6594,6072,4270,9158,7916,5752,6794,9391,6301,5842,3285,2141,3898,8027,4310,8821,7079,1307
8497,6681,4732,7151,7060,5204,9030,7157,833,5014,8723,3207,9796,9286,4913,119,5118,7650,9335,809,3675,2597,5144,3945,5090,8384,187,4102,1260,2445,2792,4422,8389,9290,50,1765,1521,6921,8586,4368,1565,5727,7855,2003,4834,9897,5911,8630,5070,1330,7692,7557,7980,6028,5805,9090,8265,3019,3802,698,9149,5748,1965,9658,4417,5994,5584,8226,2937,272,5743,1278,5698,8736,2595,6475,5342,6596,1149,6920
8188,8009,9546,6310,8772,2500,9846,6592,6872,3857,1307,8125,7042,1544,6159,2330,643,4604,7899,6848,371,8067,2062,3200,7295,1857,9505,6936,384,2193,2190,301,8535,5503,1462,7380,5114,4824,8833,1763,4974,8711,9262,6698,3999,2645,6937,7747,1128,2933,3556,7943,2885,3122,9105,5447,418,2899,5148,3699,9021,9501,597,4084,175,1621,1,1079,6067,5812,4326,9914,6633,5394,4233,6728,9084,1864,5863,1225
9935,8793,9117,1825,9542,8246,8437,3331,9128,9675,6086,7075,319,1334,7932,3583,7167,4178,1726,7720,695,8277,7887,6359,5912,1719,2780,8529,1359,2013,4498,8072,1129,9998,1147,8804,9405,6255,1619,2165,7491,1,8882,7378,3337,503,5758,4109,3577,985,3200,7615,8058,5032,1080,6410,6873,5496,1466,2412,9885,5904,4406,3605,8770,4361,6205,9193,1537,9959,214,7260,9566,1685,100,4920,7138,9819,5637,976
3466,9854,985,1078,7222,8888,5466,5379,3578,4540,6853,8690,3728,6351,7147,3134,6921,9692,857,3307,4998,2172,5783,3931,9417,2541,6299,13,787,2099,9131,9494,896,8600,1643,8419,7248,2660,2609,8579,91,6663,5506,7675,1947,6165,4286,1972,9645,3805,1663,1456,8853,5705,9889,7489,1107,383,4044,2969,3343,152,7805,4980,9929,5033,1737,9953,7197,9158,4071,1324,473,9676,3984,9680,3606,8160,7384,5432
1005,4512,5186,3953,2164,3372,4097,3247,8697,3022,9896,4101,3871,6791,3219,2742,4630,6967,7829,5991,6134,1197,1414,8923,8787,1394,8852,5019,7768,5147,8004,8825,5062,9625,7988,1110,3992,7984,9966,6516,6251,8270,421,3723,1432,4830,6935,8095,9059,2214,6483,6846,3120,1587,6201,6691,9096,9627,6671,4002,3495,9939,7708,7465,5879,6959,6634,3241,3401,2355,9061,2611,7830,3941,2177,2146,5089,7079,519,6351
7280,8586,4261,2831,7217,3141,9994,9940,5462,2189,4005,6942,9848,5350,8060,6665,7519,4324,7684,657,9453,9296,2944,6843,7499,7847,1728,9681,3906,6353,5529,2822,3355,3897,7724,4257,7489,8672,4356,3983,1948,6892,7415,4153,5893,4190,621,1736,4045,9532,7701,3671,1211,1622,3176,4524,9317,7800,5638,6644,6943,5463,3531,2821,1347,5958,3436,1438,2999,994,850,4131,2616,1549,3465,5946,690,9273,6954,7991
9517,399,3249,2596,7736,2142,1322,968,7350,1614,468,3346,3265,7222,6086,1661,5317,2582,7959,4685,2807,2917,1037,5698,1529,3972,8716,2634,3301,3412,8621,743,8001,4734,888,7744,8092,3671,8941,1487,5658,7099,2781,99,1932,4443,4756,4652,9328,1581,7855,4312,5976,7255,6480,3996,2748,1973,9731,4530,2790,9417,7186,5303,3557,351,7182,9428,1342,9020,7599,1392,8304,2070,9138,7215,2008,9937,1106,7110
7444,769,9688,632,1571,6820,8743,4338,337,3366,3073,1946,8219,104,4210,6986,249,5061,8693,7960,6546,1004,8857,5997,9352,4338,6105,5008,2556,6518,6694,4345,3727,7956,20,3954,8652,4424,9387,2035,8358,5962,5304,5194,8650,8282,1256,1103,2138,6679,1985,3653,2770,2433,4278,615,2863,1715,242,3790,2636,6998,3088,1671,2239,957,5411,4595,6282,2881,9974,2401,875,7574,2987,4587,3147,6766,9885,2965
3287,3016,3619,6818,9073,6120,5423,557,2900,2015,8111,3873,1314,4189,1846,4399,7041,7583,2427,2864,3525,5002,2069,748,1948,6015,2684,438,770,8367,1663,7887,7759,1885,157,7770,4520,4878,3857,1137,3525,3050,6276,5569,7649,904,4533,7843,2199,5648,7628,9075,9441,3600,7231,2388,5640,9096,958,3058,584,5899,8150,1181,9616,1098,8162,6819,8171,1519,1140,7665,8801,2632,1299,9192,707,9955,2710,7314
1772,2963,7578,3541,3095,1488,7026,2634,6015,4633,4370,2762,1650,2174,909,8158,2922,8467,4198,4280,9092,8856,8835,5457,2790,8574,9742,5054,9547,4156,7940,8126,9824,7340,8840,6574,3547,1477,3014,6798,7134,435,9484,9859,3031,4,1502,4133,1738,1807,4825,463,6343,9701,8506,9822,9555,8688,8168,3467,3234,6318,1787,5591,419,6593,7974,8486,9861,6381,6758,194,3061,4315,2863,4665,3789,2201,1492,4416
126,8927,6608,5682,8986,6867,1715,6076,3159,788,3140,4744,830,9253,5812,5021,7616,8534,1546,9590,1101,9012,9821,8132,7857,4086,1069,7491,2988,1579,2442,4321,2149,7642,6108,250,6086,3167,24,9528,7663,2685,1220,9196,1397,5776,1577,1730,5481,977,6115,199,6326,2183,3767,5928,5586,7561,663,8649,9688,949,5913,9160,1870,5764,9887,4477,6703,1413,4995,5494,7131,2192,8969,7138,3997,8697,646,1028
8074,1731,8245,624,4601,8706,155,8891,309,2552,8208,8452,2954,3124,3469,4246,3352,1105,4509,8677,9901,4416,8191,9283,5625,7120,2952,8881,7693,830,4580,8228,9459,8611,4499,1179,4988,1394,550,2336,6089,6872,269,7213,1848,917,6672,4890,656,1478,6536,3165,4743,4990,1176,6211,7207,5284,9730,4738,1549,4986,4942,8645,3698,9429,1439,2175,6549,3058,6513,1574,6988,8333,3406,5245,5431,7140,7085,6407
7845,4694,2530,8249,290,5948,5509,1588,5940,4495,5866,5021,4626,3979,3296,7589,4854,1998,5627,3926,8346,6512,9608,1918,7070,4747,4182,2858,2766,4606,6269,4107,8982,8568,9053,4244,5604,102,2756,727,5887,2566,7922,44,5986,621,1202,374,6988,4130,3627,6744,9443,4568,1398,8679,397,3928,9159,367,2917,6127,5788,3304,8129,911,2669,1463,9749,264,4478,8940,1109,7309,2462,117,4692,7724,225,2312
4164,3637,2000,941,8903,39,3443,7172,1031,3687,4901,8082,4945,4515,7204,9310,9349,9535,9940,218,1788,9245,2237,1541,5670,6538,6047,5553,9807,8101,1925,8714,445,8332,7309,6830,5786,5736,7306,2710,3034,1838,7969,6318,7912,2584,2080,7437,6705,2254,7428,820,782,9861,7596,3842,3631,8063,5240,6666,394,4565,7865,4895,9890,6028,6117,4724,9156,4473,4552,602,470,6191,4927,5387,884,3146,1978,3000
4258,6880,1696,3582,5793,4923,2119,1155,9056,9698,6603,3768,5514,9927,9609,6166,6566,4536,4985,4934,8076,9062,6741,6163,7399,4562,2337,5600,2919,9012,8459,1308,6072,1225,9306,8818,5886,7243,7365,8792,6007,9256,6699,7171,4230,7002,8720,7839,4533,1671,478,7774,1607,2317,5437,4705,7886,4760,6760,7271,3081,2997,3088,7675,6208,3101,6821,6840,122,9633,4900,2067,8546,4549,2091,7188,5605,8599,6758,5229
7854,5243,9155,3556,8812,7047,2202,1541,5993,4600,4760,713,434,7911,7426,7414,8729,322,803,7960,7563,4908,6285,6291,736,3389,9339,4132,8701,7534,5287,3646,592,3065,7582,2592,8755,6068,8597,1982,5782,1894,2900,6236,4039,6569,3037,5837,7698,700,7815,2491,7272,5878,3083,6778,6639,3589,5010,8313,2581,6617,5869,8402,6808,2951,2321,5195,497,2190,6187,1342,1316,4453,7740,4154,2959,1781,1482,8256
7178,2046,4419,744,8312,5356,6855,8839,319,2962,5662,47,6307,8662,68,4813,567,2712,9931,1678,3101,8227,6533,4933,6656,92,5846,4780,6256,6361,4323,9985,1231,2175,7178,3034,9744,6155,9165,7787,5836,9318,7860,9644,8941,6480,9443,8188,5928,161,6979,2352,5628,6991,1198,8067,5867,6620,3778,8426,2994,3122,3124,6335,3918,8897,2655,9670,634,1088,1576,8935,7255,474,8166,7417,9547,2886,5560,3842
6957,3111,26,7530,7143,1295,1744,6057,3009,1854,8098,5405,2234,4874,9447,2620,9303,27,7410,969,40,2966,5648,7596,8637,4238,3143,3679,7187,690,9980,7085,7714,9373,5632,7526,6707,3951,9734,4216,2146,3602,5371,6029,3039,4433,4855,4151,1449,3376,8009,7240,7027,4602,2947,9081,4045,8424,9352,8742,923,2705,4266,3232,2264,6761,363,2651,3383,7770,6730,7856,7340,9679,2158,610,4471,4608,910,6241
4417,6756,1013,8797,658,8809,5032,8703,7541,846,3357,2920,9817,1745,9980,7593,4667,3087,779,3218,6233,5568,4296,2289,2654,7898,5021,9461,5593,8214,9173,4203,2271,7980,2983,5952,9992,8399,3468,1776,3188,9314,1720,6523,2933,621,8685,5483,8986,6163,3444,9539,4320,155,3992,2828,2150,6071,524,2895,5468,8063,1210,3348,9071,4862,483,9017,4097,6186,9815,3610,5048,1644,1003,9865,9332,2145,1944,2213
9284,3803,4920,1927,6706,4344,7383,4786,9890,2010,5228,1224,3158,6967,8580,8990,8883,5213,76,8306,2031,4980,5639,9519,7184,5645,7769,3259,8077,9130,1317,3096,9624,3818,1770,695,2454,947,6029,3474,9938,3527,5696,4760,7724,7738,2848,6442,5767,6845,8323,4131,2859,7595,2500,4815,3660,9130,8580,7016,8231,4391,8369,3444,4069,4021,556,6154,627,2778,1496,4206,6356,8434,8491,3816,8231,3190,5575,1015
3787,7572,1788,6803,5641,6844,1961,4811,8535,9914,9999,1450,8857,738,4662,8569,6679,2225,7839,8618,286,2648,5342,2294,3205,4546,176,8705,3741,6134,8324,8021,7004,5205,7032,6637,9442,5539,5584,4819,5874,5807,8589,6871,9016,983,1758,3786,1519,6241,185,8398,495,3370,9133,3051,4549,9674,7311,9738,3316,9383,2658,2776,9481,7558,619,3943,3324,6491,4933,153,9738,4623,912,3595,7771,7939,1219,4405
2650,3883,4154,5809,315,7756,4430,1788,4451,1631,6461,7230,6017,5751,138,588,5282,2442,9110,9035,6349,2515,1570,6122,4192,4174,3530,1933,4186,4420,4609,5739,4135,2963,6308,1161,8809,8619,2796,3819,6971,8228,4188,1492,909,8048,2328,6772,8467,7671,9068,2226,7579,6422,7056,8042,3296,2272,3006,2196,7320,3238,3490,3102,37,1293,3212,4767,5041,8773,5794,4456,6174,7279,7054,2835,7053,9088,790,6640
3101,1057,7057,3826,6077,1025,2955,1224,1114,6729,5902,4698,6239,7203,9423,1804,4417,6686,1426,6941,8071,1029,4985,9010,6122,6597,1622,1574,3513,1684,7086,5505,3244,411,9638,4150,907,9135,829,981,1707,5359,8781,9751,5,9131,3973,7159,1340,6955,7514,7993,6964,8198,1933,2797,877,3993,4453,8020,9349,8646,2779,8679,2961,3547,3374,3510,1129,3568,2241,2625,9138,5974,8206,7669,7678,1833,8700,4480
4865,9912,8038,8238,782,3095,8199,1127,4501,7280,2112,2487,3626,2790,9432,1475,6312,8277,4827,2218,5806,7132,8752,1468,7471,6386,739,8762,8323,8120,5169,9078,9058,3370,9560,7987,8585,8531,5347,9312,1058,4271,1159,5286,5404,6925,8606,9204,7361,2415,560,586,4002,2644,1927,2824,768,4409,2942,3345,1002,808,4941,6267,7979,5140,8643,7553,9438,7320,4938,2666,4609,2778,8158,6730,3748,3867,1866,7181
171,3771,7134,8927,4778,2913,3326,2004,3089,7853,1378,1729,4777,2706,9578,1360,5693,3036,1851,7248,2403,2273,8536,6501,9216,613,9671,7131,7719,6425,773,717,8803,160,1114,7554,7197,753,4513,4322,8499,4533,2609,4226,8710,6627,644,9666,6260,4870,5744,7385,6542,6203,7703,6130,8944,5589,2262,6803,6381,7414,6888,5123,7320,9392,9061,6780,322,8975,7050,5089,1061,2260,3199,1150,1865,5386,9699,6501
3744,8454,6885,8277,919,1923,4001,6864,7854,5519,2491,6057,8794,9645,1776,5714,9786,9281,7538,6916,3215,395,2501,9618,4835,8846,9708,2813,3303,1794,8309,7176,2206,1602,1838,236,4593,2245,8993,4017,10,8215,6921,5206,4023,5932,6997,7801,262,7640,3107,8275,4938,7822,2425,3223,3886,2105,8700,9526,2088,8662,8034,7004,5710,2124,7164,3574,6630,9980,4242,2901,9471,1491,2117,4562,1130,9086,4117,6698
2810,2280,2331,1170,4554,4071,8387,1215,2274,9848,6738,1604,7281,8805,439,1298,8318,7834,9426,8603,6092,7944,1309,8828,303,3157,4638,4439,9175,1921,4695,7716,1494,1015,1772,5913,1127,1952,1950,8905,4064,9890,385,9357,7945,5035,7082,5369,4093,6546,5187,5637,2041,8946,1758,7111,6566,1027,1049,5148,7224,7248,296,6169,375,1656,7993,2816,3717,4279,4675,1609,3317,42,6201,3100,3144,163,9530,4531
7096,6070,1009,4988,3538,5801,7149,3063,2324,2912,7911,7002,4338,7880,2481,7368,3516,2016,7556,2193,1388,3865,8125,4637,4096,8114,750,3144,1938,7002,9343,4095,1392,4220,3455,6969,9647,1321,9048,1996,1640,6626,1788,314,9578,6630,2813,6626,4981,9908,7024,4355,3201,3521,3864,3303,464,1923,595,9801,3391,8366,8084,9374,1041,8807,9085,1892,9431,8317,9016,9221,8574,9981,9240,5395,2009,6310,2854,9255
8830,3145,2960,9615,8220,6061,3452,2918,6481,9278,2297,3385,6565,7066,7316,5682,107,7646,4466,68,1952,9603,8615,54,7191,791,6833,2560,693,9733,4168,570,9127,9537,1925,8287,5508,4297,8452,8795,6213,7994,2420,4208,524,5915,8602,8330,2651,8547,6156,1812,6271,7991,9407,9804,1553,6866,1128,2119,4691,9711,8315,5879,9935,6900,482,682,4126,1041,428,6247,3720,5882,7526,2582,4327,7725,3503,2631
2738,9323,721,7434,1453,6294,2957,3786,5722,6019,8685,4386,3066,9057,6860,499,5315,3045,5194,7111,3137,9104,941,586,3066,755,4177,8819,7040,5309,3583,3897,4428,7788,4721,7249,6559,7324,825,7311,3760,6064,6070,9672,4882,584,1365,9739,9331,5783,2624,7889,1604,1303,1555,7125,8312,425,8936,3233,7724,1480,403,7440,1784,1754,4721,1569,652,3893,4574,5692,9730,4813,9844,8291,9199,7101,3391,8914
6044,2928,9332,3328,8588,447,3830,1176,3523,2705,8365,6136,5442,9049,5526,8575,8869,9031,7280,706,2794,8814,5767,4241,7696,78,6570,556,5083,1426,4502,3336,9518,2292,1885,3740,3153,9348,9331,8051,2759,5407,9028,7840,9255,831,515,2612,9747,7435,8964,4971,2048,4900,5967,8271,1719,9670,2810,6777,1594,6367,6259,8316,3815,1689,6840,9437,4361,822,9619,3065,83,6344,7486,8657,8228,9635,6932,4864
8478,4777,6334,4678,7476,4963,6735,3096,5860,1405,5127,7269,7793,4738,227,9168,2996,8928,765,733,1276,7677,6258,1528,9558,3329,302,8901,1422,8277,6340,645,9125,8869,5952,141,8141,1816,9635,4025,4184,3093,83,2344,2747,9352,7966,1206,1126,1826,218,7939,2957,2729,810,8752,5247,4174,4038,8884,7899,9567,301,5265,5752,7524,4381,1669,3106,8270,6228,6373,754,2547,4240,2313,5514,3022,1040,9738
2265,8192,1763,1369,8469,8789,4836,52,1212,6690,5257,8918,6723,6319,378,4039,2421,8555,8184,9577,1432,7139,8078,5452,9628,7579,4161,7490,5159,8559,1011,81,478,5840,1964,1334,6875,8670,9900,739,1514,8692,522,9316,6955,1345,8132,2277,3193,9773,3923,4177,2183,1236,6747,6575,4874,6003,6409,8187,745,8776,9440,7543,9825,2582,7381,8147,7236,5185,7564,6125,218,7991,6394,391,7659,7456,5128,5294
2132,8992,8160,5782,4420,3371,3798,5054,552,5631,7546,4716,1332,6486,7892,7441,4370,6231,4579,2121,8615,1145,9391,1524,1385,2400,9437,2454,7896,7467,2928,8400,3299,4025,7458,4703,7206,6358,792,6200,725,4275,4136,7390,5984,4502,7929,5085,8176,4600,119,3568,76,9363,6943,2248,9077,9731,6213,5817,6729,4190,3092,6910,759,2682,8380,1254,9604,3011,9291,5329,9453,9746,2739,6522,3765,5634,1113,5789
5304,5499,564,2801,679,2653,1783,3608,7359,7797,3284,796,3222,437,7185,6135,8571,2778,7488,5746,678,6140,861,7750,803,9859,9918,2425,3734,2698,9005,4864,9818,6743,2475,132,9486,3825,5472,919,292,4411,7213,7699,6435,9019,6769,1388,802,2124,1345,8493,9487,8558,7061,8777,8833,2427,2238,5409,4957,8503,3171,7622,5779,6145,2417,5873,5563,5693,9574,9491,1937,7384,4563,6842,5432,2751,3406,7981
+9
View File
@@ -0,0 +1,9 @@
for ($a = 1; $a -lt 1000; $a++) {
for ($b = $a + 1; $b -lt 1000; $b++) {
$c = [math]::sqrt($a * $a + $b * $b)
if ($c -eq [math]::floor($c) -and $a + $b + $c -eq 1000) {
$a, $b, $c
}
}
}
+22
View File
@@ -0,0 +1,22 @@
module _92
open common
let squareChainLoop =
let squareDigits d =
let square n = n * n
d |> numDigits |> Seq.map square |> Seq.sum
let chainDict = new System.Collections.Generic.Dictionary<int,int>()
let rec chainCache = function
| x when chainDict.ContainsKey(x) -> chainDict.[x]
| 1 -> 1
| 89 -> 89
| x -> chainDict.[x] <- chainCache (squareDigits x); chainDict.[x]
allIntegers |> Seq.skip 1 |> Seq.takeWhile ((>) 10000000)
|> Seq.map chainCache
|> Seq.filter ((=) 89)
|> Seq.length
+12
View File
@@ -0,0 +1,12 @@
module _97
open System.Numerics
let multiplyLastDigitsFun d =
let l = System.Math.Pow(10.0,float(d))
fun (n, m) -> (n * m) % l
let bigPrime =
let f = multiplyLastDigitsFun 10
let p = [1..7830457] |> Seq.fold (fun s i -> f(s,2.0)) 1.0
(28433.0,p) |> f |> (+) 1.0
+90
View File
@@ -0,0 +1,90 @@
module _98
open System.IO
open common
let anagramSquares =
let words =
File.ReadAllLines(@"98_words.txt")
|> Array.collect (fun line -> line.Split(','))
|> Array.map (fun w -> w.Replace("\"", "").ToLower())
let groupAnagrams =
let concatCharArray (cs:char array) = new string(cs)
// sort by characters in each string and then glue them back together
Seq.groupBy (Array.ofSeq >> Array.sort >> (fun cs -> new string(cs)))
>> Seq.map snd
>> Seq.filter (fun l -> Seq.length l > 1)
>> Seq.map Array.ofSeq
let pairwiseTuples =
Seq.collect (
combinations 2
>> Seq.map (fun l -> l.[0], l.[1])
)
let wordAnagrams =
words
|> groupAnagrams
|> pairwiseTuples
let squares =
allSquares
|> Seq.takeWhile (digitCount >> ((>) 10))
|> Seq.groupBy digitCount
|> Seq.map (fun (dc,sqs) -> (dc, sqs |> Seq.map string |> Array.ofSeq))
|> Map.ofSeq
let hasReplacementDictionary (s1, s2) (t1, t2) =
let rec hasReplacementDictionary (sToT, tToS) (source, target) =
match source, target with
// have already seen this exact mapping -> skip it
| s::ss, t::tt when Map.containsKey s sToT && (Map.find s sToT) = t
-> hasReplacementDictionary (sToT, tToS) (ss, tt)
// have a mapping for the source, but it's not the target -> failure
| s::_, _ when Map.containsKey s sToT
-> false
// have a mapping for the target, but it's not the source -> failure
| _::_, t::_ when Map.containsKey t tToS
-> false
// never before seen mapping -> add it
| s::ss, t::tt
-> hasReplacementDictionary (Map.add s t sToT, Map.add t s tToS) (ss, tt)
// end of the line - a successful translation!
| [], [] -> true
| _ -> raise(System.ArgumentException("words not equal length"))
let los = List.ofSeq
let s = List.append (los s1) (los s2)
let t = List.append (los t1) (los t2)
hasReplacementDictionary (Map.empty, Map.empty) (s, t)
let tupleSeqAddReverse =
Seq.collect (fun (i,j) -> seq {yield (i,j); yield (j,i)})
let squareAnagrams =
squares
|> Map.map (fun _ s ->
s
|> groupAnagrams
|> pairwiseTuples
|> tupleSeqAddReverse
)
wordAnagrams
|> Seq.collect (fun wordAnagram ->
let wordLen = wordAnagram |> fst |> String.length
Map.find wordLen squareAnagrams
|> Seq.collect (fun squareAnagram ->
seq {
if hasReplacementDictionary wordAnagram squareAnagram then
yield (wordAnagram, squareAnagram)
}
)
)
|> Seq.toArray
|> Seq.map (fun (_,(i,j)) -> System.Math.Max(int i,int j))
|> Seq.max
+1
View File
File diff suppressed because one or more lines are too long
+14
View File
@@ -0,0 +1,14 @@
module _99
open System.IO
let biggestNum =
let baseExp =
File.ReadAllLines(@"99_base_exp.txt")
|> Array.map (fun line -> line.Split(',') |> Array.map float |> (fun a -> (a.[0], a.[1])))
baseExp
|> Array.mapi (fun i (b,e) -> (i + 1, e * System.Math.Log10(b)))
|> Array.sortBy snd |> Array.rev
+1000
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
module Fraction
open common
let reduce (n,d) =
let g = gcd(n,d)
(n/g,d/g)
let mul (n1,d1) (n2,d2) =
(n1 * n2, d1 * d2)
let reciprocal (n,d) = (d,n)
let add (n1,d1) (n2,d2) =
let f = (n1*d2 + n2*d1, d2*d1)
reduce f
let reduceI (n:bigint,d:bigint) =
let g = gcdI(n,d)
(n/g,d/g)
let mulI (n1:bigint,d1:bigint) (n2:bigint,d2:bigint) =
reduceI (n1 * n2, d1 * d2)
let reciprocalI (n:bigint,d:bigint) = (d,n)
let addI (n1:bigint,d1:bigint) (n2,d2) =
let f = (n1*d2 + n2*d1, d2*d1)
f
//reduceI f
+2
View File
@@ -0,0 +1,2 @@
$assemblyName = gci .\Oyster.IntX.dll | % {$_.FullName }
[System.Reflection.Assembly]::LoadFile($assemblyName)
BIN
View File
Binary file not shown.
+232
View File
@@ -0,0 +1,232 @@
module common
let allIntegers = Seq.unfold(fun i -> Some(i, i + 1)) 0
let allSquares = Seq.unfold(fun (square,odd) -> Some(square, (square+odd, odd+2))) (0,1)
let multiples n =
let rec m ns =
seq {
yield ns
yield! m (ns + n)
}
m n
let divisorsWithRule rule len =
let d = Array.create (len + 1) [] // stores the divisors for each number by index
seq {1..len} |> Seq.iter (fun i ->
seq { i .. i .. len } |> Seq.iter ( fun j ->
if rule i j then d.[j] <- i :: d.[j]
)
)
d
let divisors = divisorsWithRule (<>)
let divisorsInclSelf = divisorsWithRule (fun _ _ -> true)
let rec gcd(a,b) =
if b > a then gcd (b,a) else
match b with
| 0 -> a
| b -> gcd (b, a%b)
let rec gcdI(a:bigint,b:bigint) =
if b > a then gcdI (b,a) else
match b with
| b when b = 0I -> a
| b -> gcdI (b, a%b)
let primeArray max =
let d = Array.init (max + 1) (fun i -> i)
seq {2..(max/2)} |> Seq.iter (fun i ->
seq { 0 .. i .. max } |> Seq.iter ( fun j ->
if i <> j && j <> 0 then d.[j] <- -1
)
)
d |> Array.filter ((<) 1)
let isPrimeFunByArray primes =
let primeLookup =
primes |> Array.map (fun p -> (p, true)) |> dict
(fun n -> primeLookup.ContainsKey(n))
let isPrimeFunByMax max =
primeArray max |> isPrimeFunByArray
let isPrimeI n =
if n < 2I then false
else
let limit = float n |> sqrt |> fun x -> x + 1. |> (fun n -> bigint n)
let rec loop d =
match d with
| limit -> true
| d when n % d = 0I -> false
| _ -> loop (d + 1I)
loop 2I
let compositeArray max =
let primes = primeArray max
primes
|> Seq.pairwise
|> Seq.collect (fun (p1, p2) ->
seq { (p1+1) .. (p2 - 1) }
)
let coprimeArray len =
let c = Array.create (len + 1) []
let d = divisors len
d.[1] <- [1]
let set1 = Set [1]
for i in 2 .. len do
let dis = Set d.[i]
for j in 1 .. (i - 1) do
//if not (Set.contains j dis) then
let djs = Set d.[j]
if Set.intersect dis djs = set1 then
c.[i] <- j :: c.[i]
c
let crossMapList l1 l2 =
seq { for el1 in l1 do
for el2 in l2 do
yield (el1, el2) }
let crossSelfMapList l =
crossMapList l l
let crossMap f l1 l2 =
crossMapList l1 l2 |> Seq.map (fun (el1, el2) -> f el1 el2)
let crossSelfMap f l =
crossMap f l l
let rec permutations set =
seq {
if Set.empty = set then yield [] else
for s in set do
let remaining = set |> Set.remove s
for perm in (permutations remaining) do
yield s :: perm
}
let rec slottedPermutations slots =
seq {
if List.empty = slots then yield [] else
let set = List.head slots
for s in set do
for perm in (slottedPermutations (List.tail slots)) do
yield s :: perm
}
let combinations size set =
let rec combinations acc size set = seq {
match size, set with
| n, x::xs ->
if n > 0 then yield! combinations (x::acc) (n - 1) xs
if n >= 0 then yield! combinations acc n xs
| 0, [] -> yield acc
| _, [] -> () }
combinations [] size (set |> List.ofSeq)
let fibinoci =
let rec f (c, p) =
seq {
yield c
yield! f (c + p, c)
}
f (1I,0I)
let digitCount n =
int (System.Math.Floor(System.Math.Log10 (float n)) + 1.0)
let mapChars f n =
(string n).ToCharArray()
|> Array.map f
let joinStrings =
Array.map string
>> Array.fold (fun acc i -> i + acc) ""
let numDigits =
mapChars (string >> int)
let digitsNum (ds:int[]) =
ds
|> joinStrings
|> int
let lastDigits d n =
let s = string n
s.Substring(s.Length - d)
let rec factorial n =
match n with
| 0
| 1 -> 1
| _ -> n * factorial (n - 1)
let rec factorialI n =
match n with
| n when n = 0I -> 1I
| n when n = 1I -> 1I
| _ -> n * factorialI (n - 1I)
let takeIndexes ns input =
// Take only elements that we need to access (sequence could be infinite)
let arr = input |> Seq.take (1 + Seq.max ns) |> Array.ofSeq
// Simply pick elements at the specified indices from the array
seq { for index in ns -> arr.[index] }
let arrayToRevSeq a =
let len = (Array.length a) - 1
seq {
for i in len .. -1 .. 0 do
yield a.[i]
}
let array2DFromNested a =
Array2D.init (Array.length a) (Array.length a.[0]) (fun i j -> a.[i].[j])
let strSplit t (str:string) = str.Split(',') |> Array.map t
let strSplitInt = strSplit int
let strSplitFloat = strSplit float
let isPanDigitalD digits =
let len = Seq.length digits
let range = Seq.forall (fun d -> d <= len && d > 0) digits
let unique = Set.count (Set digits) = len
range && unique
let isPanDigital n =
isPanDigitalD (numDigits n)
let isPanDigitalGroup s =
Seq.collect numDigits s |> isPanDigitalD
let letterValue (c:char) =
int c - 64
let wordValue (w:string) =
w.ToUpper()
|> Seq.map letterValue
|> Seq.sum
let floatWrap f n =
let n = float n
f n |> int64 |> (fun n -> bigint n)
let triangleNumber n =
n |> floatWrap (fun n -> n / 2.0 * (n + 1.0))
let pentagonalNumber n =
n |> floatWrap (fun n -> n / 2.0 * (3.0 * n - 1.0))
let hexagonalNumber n =
n |> floatWrap (fun n -> n * (2.0 * n - 1.0))
let revString s =
new string (s |> Seq.toArray |> Array.rev)
let isPalindrome s =
s = revString s
File diff suppressed because it is too large Load Diff
+1219
View File
File diff suppressed because it is too large Load Diff
+64
View File
@@ -0,0 +1,64 @@
module millerRabinPrimality
// [snippet: Miller-Rabin primality test]
open System.Numerics
///See: http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
let millerRabinPrimality n a =
///This implementation is based on the Miller-Rabin Haskell implementation
///from http://www.haskell.org/haskellwiki/Testing_primality
let pow' mul sq x' n' =
let rec f x n y =
if n = 1I then
mul x y
else
let (q,r) = BigInteger.DivRem(n, 2I)
let x2 = sq x
if r = 0I then
f x2 q y
else
f x2 q (mul x y)
f x' n' 1I
let mulMod (a :bigint) b c = (b * c) % a
let squareMod (a :bigint) b = (b * b) % a
let powMod m = pow' (mulMod m) (squareMod m)
let iterate f = Seq.unfold(fun x -> let fx = f x in Some(x,fx))
let find2km n =
let rec f k m =
let (q,r) = BigInteger.DivRem(m, 2I)
if r = 1I then
(k,m)
else
f (k+1I) q
f 0I n
let n' = n - 1I
let iter = Seq.tryPick(fun x -> if x = 1I then Some(false) elif x = n' then Some(true) else None)
let (k,m) = find2km n'
let b0 = powMod n a m
match (a,n) with
| _ when a <= 1I && a >= n' ->
failwith (sprintf "millerRabinPrimality: a out of range (%A for %A)" a n)
| _ when b0 = 1I || b0 = n' -> true
| _ -> b0
|> iterate (squareMod n)
|> Seq.take(int k)
|> Seq.skip 1
|> iter
|> Option.exists id
///For Miller-Rabin the witnesses need to be selected at random from the interval [2, n - 2].
///More witnesses => better accuracy of the test.
///Also, remember that if Miller-Rabin returns true, then the number is _probable_ prime.
///If it returns false the number is composite.
let isPrimeW witnesses n =
match n with
| n when n < 2I -> false
| n when n = 2I -> true
| n when n = 3I -> true
| n when n % 2I = 0I -> false
| n -> witnesses |> Seq.forall(millerRabinPrimality n)
+32
View File
@@ -0,0 +1,32 @@
module npr_sundaypuzzle_20120422
open common
open System.IO
open System.Text.RegularExpressions
let puzzle =
let loadNames fn =
File.ReadAllLines(fn)
|> Seq.map (fun l -> Regex.Replace(l, "(\w+).*", "$1").ToLower() )
|> Seq.filter (fun n -> n.Length = 4)
let maleNames =
loadNames @"dist.male.first.txt"
let femaleNames =
loadNames @"dist.female.first.txt"
let rotateChar (c:char) =
c |> int |> (fun n -> (n + 13 - 97) % 26 + 97) |> char
let rotateName name =
name
|> mapChars rotateChar
|> Array.map string
|> Array.fold (fun acc i -> acc + i) ""
maleNames
|> Seq.map (fun n -> (n, rotateName n))
|> Seq.filter (fun (_,mn) -> Seq.exists ((=) mn) femaleNames)
|> Seq.toArray
+87
View File
@@ -0,0 +1,87 @@
module program
open System
open System.Windows.Forms
[<EntryPoint>]
let main args =
let sprintfA f = sprintf "%A" f
let funize f = fun () -> f
let myFunc () =
printfn "Evaluating myFunc"
"myFunc Result"
let sprintfFunc f = fun () -> sprintf "%A" f
let r = sprintfFunc myFunc
printfn "%s" (r())
let problems = [
11, fun () -> sprintfA _11.maxProduct;
12, fun () -> sprintfA _12.fiveDivisorTriangle;
13, fun () -> sprintfA _13.getSum;
14, fun () -> sprintfA _14.getLongestChain;
17, fun () -> sprintfA _17.getNumberWords;
18, fun () -> sprintfA _18.getTriangleMaxTotal;
19, fun () -> sprintfA _19.firstSaturdays;
20, fun () -> sprintfA _20.getSum;
21, fun () -> sprintfA _21.amicalbleSum;
22, fun () -> sprintfA _22.nameScores;
23, fun () -> sprintfA _23.sumNotAbundant;
24, fun () -> sprintfA _24.run;
25, fun () -> sprintfA _25.find1000;
26, fun () -> sprintfA _26.longestRecurringCycle;
27, fun () -> sprintfA _27.quadraticConsecutivePrimes;
28, fun () -> sprintfA _28.sumNum;
29, fun () -> sprintfA _29.getDistinctTerms;
30, fun () -> sprintfA _30.sumOfSumOfFifthNumbers;
31, fun () -> sprintfA _31.getCurrencyCombos;
32, fun () -> sprintfA _32.panDigitalProduct;
33, fun () -> sprintfA _33.cancelling;
34, fun () -> sprintfA _34.numSumDigitFactorials;
35, fun () -> sprintfA _35.circularPrime;
36, fun () -> sprintfA _36.palindromicBase10and2Sum;
37, fun () -> sprintfA _37.truncatablePrimes;
39, fun () -> sprintfA _39.rightTriPerimeter;
40, fun () -> sprintfA _40.positiveIntegerConcat;
41, fun () -> sprintfA _41.panDigital;
42, fun () -> sprintfA _42.triangleWords;
43, fun () -> sprintfA _43.pandigitalDivisible;
45, fun () -> sprintfA _45.triPentHex;
46, fun () -> sprintfA _46.smallestOddCompositeNotSumOfPrimeTwiceSquare;
47, fun () -> sprintfA _47.consequtivePrimes;
48, fun () -> sprintfA _48.seriesEnd;
49, fun () -> sprintfA _49.primeSequence;
50, fun () -> sprintfA _50.sumOfConsequitivePrimes;
52, fun () -> sprintfA _52.findSameDigits;
53, fun () -> sprintfA _53.combinationGt1M;
54, fun () -> sprintfA _54.pokerWinner;
55, fun () -> sprintfA _55.lynchrels;
56, fun () -> sprintfA _56.exponentialDigitSum;
57, fun () -> sprintfA _57.sqrtTwoDigits;
58, fun () -> sprintfA _58.primeDiagonals;
59, fun () -> sprintfA _59.cypher;
63, fun () -> sprintfA _63.powerDigits;
69, fun () -> sprintfA _69.relativePrimeFunc;
79, fun () -> sprintfA _79.findPasscode;
81, fun () -> sprintfA _81.shortestDistance;
92, fun () -> sprintfA _92.squareChainLoop;
97, fun () -> sprintfA _97.bigPrime;
98, fun () -> sprintfA _98.anagramSquares;
99, fun () -> sprintfA _99.biggestNum;
101, fun () -> sprintfA _101.sumOfFITsOfBOPs;
112, fun () -> sprintfA _112.bouncy90;
]
let problemDict = dict problems
let sw = new System.Diagnostics.Stopwatch()
printfn "starting"
sw.Start()
let result = problemDict.[43]()
sw.Stop()
printfn "%s" result
printfn "done in %A" sw.Elapsed
//Clipboard.SetText(result)
Console.ReadKey() |> ignore
0
+161
View File
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{afd5b730-9ec9-4ef7-8ddb-95b36a0d1317}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>projecteuler</RootNamespace>
<AssemblyName>projecteuler</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<Name>projecteuler</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\projecteuler.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\projecteuler.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets'))" />
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (!Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets'))" />
<ItemGroup>
<Compile Include="common.fs" />
<Compile Include="millerRabinPrimality.fs" />
<Compile Include="Fraction.fs" />
<Compile Include="11.fs" />
<Content Include="11.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="12.fs" />
<Compile Include="13.fs" />
<Content Include="13.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="14.fs" />
<Compile Include="17.fs" />
<Compile Include="18.fs" />
<Content Include="18.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="18_67.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="19_saturdays.fs" />
<Compile Include="20.fs" />
<Compile Include="21.fs" />
<Compile Include="22.fs" />
<Content Include="22_names.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="23.fs" />
<Compile Include="24.fs" />
<Compile Include="25.fs" />
<Compile Include="26.fs" />
<Compile Include="27.fs" />
<Compile Include="28.fs" />
<Compile Include="29.fs" />
<Compile Include="30.fs" />
<Compile Include="31.fs" />
<Compile Include="32.fs" />
<Compile Include="33_cancelling.fs" />
<Compile Include="34.fs" />
<Compile Include="35.fs" />
<Compile Include="36.fs" />
<Compile Include="37.fs" />
<Compile Include="39.fs" />
<Compile Include="40.fs" />
<Compile Include="41.fs" />
<Compile Include="42.fs" />
<Content Include="42_words.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="43.fs" />
<Compile Include="45.fs" />
<Compile Include="46.fs" />
<Compile Include="47.fs" />
<Compile Include="48.fs" />
<Compile Include="49.fs" />
<Compile Include="50.fs" />
<Compile Include="52.fs" />
<Compile Include="53.fs" />
<Compile Include="54.fs" />
<Content Include="54_poker.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="55.fs" />
<Compile Include="56.fs" />
<Compile Include="57.fs" />
<Compile Include="58.fs" />
<Compile Include="59.fs" />
<Content Include="59_cipher1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="69.fs" />
<Compile Include="63_power_digits.fs" />
<Compile Include="79.fs" />
<Content Include="79_keylog.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="81.fs" />
<Content Include="81_matrix.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="92.fs" />
<Compile Include="97.fs" />
<Compile Include="98.fs" />
<Content Include="98_words.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="99.fs" />
<Content Include="99_base_exp.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="101.fs" />
<Compile Include="112.fs" />
<Compile Include="npr_sundaypuzzle_20120422.fs" />
<Content Include="dist.female.first.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dist.male.first.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="program.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "projecteuler", "projecteuler.fsproj", "{AFD5B730-9EC9-4EF7-8DDB-95B36A0D1317}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFD5B730-9EC9-4EF7-8DDB-95B36A0D1317}.Debug|x86.ActiveCfg = Debug|x86
{AFD5B730-9EC9-4EF7-8DDB-95B36A0D1317}.Debug|x86.Build.0 = Debug|x86
{AFD5B730-9EC9-4EF7-8DDB-95B36A0D1317}.Release|x86.ActiveCfg = Release|x86
{AFD5B730-9EC9-4EF7-8DDB-95B36A0D1317}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal