CodeGolf: Find the Unique Paths
Posted
by
st0le
on Stack Overflow
See other posts from Stack Overflow
or by st0le
Published on 2010-12-27T09:10:02Z
Indexed on
2010/12/29
2:53 UTC
Read the original article
Hit count: 338
Here's a pretty simple idea, in this pastebin I've posted some pair of numbers. These represent Nodes of a directed graph. The input to stdin
will be of the form, (they'll be numbers, i'll be using an example here)
c d
q r
a b
b c
d e
p q
so x y
means x
is connected to y
(not viceversa)
There are 2 paths in that example. a->b->c->d->e
and p->q->r
.
You need to print all the unique paths from that graph The output should be of the format
a->b->c->d->e
p->q->r
Notes
- You can assume the numbers are chosen such that one path doesn't intersect the other (one node belongs to one path)
- The pairs are in random order.
- They are more than 1 paths, they can be of different lengths.
- All numbers are less than 1000.
If you need more details, please leave a comment. I'll amend as required.
Shameless-Plug
For those who enjoy Codegolf, please Commit at Area51 for its very own site:) (for those who don't enjoy it, please support it as well, so we'll stay out of your way...)
© Stack Overflow or respective owner