Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secret-handshake: Add canonical data (revives #159) #489

Merged
merged 2 commits into from
Jan 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions exercises/secret-handshake/canonical-data.json
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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.