七行プログラミング (452レス)
七行プログラミング http://medaka.5ch.net/test/read.cgi/php/1036141603/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
374: クロエ [sage] 2006/01/23(月) 18:13:14 ID:??? 372であってますか? http://medaka.5ch.net/test/read.cgi/php/1036141603/374
375: nobodyさん [sage] 2006/01/23(月) 18:19:38 ID:??? >>374 鯖によるから合ってるとか間違ってるとか言えん。 とにかくやって、エラーが出たらまた聞いてくれよ。 何かやるたびに聞かれたんじゃ迷惑だし、そもそもスレ違い。 http://medaka.5ch.net/test/read.cgi/php/1036141603/375
376: nobodyさん [sage] 2006/01/23(月) 19:29:44 ID:??? ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x$s+1],0..$s+1;map$m[$s /2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x]; if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i; f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset '';print header,$p[$r], table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 昨日の続きで7オセロ! モジュール詳しくないからやらないけどモジュール*だけ*で構成なんてのも面白そうだ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/376
377: nobodyさん [sage] 2006/01/23(月) 19:31:49 ID:??? >>374 質問するならまず68,000円のサポートチケットを購入してからにしてくださいw http://medaka.5ch.net/test/read.cgi/php/1036141603/377
378: 376 [sage] 2006/01/23(月) 21:15:02 ID:??? ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x($s+1)],0..$s+1;map$m[ $s/2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x] ;if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i ;f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset '';print header,$p[$r] ,table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 括弧はずしすぎでバグっていたので修正 ファイル名省略すると Lynx じゃ動かないね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/378
379: nobodyさん [sage] 2006/01/23(月) 21:31:39 ID:??? >>378 パスできない仕様はどうかと。 ファイルに記録するより Cookie にでも持たせた方がいいんじゃない? 参考に C の6行オセロを Perl に移植してみた。 オリジナルより数 byte 大きい。 ;-) #!/usr/local/bin/perl sub K{$m[$p]||do{for(@m[0..7]){$v=$p+$_;$v+=$_ while$m[$v]==9-$t;if($v-$p-$_&&$ m[$v]==$t&&($a=$s=$v=$p,$d)){{$m[$v]=$t;$m[$v+=$_]-$t&&redo}}}}}@m[40,41,49,50, 0..7]=(3,6,6,3,-10..-8,-1,1,8..10);$s=$t=3;@c=(qw(・ ○ ●),$/);while($s-1){$_% 9?K$p=$_:($m[$_]=9),print$c[$m[$_]/3]for 9..81;$a?($a=$d=$p=9):$s?($s=0,print "pass\n"):++$s;K$p+=$t-6?(($p,$_)=<>=~/\d/g,$_*9):1until$a-9;$t=9-$t;$a=$d=0} http://medaka.5ch.net/test/read.cgi/php/1036141603/379
380: nobodyさん [sage] 2006/01/23(月) 22:25:29 ID:??? >>379 できませんよ>< http://medaka.5ch.net/test/read.cgi/php/1036141603/380
381: nobodyさん [sage] 2006/01/24(火) 00:41:03 ID:??? @x='A'..'G';@y=1..10;@s=qw/合計 平均/;use CGI':all';charset '';print header, style({type,'text/css'},'table{border-collapse:collapse}td,input{text-align: right;width:70px}td,th{border:1px solid gray}'),start_form,table(Tr[th(['',@x, @s]),(map{$i=$_;$s=0;$n=0;td[$_,(map{$p=param"$x[$_]$i";($t=$s)==($s+=$p)||$n++ ;($t=$r[$_])==($r[$_]+=$p)||$v[$_]++;textfield"$x[$_]$i"}0..$#x),($r[@x]+=$s,$s ,eval{$s/$n})[1,2]]}@y),td([$s[0],@r,'']),td[$s[1],map($v[$_]?sprintf('%.3f',( $c++,($t=$r[$_]/$v[$_]),$v+=$t)[1]):'',0..@x),eval{$v/$c}]]),submit,end_form; >>368 がいまいち糞コードになりきれていなかったので平均の計算も追加。おやすみ〜 ノシ http://medaka.5ch.net/test/read.cgi/php/1036141603/381
382: 378 [sage] 2006/01/24(火) 00:44:20 ID:??? >>379 >パスできない仕様はどうかと。 あまり細かいこと考えていないのでw 今日はもう寝ますがなんかすごそうなので明日動かしてみます。 http://medaka.5ch.net/test/read.cgi/php/1036141603/382
383: nobodyさん [sage] 2006/01/25(水) 22:05:38 ID:??? >>379 昨日見てみましたがこれをCGI化するのは行数的にちょっと無理じゃないですかねぇ。 でも面白かったです。 http://medaka.5ch.net/test/read.cgi/php/1036141603/383
384: nobodyさん [sage] 2006/01/25(水) 22:06:31 ID:??? 初回起動時からの累計と過去1週間の日別カウンタ。 設定を変えれば一日の時間別みたいな使い方もできる。 ($f,$l,$z)=qw{./counter.dat 7 5};use CGI':all';sub d{sprintf '%d年%02d月%02d日(%s)',1900+$_[5],1+$_[4],$_[3],(qw/日 月 火 水 木 金 土/)[$_[6 ]]}sub n{sprintf"%0${z}d回",shift}$n=time;$d=24*60*60;$p=$n-$n%$d;if(open F, "+<$f"){eval{flock F,2};($s,@d)=map[split/\s+/],<F>;$s->[0]||=$n;$s->[1]++;$p== $d[0][0]?$d[0][1]++:unshift@d,[$p,1];$n-=$d*$l;seek F,0,0;printf F"%d\t%010d\n" ,@$_ for@d=($s,grep$n<$_->[0],splice@d,0,$l);truncate F,tell F;close F}charset '';print header,ul map{li b(n$_->[1]),d localtime$_->[0]}@d http://medaka.5ch.net/test/read.cgi/php/1036141603/384
385: nobodyさん [sage] 2006/01/25(水) 22:08:08 ID:??? 7CMS このスレで作った >>365 >>378 >>381 >>384 をモジュール化して一元管理する。 サードパーティー製品でもCGI.pmを使ったものなら大丈夫かも。 >>137 >>274 は一応動いた。 使い方は全部同じディレクトリに入れればいいだけだから。 use CGI':all';$d=param '*';@r=[$0=~/([^\\\/]+)$/,'START'];$p=$`;for$n(<*>){if($r [0][0]ne$n&&$n=~/\.cgi$/){$r='';chdir$p;open F,$n;read F,$c,-s F;tie*G=*STDOUT, 'main';eval"package C$`;$c";untie*G;$r=~s/^.+?(\r?\n){2}//s;$r=~s/(<a\s.*?\?)(. *?>)/$1*=$d&$2/gisx;$r=~s!(?=</for)!hidden -name,'*',-value,$d!egi;push@r,[ $n,$r.$@]}}AUTOLOAD{ref(shift)?($r.=join'',@_):bless[]}charset '';put header, table Tr td{style=>'vertical-align:top;text-align:left;border:1px solid gray'}, [ul(li[map a({href,"?*=$_"},$d==$_?b($r[$_][0]):$r[$_][0]),0..$#r]),$r[$d][1]] http://medaka.5ch.net/test/read.cgi/php/1036141603/385
386: nobodyさん [age] 2006/01/26(木) 18:42:38 ID:??? hage http://medaka.5ch.net/test/read.cgi/php/1036141603/386
387: nobodyさん [sage] 2006/01/26(木) 21:31:03 ID:??? 7メル ($p,$t,$s)=('/usr/sbin/sendmail','mail@example.com','メールフォームから');use CGI':all';$$_=param $_ for qw/f m/;($f)=$f=~/^([\w.-]{1,64}\@[\w.-]{1,128})$/i; ($m=substr$m,0,2**16)=~tr/\0/ /;$m=~s/\r\n?/\n/g;$m=~s/^\.$/../gm;charset '';put header,startform,'あなたのメールアドレス',textfield(-name,'f'),br,'メッセージ', br,textarea(-name,'m',-rows,10,-cols,60),br,submit,endform;if($f&&$m&&open M, "| $p -t"){print(M join"\n",'Content-Transfer-Encoding: 8bit',"Reply-To: <$f>", "To: <$t>","Subject: $s",'',$m,'')&&put '管理者へ送信しました。';close M} http://medaka.5ch.net/test/read.cgi/php/1036141603/387
388: nobodyさん [sage] 2006/01/26(木) 21:31:54 ID:??? 7カレ @c=([('silver')x 7],[('red',('black')x 5,'blue')],'lavender');use CGI':all';$s= 24*60*60;@t=localtime($t=time);@r=td{align=>'right',bgcolor=>$c[2]},font{color =>$c[1][$t[6]]},b $t[3];@t1=localtime($i=$t-$s);while($t[4]==$t1[4]||$t1[6]<6){ unshift@r,td{align=>'right'},font{color=>$c[$t[4]==$t1[4]][$t1[6]]},$t1[3];@t1= localtime($i-=$s)}@t2=localtime($i=$t+$s);while($t[4]==$t2[4]||0<$t2[6]){push@r ,td{align=>'right'},font{color=>$c[$t[4]==$t2[4]][$t2[6]]},$t2[3];@t2=localtime ($i+=$s)}charset '';put header,table Tr[map join('',@r[7*$_..7*($_+1)-1]),0..$#r] http://medaka.5ch.net/test/read.cgi/php/1036141603/388
389: nobodyさん [age] 2006/01/26(木) 21:32:37 ID:??? 何でもいいからボケッと見てないでおまいらも参加しる! http://medaka.5ch.net/test/read.cgi/php/1036141603/389
390: nobodyさん [] 2006/01/27(金) 16:58:32 ID:KYetQvuJ require "cgi-lib.pl"; &ReadParse;if($ENV{'REQUEST_METHOD'} eq 'POST'){if ($in{'imagefile'}) {open(WRITEFILE,'>', "datafile");binmode(WRITEFILE);print WRITEFILE $in{'imagefile'};close(WRITEFILE);}} 7うp掲示板 これ以上はムリポ http://medaka.5ch.net/test/read.cgi/php/1036141603/390
391: nobodyさん [sage] 2006/01/27(金) 22:17:22 ID:??? >>390 安全を保ちつつ複数ファイルに対応しる! http://medaka.5ch.net/test/read.cgi/php/1036141603/391
392: nobodyさん [sage] 2006/01/27(金) 22:18:05 ID:??? 7ナビ 同一階層以下のHTMLにリンクを貼る。携帯用サイトマップみたいなもん。 $d='./';$e='s?html?';$n=10;@l=(['prev',-1],['next',1]);use CGI':all';sub r{my( $d,$e)=@_;map{if(-d){r($_,$e)}elsif(/\.$e$/&&$p<=$c++&&$c<=$p+$n&&open F,$_){-B ||read F,$h,2**16;close F;$h=~/>\s*([^<>]*?)\s*<\/ti/is;[$_,$1||$_]}else{()}} <$d/*>}$p+=param 'p';($d)=$d=~/(.+?)[\\\/]*$/;@r=r$d,$e;if($p<0){$p=$c-$c%$n;$c =0;@r=r$d,$e}elsif(!@r){$p=0;$c=0;@r=r$d,$e}charset '';put header,dl dt(map a({ href=>"?p=".($p+$n*$_->[1])},$_->[0]),@l),dd{style=>'margin:0px'},join"\n",ol({ start=>1+$p},li[map a({href=>$_->[0]},$_->[1]),@r]),p"$c files" http://medaka.5ch.net/test/read.cgi/php/1036141603/392
393: nobodyさん [sage] 2006/01/27(金) 22:19:01 ID:??? 7 httpd これはCGIじゃないよ。 起動でlistenとhttp://127.0.0.1/index.htmlで表示。 Options Indexes があるはずも無いのでファイル名まで指定。 if(!grep(/^SERVER/i,keys%ENV)&&socket(S,2,1,0)&&setsockopt(S,65535,4,pack'l',1) &&bind(S,pack'S n a4 x8',2,80)&&listen S,1){select+(select(S),$|=1)[0];while( accept C,S){select+(select(C),$|=1)[0];@r=unpack"C*",getpeername C;if(recv(C,$d ,8192,0)&&$d=~/^GET ([\x21-\x7e]{1,256}) H/ and$p=join'/',map{s/\.+/./g;$_}grep length,split/[\\\/]+/,$1){print C 'HTTP/1.0 ',do{$n="\r\n\r\n";if(open F,"./$p" ){binmode F;read F,$b,-s F;close F;"200$n$b"}else{"404${n}Not Found\n"}};undef $b}close C;printf"$d%d.%d.%d.%d:%d\n%s\n",@r[4..7],256*$r[2]+$r[3],'-'x 64}} http://medaka.5ch.net/test/read.cgi/php/1036141603/393
394: nobodyさん [age] 2006/01/30(月) 04:20:47 ID:??? みんながんがれ!! http://medaka.5ch.net/test/read.cgi/php/1036141603/394
395: nobodyさん [sage] 2006/02/10(金) 18:36:50 ID:??? うぅ、ここPerl限定なのか… PHPスレ欲しいな。 http://medaka.5ch.net/test/read.cgi/php/1036141603/395
396: nobodyさん [sage] 2006/02/10(金) 18:41:19 ID:??? phpもOKみたいだぞ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/396
397: クロエ [] 2006/02/12(日) 00:31:01 ID:VpXKciXc >>368 365だと367の最後の×100が反映されないんですが…。せんせぇ、お願いします。 http://medaka.5ch.net/test/read.cgi/php/1036141603/397
398: nobodyさん [] 2006/02/15(水) 07:50:04 ID:Q8DDLS00 てめえらどうした!? 探求心はつきたか? http://medaka.5ch.net/test/read.cgi/php/1036141603/398
399: nobodyさん [] 2006/02/19(日) 19:16:08 ID:YpSh6qb6 昔作った今月のカレンダー表示スクリプト。 ($$,$:,$;,$=)=(localtime)[3..6];printf"%2d%s",$_,++$=%7?$":$/for(print($;+ 1900,'/',$:+1,"/$$\n",$"x(($=-=$$-1)%7*3))..28+($:-1?3-$:%7%2:!($;%4))) http://medaka.5ch.net/test/read.cgi/php/1036141603/399
400: nobodyさん [] 2006/02/28(火) 10:19:55 ID:5vE9CKm+ #!/usr/bin/perl if($ENV{'REQUEST_METHOD'}eq'POST'){read(STDIN,$b,$ENV{'CONTENT_LENGTH'}); foreach(split(/&/,$b)){($c,$d)=split(/=/,$_);$d=~tr/+/ /; $d=~s/%([a-f\d]{2})/pack('H2',$1)/egi;$form{$c}=$d}open(F,'>>z.txt'); print F "$form{y}\n";close F}print"Content-type:text/html\n\n<html> <form action=x.cgi method=post><input type=text name=y><input type=submit> </form><br><br>";open(F,'z.txt');while(<F>){print "$_<br>\n"}print'</html>'; http://medaka.5ch.net/test/read.cgi/php/1036141603/400
401: nobodyさん [] 2006/03/10(金) 16:20:32 ID:OL3a1OF8 在庫から 7wikimini ドゾ。 YukiWikiMini の7行版みたいな感じです。 実行するにはWという名前のフォルダが必要です。 use CGI":all";charset$c=Shift_JIS;*i=*param;$f=FrontPage;$i=Index;$u=Update;$F= i(P)||$f;sub e{a{href,"?E=1&P=".pop},@_}sub l($){a{href,"?P=@_"},@_}chdir W;$E= i E;$U=$F eq$u;$I=$F eq$i;$,=$/;if($_=i T){open F,">$F";print F$_}$H=$I+$U;$t=$ H?join$/,map{localtime((stat)[9]).$_}sort{$U&&-M$a<=>-M$b}<*>:($/=!open F)||$E? <F>:escapeHTML<F>;$E||$t=~s/([A-Z][a-z]+){2,}/-f$&?l$&:$&.e"?",$&/eg;put header ,start_html(-title=>$F,lang,ja,encoding,$c),l$f,$H?():e(Edit,$F),l$i,l$u,h1($F) ,$E?startform.hidden(P).textarea(T,$t,20,80).submit.endform:pre($t),$P,end_html ページ削除機能が実装されてないので、もうちょっと改良が必要っす。 http://medaka.5ch.net/test/read.cgi/php/1036141603/401
402: nobodyさん [sage] 2006/03/10(金) 18:39:49 ID:??? おまいら、このスレ出ている7行プログラムを、 インデント付けて整形するプログラムをどうか7行以内で書いてもらえませんか。 http://medaka.5ch.net/test/read.cgi/php/1036141603/402
403: nobodyさん [sage] 2006/03/10(金) 20:42:29 ID:??? >>402 モジュールの力を借りずに Perl の構文解析器を七行で書くのは 絶望的だし、この手のコードは多分に恣意的なインデントや桁揃え をしないと読み易くもならない。 ので、手っ取り早く「バラし」て流れを読みたいのなら、これで充分。 perl -MO=Deparse script.in > script.out もちろんチャレンジ精神を否定しているのではないよ。:o) http://medaka.5ch.net/test/read.cgi/php/1036141603/403
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 49 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.021s