Skip to content

Instantly share code, notes, and snippets.

View lessandro's full-sized avatar

Lessandro Mariano lessandro

View GitHub Profile
@lessandro
lessandro / dforsyth.gridc
Last active December 11, 2015 01:49
dforsyth's code
// GridC to GridLang compiler
// https://github.com/lessandro/gridc
void cell_resource() { }
void cell_empty() { }
void cell_robot() { }
int NORTH;
int EAST;
int SOUTH;
@lessandro
lessandro / seeker.gridc
Last active December 11, 2015 01:19
GridC bot - resource seeker
// GridC to GridLang compiler
// https://github.com/lessandro/gridc
void eat(dir) {
if (ffi(@LOOK, dir) == @CELL_ROBOT) ffi(@PUNCH, dir);
if (ffi(@LOOK, dir) == @CELL_RESOURCE) ffi(@PULL, dir);
}
void eat_all() {
eat(@NORTH);
@lessandro
lessandro / random.gridlang
Last active December 10, 2015 21:08
GridC bot - walk randomly
CALL << @main
END
@move1
# assign dir
# call rand
PUSH 3
RAND
# call equal
# ["dir"]
@lessandro
lessandro / Promise.java
Created October 11, 2012 19:11
Promises for Android
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import android.os.AsyncTask;
import android.util.Log;
public class Promise<T> {
private List<Callback<T>> callbacks = new ArrayList<Callback<T>>();
class Solver(object):
def __init__(self, coins):
self.coins = coins
self.path = {}
self.memo = {}
def cost(self, cents):
if cents == 0:
return 0
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#define foreach(x, it) for (typeof(x.begin()) it = x.begin(); it != x.end(); ++it)
#define WORD_SIZE 5
using namespace std;
@lessandro
lessandro / dictdb.py
Created July 6, 2012 06:53
dictdb - dict with transactions
class Dictdb:
def __init__(self):
self.db = {}
self.rdb = {}
self.rdiff = []
def rinc(self, val):
if val not in self.rdb:
self.rdb[val] = 0
self.rdb[val] += 1
import Data.Char (ord)
import Data.List (sort, group, intersperse)
import Text.ParserCombinators.Parsec
-- types
type Card = Int
type Suit = Int
type SuitCard = Int
class A
{
private int memberint;
public int someMethod(int memberint)
{
// memberint being shadowed by the parameter
this.memberint = memberint;
}
@lessandro
lessandro / out.txt
Created June 16, 2012 03:23
proggitquiz #12
0
2
7
2
5 8
2 3
1 6
5
4
0