Counting Cards Solution #3

Hi!

Did I understand correctly that the third solution used a trick with type coercion? 10 is compared to “10” converted to num, and JQKA is equated to “10” like a string?

I don’t see any type coercion in the third solution.
Which line of code are you reading?

Edit: I think you are asking about the string comparison card >= “10”
So this returns true if the lexicographical order of the string in card is greater than it equal to the string “10”.
It just so happens that all alphabetical letters will be considered as “higher” than “10”. So that is how this works.

Thanks, the explanation was easier. But still, it’s a small trick to use encoding properties in this way.

yes you have to know about the ascii table order