Dwarfs standing on the shoulders of giants puzzle discussion

yes I submitted, loaded the problem and re-submitted many times with no luck. There could also be a problem with my algorithm and not your test case but as a few people suggested there is no way to understand the issue without knowing what “complex hierarchy” means.

A few more sidenotes:

  1. I get the same results regardless of whether in.nextLine is present or commented either before or inside the loop.
  2. If I completely reload the solution by hitting the circular arrow button, instead of resetting the input algorithm of the problem I get a dummy “Hello world” code. This happens for all problems and all languages.

I also come up with this (not too soon though).
Each time you get pair of who influenced who, find corresponding nodes (small class in my case) in a dictionary (or create new).
Then show that who has an influence of who (in my case i had .Influence method). In the end you will have dictionary of N elements, you just get items with (already pre-calculated) most influence power.

People who are having troubles with the “complex hierarchy” test case, try validating the following graph by your solution: (1,2),(2,3),(2,4),(3,4),(4,5) and make sure that the result is 5.
It would be nice if it was included as one of the test cases in IDE.


I’m unable to pass the “More complex hierarchy”.
I did try (1,2),(2,3),(2,4),(3,4),(4,5) = result is 5. But test didn’t pass.

1 Like

Just a hint, you need to calculate the lenght from all roots, this mean from each person that is not relation of someone else.



I passed everything except the “Arbitrary Indexes”.
But I still don’t understand what this constraint is.
I read the description countless times, but still I don’t get it.

Does someone has a clue on this?


Just for info, I found out why !!!In my first try, I chose to use byte instead of int for the elements.
And the ‘Arbitrary Indexes’ are elements out of 0-255 range.

Good to know :smile:

will check about that but I’m pretty sure it’s not my problem … :frowning:

Hi, I had the same problem.
Think about the title of the test.
“Arbitrary indexes” means that the indexes are chosen “randomly”.
It means that the names of the vertices should not be used to determine the size of your data structure; e.g., you can have such an input :
7649 98
98 9
9 54

You have 4 different vertices, yet in your code you may be considering that you actually have 7649 vertices; which would make the program really inefficient.

Same here (PHP)

Py also passes this, but not test case.
(implementation based on Dijkstra)

In the Java version, the first influence line is empty in every example.

Hello, my solution has passed all tests but “More complex hierarchy”. I read posts above, so I tried re-submit my solution several times, in order to validate again after issue with in.txt was resolved. Program language is C#. I checked, that case (1,2),(2,3),(1,3) returns 3, not 2. Can you please share with in.txt and out.txt for this test or share any ideas what differ that test from all other tests?

Thank you in advance

This worked for the complex hierarchy. Thank you very much. I don’t think i would have found it without this hint.

Something is wrong with the validator for A Well for C++. I got all the tests right with C++ the first time except A Well. Several alternate algorithms didn’t work as well. I ported my code to Python and it worked. Hmmm…

I’ve got 100% using C++. You just have to find the longest path from the root.

Me too so no problem with c++ here, you might want to recheck your algorithms @rbzane

Same with the ‘More complex hierarchy’ test solving in Dart.

It’d be great, if this puzzle could provide more tests :smile:

Then you should first find the root and you aren’t sure if there are multiple roots? Can we asume the input is only one Directed Acyclic Graph?

It’s possible that there are many roots.

Hi. I have the same problem with ‘More complex hierarchy’ test, My algorithm achieve all other tests (including (1,2)(2,3)(2,4)(3,4)(4,5) = 5 as well). Can you share the input and output of this test (it would be very helpful, to find out what is wrong)? Language is C# and I tried more time to recheck my algorithm.