Skip to content

Commit d2e6585

Browse files
authored
Sync secret-handshake docs with problem-specifications (#777)
The secret-handshake exercise has been overhauled as part of a project to make practice exercises more consistent and friendly. For more context, please see the discussion in the forum, as well as the pull request that updated the exercise in the problem-specifications repository: - https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 - exercism/problem-specifications#2219
1 parent 58fe455 commit d2e6585

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed
Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,47 @@
11
# Instructions
22

3-
> There are 10 types of people in the world: Those who understand
4-
> binary, and those who don't.
3+
Your task is to convert a number between 1 and 31 to a sequence of actions in the secret handshake.
54

6-
You and your fellow cohort of those in the "know" when it comes to
7-
binary decide to come up with a secret "handshake".
8-
9-
```text
10-
1 = wink
11-
10 = double blink
12-
100 = close your eyes
13-
1000 = jump
5+
The sequence of actions is chosen by looking at the rightmost five digits of the number once it's been converted to binary.
6+
Start at the right-most digit and move left.
147

8+
The actions for each number place are:
159

10+
```plaintext
11+
00001 = wink
12+
00010 = double blink
13+
00100 = close your eyes
14+
01000 = jump
1615
10000 = Reverse the order of the operations in the secret handshake.
1716
```
1817

19-
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
18+
Let's use the number `9` as an example:
19+
20+
- 9 in binary is `1001`.
21+
- The digit that is farthest to the right is 1, so the first action is `wink`.
22+
- Going left, the next digit is 0, so there is no double-blink.
23+
- Going left again, the next digit is 0, so you leave your eyes open.
24+
- Going left again, the next digit is 1, so you jump.
25+
26+
That was the last digit, so the final code is:
27+
28+
```plaintext
29+
wink, jump
30+
```
31+
32+
Given the number 26, which is `11010` in binary, we get the following actions:
2033

21-
Here's a couple of examples:
34+
- double blink
35+
- jump
36+
- reverse actions
2237

23-
Given the input 3, the function would return the array
24-
["wink", "double blink"] because 3 is 11 in binary.
38+
The secret handshake for 26 is therefore:
39+
40+
```plaintext
41+
jump, double blink
42+
```
2543

26-
Given the input 19, the function would return the array
27-
["double blink", "wink"] because 19 is 10011 in binary.
28-
Notice that the addition of 16 (10000 in binary)
29-
has caused the array to be reversed.
44+
~~~~exercism/note
45+
If you aren't sure what binary is or how it works, check out [this binary tutorial][intro-to-binary].
46+
[intro-to-binary]: https://medium.com/basecs/bits-bytes-building-with-binary-13cb4289aafa
47+
~~~~
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
You are starting a secret coding club with some friends and friends-of-friends.
4+
Not everyone knows each other, so you and your friends have decided to create a secret handshake that you can use to recognize that someone is a member.
5+
You don't want anyone who isn't in the know to be able to crack the code.
6+
7+
You've designed the code so that one person says a number between 1 and 31, and the other person turns it into a series of actions.

0 commit comments

Comments
 (0)