21 lines
546 B
FSharp
21 lines
546 B
FSharp
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
|