From a1776f40c9fc8ba36472b17ea6ffec15c6af2c78 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Mon, 5 Dec 2022 09:52:42 +0300 Subject: [PATCH] whoopsies! this code crashed on certain datasets before --- 5-a.hs | 2 +- 5-b.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/5-a.hs b/5-a.hs index de6a838..0aa6bc6 100644 --- a/5-a.hs +++ b/5-a.hs @@ -5,7 +5,7 @@ import GHC.Utils.Misc (chunkList) import Data.Char (isSpace, isNumber) rotate2DList :: [[a]] -> [[a]] -rotate2DList l = map (\i -> map (!! i) l) [0 .. length l] +rotate2DList l = map (\i -> map (!! i) l) [0 .. length (head l) - 1] parseState :: String -> [[Char]] parseState = map (dropWhile isSpace) . rotate2DList . map (map (!! 1) . chunkList 4) . init . lines diff --git a/5-b.hs b/5-b.hs index daec73b..b5e73f4 100644 --- a/5-b.hs +++ b/5-b.hs @@ -5,7 +5,7 @@ import GHC.Utils.Misc (chunkList) import Data.Char (isSpace, isNumber) rotate2DList :: [[a]] -> [[a]] -rotate2DList l = map (\i -> map (!! i) l) [0 .. length l] +rotate2DList l = map (\i -> map (!! i) l) [0 .. length (head l) - 1] parseState :: String -> [[Char]] parseState = map (dropWhile isSpace) . rotate2DList . map (map (!! 1) . chunkList 4) . init . lines