fork download
  1. require 'minitest/autorun'
  2.  
  3. F=
  4. ->i,z{i.split(?\n).map{|l|z.times.map{|y|l.size.times.map{|i|z.times.map{|x|c=l[i]
  5. z<y+2&&(l[i-1..i]=='_\\'||l[i..i+1]=='/_')&&o=?_
  6. (c<?!||(x==y&&c==?\\)||(z==y+1&&c>?^)||(x-~y==z&&c==?/))&&o=c
  7. o||' '}.join}.join.rstrip}-['']}.join ?\n}
  8.  
  9. describe '#F' do
  10. describe 'small diamond' do
  11.  
  12. def diamond
  13. ' __
  14. /_/\
  15. \_\/
  16. '
  17. end
  18.  
  19. def test_1
  20. assert_equal F[diamond, 1], ' __
  21. /_/\
  22. \_\/'
  23. end
  24.  
  25. def test_2
  26. assert_equal F[diamond, 2], ' ____
  27. / /\
  28. /___/ \
  29. \ \ /
  30. \___\/'
  31. end
  32.  
  33. def test_3
  34. assert_equal F[diamond, 3], ' ______
  35. / /\
  36. / / \
  37. /_____/ \
  38. \ \ /
  39. \ \ /
  40. \_____\/'
  41.  
  42. end
  43.  
  44. def test_4
  45. assert_equal F[diamond, 4], ' ________
  46. / /\
  47. / / \
  48. / / \
  49. /_______/ \
  50. \ \ /
  51. \ \ /
  52. \ \ /
  53. \_______\/'
  54. end
  55.  
  56. def test_5
  57. assert_equal F[diamond, 5], ' __________
  58. / /\
  59. / / \
  60. / / \
  61. / / \
  62. /_________/ \
  63. \ \ /
  64. \ \ /
  65. \ \ /
  66. \ \ /
  67. \_________\/'
  68. end
  69.  
  70. def test_6
  71. assert_equal F[diamond, 6], ' ____________
  72. / /\
  73. / / \
  74. / / \
  75. / / \
  76. / / \
  77. /___________/ \
  78. \ \ /
  79. \ \ /
  80. \ \ /
  81. \ \ /
  82. \ \ /
  83. \___________\/'
  84. end
  85. end
  86.  
  87. describe 'medium diamond' do
  88. def diamond
  89. ' ____
  90. /_/\_\
  91. /\_\/_/\
  92. \/_/\_\/
  93. \_\/_/'
  94. end
  95.  
  96. def test_1
  97. assert_equal F[diamond, 1], ' ____
  98. /_/\_\
  99. /\_\/_/\
  100. \/_/\_\/
  101. \_\/_/'
  102. end
  103.  
  104. def test_2
  105. assert_equal F[diamond, 2], ' ________
  106. / /\ \
  107. /___/ \___\
  108. /\ \ / /\
  109. / \___\/___/ \
  110. \ / /\ \ /
  111. \/___/ \___\/
  112. \ \ / /
  113. \___\/___/'
  114. end
  115.  
  116. def test_3
  117. assert_equal F[diamond, 3], ' ____________
  118. / /\ \
  119. / / \ \
  120. /_____/ \_____\
  121. /\ \ / /\
  122. / \ \ / / \
  123. / \_____\/_____/ \
  124. \ / /\ \ /
  125. \ / / \ \ /
  126. \/_____/ \_____\/
  127. \ \ / /
  128. \ \ / /
  129. \_____\/_____/'
  130. end
  131.  
  132. def test_4
  133. assert_equal F[diamond, 4], ' ________________
  134. / /\ \
  135. / / \ \
  136. / / \ \
  137. /_______/ \_______\
  138. /\ \ / /\
  139. / \ \ / / \
  140. / \ \ / / \
  141. / \_______\/_______/ \
  142. \ / /\ \ /
  143. \ / / \ \ /
  144. \ / / \ \ /
  145. \/_______/ \_______\/
  146. \ \ / /
  147. \ \ / /
  148. \ \ / /
  149. \_______\/_______/'
  150. end
  151.  
  152. def test_5
  153. assert_equal F[diamond, 5], ' ____________________
  154. / /\ \
  155. / / \ \
  156. / / \ \
  157. / / \ \
  158. /_________/ \_________\
  159. /\ \ / /\
  160. / \ \ / / \
  161. / \ \ / / \
  162. / \ \ / / \
  163. / \_________\/_________/ \
  164. \ / /\ \ /
  165. \ / / \ \ /
  166. \ / / \ \ /
  167. \ / / \ \ /
  168. \/_________/ \_________\/
  169. \ \ / /
  170. \ \ / /
  171. \ \ / /
  172. \ \ / /
  173. \_________\/_________/'
  174. end
  175.  
  176. def test_6
  177. assert_equal F[diamond, 6], ' ________________________
  178. / /\ \
  179. / / \ \
  180. / / \ \
  181. / / \ \
  182. / / \ \
  183. /___________/ \___________\
  184. /\ \ / /\
  185. / \ \ / / \
  186. / \ \ / / \
  187. / \ \ / / \
  188. / \ \ / / \
  189. / \___________\/___________/ \
  190. \ / /\ \ /
  191. \ / / \ \ /
  192. \ / / \ \ /
  193. \ / / \ \ /
  194. \ / / \ \ /
  195. \/___________/ \___________\/
  196. \ \ / /
  197. \ \ / /
  198. \ \ / /
  199. \ \ / /
  200. \ \ / /
  201. \___________\/___________/'
  202. end
  203. end
  204.  
  205.  
  206. describe 'big diamond' do
  207. def diamond
  208. ' ______
  209. /_/_/\_\
  210. /_/\_\/\_\
  211. /\_\/_/\/_/\
  212. \/_/\_\/_/\/
  213. \_\/_/\_\/
  214. \_\_\/_/'
  215. end
  216.  
  217. def test_1
  218. assert_equal F[diamond, 1], ' ______
  219. /_/_/\_\
  220. /_/\_\/\_\
  221. /\_\/_/\/_/\
  222. \/_/\_\/_/\/
  223. \_\/_/\_\/
  224. \_\_\/_/'
  225. end
  226.  
  227. def test_2
  228. assert_equal F[diamond, 2], ' ____________
  229. / / /\ \
  230. /___/___/ \___\
  231. / /\ \ /\ \
  232. /___/ \___\/ \___\
  233. /\ \ / /\ / /\
  234. / \___\/___/ \/___/ \
  235. \ / /\ \ / /\ /
  236. \/___/ \___\/___/ \/
  237. \ \ / /\ \ /
  238. \___\/___/ \___\/
  239. \ \ \ / /
  240. \___\___\/___/'
  241. end
  242.  
  243. def test_3
  244. assert_equal F[diamond, 3], ' __________________
  245. / / /\ \
  246. / / / \ \
  247. /_____/_____/ \_____\
  248. / /\ \ /\ \
  249. / / \ \ / \ \
  250. /_____/ \_____\/ \_____\
  251. /\ \ / /\ / /\
  252. / \ \ / / \ / / \
  253. / \_____\/_____/ \/_____/ \
  254. \ / /\ \ / /\ /
  255. \ / / \ \ / / \ /
  256. \/_____/ \_____\/_____/ \/
  257. \ \ / /\ \ /
  258. \ \ / / \ \ /
  259. \_____\/_____/ \_____\/
  260. \ \ \ / /
  261. \ \ \ / /
  262. \_____\_____\/_____/'
  263. end
  264.  
  265. def test_4
  266. assert_equal F[diamond, 4], ' ________________________
  267. / / /\ \
  268. / / / \ \
  269. / / / \ \
  270. /_______/_______/ \_______\
  271. / /\ \ /\ \
  272. / / \ \ / \ \
  273. / / \ \ / \ \
  274. /_______/ \_______\/ \_______\
  275. /\ \ / /\ / /\
  276. / \ \ / / \ / / \
  277. / \ \ / / \ / / \
  278. / \_______\/_______/ \/_______/ \
  279. \ / /\ \ / /\ /
  280. \ / / \ \ / / \ /
  281. \ / / \ \ / / \ /
  282. \/_______/ \_______\/_______/ \/
  283. \ \ / /\ \ /
  284. \ \ / / \ \ /
  285. \ \ / / \ \ /
  286. \_______\/_______/ \_______\/
  287. \ \ \ / /
  288. \ \ \ / /
  289. \ \ \ / /
  290. \_______\_______\/_______/'
  291. end
  292.  
  293. def test_5
  294. assert_equal F[diamond, 5], ' ______________________________
  295. / / /\ \
  296. / / / \ \
  297. / / / \ \
  298. / / / \ \
  299. /_________/_________/ \_________\
  300. / /\ \ /\ \
  301. / / \ \ / \ \
  302. / / \ \ / \ \
  303. / / \ \ / \ \
  304. /_________/ \_________\/ \_________\
  305. /\ \ / /\ / /\
  306. / \ \ / / \ / / \
  307. / \ \ / / \ / / \
  308. / \ \ / / \ / / \
  309. / \_________\/_________/ \/_________/ \
  310. \ / /\ \ / /\ /
  311. \ / / \ \ / / \ /
  312. \ / / \ \ / / \ /
  313. \ / / \ \ / / \ /
  314. \/_________/ \_________\/_________/ \/
  315. \ \ / /\ \ /
  316. \ \ / / \ \ /
  317. \ \ / / \ \ /
  318. \ \ / / \ \ /
  319. \_________\/_________/ \_________\/
  320. \ \ \ / /
  321. \ \ \ / /
  322. \ \ \ / /
  323. \ \ \ / /
  324. \_________\_________\/_________/'
  325. end
  326.  
  327. def test_6
  328. assert_equal F[diamond, 6], ' ____________________________________
  329. / / /\ \
  330. / / / \ \
  331. / / / \ \
  332. / / / \ \
  333. / / / \ \
  334. /___________/___________/ \___________\
  335. / /\ \ /\ \
  336. / / \ \ / \ \
  337. / / \ \ / \ \
  338. / / \ \ / \ \
  339. / / \ \ / \ \
  340. /___________/ \___________\/ \___________\
  341. /\ \ / /\ / /\
  342. / \ \ / / \ / / \
  343. / \ \ / / \ / / \
  344. / \ \ / / \ / / \
  345. / \ \ / / \ / / \
  346. / \___________\/___________/ \/___________/ \
  347. \ / /\ \ / /\ /
  348. \ / / \ \ / / \ /
  349. \ / / \ \ / / \ /
  350. \ / / \ \ / / \ /
  351. \ / / \ \ / / \ /
  352. \/___________/ \___________\/___________/ \/
  353. \ \ / /\ \ /
  354. \ \ / / \ \ /
  355. \ \ / / \ \ /
  356. \ \ / / \ \ /
  357. \ \ / / \ \ /
  358. \___________\/___________/ \___________\/
  359. \ \ \ / /
  360. \ \ \ / /
  361. \ \ \ / /
  362. \ \ \ / /
  363. \ \ \ / /
  364. \___________\___________\/___________/'
  365. end
  366. end
  367.  
  368. describe 'even bigger diamond' do
  369. def diamond
  370. ' ________
  371. /_/\_\_\_\
  372. /\_\/\_\_\_\
  373. /\/_/\/_/_/\_\
  374. /\/\_\/_/_/\/\_\
  375. \/\/_/\_\_\/\/_/
  376. \/\_\/_/\_\/_/
  377. \/\_\_\/_/_/
  378. \/_/_/_/_/'
  379. end
  380.  
  381. def test_1
  382. assert_equal F[diamond, 1], ' ________
  383. /_/\_\_\_\
  384. /\_\/\_\_\_\
  385. /\/_/\/_/_/\_\
  386. /\/\_\/_/_/\/\_\
  387. \/\/_/\_\_\/\/_/
  388. \/\_\/_/\_\/_/
  389. \/\_\_\/_/_/
  390. \/_/_/_/_/'
  391. end
  392.  
  393. def test_2
  394. assert_equal F[diamond, 2], ' ________________
  395. / /\ \ \ \
  396. /___/ \___\___\___\
  397. /\ \ /\ \ \ \
  398. / \___\/ \___\___\___\
  399. /\ / /\ / / /\ \
  400. / \/___/ \/___/___/ \___\
  401. /\ /\ \ / / /\ /\ \
  402. / \/ \___\/___/___/ \/ \___\
  403. \ /\ / /\ \ \ /\ / /
  404. \/ \/___/ \___\___\/ \/___/
  405. \ /\ \ / /\ \ / /
  406. \/ \___\/___/ \___\/___/
  407. \ /\ \ \ / / /
  408. \/ \___\___\/___/___/
  409. \ / / / / /
  410. \/___/___/___/___/'
  411. end
  412.  
  413. def test_3
  414. assert_equal F[diamond, 3], ' ________________________
  415. / /\ \ \ \
  416. / / \ \ \ \
  417. /_____/ \_____\_____\_____\
  418. /\ \ /\ \ \ \
  419. / \ \ / \ \ \ \
  420. / \_____\/ \_____\_____\_____\
  421. /\ / /\ / / /\ \
  422. / \ / / \ / / / \ \
  423. / \/_____/ \/_____/_____/ \_____\
  424. /\ /\ \ / / /\ /\ \
  425. / \ / \ \ / / / \ / \ \
  426. / \/ \_____\/_____/_____/ \/ \_____\
  427. \ /\ / /\ \ \ /\ / /
  428. \ / \ / / \ \ \ / \ / /
  429. \/ \/_____/ \_____\_____\/ \/_____/
  430. \ /\ \ / /\ \ / /
  431. \ / \ \ / / \ \ / /
  432. \/ \_____\/_____/ \_____\/_____/
  433. \ /\ \ \ / / /
  434. \ / \ \ \ / / /
  435. \/ \_____\_____\/_____/_____/
  436. \ / / / / /
  437. \ / / / / /
  438. \/_____/_____/_____/_____/'
  439. end
  440.  
  441. def test_4
  442. assert_equal F[diamond, 4], ' ________________________________
  443. / /\ \ \ \
  444. / / \ \ \ \
  445. / / \ \ \ \
  446. /_______/ \_______\_______\_______\
  447. /\ \ /\ \ \ \
  448. / \ \ / \ \ \ \
  449. / \ \ / \ \ \ \
  450. / \_______\/ \_______\_______\_______\
  451. /\ / /\ / / /\ \
  452. / \ / / \ / / / \ \
  453. / \ / / \ / / / \ \
  454. / \/_______/ \/_______/_______/ \_______\
  455. /\ /\ \ / / /\ /\ \
  456. / \ / \ \ / / / \ / \ \
  457. / \ / \ \ / / / \ / \ \
  458. / \/ \_______\/_______/_______/ \/ \_______\
  459. \ /\ / /\ \ \ /\ / /
  460. \ / \ / / \ \ \ / \ / /
  461. \ / \ / / \ \ \ / \ / /
  462. \/ \/_______/ \_______\_______\/ \/_______/
  463. \ /\ \ / /\ \ / /
  464. \ / \ \ / / \ \ / /
  465. \ / \ \ / / \ \ / /
  466. \/ \_______\/_______/ \_______\/_______/
  467. \ /\ \ \ / / /
  468. \ / \ \ \ / / /
  469. \ / \ \ \ / / /
  470. \/ \_______\_______\/_______/_______/
  471. \ / / / / /
  472. \ / / / / /
  473. \ / / / / /
  474. \/_______/_______/_______/_______/'
  475. end
  476.  
  477. def test_5
  478. assert_equal F[diamond, 5], ' ________________________________________
  479. / /\ \ \ \
  480. / / \ \ \ \
  481. / / \ \ \ \
  482. / / \ \ \ \
  483. /_________/ \_________\_________\_________\
  484. /\ \ /\ \ \ \
  485. / \ \ / \ \ \ \
  486. / \ \ / \ \ \ \
  487. / \ \ / \ \ \ \
  488. / \_________\/ \_________\_________\_________\
  489. /\ / /\ / / /\ \
  490. / \ / / \ / / / \ \
  491. / \ / / \ / / / \ \
  492. / \ / / \ / / / \ \
  493. / \/_________/ \/_________/_________/ \_________\
  494. /\ /\ \ / / /\ /\ \
  495. / \ / \ \ / / / \ / \ \
  496. / \ / \ \ / / / \ / \ \
  497. / \ / \ \ / / / \ / \ \
  498. / \/ \_________\/_________/_________/ \/ \_________\
  499. \ /\ / /\ \ \ /\ / /
  500. \ / \ / / \ \ \ / \ / /
  501. \ / \ / / \ \ \ / \ / /
  502. \ / \ / / \ \ \ / \ / /
  503. \/ \/_________/ \_________\_________\/ \/_________/
  504. \ /\ \ / /\ \ / /
  505. \ / \ \ / / \ \ / /
  506. \ / \ \ / / \ \ / /
  507. \ / \ \ / / \ \ / /
  508. \/ \_________\/_________/ \_________\/_________/
  509. \ /\ \ \ / / /
  510. \ / \ \ \ / / /
  511. \ / \ \ \ / / /
  512. \ / \ \ \ / / /
  513. \/ \_________\_________\/_________/_________/
  514. \ / / / / /
  515. \ / / / / /
  516. \ / / / / /
  517. \ / / / / /
  518. \/_________/_________/_________/_________/'
  519. end
  520.  
  521. def test_6
  522. assert_equal F[diamond, 6], ' ________________________________________________
  523. / /\ \ \ \
  524. / / \ \ \ \
  525. / / \ \ \ \
  526. / / \ \ \ \
  527. / / \ \ \ \
  528. /___________/ \___________\___________\___________\
  529. /\ \ /\ \ \ \
  530. / \ \ / \ \ \ \
  531. / \ \ / \ \ \ \
  532. / \ \ / \ \ \ \
  533. / \ \ / \ \ \ \
  534. / \___________\/ \___________\___________\___________\
  535. /\ / /\ / / /\ \
  536. / \ / / \ / / / \ \
  537. / \ / / \ / / / \ \
  538. / \ / / \ / / / \ \
  539. / \ / / \ / / / \ \
  540. / \/___________/ \/___________/___________/ \___________\
  541. /\ /\ \ / / /\ /\ \
  542. / \ / \ \ / / / \ / \ \
  543. / \ / \ \ / / / \ / \ \
  544. / \ / \ \ / / / \ / \ \
  545. / \ / \ \ / / / \ / \ \
  546. / \/ \___________\/___________/___________/ \/ \___________\
  547. \ /\ / /\ \ \ /\ / /
  548. \ / \ / / \ \ \ / \ / /
  549. \ / \ / / \ \ \ / \ / /
  550. \ / \ / / \ \ \ / \ / /
  551. \ / \ / / \ \ \ / \ / /
  552. \/ \/___________/ \___________\___________\/ \/___________/
  553. \ /\ \ / /\ \ / /
  554. \ / \ \ / / \ \ / /
  555. \ / \ \ / / \ \ / /
  556. \ / \ \ / / \ \ / /
  557. \ / \ \ / / \ \ / /
  558. \/ \___________\/___________/ \___________\/___________/
  559. \ /\ \ \ / / /
  560. \ / \ \ \ / / /
  561. \ / \ \ \ / / /
  562. \ / \ \ \ / / /
  563. \ / \ \ \ / / /
  564. \/ \___________\___________\/___________/___________/
  565. \ / / / / /
  566. \ / / / / /
  567. \ / / / / /
  568. \ / / / / /
  569. \ / / / / /
  570. \/___________/___________/___________/___________/'
  571. end
  572. end
  573.  
  574.  
  575. end
Success #stdin #stdout 0.13s 8680KB
stdin
Standard input is empty
stdout
Run options: --seed 41550

# Running tests:

........................

Finished tests in 0.080147s, 299.4485 tests/s, 299.4485 assertions/s.

24 tests, 24 assertions, 0 failures, 0 errors, 0 skips