Skip to content

Commit 821dd3b

Browse files
authored
Add details to BIT problems (#184)
1 parent 1266c63 commit 821dd3b

7 files changed

+21
-11
lines changed

bit/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ Left shifting can be viewed as a multiplication operation by 2 raised to the pow
5050
```Go
5151
package main
5252

53-
import (
54-
"fmt"
55-
)
53+
import "fmt"
5654

5755
func main() {
5856
fmt.Println(1 << 5) // Prints 32. 1 * 2^5 = 32

bit/addition_without_operators_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ TestAdditionWithoutArithmeticOperators tests solution(s) with the following sign
77
88
func Add(x, y int) int
99
10-
Add x by y, two integers without using any arithmetic operators such as {+,-,/,*,++,--,+=,…}.
10+
Given two integers add them without using any arithmetic operators such as {+,-,/,*,++,--,+=,…}.
11+
12+
For example given 2 and 3 return 5.
1113
*/
1214
func TestAdditionWithoutArithmeticOperators(t *testing.T) {
1315
tests := []struct {

bit/division_without_operators_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ TestDivision tests solution(s) with the following signature and problem descript
77
88
func Divide(x, y int) int
99
10-
Divide x by y, two integers without using the built-in `/` or `*` operators.
10+
Given two integers, divide them without using the built-in `/` or `*` operators.
11+
12+
For example given 20 and 4 return 5.
1113
*/
1214
func TestDivision(t *testing.T) {
1315
tests := []struct {

bit/is_power_of_two_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ TestIsPowerOfTwo tests solution(s) with the following signature and problem desc
77
88
func IsPowerOfTwo(input int) bool
99
10-
Using bit manipulation, return true if a given number like 2 and false otherwise.
10+
Using bit manipulation, return true if a given number is a power of 2 and false otherwise.
11+
12+
For example given 20 return false. Given 256 return true because 2 ^ 8 = 256.
1113
*/
1214
func TestIsPowerOfTwo(t *testing.T) {
1315
tests := []struct {

bit/max_without_comparison_operators_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ TestMax tests solution(s) with the following signature and problem description:
77
88
func Max(x, y int) int
99
10-
Write max, a function that returns the largest of two numbers without using a
11-
any of the comparison operators such as {if, switch,…}.
10+
Given two integers, return the larger of the two without using any comparison
11+
operations like {if, switch,…}.
12+
13+
For example given 20 and 2 return 20.
1214
*/
1315
func TestMax(t *testing.T) {
1416
tests := []struct {

bit/middle_without_division_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ TestMiddleWithoutDivision tests solution(s) with the following signature and pro
77
88
func MiddleWithoutDivision(min, max int)
99
10-
Given two integers min and max like `1` and `5`, return an integer like `3` that is in
11-
the middle of the two.
10+
Given two integers return the integer that is in the middle of the two integers without
11+
using any arithmetic operators such as {+,-,/,*,++,--,+=,…}.
12+
13+
For example given 1 and 5, return 3. This is because 3 is in the middle of integers 1 to 5.
1214
*/
1315
func TestMiddleWithoutDivision(t *testing.T) {
1416
tests := []struct {

bit/oddly_repeated_number_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ TestOddlyRepeatedNumber tests solution(s) with the following signature and probl
77
88
func OddlyRepeatedNumber(list []int) int
99
10-
Given an array of integers that are all repeated an even number of times except one,
10+
Given a slice of integers that are all repeated an even number of times except one,
1111
find the oddly repeated element.
12+
13+
For example given {1, 2, 2, 3, 3} return 1. Given {1, 2, 1, 2, 3} return 3.
1214
*/
1315
func TestOddlyRepeatedNumber(t *testing.T) {
1416
tests := []struct {

0 commit comments

Comments
 (0)