How is the rank earned at the end of a level calculated?

I assumed that is was based on score, but then I beat a level in less moves but with a lower score and received a higher rank. If the rank is based on remaining moves, just like the pokemon's catchability, what is the purpose of receiving a score?
Best Answer
The rank is based on the number of moves left after dealing enough damage to the Pokemon you are playing against. I take it as a rule of thumb for, the regular levels, that half the given moves give S rank (rounded up if the moves is odd; e.g. if you have 15 moves, using 8 moves or lower and complete the stage gives you S), and similar for time based levels, using half the given time will give you S.
The score on regular levels might not mean much to the player. But this score can be used in online competitions. The last one as of today was a timed level with 1 minute to get a highest score against MegaCharizard Y and the players are ranked based off their scores, which then is used to determine who gets prizes and who don't.
Pictures about "How is the rank earned at the end of a level calculated?"



Rank of matrix
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pavel Bak, MART PRODUCTION, Ketut Subiyanto, cottonbro