Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Get same position value in 2nd array

by muba (Priest)
on Dec 22, 2012 at 01:10 UTC ( [id://1009966]=note: print w/replies, xml ) Need Help??


in reply to Get same position value in 2nd array

A good way to approach a problem like this, and you don't know how, is to think how you would do it in real life and then tell the computer to to that exact same thing.

So we need a simile here.

You have, in front of you, a partly filled in crosswords puzzle. This is array 1. Your friend, whom you're on the phone with, has the exact same crosswords puzzle, but still entirely blank. This is array 2. What you and your friend want, is to solve this crossword puzzle over the phone but you want to be "on the same page", so the two of you have decided that you will give him all the answers you've already found.

How would you do this? You would walk through your answers and using their numbers as a reference, you relay the words you've found. So what you would say would sound like this: "One horizontal is monkey. Two vertical is bisshop. Fourty-six horizontal is mountain."

In other words, as you iterate over array 1, you keep track of the "position" you're at, and then use that to do the corresponding position in array 2 &mdash in this case, tell your friend to fill in the value you have at that position.

Which is exactly what BrowserUk and blue_cowdawg are doing above, here and here.

  • Comment on Re: Get same position value in 2nd array

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1009966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found