Skip to content

Instantly share code, notes, and snippets.

@rnelson
Created December 10, 2017 13:49
Show Gist options
  • Save rnelson/e7a93d28c6bbd56653ea2e8de4d98164 to your computer and use it in GitHub Desktop.
Save rnelson/e7a93d28c6bbd56653ea2e8de4d98164 to your computer and use it in GitHub Desktop.
Attempts at AoC 2017 Day 2b
open System
open System.IO
open System.Linq
open System.Text.RegularExpressions
let readInput(filename:string) =
let lines = File.ReadAllLines filename
[|
for l in (lines |> Array.toSeq) do
yield Regex.Split(l, "\s+") |> Array.map int
|]
let evenlyDivide x y =
let values = [|x; y;|]
let a = Array.max values
let b = Array.min values
let ans = a / b
ans
let evenlyDivides x y =
let values = [|x; y;|]
let a = Array.max values
let b = Array.min values
let ans = ((a / b) = 0)
ans
let getDivisibleCount arr =
let values = [|
for row in arr do
//let pairs = Seq.allPairs row
//printfn "%A" pairs
// row
// |> Seq.allPairs
// |> evenlyDivides
//yield pairs
//yield 0
for x in row do
printfn "x: %A" x
for y in row do
printfn "y: %A" y
if x <> y && evenlyDivides(x, y) then
yield evenlyDivide(x, y)
else
yield 0
|]
values
let input = readInput("C:/Users/rnels/Documents/adventofcode/advent2017/inputs/sample02.txt")
printfn "input: %A" input
getDivisibleCount(input) |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment