From 52c3d0499e3fbf4930034ab452af3f562f5672ed Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 16 Apr 2025 03:28:54 +0900 Subject: initial commit --- 1-sliding-puzzle/entry.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 1-sliding-puzzle/entry.rb (limited to '1-sliding-puzzle/entry.rb') diff --git a/1-sliding-puzzle/entry.rb b/1-sliding-puzzle/entry.rb new file mode 100644 index 0000000..2f3f31e --- /dev/null +++ b/1-sliding-puzzle/entry.rb @@ -0,0 +1,44 @@ +$b='bcdefghia';eval($s='t={h:[1,0],j:[0,-1],k: +[0,1],l:[-1,0],i:[0,0]};p=->a,b{i=$b.index(?a +); x = i% +3+ a;y = i/3+b;(x< 0 ||2 0&& ( sra n d(o ); +a= b=n = 45; ( p[* (a +,b =(t . values-[[ - a,-b],[0, 0] +]) .sa m ple)]&&n- = 1)while(n >0 +); ) ; en +d;print("$b=\47#$b\47;eval($s=\47");n="111114 +1424414143341142414424344111143434".scan(/.{, +5} / ) ;m +=" 000 001 1 00101111" . scan(/.{, 3} +/) ;s= 0;b = ->_=1{_.t i mes{print ($ +s[ (s+ =1) - 1]) } };w =- +>_ =13 {pr i nt" \ 40" *_ +}; b[22];put s ;3.times{ | y|b[45];p ut +s; b[2];w[]; b [];w[];b[ ] ;w[];b[2] ;p +ut s;1 0 .ti m es{ |l| b[ +2] ;3. t ime s {|x |w[ 2] +;$ b[y * 3+x]==?a? ( (l==3&&!p ri +nt ("\ 4 0\40\124\ 1 22\111\10 3\ +11 3 \ 40 +\40"))||(l==5&&!print("\105\120\111\123\117\1 +04\105\40\111"))||w[9]):m[n[$b[y*3+x].ord-98] +[l / 2 ]. +to _i].chars { (_1==?1?b : w) +[3 ]};w[2];b [ x/2+1]};p u ts +}; b[2 ] ;w[ ];b [ ]; +w[ ];b [ ];w []; b TRICK [2 +]; put s ;b[45];pu t s} +;b [9] ; puts("\47 . EPISODE I gs +ub (/[ [ :sp ace : ][ +:u ppe r :]] /,% % %) +); "); i ||break;p r in +t( "\1 2 enter\40[ h jk +l] \ 4 0o +r\40[q]uit\40>\40");o=:"#{$stdin.gets.chomp}" +;puts;end'.gsub(/[[:space:][:upper:]]/,%%%)); -- cgit v1.2.3-70-g09d2