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
$ cat stat | |
a249ded 68.390 | |
a249ded 67.585 | |
a249ded 66.976 | |
a249ded 67.658 | |
a249ded 66.592 | |
a249ded 68.217 | |
a249ded 67.328 | |
a249ded 66.319 | |
a249ded 68.024 |
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
enum Hand <Rock Paper Scissors>; | |
multi infix:<beats>(Paper, Rock) { True } | |
multi infix:<beats>(Rock, Scissors) { True } | |
multi infix:<beats>(Scissors, Paper) { True } | |
multi infix:<beats>($, $) { False } | |
my $p1 = Hand.roll; | |
say "Player 1 chooses {$p1}"; |
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
multi MAIN { | |
my $a = prompt "a (bigger number): "; | |
my $b = prompt "b (smaller number): "; | |
my ($q, $r) = euclidean($a, $b); | |
say "q: $q"; | |
say "r: $r"; | |
} | |
multi MAIN("test") { |
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
# fizzbuzz without conditionals in Perl 6 | |
# Simple pattern matching using multi subs | |
sub fizzbuzz($n) { | |
multi case($, $) { $n } | |
multi case(0, $) { "fizz" } | |
multi case($, 0) { "buzz" } | |
multi case(0, 0) { "fizzbuzz" } | |
case $n % 3, $n % 5; |
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
# see http://irclog.perlgeek.de/perl6/2015-03-11#i_10258447 for background | |
my @values = 5, 33, 44, 52, 66; | |
constant DESIRED_RESULT = 283; | |
for 1..Inf -> $elems { | |
# Three symmetry breakers: | |
# | |
# (a) Terms in sums happen in nondecreasing order of their first factor | |
# (b) Factors in products happen in nondecreasing order |
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
TIME moves placements swaps resigns timeouts TOTAL req/s s/req | |
================================================================================================ | |
47m 36.012s 18770 18314 225 443 13 37765 13.22 0.075 | |
36m 51.226s 9385 18314 225 443 13 28380 12.83 0.078 | |
26m 6.464s 9385 9157 225 443 13 19223 12.27 0.081 | |
15m 11.009s 4693 4579 225 443 13 9953 10.93 0.091 | |
9m 42.419s 2347 2290 225 443 13 5318 9.13 0.110 | |
6m 52.158s 1174 1146 225 443 13 3002 7.28 0.137 | |
5m 28.929s 588 574 225 443 13 1843 5.60 0.179 | |
4m 46.100s 295 288 225 443 13 1264 4.42 0.226 |
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
sub paragraphs { $^s.split: /\n\n+/ } | |
sub is-code-block { $^s ~~ /^ ' ' ** 4/ } | |
sub escape { $^s.trans: ['>', '<', '&'] => ['>', '<', '&'] } | |
for paragraphs(slurp.trim) -> $_ is copy { | |
if is-code-block($_) { | |
say "<code><pre>{ .indent(-4).&escape }</code></pre>"; | |
} | |
else { | |
.=subst(:g, / '[' (<-[\]]>+) '](' (<-[)]>+) ')' /, -> $/ { qq[<a href="$1">{$0}</a>] }); |
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
$ python | |
Python 2.7.6 (default, Mar 22 2014, 22:59:56) | |
[GCC 4.8.2] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> class C: | |
... def __init__(self, name): | |
... self.name = name | |
... def foo(self): | |
... print self.name | |
... |
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
# The input coordinate system looks like this: | |
# | |
# (-3,+2) (-2,+2) (-1,+2) ( 0,+2) (+1,+2) (+2,+2) (+3,+2) | |
# | |
# (-3,+1) (-2,+1) (-1,+1) ( 0,+1) (+1,+1) (+2,+1) (+3,+1) | |
# | |
# (-3, 0) (-2, 0) (-1, 0) ( 0, 0) (+1, 0) (+2, 0) (+3, 0) | |
# | |
# (-3,-1) (-2,-1) (-1,-1) ( 0,-1) (+1,-1) (+2,-1) (+3,-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
$ python | |
Python 2.7.6 (default, Mar 22 2014, 22:59:56) | |
[GCC 4.8.2] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> val = 1e3000 | |
>>> val | |
inf | |
>>> 1 ** val | |
1.0 |
NewerOlder