This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.HashSet; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.Map; | |
import java.util.Set; | |
public class LinkedMap<K, V> implements Map<K, V> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.Comparator; | |
public class Test | |
{ | |
public static void main(String[] args) | |
{ | |
Integer[] numbers = { 1, 5, 2, 7, 2, 42, 1 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.tomsanders.util; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Method; | |
import java.util.Arrays; | |
import java.util.List; | |
public abstract class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.net.Socket; | |
import java.net.URI; | |
import java.nio.ByteBuffer; | |
import java.util.ArrayList; | |
import java.util.HashMap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, timedelta | |
import itertools | |
monthly = lambda first: (first + timedelta(days = i * 365 / 12) for i in itertools.count()) | |
weekly = lambda first: (first + timedelta(days = i * 7) for i in itertools.count()) | |
repeating = lambda first, dates: (lambda since: next(d for d in dates(first) if d > since)) | |
transactions = [ | |
("Rent", -300.00, repeating(date(2014, 3, 1), monthly)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EchoServer | |
import StdEnv, StdTCP | |
port :== 1887 | |
Start world | |
# (console, world) = stdio world | |
# (ok, listener, world) = openTCP_Listener port world | |
| not ok = fclose (console <<< "ehhh") world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
minimalize [] _ = [] | |
minimalize remaining ((a, b) : xs) | |
| elem a remaining || elem b remaining = | |
(a, b) : minimalize (filter (\x -> x /= a && x /= b) remaining) xs | |
| otherwise = minimalize remaining xs | |
readInts = getLine >>= \line -> return $ map read $ words $ line | |
readEdge = readInts >>= \[a, b] -> return (a, b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.List | |
type Mapping = [(Char, Char)] | |
derive_mapping :: String -> [String] -> Mapping | |
derive_mapping plain encrypted = | |
merge_mappings $ | |
filter is_consistent $ | |
map (extract_mapping plain) $ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.tomsanders.game.egine.util; | |
public class Line | |
{ | |
private final double slope; | |
private final double intercept; | |
private final Vector pointA; | |
private final Vector pointB; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Net.NetworkInformation; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; |
NewerOlder