-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path25.fs
37 lines (30 loc) · 1011 Bytes
/
25.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
open System
open System.IO
let stopWatch = System.Diagnostics.Stopwatch.StartNew()
let DEBUG = false
let dbg v =
if DEBUG then
printfn "%A" v
v
let lines =
File.ReadAllText(@"input").Trim().Split("\n\n")
|> Array.map (fun x -> x.Split("\n") |> Array.map Array.ofSeq)
let ans1 =
lines
|> Array.partition (fun x -> x[0][0] = '#')
||> (fun a b ->
(a
|> Array.map (fun x ->
[| 0..4 |]
|> Array.map (fun i -> [| 1..6 |] |> Array.takeWhile (fun j -> x[j][i] = '#') |> Array.length)),
b
|> Array.map (fun x ->
[| 0..4 |]
|> Array.map (fun i -> [| 5..-1..0 |] |> Array.takeWhile (fun j -> x[j][i] = '#') |> Array.length))))
||> fun L K ->
Array.allPairs L K
|> Array.Parallel.filter (fun (l, k) -> [| 0..4 |] |> Array.forall (fun i -> l[i] + k[i] < 6))
|> Array.length
stopWatch.Stop()
printfn "%A" ans1
printfn "Time: %fms" stopWatch.Elapsed.TotalMilliseconds