Point value -> 2
Cost -> 5B
3G
Card Color <- G
Notation: Red – R, Blue – U, Black – B, Green – G, White – W
In this game, players will have a set of colored tokens (Red, Blue, Green, Black, White). Their objective is to purchase cards using those tokens.
Cards will have a cost of some number of the above listed colored tokens. For example, a card can cost 2 blue tokens and 1 green token. If a player has 2 blue tokens and 1 red token, they cannot buy the card because they do not have the necessary green currency.
The goal for this part is to implement a function that determines if a card can be purchased by a particular player given the current state of the game. How you choose to represent the purchase, game state, and function signature is completely up to you.
这道题要求你设计一种表示玩家和卡牌状态的数据结构,并实现一个“是否可购买”的判断函数。核心思路是把卡牌的花费抽象成五种颜色代币的需求表,再和玩家当前持有的代币数量逐项比较;只要任意一种颜色不足,就无法购买。题目没有强制规定函数签名,因此更考察你对建模、字典 / 哈希表表示以及条件判断逻辑的设计能力。