Problem 85 sorting by Y and X

Back to Problem Solutions forum

ecolog_veteran     2019-12-02 16:14:29
User avatar

I have a problem with stars' sorting after calculation of their coordinates after rotation. So, how to sort the stars correctly in this task?

Rodion (admin)     2020-01-03 13:05:11
User avatar

Hi Friend!

Not sure what exactly problem you have. Let me try to rephrase. If the star has Y coordinate less than another, it should appear earlier in the output.

In case if two stars have the same Y coordinate, the one with smaller X should appear earlier.

Hopefully I remember this correctly.

omsarmiento1953     2023-01-11 03:58:19

I fail to understand this.

I thought I only needed to sort the Xs and Ys raw. Y as primary key. X as secondary key. Apparently, it's not the case here.

There seem to be a need to process the given Xs and Ys for a new Xs and Ys.

Can you point me to resources to better understand this problem?

Thanks.

zelevin     2023-01-11 05:57:24

You understand the sorting correctly, but before sorting you need to rotate the whole map by the requested number of degrees.

omsarmiento1953     2023-01-11 19:21:29

I got it!

My issue was I didn't read the problem well enough.

I missed the part where it mentioned the angle and rotation.

Thank you, Zelevin.

You helpeed me get it right.

Thanks!!

Please login and solve 5 problems to be able to post at forum