From: StarLion Date: 2005-12-10T06:35:32+09:00 Subject: Unspecified Syntax Error def MakeBoard rcount = 0 puts "Push enter, then begin input. (For Input Format Compliance, extra enter key is necessary)" gets board = [0,0,0,0,0,0,0,0,0] 9.times do instr = gets board[rcount] = [instr[0],instr[1],instr[2],instr[3],instr[4],instr[5],instr[6],instr[7],instr[8]] rcount += 1 end return board end def CheckBoard(board) complete = 1 #Is the puzzle complete? problems = 0 #Are there any problems? #first, rows. h = 0 9.times do g = 0 group = [0,0,0,0,0,0,0,0,0] 9.times do if board[h][g] == "." group[g] = 0 complete = 0 else group[g] = board[h][g] end end problems = VerifyGroup(group) #puts "Row " + h.to_s + " Problems? " + problems.to_s end #end Row Check #next, columns. h = 0 9.times do g = 0 group = [0,0,0,0,0,0,0,0,0] 9.times do if board[g][h] == "." group[g] = 0 complete = 0 else group[g] = board[g][h] end end problems = VerifyGroup(group) #puts "Col " + h.to_s + " Problems? " + problems.to_s end ##end Col Check ##Finally, the tricky one... the Boxes.. startx = 0 starty = 0 curx = 0 cury = 0 count = 0 group = [0,0,0,0,0,0,0,0,0] 3.times do #Row Blocks 3.times do #Cols Blocks 3.times do #Rows of Block 3.times do #Cols of Block if board[curx][cury] == "." group[count] = 0 else group[count] = board[curx][cury] end curx += 1 end curx = startx cury += 1 end #We now have a 3x3 block. Verify Data. problems = VerifyGroup(group) #puts "Box " + startx.to_s + "," + starty.to_s + " Problems? " + problems.to_s count = 0 startx += 3 cury = starty curx = startx end starty += 3 startx = 0 cury = starty curx = startx end #Resolve the output. if problems == 0 if complete == 1 $output = $output + "You've done it!\n" else $output = $output + "Looking good so far...\n" end else $output = $output + "You've got a problem.\n" end end #FINALLY! def VerifyGroup(group) #logic for Check flag = 0 check = [0,0,0,0,0,0,0,0,0,0] group.each do |num| if check[num] == 0 && num != 0 check[num] = 1 else if num == 0 check[0] = 0 else flag = 1 end num += 1 end return flag end $output = "" n = gets n.to_i.times do board = MakeBoard() CheckBoard(board) puts $output end Throws unspecified "Syntax Error" on 126 (last line of the code - 'end')... no idea what's going wrong? -- Posted via http://www.ruby-forum.com/.