diff --git a/bit/README.md b/bit/README.md index ffe40fc..3441f37 100644 --- a/bit/README.md +++ b/bit/README.md @@ -50,9 +50,7 @@ Left shifting can be viewed as a multiplication operation by 2 raised to the pow ```Go package main -import ( - "fmt" -) +import "fmt" func main() { fmt.Println(1 << 5) // Prints 32. 1 * 2^5 = 32 diff --git a/bit/addition_without_operators_test.go b/bit/addition_without_operators_test.go index 502b5d1..9e701d2 100644 --- a/bit/addition_without_operators_test.go +++ b/bit/addition_without_operators_test.go @@ -7,7 +7,9 @@ TestAdditionWithoutArithmeticOperators tests solution(s) with the following sign func Add(x, y int) int -Add x by y, two integers without using any arithmetic operators such as {+,-,/,*,++,--,+=,…}. +Given two integers add them without using any arithmetic operators such as {+,-,/,*,++,--,+=,…}. + +For example given 2 and 3 return 5. */ func TestAdditionWithoutArithmeticOperators(t *testing.T) { tests := []struct { diff --git a/bit/division_without_operators_test.go b/bit/division_without_operators_test.go index 2dc1bf5..ab3c265 100644 --- a/bit/division_without_operators_test.go +++ b/bit/division_without_operators_test.go @@ -7,7 +7,9 @@ TestDivision tests solution(s) with the following signature and problem descript func Divide(x, y int) int -Divide x by y, two integers without using the built-in `/` or `*` operators. +Given two integers, divide them without using the built-in `/` or `*` operators. + +For example given 20 and 4 return 5. */ func TestDivision(t *testing.T) { tests := []struct { diff --git a/bit/is_power_of_two_test.go b/bit/is_power_of_two_test.go index b50bea6..1f44251 100644 --- a/bit/is_power_of_two_test.go +++ b/bit/is_power_of_two_test.go @@ -7,7 +7,9 @@ TestIsPowerOfTwo tests solution(s) with the following signature and problem desc func IsPowerOfTwo(input int) bool -Using bit manipulation, return true if a given number like 2 and false otherwise. +Using bit manipulation, return true if a given number is a power of 2 and false otherwise. + +For example given 20 return false. Given 256 return true because 2 ^ 8 = 256. */ func TestIsPowerOfTwo(t *testing.T) { tests := []struct { diff --git a/bit/max_without_comparison_operators_test.go b/bit/max_without_comparison_operators_test.go index 2f087d0..fb2144c 100644 --- a/bit/max_without_comparison_operators_test.go +++ b/bit/max_without_comparison_operators_test.go @@ -7,8 +7,10 @@ TestMax tests solution(s) with the following signature and problem description: func Max(x, y int) int -Write max, a function that returns the largest of two numbers without using a -any of the comparison operators such as {if, switch,…}. +Given two integers, return the larger of the two without using any comparison +operations like {if, switch,…}. + +For example given 20 and 2 return 20. */ func TestMax(t *testing.T) { tests := []struct { diff --git a/bit/middle_without_division_test.go b/bit/middle_without_division_test.go index effccf2..03fc5bb 100644 --- a/bit/middle_without_division_test.go +++ b/bit/middle_without_division_test.go @@ -7,8 +7,10 @@ TestMiddleWithoutDivision tests solution(s) with the following signature and pro func MiddleWithoutDivision(min, max int) -Given two integers min and max like `1` and `5`, return an integer like `3` that is in -the middle of the two. +Given two integers return the integer that is in the middle of the two integers without +using any arithmetic operators such as {+,-,/,*,++,--,+=,…}. + +For example given 1 and 5, return 3. This is because 3 is in the middle of integers 1 to 5. */ func TestMiddleWithoutDivision(t *testing.T) { tests := []struct { diff --git a/bit/oddly_repeated_number_test.go b/bit/oddly_repeated_number_test.go index 36d00f4..b6f3407 100644 --- a/bit/oddly_repeated_number_test.go +++ b/bit/oddly_repeated_number_test.go @@ -7,8 +7,10 @@ TestOddlyRepeatedNumber tests solution(s) with the following signature and probl func OddlyRepeatedNumber(list []int) int -Given an array of integers that are all repeated an even number of times except one, +Given a slice of integers that are all repeated an even number of times except one, find the oddly repeated element. + +For example given {1, 2, 2, 3, 3} return 1. Given {1, 2, 1, 2, 3} return 3. */ func TestOddlyRepeatedNumber(t *testing.T) { tests := []struct {