Skip to content

Instantly share code, notes, and snippets.

@clairvy
Created August 28, 2009 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairvy/176674 to your computer and use it in GitHub Desktop.
Save clairvy/176674 to your computer and use it in GitHub Desktop.
3: 4
8: 15
6: 12
571
798
340
741
739
629
870
599
293
998
346
519
523
145
994
990
171
861
545
557
278
814
733
627
776
966
541
750
407
567
506
564
957
380
259
513
751
970
124
547
103
512
806
648
983
760
666
451
244
841
571: 572
798: 1920
340: 756
741: 1120
739: 740
629: 684
870: 2160
599: 600
293: 294
998: 1500
346: 522
519: 696
523: 524
145: 180
994: 1728
990: 2808
171: 260
861: 1344
545: 660
557: 558
278: 420
814: 1368
733: 734
627: 960
776: 1470
966: 2304
541: 542
750: 1872
407: 456
567: 968
506: 864
564: 1344
957: 1440
380: 840
259: 304
513: 800
751: 752
970: 1764
124: 224
547: 548
103: 104
512: 1023
806: 1344
648: 1815
983: 984
760: 1800
666: 1482
451: 504
244: 434
841: 871
2481
4698
5258
1389
6149
7332
6187
9987
2243
9547
6022
9962
2739
2416
3052
4026
1505
3203
1944
8983
1345
4450
4414
3124
1471
4274
5955
2038
5233
7511
4306
3342
8722
7509
7755
8207
9921
8460
7087
8910
7521
4206
1854
9955
1311
7623
2729
3119
4949
8897
2481: 3312
4698: 10890
5258: 8640
1389: 1856
6149: 7392
7332: 18816
6187: 6480
9987: 13320
2243: 2244
9547: 9548
6022: 9036
9962: 15876
2739: 4032
2416: 4712
3052: 6160
4026: 8928
1505: 2112
3203: 3204
1944: 5460
8983: 9688
1345: 1620
4450: 8370
4414: 6624
3124: 6048
1471: 1472
4274: 6414
5955: 9552
2038: 3060
5233: 5234
7511: 9120
4306: 6462
3342: 6696
8722: 15390
7509: 10016
7755: 13824
8207: 8520
9921: 13232
8460: 26208
7087: 7480
8910: 26136
7521: 10560
4206: 8424
1854: 4056
9955: 13104
1311: 1920
7623: 13832
2729: 2730
3119: 3120
4949: 5814
8897: 10752
43772
69614
95223
72767
91526
83047
42228
61060
21836
34197
87260
72532
54799
55429
31490
51073
28126
88784
32711
33421
46659
54230
57544
40749
41942
48357
99875
44431
18755
48138
54411
27712
39498
15025
23948
33825
97192
64043
80949
92412
98834
96097
98509
36093
94407
39799
67270
50463
70562
80176
43772: 79296
69614: 104424
95223: 126968
72767: 72768
91526: 137292
83047: 83048
42228: 120960
61060: 133056
21836: 39312
34197: 45600
87260: 183288
72532: 126938
54799: 54800
55429: 60480
31490: 58752
51073: 55728
28126: 50400
88784: 178560
32711: 37392
33421: 35200
46659: 63232
54230: 116640
57544: 107910
40749: 58944
41942: 64056
48357: 72800
99875: 134784
44431: 44872
18755: 25536
48138: 98496
54411: 82944
27712: 55118
39498: 82080
15025: 18662
23948: 41916
33825: 62496
97192: 182250
64043: 74556
80949: 119168
92412: 248976
98834: 148254
96097: 96098
98509: 102816
36093: 49248
94407: 125880
39799: 39800
67270: 142992
50463: 87120
70562: 105846
80176: 155372
while 1<2 do let n=read_int()in let s=ref 0 in for i=1 to n do(n mod i==0)&&(s:=!s+i;1<2)done;Printf.printf"%d: %d\n"n!s done
#!/usr/bin/env perl
use Test::More qw/ no_plan /;
my $ocaml = 'ocaml';
my $script = 'golf.ml';
sub execute {
my ($num) = @_;
my $in_fname = "$num.in";
my $cmd = join(' ', $ocaml, $script, '<', $in_fname, '2>/dev/null', '|');
open(my $fh, $cmd) or die;
my $buf = join('', <$fh>);
return $buf;
}
sub expect {
my ($num) = @_;
my $fname = "$num.out";
open(my $fh, '<', $fname) or die;
my $buf = join('', <$fh>);
return $buf;
}
{
my $name;
my $num;
foreach my $num (1 .. 4) {
$name = 'simple ' . $num;
is(execute($num), expect($num), $name);
}
}
#!/usr/bin/env zsh
for i in 1 2 3 4; do for f in golf*.ml; do diff <( ocaml $f < $i.in 2>/dev/null) $i.out; done; done
wc -c golf*.ml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment