From 4695115dadd6ff5c167e1ff2fd5cd04aad81fcb6 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Fri, 8 Dec 2017 06:53:13 +0100 Subject: [PATCH] More concise --- AdventOfCode2017/Day8.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AdventOfCode2017/Day8.fs b/AdventOfCode2017/Day8.fs index 04ec413..fcdda30 100644 --- a/AdventOfCode2017/Day8.fs +++ b/AdventOfCode2017/Day8.fs @@ -21,8 +21,7 @@ let execute (input : Instruction list) : int * int = let regCondValue = register |> Map.tryFind regCond |> Option.defaultValue 0 let op' = match op with ">" -> (>) | "<" -> (<) | ">=" -> (>=) | "<=" -> (<=) | "!=" -> (<>) | "==" | _ -> (=) if op' regCondValue valueCond then - let regValue = register |> Map.tryFind reg |> Option.defaultValue 0 - let regValue' = match ins with "inc" -> regValue + value | "dec" -> regValue - value | _ -> regValue + let regValue' = (register |> Map.tryFind reg |> Option.defaultValue 0) + match ins with "inc" -> value | "dec" -> -value | _ -> 0 max highest regValue', register |> Map.add reg regValue' else highest, register -- 2.45.2