Skip to content

Instantly share code, notes, and snippets.

View lgastako's full-sized avatar

John lgastako

  • Francon & Heyer
  • Milky Way Galaxy, Third Rock from the Sun
View GitHub Profile
{-# LANGUAGE LambdaCase #-}
module Loupe
( analyze
, analyze'
, analyzeMay
) where
import Language.Haskell.Exts.Parser
import Language.Haskell.Exts.SrcLoc
@lgastako
lgastako / MasterMindCodes.hs
Last active August 5, 2019 16:36
MasterMind codes corrected
module MasterMindCodes where
main :: IO ()
main = writeFile "/tmp/MasterMindCodes.txt"
. unlines
. map (unwords . map show)
$ codes
codes :: [[Int]]
codes = do
module MasterMindCodes where
import Data.List
main :: IO ()
main = writeFile "/tmp/MasterMindCodes.txt"
. unlines
. map (unwords . map show)
$ codes
1
1 2
1 2 3
1 2 3 5
1 2 3 5 4
1 2 3 5 4 7 8 6 9
1 2 3 5 4 7 8 9 6
1 2 3 5 6
1 2 3 5 6 9 8 4 7
module SwipeCodes where
import Data.List
-- [x] Between 5 to 8 "digits"
-- [x] At least 1 horizontal line was filled
-- [x] It spanned all 3 horizontal lines
-- [x] It spanned all 3 vertical
-- [x] It started downward (may have come back up)
-- [x] You can't use the same node twice and
module SwipeCodes where
import Data.List
-- [x] Between 5 to 8 "digits"
-- [x] At least 1 horizontal line was filled
-- [x] It spanned all 3 horizontal lines
-- [x] It spanned all 3 vertical
-- [x] It started downward (may have come back up)
-- [x] You can't use the same node twice and
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Lambda.Parser where
import Viper.Prelude
import Data.Attoparsec.Text
import Data.Eq.Deriving ( deriveEq1 )
property running : False
property checkInterval : 30
on run
tell application "System Events"
if (exists application process "zoom.us") then
running = True
end if
end tell
end run
main = interact $ show . f . map (map read . words) . lines
f :: [[Int]] -> Int
f ([n]:xs:_)
| isArith xs = nthArith n xs
| otherwise = nthGeom n xs
isArith :: [Int] -> Bool
isArith (a:b:c:_) = b - a == c - b
main = interact $ show . f . map read . words
f (n:a:b:c:_)
| b - a == c - b = arith !! n
| otherwise = geo !! n
where
arith = [a, b ..]
geo = if diffsigns || increasing
then a:map (*d) geo
else a:map (`div` e) geo