Skip to content

Instantly share code, notes, and snippets.

View mjdominus's full-sized avatar

Mark Jason Dominus (陶敏修) mjdominus

View GitHub Profile
@mjdominus
mjdominus / Program
Created October 28, 2013 18:32
Tabletop game probability
#!/usr/bin/perl
for $p (1..6) {for $q (1..6) {for $r (1..6) {
my @dice = sort { $a <=> $b } $p, $q, $r;
$count{join "-", @dice}++;
}}}
for my $roll (sort keys %count) {
printf "%5s %3d %5.2f%%\n",
$roll, $count{$roll}, $count{$roll}*100/216;
Delivered-To: [email protected]
Received: by 10.76.133.164 with SMTP id pd4csp327526oab;
Mon, 14 Oct 2013 15:17:56 -0700 (PDT)
X-Received: by 10.182.44.134 with SMTP id e6mr30188804obm.14.1381789076174;
Mon, 14 Oct 2013 15:17:56 -0700 (PDT)
Return-Path: <[email protected]>
Received: from 216459-web1.unfuddle.com (216459-web1.unfuddle.com. [98.129.249.98])
by mx.google.com with ESMTP id gw9si16977581obc.33.1969.12.31.16.00.00;
Mon, 14 Oct 2013 15:17:56 -0700 (PDT)
@mjdominus
mjdominus / gist:6826238
Created October 4, 2013 13:51
graphviz input file for 22-vertex asymmetric cubic graph
graph g22 {
shape=circle;
0 [color=blue];
1 [color=green];
2 [color=green];
3 [color=green];
0 -- 1;
0 -- 2;
0 -- 3;
1 -- 4;
@mjdominus
mjdominus / tic-tac-toe.pl
Created September 6, 2013 15:53
Program to count all possible tie-tac-toe positions
#
# 123
# 456
# 789
#
my @lines = ([1,2,3], [4,5,6], [7,8,9],
[1,4,7], [2,5,8], [3,6,9],
[1,5,9], [3,5,7],
#!/usr/bin/perl
#
# http://math.stackexchange.com/questions/457360/splitting-stacks-nim
#
#
my %did;
for my $total (1 .. 10) {
my $pp = partitions($total);
for my $p (@$pp) {
@mjdominus
mjdominus / Complete output
Last active December 19, 2015 20:09
Square polynomino packings
This file has been truncated, but you can view the full file.
Examining:
.....
.....
.....
.....
.....
Examining:
333..
333..
@mjdominus
mjdominus / gist:5817351
Created June 19, 2013 19:38
git log --cherry-mark --oneline --graph --decorate budget-shutoff-rebase budget-shutoff
= 26cf20b (HEAD, shared/budget-shutoff-rebase, budget-shutoff-rebase) When a budget cap is mod
* 663b74b budgets are now disabled when they are exceeded
* aaa0e09 tweaks and cleanups in AlertTrackingLoad.pm
= b1ff9c2 New budget_for_date method gets the budget for a given board on a given date
* a1c4ccf Start test file for exhausted budget shutoff
= 4d7c3b6 get rid of nonportable curdate() in SQL
= 6a6e257 tests for budget->enable et al
= 23974b3 methods to enable and disable budgets
= b0cf6fc add disabled_at field to board_budget table
* 3831f98 (shared/master, git-svn, master) discount for unfuddle #4174
@mjdominus
mjdominus / gist:5794190
Created June 17, 2013 01:41
Scale class
I want to define a type class that supports a scaling operation. This
includes polynomials, and various decorated sorts of polynomials.
I tried
class Num s => Scale s a where
scale :: s -> a -> a
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS tiny AND var6 IS tiny THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS tiny AND var6 IS small THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS tiny AND var6 IS large THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS tiny AND var6 IS huge THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS small AND var6 IS tiny THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS small AND var6 IS small THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS small AND var6 IS large THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND var5 IS small AND var6 IS huge THEN output IS -
IF var1 IS tiny AND var2 IS tiny AND var3 IS tiny AND var4 IS tiny AND v
@mjdominus
mjdominus / gist:5711342
Created June 5, 2013 03:06
what is 'lower" for?
data Zero
data Succ a
lower :: Succ a -> a
lower = undefined
class Modulus a where
modulus :: a -> Integer
instance Modulus Zero where