This file contains 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
# http://www.reddit.com/r/dailyprogrammer/comments/32vlg8/20150417_challenge_210_hard_loopy_robots/ | |
type Point{T <: Real} | |
x :: T | |
y :: T | |
end | |
const NORTH = uint8(0) | |
const EAST = uint8(1) | |
const SOUTH = uint8(2) | |
const WEST = uint8(3) |
This file contains 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
#!/usr/bin/gawk -f | |
# C / C++ code minifier by silverweed | |
# Strips all superfluous blank spaces still producing compilable code. | |
# Somewhat tested. | |
BEGIN { | |
for (i = 1; i < length(ARGV); ++i) { | |
if (match(ARGV[i],/^-([0-9]+)$/,mch)) { | |
maxlines = mch[1] | |
} |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
-- Emit sitemap for maud (requires access to maud db) | |
import Database.MongoDB | |
import System.Environment | |
import Data.Time.Clock.POSIX | |
import qualified Data.Time.Format as DTF | |
import Data.List (intercalate) | |
import Data.List.Split | |
domain :: String |
This file contains 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
rovars: rovars.tab.c lex.yy.c | |
gcc -o rovars $^ -lm | |
rovars.tab.c: rovars.y | |
bison -d $< | |
lex.yy.c: rovars.l | |
flex $< |
This file contains 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
/* Roman numbers calculator | |
* compile with something like: `bison rocalc.y && gcc -o rocalc rocalc.tab.c -lm` | |
* Requires: Bison >= 3.0 | |
* Author: silverweed | |
*/ | |
%{ | |
#include <math.h> | |
#include <stdio.h> | |
#include <string.h> | |
int yylex(void); |
This file contains 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
-- generate random assembly for tiny | |
opcodes = { | |
{{ 'AND', 'm', 'm' }, { 'AND', 'm', 'c' }}, | |
{{ 'OR', 'm', 'm' }, { 'OR', 'm', 'c' }}, | |
{{ 'XOR', 'm', 'm' }, { 'XOR', 'm', 'c' }}, | |
{{ 'NOT', 'm' }}, | |
{{ 'MOV', 'm', 'm' }, { 'MOV', 'm', 'c' }}, | |
{{ 'RANDOM', 'm' }}, | |
{{ 'ADD', 'm', 'm' }, { 'ADD', 'm', 'c' }}, | |
{{ 'SUB', 'm', 'm' }, { 'SUB', 'm', 'c' }}, |
NewerOlder