This file contains hidden or 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
No red node has a red parent or a red node has only black children. | |
Every path from the root node to an empty node contains the same number of black nodes. | |
The root and leaves of the tree are black. |
This file contains hidden or 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
data Color = R | B deriving Show | |
data Tree a = E | T Color (Tree a) a (Tree a) deriving Show |
This file contains hidden or 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 GADTs, DataKinds #-} | |
module BST where | |
data Nat = Zero | Succ Nat | |
data Tree n a where | |
Branch :: T n a -> Tree (Succ n) a | |
Leaf :: Tree Zero a | |
data T n a = NodeR (Tree n a) a (Tree (Succ n) a) -- right subtree has height + 1 |
This file contains hidden or 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
Timing the performance of various ways of extracting top k elements from a vector: | |
Here sequence size is about 10000 | |
and k=300 | |
Here is a randomly generated vector containing 10K maps. Each of the maps look like this | |
{ | |
:id 123 | |
:data (0 1 2 3 ....) | |
:more-data (0 1 2 3 ....) |
This file contains hidden or 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
settings_table = { | |
{ | |
-- Edit this table to customise your rings. | |
-- You can create more rings simply by adding more elements to settings_table. | |
-- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'. | |
name='time', | |
-- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''. | |
arg='%I.%M', | |
-- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100. | |
max=12, |
This file contains hidden or 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
board = [] | |
board_size = -1 | |
def initiateBoard (board_dimensions): | |
global board | |
global board_size | |
global knights_moves | |
board_size = board_dimensions | |
for i in range(0, board_size): | |
board.append(board_size*[0]) |
NewerOlder