Skip to content

Instantly share code, notes, and snippets.

View yasith's full-sized avatar
🐢

Yasith Vidanaarachchi yasith

🐢
  • Google
  • Toronto, Canada
  • 03:41 (UTC -04:00)
View GitHub Profile
#include <iostream>
#include <cmath>
using namespace std;
int findRoot(int num, int root){
int newNum = (int)abs((float)num);
// cout << "Finding root " << root << " for " << newNum << endl;
for(int i = 2; i <= newNum/root; i++){
int val = i;
@yasith
yasith / MyBot.java
Created September 29, 2010 06:47 — forked from anonymous/gai
import java.util.*;
public class MyBot {
// The DoTurn function is where your code goes. The PlanetWars object
// contains the state of the game, including information about all planets
// and fleets that currently exist. Inside this function, you issue orders
// using the pw.IssueOrder() function. For example, to send 10 ships from
// planet 3 to planet 8, you would say pw.IssueOrder(3, 8, 10).
//
// There is already a basic strategy in place here. You can use it as a
#!/bin/bash
for file in example_bots/*.jar
do
player_1_counter=0
player_2_counter=0
echo "Bot: $file"
for i in {1..100}
do
#echo "Map: $i"
RES=`java -jar tools/PlayGame.jar maps/map$i.txt 1000 1000 log.txt "java -jar $file" "./MyBot" 2>&1 | grep ^Player`
@yasith
yasith / threeclr.cpp
Created February 3, 2011 07:16
Threeclr recursive solution SLOW
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdlib>
#include <cstring>
@yasith
yasith / btree.cpp
Created August 12, 2011 12:58
Binary tree implementation in C++
#include <iostream>
#include <cmath>
#define p(x) cout << #x << ":" << x << endl;
#define LIMIT (int)pow(2, 3)
using namespace std;
class Node{
@yasith
yasith / linkedlist.cpp
Created August 13, 2011 06:41
Simple Linked List
#include <string>
#include <iostream>
using namespace std;
class Node{
public:
string s;
int id;
Node *next;
@yasith
yasith / gist:1449920
Created December 9, 2011 02:50
CSC108 Dec. 2009 3
def reverse_linearsearch(v, L):
index = len(L) - 1
while index > -1 and L[index] != v:
index -= 1
return index
def find_all(v, L):
li = [reverse_linearsearch(v, L)]
@yasith
yasith / gist:1508286
Created December 21, 2011 23:58
vimrc
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set ai ts=2 sw=2 nu expandtab
filetype plugin on
filetype indent on
syntax enable
set t_Co=256
set background=dark
@yasith
yasith / gist:1508312
Created December 22, 2011 00:11
solarized fix for .vimrc
set t_Co=256
set background=dark
if !has('gui_running')
let g:solarized_termcolors=&t_Co
let g:solarized_termtrans=1
endif
colorscheme solarized
@yasith
yasith / stars.cpp
Created February 18, 2012 18:40
Stars energy, dp
map<vector<int>, int > dp;
int rec(vector<int> v){
if(dp.find(v) != dp.end()){
return dp[v];
}
if(v.size() == 2){
return 0;
}