Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # generate 10 ttt with rand Xs & Os
  2.  
  3. takeaway
  4. 1. for the space in between each ttt, puts (outside the loop, not inside the loop)
  5.  
  6. ```ruby
  7.  
  8. def gen_ttt
  9.  
  10. a = ("X"*4 + "O"*5 ).split(//)
  11. b = Array.new(3){Array.new(a.sample(3))}
  12.  
  13. ttt =
  14. for i in 1..10
  15. b.each do |row|
  16. p row
  17. end
  18. puts # instead p "\n" for space
  19. end
  20.  
  21. return ttt
  22.  
  23. end
  24.  
  25. puts gen_ttt
  26.  
  27.  
  28.  
  29.  
  30. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement