Skip to content

Instantly share code, notes, and snippets.

@Shekeen
Shekeen / gist:8b70f9ecdfc507e9b238
Created June 11, 2015 15:47
Burrows-Wheeler transform
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
class StringView {
char* begin_;
size_t length_;
public:
@Shekeen
Shekeen / variadic_isoneof.cpp
Last active August 29, 2015 14:15
Variadic template function for comparison with multiple values
#include <iostream>
#include <cstdarg>
//IsOneOf(x, a, b, c) is an equivalent of (x == a || x == b || x == c)
template<typename T>
bool IsOneOf(const T& var, const T& val)
{
return var == val;
}
"""Simple TCP server for playing Tic-Tac-Toe game.
Use Player-to-Player game mode based on naming auth.
No thoughts about distribution or pub/sub mode
(for monitoring or something like this). Just
basic functionality.
"""
import time
import logging
divideIntoParts :: [String] -> String -> [String]
divideIntoParts = divideIntoParts' [] ""
where
divideIntoParts' :: [String] -> String -> [String] -> String -> [String]
divideIntoParts' accList accStr _ "" = reverse ((reverse accStr) : accList)
divideIntoParts' accList accStr patterns str@(l:ls) = let (matched, rest) = matchPatterns patterns str
in
if null matched
then divideIntoParts' accList (l:accStr) patterns ls
else divideIntoParts' (matched : (reverse accStr) : accList) "" patterns rest
primes = [n | n<-[2..], not $ elem n [j*k | j<-[2..n-1], k<-[2..min j (n`div`j)]]]
@Shekeen
Shekeen / gist:4215966
Created December 5, 2012 14:40
Endless labyrint
maze = map (("\\/" !!) . (`mod` 2) . (`mod` 65537)) $ iterate ((+1) . (*0x8088405)) 123
putStrLn maze
@Shekeen
Shekeen / fibs.hs
Created October 19, 2012 15:42
Fibonacci numbers
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)