fork download
  1. #coding:utf-8
  2. require "dxruby"
  3.  
  4. # ----------------------------- array rot lib --------------------------------
  5.  
  6. def array_rot45 vv
  7. vv.transpose.each_with_index.map do | m , i |
  8. [nil]*i + m + [nil]*((vv.size-1) - i)
  9. end.transpose.map(&:compact)
  10. end
  11.  
  12. def array_rot45_decode a
  13. z = a.map(&:size).max
  14. a.each_with_index.inject( z.times.map do [] end ) do | c , ( m , i ) |
  15. z.times.each_with_object c do | k |
  16. if (k...(z+k)) === i
  17. if c[k].size != z
  18. c[k].push m.pop
  19. end
  20. end
  21. end
  22. end
  23. end
  24.  
  25. def array_rot_print v
  26. v.map(&:to_s).each do | m |
  27. puts m.rjust( m.size/2 + v.size + 5 )
  28. end
  29. end
  30.  
  31.  
  32. def array_rot n , v
  33. case n
  34. when 0 , 360
  35. v
  36. when 90
  37. v.transpose.map(&:reverse)
  38. when 180
  39. v.map(&:reverse).reverse
  40. when 270
  41. v.map(&:reverse).transpose
  42. when 45
  43. array_rot45 v
  44. when 135
  45. array_rot45 v.reverse.transpose
  46. when 225
  47. array_rot45 v.map(&:reverse).reverse
  48. when 315
  49. array_rot45 v.map(&:reverse).transpose
  50. else
  51. p "err"
  52. end
  53. end
  54.  
  55. def array_rot_decode n , v
  56. case n
  57. when 0 , 360
  58. v
  59. when 90
  60. v.map(&:reverse).transpose
  61. when 180
  62. v.map(&:reverse).reverse
  63. when 270
  64. v.transpose.map(&:reverse)
  65. when 45
  66. array_rot45_decode v
  67. when 135
  68. array_rot45_decode(v.reverse).map(&:reverse)
  69. when 225
  70. array_rot45_decode v.map(&:reverse).reverse
  71. when 315
  72. array_rot45_decode(v).transpose.map(&:reverse)
  73. else
  74. p "err"
  75. end
  76. end
  77.  
  78. # ---------------------------------------------------------------------
  79.  
  80.  
  81. def recthit x1 , y1 , w1 , h1 , x2 , y2 , w2 , h2
  82. x1 + w1 > x2 && x1 < x2 + w2 && y1 + h1 > y2 && y1 < y2 + h2 ; end
  83. def f mm , x , y , n
  84. return mm if mm[x][y] != "0"
  85. def miko_neko mm , x , y , n
  86. miko_neko_sub n do | r |
  87. tmp = mm[x][y]
  88. mm[x][y] = "5"
  89. mm[x].sub!( r ){ "#{n}"*$1.size }
  90. mm[x].sub!("5",tmp)
  91. mm
  92. end
  93. mm
  94. end
  95. def miko_neko_sub n
  96. [ /(#{n}#{3^n}+5)/ , /(5#{3^n}+#{n})/ ].each do | r |
  97. yield r
  98. end
  99. end
  100. def transpose2 a ; a.replace a.map(&:chars).map(&:to_a).transpose.map(&:join) ; end
  101. miko_neko mm , x , y , n
  102. transpose2 miko_neko transpose2(mm) , y , x , n
  103.  
  104. #------------------naname----------------------
  105. def array_to_chars mm
  106. mm.map(&:chars).map(&:to_a)
  107. end
  108. def miko_array mm , x , y , n , ang , v
  109. miko_neko_sub n do | r |
  110. tmp = mm[x][y]
  111. mm[x][y] = "5"
  112. a = array_rot ang , array_to_chars( mm )
  113. a.map!(&:join)
  114. a[v].sub!( r ){ "#{n}"*$1.size }
  115. a[v].sub!("5",tmp)
  116. mm.replace array_rot_decode( ang , array_to_chars(a) ).map!(&:join)
  117. end
  118. end
  119. miko_array mm , x , y , n , 45 , x + y
  120. miko_array mm , x , y , n , 315 , x +7 -y
  121. end
  122. font = Font.new 20
  123. size = 30
  124. mm = [ "00000000" , "00000000" , "00000000" , "00021000" , "00012000" , "00000000" , "00000000" , "00000000" ,]
  125. Window.loop do
  126. exit if Input.keyPush? K_F9
  127. 64.times do | i | (k=i/8) ; (u=i%8)
  128. Window.drawFont k*size , u*size , %w!□ ○ ●![mm[k][u].to_i] , font , { color: [170,140,160 ] }
  129. if recthit( k*size , u*size , font.getWidth("□"), font.size, Input.mousePosX,Input.mousePosY,1,1 )
  130. f mm , k , u , 2 if Input.mousePush?(M_LBUTTON)
  131. f mm , k , u , 1 if Input.mousePush?(M_RBUTTON)
  132. end
  133. end
  134. end
  135.  
Runtime error #stdin #stdout #stderr 0.03s 8344KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- dxruby (LoadError)
	from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
	from prog.rb:2:in `<main>'