Download - There are so many ways to shuffle it
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
TASMWTSI
koichi taniguchi(@nipotan)
tokyo, japanlivedoor co.,ltd.
there are so many ways to shuffle it
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 毎週金曜日、ライブドアのとある部署で…
• 他の人が一週間の活動報告を行なう慣習
• commit log から作業内容を読み解く
In a department of our company,
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 毎週金曜日、ライブドアのとある部署で…
• 他の人が一週間の活動報告を行なう慣習
• commit log から作業内容を読み解く
we each have the practice to reportanother colleague’s weekly activities with each other ...
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 毎週金曜日、ライブドアのとある部署で…
• 他の人が一週間の活動報告を行なう慣習
• commit log から作業内容を読み解く
at every Friday's regular meeting.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 毎週金曜日、ライブドアのとある部署で…
• 他の人が一週間の活動報告を行なう慣習
• commit log から作業内容を読み解く
We each report what its own target did what in this week by checking the diffs out from the revision control system.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 行なうことによって…
• 変化し続ける複雑なシステムの中身を理解
• ソースコード全体の品質を保てる
This changes the inside of our complicated systemwhich is changing continually to be comprehensible to us.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 行なうことによって…
• 変化し続ける複雑なシステムの中身を理解
• ソースコード全体の品質を保てる
And it's a good way to keep the quality of our entire source code.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 行なうためには…
• 誰が誰の仕事をチェックするの?
• 制限されたルール下でライブコーディング
Although, we need to decide that"who will check who?" to do it every week.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• 行なうためには…
• 誰が誰の仕事をチェックするの?
• 制限されたルール下でライブコーディング
We each do live coding to make a decision in some rules of each season.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• それを…
• 「シャッフルのお時間」と呼ぶ
We call it"Time to Shuffle" ...
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• …って、ただのシャッフルだろ?ww
• ただのシャッフルと侮るなかれ
You may think "Just Shuffle? So?" Don't underestimate our performances.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the story line . . .
• …って、ただのシャッフルだろ?ww
• ただのシャッフルと侮るなかれ
Now I’m going to introduce youthe masterpieces of our SHUFFLE.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
This season is just to be familiar with doing live coding for us.
season 1
"no rules"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
And there's NO highlightsbecause it's boring.
season 1
"no rules"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
In the second season,
season 2
"rand prohibited"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
rand() and similar functionwhich is derived from rand() are prohibited.
season 2
"rand prohibited"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -MTime::HiRes -le '@a=@b=qw(claire tracy mohinder hiro matt nathan peter sylar);$t=Time::HiRes::time*100000%$#b+1;for(0..$#a){print $a[$_].q{ => }.$b[($_+$t)%(scalar @b)]}'claire => hirotracy => mattmohinder => nathanhiro => petermatt => sylarnathan => clairepeter => tracysylar => mohinder
First, microseconds are multiplied by hundred thousand.Then the random digit was made from them.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"
Probably all you guys come up with the same idea.
% perl -MTime::HiRes -le '@a=@b=qw(claire tracy mohinder hiro matt nathan peter sylar);$t=Time::HiRes::time*100000%$#b+1;for(0..$#a){print $a[$_].q{ => }.$b[($_+$t)%(scalar @b)]}'claire => hirotracy => mattmohinder => nathanhiro => petermatt => sylarnathan => clairepeter => tracysylar => mohinder
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"
Also, it just moved the elements of the array.
% perl -MTime::HiRes -le '@a=@b=qw(claire tracy mohinder hiro matt nathan peter sylar);$t=Time::HiRes::time*100000%$#b+1;for(0..$#a){print $a[$_].q{ => }.$b[($_+$t)%(scalar @b)]}'claire => hirotracy => mattmohinder => nathanhiro => petermatt => sylarnathan => clairepeter => tracysylar => mohinder
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -e '@m=@r=qw(claire tracy mohinder hiro matt nathan peter sylar); sub r{hex(`md5sum /proc/stat|head -c8`)%@m} while(++$c<100||scalar grep {$m[$_] eq $r[$_]} (0..$#m)){$a=&r;$b=&r; @r[$a,$b] = @r[$b,$a]} printf "%-8s => %-8s\n", $m[$_], $r[$_] for (0..$#m);'claire => tracytracy => petermohinder => hirohiro => sylarmatt => mohindernathan => clairepeter => nathansylar => matt
Next, it has the original random function.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -e '@m=@r=qw(claire tracy mohinder hiro matt nathan peter sylar); sub r{hex(`md5sum /proc/stat|head -c8`)%@m} while(++$c<100||scalar grep {$m[$_] eq $r[$_]} (0..$#m)){$a=&r;$b=&r; @r[$a,$b] = @r[$b,$a]} printf "%-8s => %-8s\n", $m[$_], $r[$_] for (0..$#m);'claire => tracytracy => petermohinder => hirohiro => sylarmatt => mohindernathan => clairepeter => nathansylar => matt
It recognizes a part of the produced MD5 message digest of kernel/system statistics (/proc/stat) as hex string,
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -e '@m=@r=qw(claire tracy mohinder hiro matt nathan peter sylar); sub r{hex(`md5sum /proc/stat|head -c8`)%@m} while(++$c<100||scalar grep {$m[$_] eq $r[$_]} (0..$#m)){$a=&r;$b=&r; @r[$a,$b] = @r[$b,$a]} printf "%-8s => %-8s\n", $m[$_], $r[$_] for (0..$#m);'claire => tracytracy => petermohinder => hirohiro => sylarmatt => mohindernathan => clairepeter => nathansylar => matt
and the corresponding value of itis divided by the number of arguments.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -e '@m=@r=qw(claire tracy mohinder hiro matt nathan peter sylar); sub r{hex(`md5sum /proc/stat|head -c8`)%@m} while(++$c<100||scalar grep {$m[$_] eq $r[$_]} (0..$#m)){$a=&r;$b=&r; @r[$a,$b] = @r[$b,$a]} printf "%-8s => %-8s\n", $m[$_], $r[$_] for (0..$#m);'claire => tracytracy => petermohinder => hirohiro => sylarmatt => mohindernathan => clairepeter => nathansylar => matt
Then it returns the remainder. It is a random integer.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 2 "rand prohibited"% perl -e '@m=@r=qw(claire tracy mohinder hiro matt nathan peter sylar); sub r{hex(`md5sum /proc/stat|head -c8`)%@m} while(++$c<100||scalar grep {$m[$_] eq $r[$_]} (0..$#m)){$a=&r;$b=&r; @r[$a,$b] = @r[$b,$a]} printf "%-8s => %-8s\n", $m[$_], $r[$_] for (0..$#m);'claire => tracytracy => petermohinder => hirohiro => sylarmatt => mohindernathan => clairepeter => nathansylar => matt
And it tries to shuffle each elements completelybut it might be given up if it spins over hundred times.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
In the third season,
season 3
"increasecombinations
possible"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
We should increase all possible combinations more than number of members.
season 3
"increasecombinations
possible"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
That is, just moving the elements is prohibited.Instead, we can use rand() again from the season.
season 3
"increasecombinations
possible"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
We did it!
season 3
"increasecombinations
possible"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
-module(shuffle).-export([main/1,comb/2]).
main(A) -> All = comb(A,A), Set = lists:nth(random:uniform(length(All)), All), output(Set).
output([]) -> true;output([{A,B}|T]) -> io:format("~w => ~w~n", [A,B]), output(T).
comb([], _) -> [[]];comb([H|T], B) -> [ [{H, X}|Rest] || X<-B--[H], Rest<-comb(T, B--[X]) ].
Erlang?!
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
% erlErlang R14B (erts-5.8.1) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.1 (abort with ^G)1> c(shuffle).{ok,shuffle}2> shuffle:main([claire,mohinder,hiro,matt,nathan,peter,sylar]).claire => mohindermohinder => nathanhiro => mattmatt => sylarnathan => clairepeter => hirosylar => petertrue
I'm not sure,but it maybe works correctly.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
% ruby -e 'a=b=%w(claire tracy mohinder hiro matt nathan peter sylar); b=b.sort_by{rand} until (0..a.size-1).all?{|i|a[i]!=b[i]};a.zip(b){|x,y| puts "%8s => %s" % [x,y]}' claire => nathan tracy => hiromohinder => peter hiro => matt matt => mohinder nathan => sylar peter => claire sylar => tracy
Ruby?!
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
Excuse me. This is Yet Another Perl Conference, isn't it.Why don't you use Perl?
% ruby -e 'a=b=%w(claire tracy mohinder hiro matt nathan peter sylar); b=b.sort_by{rand} until (0..a.size-1).all?{|i|a[i]!=b[i]};a.zip(b){|x,y| puts "%8s => %s" % [x,y]}' claire => nathan tracy => hiromohinder => peter hiro => matt matt => mohinder nathan => sylar peter => claire sylar => tracy
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
By the way, is zip() cool, it isn’t?
% ruby -e 'a=b=%w(claire tracy mohinder hiro matt nathan peter sylar); b=b.sort_by{rand} until (0..a.size-1).all?{|i|a[i]!=b[i]};a.zip(b){|x,y| puts "%8s => %s" % [x,y]}' claire => nathan tracy => hiromohinder => peter hiro => matt matt => mohinder nathan => sylar peter => claire sylar => tracy
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 3 "increase combinations possible"
We can use "Z" for zip() operator in perl6.But I’m not sure about perl6.
% perl6 -e 'for ("foo", "bar", "baz") Z ("qux", "quux", "corge") -> $a, $b { say "$a => $b" }'foo => quxbar => quuxbaz => corge
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4
"time trial"This season is like a time trial.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
In addition,it was laid down the most strict rules so far.
season 4
"time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール
The rules of the season are...
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く
write a perl subroutine which gets an arrayref of member list as the parameter ...
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く
and returns an arrayref of target members.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと
Increase all possible combinationsmore than number of members.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する
Eliminate the pairs that includethe target of someone is oneself.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く
Possibly faster than ever before.For comparison, we try to benchmark ...
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く
10,000 times shuffle of 10 members,1,000 times shuffle of 1,000 members,
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く
and 10 times shuffle of 10,000 members.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く
Then we evaluate the results comprehensively and assume which is the reigning champion.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く• 先に書いてきて実行するだけというのは禁止
Preparing some tricks ahead of timeand playing it is prohibited.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く• 先に書いてきて実行するだけというのは禁止• 「毎回違う結果になる」「全組み合わせが出来る」「ペアになりやすい/なりにくいが無い」のいずれかを満たす
Meet the any of following conditions,
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial"
• このシーズンにおけるルール• メンバ一の arrayref を受け取り、ペアになる対象メンバーの
arrayref を返すサブルーチンを書く• 可能な組み合わせが少なくともメンバー数より多いこと• 自分自身を見る人がいる組み合わせは除外する• 出来れば今までの誰よりも高速に動くものを書く• 先に書いてきて実行するだけというのは禁止• 「毎回違う結果になる」「全組み合わせが出来る」「ペアになりやすい/なりにくいが無い」のいずれかを満たす
it gives "different results each time","all possible combinations" and/or "even results".
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { my $array = shift; my $array2; do { $array2 = [sort { rand(3)-1 } @$array]; } while (grep $$array[$_] eq $$array2[$_], (0..$#$array)); return $array2;}
At first, this is the interim champion.It’s not so fast because it’s the reference implementation.
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { my $array = shift; my $n = $#$array; my @index = (0..$n); my $i; for (0..$n) { $i = int(rand($n)); redo if $_ == $index[$i] || $i == $index[$_]; ( $index[$_], $index[$i] ) = ( $index[$i], $index[$_] ); } return [ @$array[@index] ];}
This is the 2nd champion.It works more than 4 times faster than the former champion.
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { my @array = @{$_[0]}; my ($i, $r) = scalar @array; while(--$i) { $r = rand($i); @array[$i, $r] = @array[$r, $i]; } return \@array;}
This is the 4th champion.Incidentally, it’s very similar to Fisher-Yates shuffle.
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { my @array = @{$_[0]}; my ($i, $r) = scalar @array; while(--$i) { $r = rand($i); @array[$i, $r] = @array[$r, $i]; } return \@array;}
You can find out the technique like this in perldoc -q shuffle (in perlfaq4).
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { return _shuffle(@_); BEGIN{ my $MAGIC = 3; my @MAGIC = ([1,2,0], [2,0,1]); srand; my $R=int rand(1000000); sub _shuffle { my $arg = shift; my $n = scalar @$arg; my $is_odd = $n % 2; $n -= $MAGIC if $is_odd; my $half = $n / 2; my $r_a = ($R / $half) % ($half); my $r_b = ($R % $half); $R++; my @sep = (0 => $r_a, $r_a+1 => $half - 1, $half => $half + $r_b, $half + $r_b + 1 => $n -1);
This is the 5th champion.It doesn't shuffle accurately. It's so tricky.
my @magic = (); if ($is_odd){ @sep = map{$_ + $MAGIC} @sep; @magic = @{$MAGIC[($R / $half / $half) % 2]}; } return [@$arg[@magic, $sep[6] .. $sep[7], $sep[4] .. $sep[5], $sep[2] .. $sep[3], $sep[0] .. $sep[1] ]]; } }}
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { return _shuffle(@_); BEGIN{ my $MAGIC = 3; my @MAGIC = ([1,2,0], [2,0,1]); srand; my $R=int rand(1000000); sub _shuffle { my $arg = shift; my $n = scalar @$arg; my $is_odd = $n % 2; $n -= $MAGIC if $is_odd; my $half = $n / 2; my $r_a = ($R / $half) % ($half); my $r_b = ($R % $half); $R++; my @sep = (0 => $r_a, $r_a+1 => $half - 1, $half => $half + $r_b, $half + $r_b + 1 => $n -1);
It works about 30% faster than Fisher-Yates shuffle.But It doesn't work at all under a specific condition.
my @magic = (); if ($is_odd){ @sep = map{$_ + $MAGIC} @sep; @magic = @{$MAGIC[($R / $half / $half) % 2]}; } return [@$arg[@magic, $sep[6] .. $sep[7], $sep[4] .. $sep[5], $sep[2] .. $sep[3], $sep[0] .. $sep[1] ]]; } }}
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { return _shuffle(@_); BEGIN{ my $MAGIC = 3; my @MAGIC = ([1,2,0], [2,0,1]); srand; my $R=int rand(1000000); sub _shuffle { my $arg = shift; my $n = scalar @$arg; my $is_odd = $n % 2; $n -= $MAGIC if $is_odd; my $half = $n / 2; my $r_a = ($R / $half) % ($half); my $r_b = ($R % $half); $R++; my @sep = (0 => $r_a, $r_a+1 => $half - 1, $half => $half + $r_b, $half + $r_b + 1 => $n -1);
If you want to read the code carefully,Please wait the publication of this slide.
my @magic = (); if ($is_odd){ @sep = map{$_ + $MAGIC} @sep; @magic = @{$MAGIC[($R / $half / $half) % 2]}; } return [@$arg[@magic, $sep[6] .. $sep[7], $sep[4] .. $sep[5], $sep[2] .. $sep[3], $sep[0] .. $sep[1] ]]; } }}
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { return [Foo::fisher_yates(@{$_[0]})]; BEGIN { my $use = sub { eval qq{ use $_[0]; }; return $@ ? () : 1; }; push @INC, qw(Foo/blib/lib Foo/blib/arch); unless ($use->('Foo')) { if (-d 'Foo') { system(qw/rm -frv Foo/) && die $^E; } system(qw/h2xs -A -n Foo/) && die $^E; chdir 'Foo' or die $!; open my $xs, '>', 'Foo.xs' or die $!; print $xs <<'XSUB';#include "EXTERN.h"#include "perl.h"#include "XSUB.h"#include "ppport.h"
This is the 6th champion. A Fisher-Yates XS implementation is embedded in a subroutine forcibly.
MODULE = Foo PACKAGE = Foovoidfisher_yates(...)PROTOTYPE: @CODE: UV i = items; while (--i) { UV swap = (UV)(Drand01() * i); SV *tmp = ST(swap); ST(swap) = ST(i); ST(i) = tmp; } XSRETURN(items);XSUB
close $xs; (system($^X, 'Makefile.PL') || system('make')) && die $^E; chdir '..' or die $!; $use->('Foo') or die $@; print "-" x 50 . "\n"; } };}
season 4 "time trial"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
sub shuffle { return [Foo::fisher_yates(@{$_[0]})]; BEGIN { my $use = sub { eval qq{ use $_[0]; }; return $@ ? () : 1; }; push @INC, qw(Foo/blib/lib Foo/blib/arch); unless ($use->('Foo')) { if (-d 'Foo') { system(qw/rm -frv Foo/) && die $^E; } system(qw/h2xs -A -n Foo/) && die $^E; chdir 'Foo' or die $!; open my $xs, '>', 'Foo.xs' or die $!; print $xs <<'XSUB';#include "EXTERN.h"#include "perl.h"#include "XSUB.h"#include "ppport.h"
It works about 2 times faster thanthe former champion.
MODULE = Foo PACKAGE = Foovoidfisher_yates(...)PROTOTYPE: @CODE: UV i = items; while (--i) { UV swap = (UV)(Drand01() * i); SV *tmp = ST(swap); ST(swap) = ST(i); ST(i) = tmp; } XSRETURN(items);XSUB
close $xs; (system($^X, 'Makefile.PL') || system('make')) && die $^E; chdir '..' or die $!; $use->('Foo') or die $@; print "-" x 50 . "\n"; } };}
season 4 "time trial" side story
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
As a side story.
season 4 "time trial" side story
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
Satoshi Ueda (gunyoki), all you saw him a little while ago,he is a former member of ours.
season 4 "time trial" side story
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
He said on IRC ...
19:55:00 <gunyoki> タスク構造体のCPU消費時間を変更するkernel moduleを書いた19:56:38 <gunyoki> あらゆる計算を時間0で行えます
season 4 "time trial" side story
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
<gunyoki> I wrote a kernel module which can change the CPU expended time of the task structure.
19:55:00 <gunyoki> タスク構造体のCPU消費時間を変更するkernel moduleを書いた19:56:38 <gunyoki> あらゆる計算を時間0で行えます
season 4 "time trial" side story
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
<gunyoki> It enable that the (not actual) time for any kind of calculation to be zero.
19:55:00 <gunyoki> タスク構造体のCPU消費時間を変更するkernel moduleを書いた19:56:38 <gunyoki> あらゆる計算を時間0で行えます
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial" side story#include <linux/kernel.h>#include <linux/module.h>#include <linux/sched.h>#include <linux/proc_fs.h>#include <asm/uaccess.h>
#define PROC_NAME "driver/utime"
static int pid;module_param(pid, int, 0666);
static int proc_read(char *page, char **start, off_t offset, int count, int *eof, void *data){ unsigned long outbyte; struct task_struct *process; if (offset > 0) { *eof = 1; return 0; } process = find_task_by_pid(pid); if (!process) { printk("pid error: %d\n", pid); *eof = 1; return 0; } outbyte = sprintf(page, "%ld", process->utime); printk("proc_read len = %lu\n", outbyte); *eof = 1; return outbyte;}
static int proc_write(struct file *page, const char *buf, unsigned long len, void *data){ char tmp[64]; long utime; struct task_struct *process; if (copy_from_user(tmp, buf, len)) return -EFAULT; utime = simple_strtol(tmp, NULL, 0); process = find_task_by_pid(pid); if (!process) { printk("pid error: %d\n", pid); return -EFAULT; } printk("utime: %ld -> %ld\n", process->utime, utime); process->utime = utime; return len;}
int init_module(void){ struct proc_dir_entry *entry; entry = create_proc_entry(PROC_NAME, 0666, NULL); if (entry == 0) return -EINVAL; entry->read_proc = proc_read; entry->write_proc = proc_write; return 0;}
void cleanup_module(void){ remove_proc_entry(PROC_NAME, NULL);}
MODULE_LICENSE("GPL2");kernel_module
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial" side story
makefile
obj-m += foo.o
KDIR := /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)
default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modulesclean: rm -f *.o *.ko *.mod.c
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial" side story
perl
sub shuffle { my $array = shift; our $pid; if ($pid == 0) { $pid = $$; open my $pid_file, '>/sys/module/foo/pid'; print $pid_file $pid; close $pid_file; } open my $utime_file, '+</proc/driver/utime'; my $utime = <$utime_file>; my $result = champion($array); print $utime_file $utime; close $utime_file; return $result;}
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial" side story
perl
sub shuffle { my $array = shift; our $pid; if ($pid == 0) { $pid = $$; open my $pid_file, '>/sys/module/foo/pid'; print $pid_file $pid; close $pid_file; } open my $utime_file, '+</proc/driver/utime'; my $utime = <$utime_file>; my $result = champion($array); print $utime_file $utime; close $utime_file; return $result;}
He doesn’t write any shuffle code.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
season 4 "time trial" side story
perl
sub shuffle { my $array = shift; our $pid; if ($pid == 0) { $pid = $$; open my $pid_file, '>/sys/module/foo/pid'; print $pid_file $pid; close $pid_file; } open my $utime_file, '+</proc/driver/utime'; my $utime = <$utime_file>; my $result = champion($array); print $utime_file $utime; close $utime_file; return $result;}
He doesn’t write any shuffle code.unforgiv
able che
at
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
final season
"lipstick on an after-image"
Finally, it’s the final season.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
final season
"lipstick on an after-image"
This title comes from a SF novel, written by Yasutaka Tsutsui.
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
final season
"lipstick on an after-image"
Prohibited characters are increasing week by week.
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e ' # XXX your shuffle code here. '
The basic format is a one-liner like above.
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e 'chomp(@m=<>);@i=(0..$#m);$j=@m;while($j--) {$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(0..$#m) {printf(qq{%s=>%s\n},$m[$_],$m[$i[$_]])}'
At the start, there was no prohibited characters.
prohibits:
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e 'chomp(@m=<>);@i=(0..$#m);$j=@m;while($j--) {$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(0..$#m) {printf(qq{%s=>%s\n},$m[$_],$m[$i[$_]])}'
Next, using "0", "s" and "t" were prohibited.
prohibits:
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e 'chomp(@m=<>);@i=(()..$#m);$j=@m;while($j--) {$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(()..$#m) {warn $m[$_]." => ".$m[$i[$_]]."\n"}'
In the early stage, we couldn’t use printf().warn() was used instead of it to output the result.
prohibits: 0 s t
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e 'chomp(@m=<>);@i=(()..$#m);$j=@m;while($j--) {$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(()..$#m) {warn $m[$_]." => ".$m[$i[$_]]."\n"}'
Next, using "h", "k", "q" and " (double quotation) were prohibited.
prohibits: 0 s t
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '@m=<>;@i=(1-1..$#m);$j=$#m;for(;$j;$j--){$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(()..$#m){warn $m[$_].'\'' => '\''.$m[$i[$_]]}'
We couldn’t use while().And quotation operators made us painful.
prohibits: " 0 h k q s t
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '@m=<>;@i=(1-1..$#m);$j=$#m;for(;$j;$j--){$r=rand($j);@i[$j,$r]=@i[$r,$j]};for(()..$#m){warn $m[$_].'\'' => '\''.$m[$i[$_]]}'
Next, "y", "," and ";" were prohibited.
prohibits: " 0 h k q s t
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{@m=<> xor @i=(1-1..$#m) xor $j=@m} for(1..--$j){$r=rand($j) xor @i[$j--=>$r]=@i[$r=>$j]} for(()..$#m){warn $m[$_].'\'' => '\''.$m[$i[$_]]}'
We started to join each statements by "xor" operator.
prohibits: " , 0 ; h k q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{@m=<> xor @i=(1-1..$#m) xor $j=@m} for(1..--$j){$r=rand($j) xor @i[$j--=>$r]=@i[$r=>$j]} for(()..$#m){warn $m[$_].'\'' => '\''.$m[$i[$_]]}'
Next, "o" was prohibited.
prohibits: " , 0 ; h k q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{@m=<>} {@i=(1-1..$#m)} {$j=@m} {map {{$r=rand($j)}=>{@i[$j--=>$r]=@i[$r=>$j]}} (1..--$j)} map {warn $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)'
xor was no longer available.
prohibits: " , 0 ; h k o q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{@m=<>} {@i=(1-1..$#m)} {$j=@m} {map {{$r=rand($j)}=>{@i[$j--=>$r]=@i[$r=>$j]}} (1..--$j)} map {warn $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)'
Next, "-" was prohibited.
prohibits: " , 0 ; h k o q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x=eval("\x2d1") } {@m=<>} {@i=(()..$#m)} {$j=@m} {map {{$r=rand($j)}=>{@i[$j=>$r]=@i[$r=>$j]} => $j+=$x} (1..($j+=$x))} map {warn $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)'
We needed to require some creative thinking to do -1.
prohibits: " , - 0 ; h k o q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x=eval("\x2d1") } {@m=<>} {@i=(()..$#m)} {$j=@m} {map {{$r=rand($j)}=>{@i[$j=>$r]=@i[$r=>$j]} => $j+=$x} (1..($j+=$x))} map {warn $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)'
Next, "r" was prohibited.
prohibits: " , - 0 ; h k o q s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x=eval("\x2d1") } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v *= $v}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {@d = map { $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} {die @d}'
We couldn’t use rand().And also warn() was not available to output the result.
prohibits: " , - 0 ; h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x=eval("\x2d1") } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v *= $v}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {@d = map { $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} {die @d}'
We considered that die() wasthe last way to output.
prohibits: " , - 0 ; h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x=eval("\x2d1") } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v *= $v}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {@d = map { $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} {die @d}'
Next, "e" was prohibited.
prohibits: " , - 0 ; h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v = (45 * $v + 555) % (4 ** 5)}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {map { $d .= $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} &$d'
We couldn’t eval().We couldn’t die().
prohibits: " , - 0 ; e h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v = (45 * $v + 555) % (4 ** 5)}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {map { $d .= $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} &$d'
The output result was like;"Undefined subroutine &main::clair => hiro ... called at -e line 1, <> line 7."
prohibits: " , - 0 ; e h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v = (45 * $v + 555) % (4 ** 5)}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {map { $d .= $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} &$d'
Also, we started to use Linear congruential generators (LCGs) to generate a random digit.
prohibits: " , - 0 ; e h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v = (45 * $v + 555) % (4 ** 5)}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {map { $d .= $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} &$d'
To tell you the truth, I’m not sure about it.Wikipedia it for ourselves.
prohibits: " , - 0 ; e h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$}{map {{$v = (45 * $v + 555) % (4 ** 5)}=> {$p = $v % $j}=>{@i[$j=>$p]=@i[$p=>$j]} => $j+=$x} (1..($j+=$x))} {map { $d .= $m[$_].'\'' => '\''.$m[$i[$_]]} (()..$#m)} &$d'
Next, "p" was prohibited.
prohibits: " , - 0 ; e h k o q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$} {$zz='\''z'\'' x ($j+=$x)} {$zz=~/z(??{({$v = (45 * $v + 555) % (4 ** 5)}=> {$z = $v % $j}=>{@i[$j=>$z]=@i[$z=>$j]} => $j+=$x) })/} {$zz='\''z'\'' x @m}{$zz=~/z(??{( $d .= $m[$zzz].'\'' => '\''.$m[$i[$zzz++]] ) })/ } &$d'
map() the last built-in function was gone.
prohibits: " , - 0 ; e h k o p q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''L1'\''^'\''a'\'' } {@m=<>} {@i=(()..$#m)} {$j=@m} {$v=$$} {$zz='\''z'\'' x ($j+=$x)} {$zz=~/z(??{({$v = (45 * $v + 555) % (4 ** 5)}=> {$z = $v % $j}=>{@i[$j=>$z]=@i[$z=>$j]} => $j+=$x) })/} {$zz='\''z'\'' x @m}{$zz=~/z(??{( $d .= $m[$zzz].'\'' => '\''.$m[$i[$zzz++]] ) })/ } &$d'
On this ocation, prohibited "a", "b", "c", "d", "f", "g", "i", "j", "l", "m", "n", "u", "v", "w" and "z" (every alphabet except "x").
prohibits: " , - 0 ; e h k o p q r s t y
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''%'\''|'\''('\''.1 } {@xx=<>} {@xxx=(()..$#xx)} {$xxxx=@xx} {$xxxxx=$$} {$xxxxxx='\''x'\'' x ($xxxx+=$x)} {$xxxxxx=~/x(??{({$xxxxx = (45 * $xxxxx + 555) % (4 ** 5)}=> {$xxxxxxx = $xxxxx % $xxxx}=>{@xxx[$xxxx=>$xxxxxxx]=@xxx[$xxxxxxx=>$xxxx]} => $xxxx+=$x) })/} {$xxxxxx='\''x'\'' x @xx}{$xxxxxx=~/x(??{( $xxxxxxxxx .= $xx[$xxxxxxxx].'\'' => '\''.$xx[$xxx[$xxxxxxxx++]] ) })/ } &$xxxxxxxxx'
Does anybody fix my J’ai perdu le do de ma clarinette?
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w y z
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''%'\''|'\''('\''.1 } {@xx=<>} {@xxx=(()..$#xx)} {$xxxx=@xx} {$xxxxx=$$} {$xxxxxx='\''x'\'' x ($xxxx+=$x)} {$xxxxxx=~/x(??{({$xxxxx = (45 * $xxxxx + 555) % (4 ** 5)}=> {$xxxxxxx = $xxxxx % $xxxx}=>{@xxx[$xxxx=>$xxxxxxx]=@xxx[$xxxxxxx=>$xxxx]} => $xxxx+=$x) })/} {$xxxxxx='\''x'\'' x @xx}{$xxxxxx=~/x(??{( $xxxxxxxxx .= $xx[$xxxxxxxx].'\'' => '\''.$xx[$xxx[$xxxxxxxx++]] ) })/ } &$xxxxxxxxx'
And finally,
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w y z
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $x='\''%'\''|'\''('\''.1 } {@xx=<>} {@xxx=(()..$#xx)} {$xxxx=@xx} {$xxxxx=$$} {$xxxxxx='\''x'\'' x ($xxxx+=$x)} {$xxxxxx=~/x(??{({$xxxxx = (45 * $xxxxx + 555) % (4 ** 5)}=> {$xxxxxxx = $xxxxx % $xxxx}=>{@xxx[$xxxx=>$xxxxxxx]=@xxx[$xxxxxxx=>$xxxx]} => $xxxx+=$x) })/} {$xxxxxx='\''x'\'' x @xx}{$xxxxxx=~/x(??{( $xxxxxxxxx .= $xx[$xxxxxxxx].'\'' => '\''.$xx[$xxx[$xxxxxxxx++]] ) })/ } &$xxxxxxxxx'
We decided to prohibit the last best hope,"x".
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w y z
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $_1='\''%'\''|'\''('\''.1 } {$/='\'''\''} {$_2=<>} {$*=1} {@_3=()} {$_2=~/^(.+?)$(??{{$_3[$#_3+1]=$1}{$#_3?$_4.='\''_'\'':'\'''\''}{'\''^'\''}})/} {@_6=(()..$#_3)} {$_7=$#_3} {$_5=$$} {$_4=~/_(??{({$_5 = (45 * $_5 + 555) % (4 ** 5)}=> {$_11 = $_5 % $_7}=>{@_6[$_7=>$_11]=@_6[$_11=>$_7]} => $_7+=$_1) })/} {$_4.='\''_'\''}{$_4=~/_(??{( $_8 .= $_3[$_9].'\'' => '\''.$_3[$_6[$_9++]].'\'' '\'' ) })/ } &$_8'
This is the final form without using alphabet.
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w x y z
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $_1='\''%'\''|'\''('\''.1 } {$/='\'''\''} {$_2=<>} {$*=1} {@_3=()} {$_2=~/^(.+?)$(??{{$_3[$#_3+1]=$1}{$#_3?$_4.='\''_'\'':'\'''\''}{'\''^'\''}})/} {@_6=(()..$#_3)} {$_7=$#_3} {$_5=$$} {$_4=~/_(??{({$_5 = (45 * $_5 + 555) % (4 ** 5)}=> {$_11 = $_5 % $_7}=>{@_6[$_7=>$_11]=@_6[$_11=>$_7]} => $_7+=$_1) })/} {$_4.='\''_'\''}{$_4=~/_(??{( $_8 .= $_3[$_9].'\'' => '\''.$_3[$_6[$_9++]].'\'' '\'' ) })/ } &$_8'
Actually, it doesn’t work with perl 5.10.x or later because $*, (deprecated) variable has been removed.
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w x y z
final season "lipstick on an after-image"
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
% cat members.txt | perl -e '{ $_1='\''%'\''|'\''('\''.1 } {$/='\'''\''} {$_2=<>} {$*=1} {@_3=()} {$_2=~/^(.+?)$(??{{$_3[$#_3+1]=$1}{$#_3?$_4.='\''_'\'':'\'''\''}{'\''^'\''}})/} {@_6=(()..$#_3)} {$_7=$#_3} {$_5=$$} {$_4=~/_(??{({$_5 = (45 * $_5 + 555) % (4 ** 5)}=> {$_11 = $_5 % $_7}=>{@_6[$_7=>$_11]=@_6[$_11=>$_7]} => $_7+=$_1) })/} {$_4.='\''_'\''}{$_4=~/_(??{( $_8 .= $_3[$_9].'\'' => '\''.$_3[$_6[$_9++]].'\'' '\'' ) })/ } &$_8'
We are seeking a mature individualwith excellent shuffle skills.
prohibits: " , - 0 ; a b c d e f g h i j k l m n o p q r s t u v w x y z
YAPC::ASIA 2010 L IGHTNING TALKS
T H E R E A R E S O M A N Y W A Y S T O S H U F F L E I T
the end