We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The best answer here, unfortunately, is "wrong" as per the simulator. Here's why: The top 3 results for the alleged "correct answer" do not display the best bang for the buck for a given wand of high power and age (look at the second result)
1038 496 4789 10
1130 494 9439 10
1315 492 4126 10
I wrote the following query, which makes sense, achieves the goal of the question like so:
SELECT w.id, p.age, w.coins_needed, w.power
FROM Wands w
INNER JOIN Wands_Property p
ON p.code = w.code
WHERE p.is_evil = 0
ORDER by w.power DESC, p.age DESC, w.coins_needed
which results in (for the first 3 rows):
1038 496 4789 10
1303 496 6678 10
1130 494 9439 10
Note the second row. My query correctly orders it - note that, on the second row, the number of galleons for an older level 10 wand is less than the "correct" answer.
This question should be removed from the simulator as the "correct" answer is patently wrong!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ollivander's Inventory
You are viewing a single comment's thread. Return to all comments →
The best answer here, unfortunately, is "wrong" as per the simulator. Here's why: The top 3 results for the alleged "correct answer" do not display the best bang for the buck for a given wand of high power and age (look at the second result)
1038 496 4789 10
1130 494 9439 10
1315 492 4126 10
I wrote the following query, which makes sense, achieves the goal of the question like so:
SELECT w.id, p.age, w.coins_needed, w.power FROM Wands w INNER JOIN Wands_Property p ON p.code = w.code WHERE p.is_evil = 0 ORDER by w.power DESC, p.age DESC, w.coins_needed
which results in (for the first 3 rows):
1038 496 4789 10
1303 496 6678 10
1130 494 9439 10
Note the second row. My query correctly orders it - note that, on the second row, the number of galleons for an older level 10 wand is less than the "correct" answer.
This question should be removed from the simulator as the "correct" answer is patently wrong!