0
\$\begingroup\$

Write a programs that reads the file Smart.txt & outputs the order from Most Smart to Least smart.

--Smart.txt
Sam John
John Michael
Taylor Sam

In the above text file the person on the left is smarter than the person on the right. So we have to finally print the output as follows:

Taylor Sam John Michael

There can be multiple entries of name but we can always deduce who is the smarter than whom.

Another Example would be:

--Smart.txt
Hank Jane
Hal Scott
Jane Scott
Aaron Hank
Tori Hal
Hank Tori
Hal Jane

Output:

Aaron Hank Tori Hal Jane Scott

The shortest code in bytes wins.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ I can figure out what you're asking, but it really isn't immediately obvious. You should probably specify this more clearly. \$\endgroup\$ Dec 7 '15 at 14:10
  • 1
    \$\begingroup\$ What happens if there is a loop in smartness (In your example, if the second line is John Taylor)? What if there are no entries? \$\endgroup\$ Dec 7 '15 at 14:15
  • 1
    \$\begingroup\$ Welcome to PPCG.SE! Great first post! As SuperJedi224 and NathanMerrill stated, the question is not entirely clear. You should follow their suggestions, and if the question is still unclear, try sandboxing it. The sandbox is our way to get community feedback on challenges before their are asked. Happy golfing! \$\endgroup\$
    – GamrCorps
    Dec 7 '15 at 14:20
  • \$\begingroup\$ @NathanMerrill As I mentioned in the 2nd last line, you will always be able to deduce who will be the smartest. I'll add another example in my question. \$\endgroup\$ Dec 7 '15 at 14:20
  • \$\begingroup\$ @PrashastMehra then, if it is always clear, then my golf simply needs to remove redundant information, and then print out the adjacencies in order. (In your 2nd example, the first 2 lines are redundant) \$\endgroup\$ Dec 7 '15 at 14:28

Browse other questions tagged or ask your own question.