Skip to content

Instantly share code, notes, and snippets.

View wreczek's full-sized avatar

Wiktor Reczek wreczek

View GitHub Profile
BOARD = [
[7,8,0,4,0,0,1,2,0],
[6,0,0,0,7,5,0,0,9],
[0,0,0,6,0,1,0,7,8],
[0,0,7,0,4,0,2,6,0],
[0,0,1,0,5,0,9,3,0],
[9,0,4,0,6,0,0,0,5],
[0,7,0,3,0,0,0,1,2],
[1,2,0,0,0,7,4,0,0],
[0,4,9,2,0,6,0,0,7]
@wreczek
wreczek / url_service.py
Created April 16, 2020 20:02
Implementation of the URL website for recruitment interview purposes
#!/usr/bin/env python
"""Server site implementation of the product, where users can
save URLs and retrieve them later."""
__author__ = "Wiktor Reczek"
class UrlService:
"""CRUD service without `update`."""
{-# LANGUAGE RankNTypes #-}
module ChurchNumerals
( church, unchurch, zero, one, two, three, four,
five, six, seven, eight, nine, ten
) where
-- we define natural numbers of Church
type Church a = (a -> a) -> a -> a
-- converting functions
module ChurchBooleans
(true, false, not', and', or', xor', to_boolean) where
-- defining Church values: true and false
true :: t1 -> t -> t1
true= \x y -> x
false :: t -> t1 -> t1
false= \x y -> y
module Calculation
(increment, decrement, add, mul, pow) where
-- arithmetic operations, additionally give us the
-- view of new, undefined numerals
increment :: ((a -> b) -> c -> a) -> (a -> b) -> c -> b
increment = \g f x -> f(g(f)(x))
decrement :: (((r -> b) -> (b -> c) -> c) ->
module Pairs
(first, second,pair) where
--needed for first and second operations, uses true and false
-- from ChurchBooleans
import ChurchBooleans
-- functions that are needed for list operations
first :: ((t1 -> t2 -> t1) -> t) -> t
first = \f -> f(true)
module Calculation
(increment, decrement, add, mul, pow) where
-- arithmetic operations, additionally give us the
-- view of new, undefined numerals
increment :: ((a -> b) -> c -> a) -> (a -> b) -> c -> b
increment = \g f x -> f(g(f)(x))
decrement :: (((r -> b) -> (b -> c) -> c) ->