2 Replies - 1884 Views - Last Post: 11 February 2009 - 10:08 PM Rate Topic: -----

#1 Everlong   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-February 09

Print Paths of Number Grid

Posted 11 February 2009 - 07:09 PM

I need some help with a project. I'm trying to print out all possible combinations of a number grid.

For example:

1 3 2 5 4
2 4 3 1 5
5 3 4 2 3
4 3 1 5 2
5 3 4 1 2

The numbers are randomly generated. You start at the top of each column and then can either move down or diagonally down until you reach the bottom of any column. I need to find all of the possible number combinations. I'm stumped, any ideas?

EDIT: The numbers would probably be passed into the function as an array of nodes. And these nodes contain pointers to each of its 3 childs (center, left, and right) and its respective int value.

This post has been edited by Everlong: 11 February 2009 - 07:13 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Print Paths of Number Grid

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,234
  • Joined: 14-September 07

Re: Print Paths of Number Grid

Posted 11 February 2009 - 09:13 PM

Unless I'm misreading, a string permutation would solve this problem nicely: see here
Was This Post Helpful? 0
  • +
  • -

#3 Everlong   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-February 09

Re: Print Paths of Number Grid

Posted 11 February 2009 - 10:08 PM

Hi KYA,

I think you might have misread. The only combinations allowed begin at the top of a column and then move either down or diagonally down until it reaches the bottom row. I can't see a way to use permutations.
It is essentially like printing out all of the possible paths (from root to leaves) of a tree in which each node has three children (left-down, down, right-down).

If you did understand the problem correctly, could you elaborate on how to use a permutation with this problem?

This post has been edited by Everlong: 11 February 2009 - 10:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1