Skip to content

Instantly share code, notes, and snippets.

@bouk
bouk / gist:4178408
Created November 30, 2012 20:34
result
9,12d8
< celt
< celts
< ceres
< cerf
15,17d10
< cf
< ci
< cipro
23d15
@bouk
bouk / gist:4178208
Created November 30, 2012 20:06
Letterpress cheater
#include <string>
#include <algorithm>
#include <list>
#include <cstring>
#include <fstream>
#include <iostream>
#include <cctype>
#include <vector>
#include <set>
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Needs program filename argument"
exit 1
fi
executable=`mktemp`
echo "Testing $1"
echo
@bouk
bouk / gist:3939575
Created October 23, 2012 15:47
Proper todo list!
# encoding: UTF-8
module BoukeTodoApp
class TodoList
def initialize(filename)
@items = []
@filename = filename
self.load
end
@bouk
bouk / gist:3939072
Created October 23, 2012 14:31
Blah
# encoding: UTF-8
TodoItem = Struct.new(:done, :contents)
todos = []
if File.exists? 'list.td'
File.open('list.td') do |f|
todos = f.read.split("\n")
todos.map! { |item|
new_item = TodoItem.new
new_item.done, new_item.contents = item.split("|")
new_item
'''
The algorithm works as follows:
It simply checks all positions, with positions being marked with None (unknown) x (part of a ship) or o (no ship)
Because the description says that ships can't touch (including diagonally) you know for sure that if a position
has the part of a ship that the positions diagonal to it don't, like so:
o.o
.x.
o.o
$(document).ready(function()
{
}
);