4.0 KiB
4.0 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
565bbe00e9cc8ac0725390f4 | Counting Cards | 1 | 计数卡 |
Description
计数变化 | 牌 |
---|---|
+1 | 2,3,4,5,6 |
0 | 7,8,9 |
-1 | 10,'J','Q','K','A' |
card
参数,可以是数字或字符串,并根据卡的值递增或递减全局count
变量(参见表格)。然后,该函数将返回一个包含当前计数的字符串,如果计数为正则返回字符串Bet
,如果计数为零或为负,则返回Hold
。当前计数和玩家的决定( Bet
或Hold
)应该由一个空格分隔。 示例输出 -3 Hold
5 Bet
提示 当值为7,8或9时,请勿将
count
重置为0。 不要返回数组。
不要在输出中包含引号(单引号或双引号)。
Instructions
Tests
tests:
- text: 牌序列<code>5 Bet</code>应该返回<code>5 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
- text: '卡片序列7,8,9应返回<code>0 Hold</code>'
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
- text: 卡序列10,J,Q,K,A应返回<code>-5 Hold</code>
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
- text: '卡序列3,7,Q,8,A应返回<code>-1 Hold</code>'
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
- text: 牌序列2,J, <code>1 Bet</code>应该返回<code>1 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
- text: 牌序列<code>1 Bet</code>应该返回<code>1 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
- text: '卡序列3,2,A,10,K应返回<code>-1 Hold</code>'
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
Challenge Seed
var count = 0;
function cc(card) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Solution
// solution required