Skip to content

Commit

Permalink
Merge pull request #489 from petertseng/secret-handshake-json
Browse files Browse the repository at this point in the history
secret-handshake: Add canonical data (revives #159)
  • Loading branch information
petertseng committed Jan 15, 2017
2 parents 3c67665 + f78527d commit ca0431c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 8 deletions.
67 changes: 67 additions & 0 deletions exercises/secret-handshake/canonical-data.json
@@ -0,0 +1,67 @@
{
"commands": {
"description": ["Create a handshake for a number"],
"cases": [
{
"description": "wink for 1",
"input": 1,
"expected": ["wink"]
},
{
"description": "double blink for 10",
"input": 2,
"expected": ["double blink"]
},
{
"description": "close your eyes for 100",
"input": 4,
"expected": ["close your eyes"]
},
{
"description": "jump for 1000",
"input": 8,
"expected": ["jump"]
},
{
"description": "combine two actions",
"input": 3,
"expected": ["wink", "double blink"]
},
{
"description": "reverse two actions",
"input": 19,
"expected": ["double blink", "wink"]
},
{
"description": "reversing one action gives the same action",
"input": 24,
"expected": ["jump"]
},
{
"description": "reversing no actions still gives no actions",
"input": 16,
"expected": []
},
{
"description": "all possible actions",
"input": 15,
"expected": ["wink", "double blink", "close your eyes", "jump"]
},
{
"description": "reverse all possible actions",
"input": 31,
"expected": ["jump", "close your eyes", "double blink", "wink"]
},
{
"description": "do nothing for zero",
"input": 0,
"expected": []
},
{
"description": "do nothing if lower 5 bits not set",
"input": 32,
"expected": []
}
]
}
}
14 changes: 6 additions & 8 deletions exercises/secret-handshake/description.md
Expand Up @@ -16,12 +16,10 @@ binary decide to come up with a secret "handshake".

Here's a couple of examples:

Given the input 9, the function would return the array
["wink", "jump"]
Given the input 3, the function would return the array
["wink", "double blink"] because 3 is 11 in binary.

Given the input "11001", the function would return the array
["jump", "wink"]


The program should consider strings specifying an invalid binary as the
value 0.
Given the input 19, the function would return the array
["double blink", "wink"] because 19 is 10011 in binary.
Notice that the addition of 16 (10000 in binary)
has caused the array to be reversed.

0 comments on commit ca0431c

Please sign in to comment.