このようなシリコンバレーの「3コンマクラブ」シーンに触発され、このチャレンジでは10人にそれぞれが属する「コンマクラブ」を伝えます。
「コンマクラブ」という用語に慣れていない場合は、説明しましょう。持っているお金が1,000.00ドルから999,999.99ドルの範囲であれば、1コンマクラブにいます。$ 1,000,000.00から$ 999,999,999.99の範囲にある場合、2コンマクラブにいます。地球上の個人(AFAIK)は1兆ドル以上を所有していないため、これらの「クラブ」は3コンマクラブを通じて繰り返されます(日本円はすぐに別の話になります)。したがって、銀行口座のカンマの数は、米国および英国で最も一般的な表記基準に従って、あなたが所属するカンマクラブを示します。同じ「コンマ」ルールが負の数値にも適用されます(ただし、負のコンマクラブにはなりたくないでしょう)。包括範囲[-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.561コンマクラブにもありますか?
"<name> is in the <number of commas>-club."
"Name number,Name number,..."受け入れられるようなものですか?