I’m stumped. Worked on this problem for over three hours. I created an
array:
current_state = [3, 1, 6, 5, 2, 0, 4, 7, 8]
and
puts "Current_state.index(0) = " + current_state.index(0).to_s displays
a 5, as would be expected
puts "Length of current_state array = " + current_state.length.to_s
displays a 9, as expected
I defined a Priority Queue to create an ascending queue with:
open_queue = PQueue.new(proc{|x,y| x[0][0]<y[0][0]})
Then I push it into the Priority Queue with four other objects:
open_queue.push([[hv], [node_level], [direction_of_prior_move],
[current_state], [parent_node]])
but when later on I pop it out of the open_queue
removed_entry = []
removed_entry = open_queue.pop
and then move it back to current_state
current_state = removed_entry[3].dup <== I’ve tried this
with
and without the dup
current_state appears to be an array with one entry of “316520478”
puts "Current_state = " + current_state.to_s
==>
316520478 so clearly this is the value it has
puts "Class of Current_state = " + current_state.class.to_s ==>
Array so clearly it is still an array
If I execute the index function again it gives a nil value, as you would
expect with one 9 digit number in the array
I’ve tried with and without the quotes:
puts "Current_state.index(0) = " + current_state.index(“0”).to_s
and
puts "Current_state.index(0) = " + current_state.index(0).to_s
and
puts "Length of current_state array = " + current_state.length.to_s
displays a value of 1, confirming that it has become a single nine digit
number. If the updated array has only one entry in it, of course it
would
not be a 0 or “0” or any value but even “316520478” returns nothing, not
a
zero, which is strange.
I need to have the current_state array stay as an array of 9 single
digit
numbers.
What am I ignoring? How am I changing the nature of the current_state
array
when I push or pop it into or from the queue? I need to have an array
with
9 separate digits in it so I can index them.
Help!
No Sam