Finished
33// convenience to get you started writing code faster.
44//
55
6export const commands = () => {
7 throw new Error('Remove this line and implement the function');
6export const commands = (number) => {
7 // Edge Case: Handle non-integer inputs
8 if (!Number.isInteger(number)) {
9 throw new Error('Input must be an integer');
10 }
11
12 // Edge Case: Handle negative numbers
13 if (number < 0) {
14 throw new Error('Input must be a non-negative integer');
15 }
16
17 // Only consider the last 5 bits (mask with 31 or 0b11111)
18 const maskedNumber = number & 31;
19
20 const actions = [];
21
22 // Check each bit from right to left (LSB to MSB)
23 if (maskedNumber & 1) { // 00001 - wink
24 actions.push('wink');
25 }
26
27 if (maskedNumber & 2) { // 00010 - double blink
28 actions.push('double blink');
29 }
30
31 if (maskedNumber & 4) { // 00100 - close your eyes
32 actions.push('close your eyes');
33 }
34
35 if (maskedNumber & 8) { // 01000 - jump
36 actions.push('jump');
37 }
38
39 // Edge Case: Handle reverse flag (16 or 10000)
40 if (maskedNumber & 16) { // 10000 - reverse
41 actions.reverse();
42 }
43
44 return actions;
845};
46
47// Handled Edge Cases: non-integer inputs, negative numbers, number greater than 31 (masked), number with only reverse flag set, number with all bits set
Test NameStatus
wink for 1
Pass
double blink for 10
Pass
close your eyes for 100
Pass
jump for 1000
Pass
combine two actions
Pass
reverse two actions
Pass
reversing one action gives the same action
Pass
reversing no actions still gives no actions
Pass
all possible actions
Pass
reverse all possible actions
Pass
do nothing for zero
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.