This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from re import findall | |
def has_digit(s:str) -> bool: | |
return any(c.isdigit() for c in s) | |
def has_upper(s:str) -> bool: | |
return any(c.isupper() for c in s) | |
def has_lower(s:str) -> bool: | |
return any(c.islower() for c in s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- {-# LANGUAGE FlexibleInstances, FlexibleContexts #-} | |
import Data.Monoid | |
data Bool' = True' | False' | |
deriving (Show, Ord, Eq) | |
(and') = (&&) | |
(or') = (||) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-} | |
module JoinList where | |
import Data.Monoid | |
import Control.Applicative | |
-- import qualified Foldable as F | |
import Buffer | |
import Sized | |
import Scrabble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
{-# OPTIONS_GHC -fno-warn-missing-methods #-} | |
module Fibonacci where | |
-- Exercise 1 | |
fib :: Integer -> Integer | |
fib 0 = 0 | |
fib 1 = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} | |
module Calc where | |
import qualified Data.Map as M | |
import ExprT | |
import Parser | |
import qualified StackVM as VM | |
import Data.Maybe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Exercise 1 | |
fun1 :: [Integer] -> Integer | |
fun1 [] = 1 | |
fun1 (x:xs) | |
| even x = (x - 2) * fun1 xs | |
| otherwise = fun1 xs | |
fun1' :: [Integer] -> Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (nub, sort) | |
-- Local Maxima | |
localMaxima :: [Integer] -> [Integer] | |
localMaxima (x:y:z:zs) | |
| y > x && y > z = y : localMaxima (z:zs) | |
| otherwise = localMaxima (y:z:zs) | |
localMaxima _ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Golf where | |
import Data.List | |
import qualified Data.Map.Strict as Map | |
-- Skips | |
everyN :: Int -> [a] -> [a] | |
everyN n xs = case drop (n-1) xs of | |
(y:ys) -> y : (everyN n ys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -Wall #-} | |
module LogAnalysis where | |
import Text.Read (readMaybe) | |
import Log | |
rmInt :: String -> Maybe Int | |
rmInt = readMaybe | |
rmTime :: String -> Maybe TimeStamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Credit Cards | |
toDigitsRev :: Integer -> [Integer] | |
toDigitsRev 0 = [] | |
toDigitsRev n = (n `mod` 10) : toDigitsRev (n `div` 10) | |
toDigits :: Integer -> [Integer] | |
toDigits = reverse . toDigitsRev | |
doubleEveryOther :: [Integer] -> [Integer] |