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
+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"
*)