From: "James K." Date: 2011-05-25T15:08:50+09:00 Subject: Please Help: Recursion and Array Problem (Noob) The explanation of what I'm trying to do are noted in the comments... I'm freakin' lost... the really big issue is determining how to test mines that have been blown up against remaining mines... you'll find that comment smack dab in the middle... today is the first day I've ever used Ruby, I appreciate the help: ## Load data from file into Python mines_data = file.open('example_mines.txt', 'r') ## function to determine if a mine blows up another mine def within_blast_radius(x1, y1, blast_radius, x2, y2) ((x1 - x2) ** 2 + (y1 - y2) ** 2) <= (blast_radius ** 2) end ## define variables to keep track of outputs qty_mines_blown = 0 max_mines_blown = 0 ## define a multidimensional array with x number of rows and 3 columns master_array = array.new(r) {Array.new(3)} cnt = 0 starting_mine = master_array [cnt] # For Each Mine do this: master_array.each = {|r| # within_blast_radius(x1, y1, bomb_radius, x2, y2) ## Tests to see if bomb x1, y1 blows up bomb x2, y2 master_array.each{|r| if within_blast_radius(master_array[cnt][1], master_array[cnt][2], master_array[cnt][3], master_array[r][1], master_array[r][2]) = True qty_mines_blown += 1 ## code to test mines that have been blown up against remaining mines endif } if qty_mines_blown > max_mines_blown max_mines_blown = qty_mines_blown answers_array.delete answers_array[0] = starting_mine elseif qty_mines_blown = max_mines_blown answers_array.next_line = starting_mine endif cnt += 1 } print "The maximum number of mines that can be blown up from triggering just one mine is: " print max_mines_blown print "The location and blast radius of mine(s) that can trigger the blast is :" print elements in answers_array -- Posted via http://www.ruby-forum.com/.