Skip to content

Instantly share code, notes, and snippets.

@jadiunr
Last active May 7, 2019 07:15
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 jadiunr/3567f5e1b105304257eaec22a09d912a to your computer and use it in GitHub Desktop.
Save jadiunr/3567f5e1b105304257eaec22a09d912a to your computer and use it in GitHub Desktop.
暗号
use strict;
use warnings;
use feature 'say';
use POSIX 'ceil';
use Time::Piece;
use Time::Seconds;
my $count = ceil(log(0.5) / log((shift(@ARGV) or 99.95) * 0.01));
my $begin_date = (Time::Piece->strptime("2019-05-01","%Y-%m-%d") - ONE_DAY * $count)->ymd;
say "${count}counts, Try on ${begin_date}";
# Rubyワンライナー
# ruby -rdate -e 'puts Date.new(2019,5,1)-(Math.log(0.5)/Math.log(0.9995)).ceil'
=encoding utf8
=head1 NAME
ケイスケホンダ
=head1 DESCRIPTION
たかしくん(仮名)は本田圭佑とじゃんけんで勝負をすることになりました。
1日1回だけじゃんけんをすることが可能で、平成が終わるまでに本田圭佑に1回でも勝てる確率を
50%にするには、何年何月何日にじゃんけんを始めないと行けないでしょう?
なお、本田圭佑が勝つ確率は99.95%とし、平成は、2019年4月30日23:59:59に終わるとする。
は?
=head1 USAGE
perl keisuke_honda.pl <honda_winrate>
# e.g.
perl keisuke_honda.pl 98
引数が無い場合は本田圭佑の勝率は99.95%として計算される
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment