From 7aa57f5cee65fca7b05b647e5ed54960af517e5d Mon Sep 17 00:00:00 2001 From: Ackerley Tng Date: Tue, 10 Oct 2017 06:41:27 +0800 Subject: [PATCH] Add parameters to exercise placeholder Add parameters to exercise placeholder for variable-length-quantity. Also changed variable naming from bytes to bytes_ to avoid shadowing python's bytes Fixes: #651 --- exercises/variable-length-quantity/example.py | 12 ++++++------ .../variable_length_quantity.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/variable-length-quantity/example.py b/exercises/variable-length-quantity/example.py index a1d4bb6f..5a59cb7f 100644 --- a/exercises/variable-length-quantity/example.py +++ b/exercises/variable-length-quantity/example.py @@ -3,32 +3,32 @@ SEVENBITSMASK = 0x7f def encode_single(n): - bytes = [n & SEVENBITSMASK] + bytes_ = [n & SEVENBITSMASK] n >>= 7 while n > 0: - bytes.append(n & SEVENBITSMASK | EIGHTBITMASK) + bytes_.append(n & SEVENBITSMASK | EIGHTBITMASK) n >>= 7 - return bytes[::-1] + return bytes_[::-1] def encode(numbers): return sum((encode_single(n) for n in numbers), []) -def decode(bytes): +def decode(bytes_): values = [] n = 0 - for i, byte in enumerate(bytes): + for i, byte in enumerate(bytes_): n <<= 7 n += (byte & SEVENBITSMASK) if byte & EIGHTBITMASK == 0: values.append(n) n = 0 - elif i == len(bytes) - 1: + elif i == len(bytes_) - 1: raise ValueError('incomplete byte sequence') return values diff --git a/exercises/variable-length-quantity/variable_length_quantity.py b/exercises/variable-length-quantity/variable_length_quantity.py index 2536c2e6..41bdcdc8 100644 --- a/exercises/variable-length-quantity/variable_length_quantity.py +++ b/exercises/variable-length-quantity/variable_length_quantity.py @@ -1,6 +1,6 @@ -def encode(): +def encode(numbers): pass -def decode(): +def decode(bytes_): pass