Counting Cards; I dont understand it at all, maybe coding isnt for me

I apparently haven’t learned anything this entire section because I get to this section and have no idea what to do and even after I saw the answer I can’t even fathom how anyone would get to this answer. Could someone explain to me this part and what every piece means. I am starting the reconsider going through this FCC at all after this…