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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef unsigned char tile_t; | |
typedef struct { | |
// size is the number of tiles between the center of the pile and any of its edges | |
// so, size 0 has one tile, size 1 has 1+8 = 9 tiles, size 2 has 1+8+16=25 tiles, etc. | |
int size; |
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 <stdio.h> | |
#include <stdbool.h> | |
#define MAX_TURNS 12 | |
// true if we've found a way for the game to end by MAX_TURNS | |
// false if not | |
bool play(int turn, int p0, int p1, int p2) { | |
turn++; | |
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
{-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts #-} | |
module Quantum where | |
import Data.Complex | |
import Control.Monad.Random | |
import Control.Lens | |
-- |Dot product of complex vectors | |
dotprod a b = sum (zipWith (*) a (map conjugate b)) |
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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
module MatrixStuff where | |
import Data.List (sortBy, transpose, findIndex, find) | |
import Data.Ord (comparing) | |
import Control.Monad (ap) | |
import Control.Monad.Instances | |
import Data.Ratio | |
import Data.Complex |