This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
import qualified Data.Map as M | |
-- Cell | |
data Cell = Cross | Naught | Empty deriving (Eq, Show) | |
to_char Cross = 'X' | |
to_char Naught = 'O' | |
to_char Empty = '.' | |
to_int Cross = 2 |
int[][] data = new int[3][3]; | |
private void aiMove() { | |
Score s = minimax(null, true); | |
data[s.move.x][s.move.y] = COMPUTER; | |
} | |
static class Score { | |
Point move; | |
int score; |
import Data.Map | |
import System.Random | |
group assoc = fromListWith (++) [(k,[v]) | (k,v) <- assoc] | |
mapChooseRandom g = zipWith chooseRandom (randoms g) | |
chooseRandom r list = list !! (r `mod` (length list)) | |
learn str = group $ zip prefices suffices | |
where prefices = zip w (tail w) |
import java.util.*; | |
public class Markov { | |
final static int MAX = 100; | |
public static void main(String[] args) { | |
Map<List<String>,List<String>> map = new HashMap<>(); | |
List<String> prefix = Arrays.asList("", ""); |
package com.company; | |
import retrofit.RestAdapter; | |
import retrofit.http.GET; | |
import retrofit.http.Path; | |
import rx.Observable; | |
import rx.Subscriber; | |
import rx.functions.Action1; | |
import rx.functions.Func1; | |
import rx.functions.Func2; |
class trie { | |
int count; | |
unordered_map<char, trie> children; | |
int& get(const char* s) { | |
if (*s == '\0') { | |
return count; | |
} else { | |
return children[*s].get(s+1); | |
} |
#include <iostream> | |
using namespace std; | |
const char CLOSED = '#'; | |
const char MINE = '*'; | |
const char EMPTY = '-'; | |
const int row = 2; | |
const int col = 6; | |
char input[row][col] = { |
package com.jooyunghan.concurrency; | |
import static java.lang.String.format; | |
import java.util.concurrent.ArrayBlockingQueue; | |
import java.util.concurrent.BlockingQueue; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
class Message { |
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
type Data struct { | |
data string | |
rq1, rq2, rs1, rs2 chan bool |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer