From: Gregory Brown Date: 2005-12-11T02:48:56+09:00 Subject: Re: Logic... On 12/10/05, StarLion wrote: > def MakeBoard > rcount = 0 > puts "Push enter, then begin input. (For Input Format Compliance, extra > enter key is necessary)" > gets > board = [[],[],[],[],[],[],[],[],[]] > 9.times do > instr = gets > board[rcount] = > [instr[0].to_i,instr[1].to_i,instr[2].to_i,instr[3].to_i,instr[4].to_i,instr[5].to_i,instr[6].to_i,instr[7].to_i,instr[8].to_i] > rcount += 1 > puts board[rcount] > end #do > return board > end #MakeBoard > > Is my logic flawed here? the puts doesnt actually output anything. I think this is a little cleaner: make_board returns a board split by spaces. i.e. you enter the rows like 1 0 1 0 2 1 8 2 1 1 2 1 1 9 1 9 1 9 ... The method returns the actual array, and I map and join for pretty printing in the puts. Tweak as needed, code below. ------------------------------------------------ def make_board board = [] puts "input rows, seperated by spaces:" 9.times { board << gets.split(" ")[0..8].map { |e| e.to_i } } return board end puts make_board.map { |r| r.join(" ") }.join("\n")