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 problem indicates that the definition of the queens seeing each other diagnonally is "lie in a line inclined 45 degrees or 135 degrees to the base of board." then the example of an invalid solution is:
7
1 3 5 7 2 4 6
This is not right. The sequence "1 3 5 7" represent a 26.565 degree line, not a 45 degree line. This is because the slope is 2 columns to each 1 row. A 45 degree line would have a slope of 1 column for each row, or a sequence like:
7
1 2 3 4 7 6 5
Please confirm that the scoring engine checks strictly for a 45 degree line, or does it check for three queens sequenced with the same slope line? If it shecks for the same slope line, does that imply the following sequence is also wrong:
7
1 4 7 2 5 3 6
??
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Spies, Revised
You are viewing a single comment's thread. Return to all comments →
The problem indicates that the definition of the queens seeing each other diagnonally is "lie in a line inclined 45 degrees or 135 degrees to the base of board." then the example of an invalid solution is:
7
1 3 5 7 2 4 6
This is not right. The sequence "1 3 5 7" represent a 26.565 degree line, not a 45 degree line. This is because the slope is 2 columns to each 1 row. A 45 degree line would have a slope of 1 column for each row, or a sequence like:
7
1 2 3 4 7 6 5
Please confirm that the scoring engine checks strictly for a 45 degree line, or does it check for three queens sequenced with the same slope line? If it shecks for the same slope line, does that imply the following sequence is also wrong:
7
1 4 7 2 5 3 6
??