-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path151_interlocking_binary_pairs.js
More file actions
39 lines (24 loc) · 976 Bytes
/
151_interlocking_binary_pairs.js
File metadata and controls
39 lines (24 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Task
// Write a function that checks if two non-negative integers make an "interlocking binary pair".
// Interlock ?
// numbers can be interlocked if their binary representations have no 1's in the same place
// comparisons are made by bit position, starting from right to left (see the examples below)
// when representations are of different lengths, the unmatched left-most bits are ignored
// Examples
// a = 9, b = 4
// Stacking representations shows how they can interlock.
// 9 1001
// 4 100
// Here, no 1's share any position, so the function returns true.
// a = 3, b = 6
// These representations do not interlock.
// 3 11
// 6 110
// Finding they both have a 1 in the same position, the function returns false.
// Input
// Two non-negative integers.
// Output
// Boolean true or false whether or not these integers are interlockable.
function interlockable(a, b) {
// TODO
}