Skip to content

Add details to BIT problems #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions bit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion bit/addition_without_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion bit/division_without_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion bit/is_power_of_two_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions bit/max_without_comparison_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions bit/middle_without_division_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion bit/oddly_repeated_number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down