受到像这样的硅谷“三个逗号俱乐部”场景的启发,在这一挑战中,您将告诉十个人每个人所属的“逗号俱乐部”。
如果您不熟悉“逗号俱乐部”一词,请让我解释一下:如果您拥有的钱在$ 1,000.00到$ 999,999.99之间,则您就是一个逗号俱乐部;如果您的帐户价格在$ 1,000,000.00到$ 999,999,999.99之间,则您在两个逗号俱乐部中;这些“俱乐部”通过三逗号俱乐部重复出现,因为地球上没有一个人拥有超过一万亿美元的资产(日元很快就会变成另一个故事)。因此,根据美国和英国最常见的标记标准,您的银行帐户中的逗号数表示您所属的逗号俱乐部。相同的“逗号”规则适用于负数(尽管您不希望成为负逗号俱乐部):负数(包括在内)[-0.01,-999。
测试用例
Friend Amount
John 100000
Jamie 0.05
Kylie 1549001.10
Laura 999999999.99
Russ 986000000
Karla 1
Reid 99.99
Mark 999.99
Manson 1000.01
Lonnie 999999999999.00
Nelly -123.45
正确的答案:
John is in the 1-comma club.
Jamie is in the 0-comma club.
Kylie is in the 2-comma club.
Laura is in the 2-comma club.
Russ is in the 2-comma club.
Karla is in the 0-comma club.
Reid is in the 0-comma club.
Mark is in the 0-comma club.
Manson is in the 1-comma club.
Lonnie is in the 3-comma club.
Nelly is in the 0-comma club.
无论您需要获得friends阵列的任何阵列设置,amounts阵列都不计入您的分数。因此,对于Python,以下代码不计算在内:
f = ['John', 'Jamie', 'Kylie', 'Laura', 'Russ', 'Karla', 'Reid', 'Mark', 'Manson', 'Lonnie']
a = ['100000', '0.05', '1549001.10', '999999999.99', '986000000', '1', '99.99', '999.99', '1000.01', '999999999999.00']
编辑:请参阅修改后的测试用例
我从测试用例中删除了实际的字符串逗号,这使事情变得有些困难,而不是仅仅计算逗号。
-$1,234.56也将在1-逗号俱乐部中?
"<name> is in the <number of commas>-club."
"Name number,Name number,..."是否可以接受?