File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ *
3+ * 5.6 Conversion: Write a function to determine the number of bits you would need to flip to convert integer A to integer B.
4+
5+ EXAMPLE
6+ Input: 29 (or: 111131), 15 (or: 131111)
7+
8+ Output: 2
9+
10+ Hints: #336, #369
11+ *
12+ * @param number
13+ */
14+ function conversion ( number ) {
15+
16+ }
17+
18+ module . exports = conversion ;
Original file line number Diff line number Diff line change 1+ const expect = require ( 'chai' ) . expect ;
2+ const conversion = require ( './06-conversion' ) ;
3+
4+ describe ( 'Bit Manipulation: conversion' , function ( ) {
5+ it ( 'power of two' , function ( ) {
6+ expect ( conversion ( 0b0 ) ) . to . equal ( true ) ;
7+ } ) ;
8+
9+ it ( 'no power of two' , function ( ) {
10+ expect ( conversion ( 0b111 ) ) . to . equal ( false ) ;
11+ } ) ;
12+ } ) ;
You can’t perform that action at this time.
0 commit comments