首页 » assignment辅导 » Python代写 | Function Writing Python Card Game

Python代写 | Function Writing Python Card Game

本次澳洲代写主要为Python卡牌游戏相关的assignment

Q1

Write a function called phazed_group_type that takes the following single argument:

group

A group of cards in the form of a list, each element of which is a 2-character string with the value (drawn from ‘234567890JQKA’) followed by the suit (drawn from ‘SHDC’), e.g. [‘2C’‘2S’‘2H’] represents a group of three cards, made up of the Two of Clubs, the Two of Spades, and the Two of Hearts.

The function should return a sorted list of integers indicating card combination types as specified below, in the case that group is a valid instance of one or more of the following combinations of cards (and the empty list in the instance that it doesn’t correspond to any valid card combination). Note that the combination of cards in its entirety must satisfy the requirements of the combination definition, such that [‘2C’‘2C’‘4C’‘KC’‘9C’‘AH’‘JC’] is not a valid set of three cards of the same value, e.g., as it is made up of seven cards (despite the fact that it contains [‘2C’‘2C’‘AH’] which is a valid set of three cards of the same value).

1

set of three cards of the same value, e.g. [‘2C’‘2S’‘2H’] represents a set of three Twos. Note that the set may include Wilds, but must include at least two “natural” cards (i.e. non-Wild cards), which define the value. Note also that the sequence of the cards is not significant for this group type.

2

set of seven cards of the same suit, e.g. [‘2C’‘2C’‘4C’‘KC’‘9C’‘AH’‘JC’] represents a set of seven Clubs. Note that the set may include Wilds (as we see in our example, with the Ace of Hearts), but must include at least two “natural” cards (i.e. non-Wild card), which define the suit. Note also that the sequence of the cards is not significant for this group type.

3

set of four cards of the same value, e.g. [‘4H’‘4S’‘AC’‘4C’] represents a set of four Fours. Note that the set may include Wilds (as we see in our example, with the Ace of Clubs), but must include at least two “natural” cards (i.e. non-Wild cards), which define the value. Note also that the sequence of the cards is not significant for this group type.

4

run of eight cards, e.g. [‘4H’‘5S’‘AC’‘7C’‘8H’‘AH’‘0S’‘JC’] represents a run of eight cards. Note that the card combination may include Wilds (as we see in our example, with the Ace of Clubs standing in for a Six and the Ace of Hearts standing in for a Nine), but must include at least two “natural” cards (i.e. non-Wild cards). Note also that the sequence of the cards is significant for this group type, and that [‘4H’‘5S’‘AC’‘8H’‘7C’‘AH’‘0S’‘JC’], e.g., is not a valid run of eight, as it is not in sequence.

5

run of four cards of the same colour, e.g. [‘4H’‘5D’‘AC’‘7H’] represents a run of four Red cards. Note that the card combination may include Wilds (as we see in our example, with the Ace of Clubs standing in for a Red Six), but must include at least two “natural” cards (i.e. non-Wild cards), which define the colour. Note also that the sequence of the cards is significant for this group type, and that [‘4H’‘5D’‘7H’‘AC’] is not a valid run of four cards of the same colour, as it is not in sequence.

6

34-accumulation of cards, that is an accumulation of cards totalling 34 in value, e.g. [‘KS’‘0D’‘8C’‘3S’]. Note that for accumulations, Aces do not function as Wilds, and simply take the value 1.

7

34-accumulation of cards of the same colour, that is an accumulation of cards of the same colour totalling 34 in value, e.g. [‘KS’‘0C’‘8C’‘3S’]. Note that for accumulations, Aces do not function as Wilds, and simply take the value 1.

 

Example

>>> phazed_group_type([‘2C’, ‘2S’, ‘2H’])

[1]

>>> phazed_group_type([‘2C’, ‘2C’, ‘4C’, ‘KC’, ‘9C’, ‘AH’, ‘JC’])

[2]

>>> phazed_group_type([‘4H’, ‘4S’, ‘AC’, ‘4C’])

[3]

>>> phazed_group_type([‘4H’, ‘5S’, ‘AC’, ‘7C’, ‘8H’, ‘AH’, ‘0S’, ‘JC’])

[4]

>>> phazed_group_type([‘4H’, ‘5D’, ‘AC’, ‘7H’])

[5]

>>> phazed_group_type([‘KS’, ‘0D’, ‘8C’, ‘3S’])

[6]

>>> phazed_group_type([‘KS’, ‘0C’, ‘8C’, ‘3S’])

[6, 7]

>>> phazed_group_type([‘2C’, ‘2C’, ‘4C’, ‘KC’, ‘9C’, ‘AS’, ‘3C’])

[2, 6, 7]

>>> phazed_group_type([‘4H’, ‘5D’, ‘7C’, ‘AC’])

[]


程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipnxx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank