From 6bb9e11cf519fee1643e191127c045ba9a733e5f Mon Sep 17 00:00:00 2001 From: Andy Beger Date: Tue, 8 Dec 2015 22:15:16 -0600 Subject: [PATCH 1/2] secret-handshake: Add canonical data (revives #159) Implementing tracks: * https://github.com/exercism/xcsharp/blob/master/exercises/secret-handshake/SecretHandshakeTest.cs * https://github.com/exercism/xecmascript/blob/master/exercises/secret-handshake/secret-handshake.spec.js * https://github.com/exercism/xfsharp/blob/master/exercises/secret-handshake/SecretHandshakeTest.fs * https://github.com/exercism/xgo/blob/master/exercises/secret-handshake/secret_handshake_test.go * https://github.com/exercism/xhaskell/blob/master/exercises/secret-handshake/test/Tests.hs * https://github.com/exercism/xjavascript/blob/master/exercises/secret-handshake/secret-handshake.spec.js * https://github.com/exercism/xlua/blob/master/exercises/secret-handshake/secret-handshake_spec.lua * https://github.com/exercism/xobjective-c/blob/master/exercises/secret-handshake/SecretHandshakeTest.m * https://github.com/exercism/xperl5/blob/master/exercises/secret-handshake/handshake.t * https://github.com/exercism/xpython/blob/master/exercises/secret-handshake/handshake_test.py * https://github.com/exercism/xruby/blob/master/exercises/secret-handshake/secret_handshake_test.rb * https://github.com/exercism/xscala/blob/master/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala * https://github.com/exercism/xswift/blob/master/exercises/secret-handshake/SecretHandshakeTest.swift Summary of tests among these languages: * All language tracks test: 1, 2, 4, 8, 3, 19, 31. * Go, Haskell, Objective C, Scala, and Swift additionally test 0. * Go is the only track that tests 32, 33. * Python is the only track that tests 9, 22, 5, -9. * Python is the only track that tests action -> number conversions. * Haskell, Python, and Scala test strings (string binary -> number conversion) * ECMAScript and JavaScript test strings (only that strings are rejected) * Perl and Ruby test strings (that they are accepted but result in an empty array) Closes #159 by way of replacement. Closes https://github.com/exercism/todo/issues/145 Changes since #159: * remove decode and composition cases Discussion in #159 indicates that the decode step should be removed. Since composition includes decode, that implies composition should be removed as well. * Test only integers Discussion in #159 indicates we don't do binary conversions, so all string inputs are geeting removed. * Test only positive integers It's recommended to use unsigned integers for bitwise operations. * describe importance of each test * All actions is 15 (1111), not 16 (10000) * Add cases for reverse singleton and nothing --- .../secret-handshake/canonical-data.json | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 exercises/secret-handshake/canonical-data.json diff --git a/exercises/secret-handshake/canonical-data.json b/exercises/secret-handshake/canonical-data.json new file mode 100644 index 0000000000..7cd03be42b --- /dev/null +++ b/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": [] + } + ] + } +} From f78527dd03678e49e0202d1829e5450b56857988 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 14 Jan 2017 11:52:44 -0800 Subject: [PATCH 2/2] secret-handshake: Use 3 and 19, not 9 and "11001" We'd like to use 3 and 19 to match up with what's in the test cases already used by most languages. We also do not want to do binary to integer conversions, by discussion in #159. This covers most tasks in #335, though I would probably still leave #335 open because explicit discussion of numbers larger than 11111 has not been added. --- exercises/secret-handshake/description.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/exercises/secret-handshake/description.md b/exercises/secret-handshake/description.md index 77cf52e414..3bb7b31c6d 100644 --- a/exercises/secret-handshake/description.md +++ b/exercises/secret-handshake/description.md @@ -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.