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 | |
import Data.Int | |
import Data.Bits | |
import System.IO | |
type Bitmap = Int64 | |
data Problem = Problem Int {-rows-} Int {-cols-} Bitmap {-board-} [Bitmap] {-tiles-} | |
extract :: [String] -> [Problem] | |
extract ls = |
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
(2,0), (0,0), (0,1) | |
(1,1), (0,3), (0,0), (3,1), (1,2) | |
(3,1), (1,0), (1,2), (2,2), (0,0) | |
(3,1), (0,1), (1,3), (0,2), (2,0) | |
(3,1), (2,3), (1,0), (0,0), (5,1) | |
(3,2), (1,2), (0,2), (1,0), (1,1) | |
(0,1), (0,4), (1,1), (0,0), (2,2) | |
(2,2), (2,1), (1,5), (0,3), (0,2) | |
(3,3), (2,2), (3,1), (0,0), (2,0) | |
(1,1), (2,0), (0,2), (0,4), (2,3) |
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 | |
import Data.Int | |
import Data.Bits | |
import Control.Arrow | |
import System.IO | |
type Bitmap = Int64 | |
data Problem = Problem { | |
rows :: Int, | |
cols :: Int, |
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
(2,0) (0,0) (0,1) | |
(1,1) (0,3) (0,0) (3,1) (1,2) | |
(3,1) (1,0) (1,2) (2,2) (0,0) | |
(3,1) (0,1) (1,3) (0,2) (2,0) | |
(3,1) (2,3) (1,0) (0,0) (5,1) | |
(3,2) (1,2) (0,2) (1,0) (1,1) | |
(0,1) (0,4) (1,1) (0,0) (2,2) | |
(2,2) (2,1) (1,5) (0,3) (0,2) | |
(3,3) (2,2) (3,1) (0,0) (2,0) | |
(1,1) (2,0) (0,2) (0,4) (2,3) |
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
fib = map fib' [0..] where | |
fib' 0 = 0; fib' 1 = 1; fib' n = (fib !! (n-1))+(fib !! (n-2)) |
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
Prelude> let eps = 0.00000001 | |
Prelude> let fix f x_1 x_2 = let f_x = x_1 - (f x_1)*(x_1 - x_2)/((f x_1) - (f x_2)) in if abs (f_x - x_1) < eps then f_x else fix f f_x x_1 | |
Prelude> let root a = fix ((flip (-)) a . flip (^) 3) (a-1) (a+1) | |
Prelude> root 27 | |
3.0 | |
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
class ImplicitString(val c : C[String]) extends AnyVal { | |
def foo(): Unit = Console.println(c.t.toUpperCase()) | |
} | |
class ImplicitInt(val c: C[Int]) extends AnyVal { | |
def foo(): Unit = Console.println(c.t) | |
} |
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
class C[T] | |
object ImplicitString { | |
def foo(): Unit = Console.println("of String") | |
} | |
object ImplicitInt { | |
def foo(): Unit = Console.println("of Int") | |
} |