Last active
September 4, 2022 05:44
-
-
Save kat0h/ab0078de8c004c30bea757dfccca38df to your computer and use it in GitHub Desktop.
プログラム
This file contains hidden or 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
# アナログ時計の形に整形された 自分自身と等しいプログラムを出力するプログラム | |
eval$s=%w'a=Array;s= | |
34;b=a.new(s){a.new(s,0)};(0.. | |
.s).each{|x|(0...s).each{|y|xx=x-s/2.1 | |
;yy=y-s/2.1;i=xx**2+yy**2;b[y][x]=(s/2.8)* | |
*2<i&&i<(s/2)**2?1:((i<(s/20)**2)?1:0)}};l=Math; | |
t=Time.new;h,m=( t.hour%12+t.min* | |
0.00872664625) *0.5235,t.min* | |
0.1047;c=->(p, z,u,d,e){g=d | |
-z;i=(g>=0)? 1:-1;o=e-u;j | |
=(o>=0)?1:-1 ;g=g.abs*2;o | |
=o.abs*2;p [u][z]=1;x=z | |
;y=u;if(g> o);f=o-g/2 | |
;until(x== d);k=f>=0; | |
y+=(k)?j:0 ;f-=(k)?g: | |
0;x+=i;f+= o;p[y][x]= | |
1;end;else ;f=g-o/2;u | |
ntil(y==e) ;if(f>=0); | |
x+=i;f-=o; end;y+=j;f | |
+=g;p[y][x ]=1;end;en | |
d;};c.call (b,s/2,s | |
/2,(l.sin( m)*(s/2.6) | |
+s/2).to_i,( -l.cos(m)* | |
(s/2.5)+s/ 2).to_i);c.c | |
all(b,s/2,s/ 2,(l.sin(h | |
)*(s/5)+s/ 2).to_i,(-l. | |
cos(h)*(s/4) +s/2).to_i); | |
e=0;q="";b.eac h{|y|y.each{|x | |
|q+=(x==1)?("e val$s=%w"<<39<<$ | |
s*3)[e..e+1]:32.chr* 2;e+=(x==1)?2:0;};q | |
<<10};q[-33,6]=""<<39<<".join";puts(q)#'.join | |
######################################## | |
########Analog Clock Quine######## | |
########################## | |
############## |
This file contains hidden or 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
eval$s=%w' t="e val$ | |
s=% w"<< 39<< ($s* | |
3);s =?0 ;b=[ ""]* | |
7;Ti me .now .str | |
ftim e( "%H: %M") | |
.spl it(" ").e | |
ach{ |n|c =[12 | |
6,48 ,109 ,121 | |
,51,9 1,95 ,112 | |
,127, 123] [n.to_ i];h= ->(i ){n= | |
=?:?s *2:c &i> 0?s +?1 *4+ s*2: s* | |
7};v= ->(i ,j) {n= =?: ??1 +s:( c& | |
i>0?? 1:s) +s* 4+( c&j >0?? 1+ | |
s:s*2 )};b [0] +=h [64 ];b[ 1] | |
+=v[ 2,32 ];b[ 2]=b[1]; b[3]+=h[ | |
1];b [4]+ =v[4 ,16];b[5 ]=b[4];b[ | |
6]+=h [8]; };b= [?1*30]* 7+[s ]+b;b | |
+=[s] + [?1* 30]* 8;c=0;o= "";b .each | |
{|i| i .spl it( "") .ea ch{| j|o+= | |
(j== s )??\s :t [c] ;c+ = (j== s)?0: | |
1;};o + =?\n ;}; o[- 7,6 ] =""< <39< | |
<".join" ;puts( o)# 2021 (c) Kota Kato '.join |
This file contains hidden or 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
// Zコンビネーター | |
const Z = ( | |
A => ( | |
B => A(c => B(B)(c)) | |
)( | |
B => A(c => B(B)(c)) | |
) | |
) | |
// リストの操作 | |
const CAR = i => i[0] | |
const CDR = i => i[1] | |
// Pythonのrange関数相当 | |
const RANGE = n => Z( | |
X => i => i == 1 ? [i, []] : [i, X(i - 1)] | |
)(n) | |
// map関数 (引数の関数をリスト全てに適用する高階関数) | |
const MAP = ( | |
F => l => Z( | |
X => m => CDR(m).length == 0 ? [F(CAR(m)), []] : [F(CAR(m)), X(CDR(m))] | |
)( | |
l | |
) | |
) | |
// FizzBuzz | |
const FIZZBUZZ = x => ( | |
MAP( | |
i => i % 15 ? i % 3 ? i % 5 ? i : 'Buzz' : 'Fizz' : 'FizzBuzz' | |
)( | |
RANGE(x) | |
) | |
) | |
console.log(FIZZBUZZ(100).flat(Infinity).reverse()) | |
// 一行 | |
(x=>((Z=>(F=>l=>Z(X=>m=>m[1].length?[F(m[0]),X(m[1])]:[F(m[0]),[]])(l))(i=>i%15?i%3?i%5?i:'Buzz':'Fizz':'FizzBuzz')((n=>Z(X=>i=>i==1?[i,[]]:[i,X(i-1)])(n))(x)))(A=>(B=>A(c=>B(B)(c)))(B=>A(c=>B(B)(c))))))(100).flat(1/0).reverse() |
This file contains hidden or 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
// https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_B のコードゴルフ | |
c;main(s){while(c=getchar(),c!=10)s+=c-48;--s?:exit(0);printf("%d\n",s);main(1);} |
This file contains hidden or 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
# 実行可能なアスキーアートを出力するプログラム | |
# 実行するごとに2種類の絵柄がループする | |
eval$z=%w"n | |
=0 ;d='eval$z=%w'+34.c | |
hr+$z*9;d[12]=d[12]==?0??1:? | |
0;a=['n0htknd4 cgp0q3vvom | |
dho1djbmmi 2g3bik7t4e | |
74moo jqsmdg1c7 | |
qg bgg1rh442 | |
lmlssk6ecvtqpq18qtecho83spt64n81nqv49m | |
lsht44elpvmmj2c1njjl1jcminfbr2k9b62bf24v','c248 | |
fd87qi7lmt5en6gt78j 5qstfkn7 2c7fkmvs5jup | |
uq2s8m mfjb 7rd49hov 3ortdp | |
0e3 b54khj8 vv | |
28d0 lv7bf' | |
];$ w=0;$ | |
s=' ';$c=0;a[ | |
n].to_i(32).to_s()[1..-1].scan( | |
/.{1,#{2}}/).map{|s|s.to_i()} .each{|i | |
|i.times{|j|$s+=($w?(3 2.chr):d[$ | |
c]);$c+=($w?0:1) ;} | |
;$w=!$w;}; | |
$s[[ | |
-6][0] ,6]=34 .chr+' .join' | |
;p ut s$ s. sc | |
an(/.{ 1, #{ [58,46 ][n]}} | |
/) .j oi n( 10 | |
.chr)# ".join # 2022 kat0h |
This file contains hidden or 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
# VimエディタでQuine | |
vim -es +'let src="norm ivim -es +^=nr2char(39)@let src=^=nr2char(34)@^=src@^=nr2char(34)@ | exe src->tr(^=nr2char(34)..nr2char(37)..nr2char(94)..nr2char(64)..nr2char(34)@, nr2char(27)..nr2char(18)..nr2char(10))^=nr2char(39)@ +^=nr2char(39)..nr2char(37)@p|q!^=nr2char(39)@" | exe src->tr("%^@", nr2char(27)..nr2char(18)..nr2char(10))' +'%p|q!' | bash | bash | bash | bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment