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
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
class StringView { | |
char* begin_; | |
size_t length_; | |
public: |
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
#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; | |
} |
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
"""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 |
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
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 |
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
primes = [n | n<-[2..], not $ elem n [j*k | j<-[2..n-1], k<-[2..min j (n`div`j)]]] |
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
maze = map (("\\/" !!) . (`mod` 2) . (`mod` 65537)) $ iterate ((+1) . (*0x8088405)) 123 | |
putStrLn maze |
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
fibs = 0 : 1 : zipWith (+) fibs (tail fibs) |