Skip to content

Instantly share code, notes, and snippets.

ListOfAlgorithms = new Algorithm[](initialAlgorithmCoeffcients)
foreach dataset in datasets
foreach algorithm in ListOfAlgorithms
// do a trial on a dataset
algorithm.apply(dataset)
//score how the algorithms did
algorithm.score = ScoringFunction(algorithm.result)
//good algorithms live, bad ones die
if algorithm.score > GOOD_CUTOFF
algorithm.duplicate();
@chrisc24
chrisc24 / Program.cs
Created July 4, 2012 06:06
Programming Challenge #71 /w Comments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
//Problem:
@chrisc24
chrisc24 / sillyDeserialize.java
Created April 27, 2012 02:22
messed up deserialization
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;
namespace ConsoleApplication1
{
@chrisc24
chrisc24 / SnakesNLadders.py
Created April 26, 2012 04:16
Snakes and ladders!
teleports = {1:38, 4:14, 9:31, 16:6, 21:42, 36:44, 47:26, 49:11, 51:67, 56:53, 62:19, 64:60, 71:91, 80:100, 87:24, 93:73, 95:75, 98:78}
board = [[] for i in range(101)]
def getPossibleNextSquares(x):
nextSquares = []
for i in range(1, 7):
if x + i in teleports.keys():
nextSquares.append(teleports[x+i])
elif x + i >= 101:
@chrisc24
chrisc24 / edges.py
Created April 24, 2012 13:57
Find the Island From Edges
edges = [( 0,22),( 0,39),( 0,47),( 1, 5),( 2,38),( 2,39),( 2,44),( 4,23),( 4,33),
( 5,19),( 6,17),( 6,35),( 6,45),( 7,49),( 8,24),( 8,40),( 9,25),( 7,10),
(10,11),(10,21),(11,30),(12,32),(13,27),(14,33),(14,36),(15,49),(16,48),
(18,37),(18,45),(19,24),(19,40),(20,39),(21,34),(25,36),(26,27),(26,31),
(26,32),(28,48),(29,36),(29,41),(35,43),(38,42),(39,44),(43,46),(48,49)]
class PointCollection:
members = set([])
masterDictionary = {}
distinctList = []
@chrisc24
chrisc24 / bottles.py
Created April 24, 2012 04:46
99 Bottles of Beer on the wall
tensPlaceStrings = { 2:"Twenty", 3:"Thirty", 4:"Forty", 5:"Fifty", 6:"Sixty", 7:"Seventy", 8:"Eighty", 9:"Ninety"}
oneToNineteenStrings = {1:"One", 2:"Two", 3:"Three", 4:"Four", 5:"Five", 6:"Six",7:"Seven",8:"Eight",9:"Nine",
10:"Ten",11:"Eleven", 12:"Twelve", 13:"Thirteen", 14:"Fourteen", 15:"Fifteen", 16:"Sixteen",
17:"Seventeen", 18:"Eighteen", 19:"Nineteen"}
def bottlePlural(num):
if num != 1:
return "bottles"
else:
return "bottle"
@chrisc24
chrisc24 / BestBox
Created April 23, 2012 14:50
BestBox V2
Create a data structure for each box
* Data about the box itself (x,y,z) (name?)
* bestDepth (initialize to 1)
* bestBox (initialize to null)
Sort Boxes ascending by size (x * y * z) (NLogN)
Starting with the smallest box:
Compare backwards with all smaller boxes.
@chrisc24
chrisc24 / BoxesWithinBoxes
Created April 23, 2012 14:04
Boxes Within Boxes Spoiler!!!
For Each Box:
Compare to all other boxes,
Create a list of boxes that could fit inside it (one layer only)
(N^2),
For each box, create a data structure that includes the box itself, an int bestCount and another box bestBox
Sort the boxes by size (N Log N).
Iterate through the boxes started with the smallest
If a box doesn't contain any boxes give it bestCount 1, and bestbox Null