-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
273 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package basic | ||
|
||
func Factorial(n int) int { | ||
if n == 1 { | ||
return 1 | ||
} else { | ||
return n * Factorial(n - 1) | ||
} | ||
if n == 1 { | ||
return 1 | ||
} else { | ||
return n * Factorial(n-1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package basic | ||
|
||
func FizzBuzz(num int) any { | ||
if num % 3 == 0 && num % 5 == 0 { | ||
return "FizzBuzz" | ||
} else if num % 3 == 0 { | ||
return "Fizz" | ||
} else if num % 5 == 0 { | ||
return "Buzz" | ||
} else { | ||
return num | ||
} | ||
if num%3 == 0 && num%5 == 0 { | ||
return "FizzBuzz" | ||
} else if num%3 == 0 { | ||
return "Fizz" | ||
} else if num%5 == 0 { | ||
return "Buzz" | ||
} else { | ||
return num | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package basic | ||
|
||
func Recursive(n int) int { | ||
if n < 100 { | ||
return Recursive(n + n) | ||
} else if n >= 100 { | ||
return n | ||
} else { | ||
return 0 | ||
} | ||
if n < 100 { | ||
return Recursive(n + n) | ||
} else if n >= 100 { | ||
return n | ||
} else { | ||
return 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
package data | ||
|
||
type Queues struct { | ||
Elems []string | ||
Elems []string | ||
} | ||
|
||
func (q *Queues) InsertQueues(elem string){ | ||
if elem == "" { | ||
println("data null") | ||
} | ||
func (q *Queues) InsertQueues(elem string) { | ||
if elem == "" { | ||
println("data null") | ||
} | ||
|
||
q.Elems = append(q.Elems, elem) | ||
q.Elems = append(q.Elems, elem) | ||
} | ||
|
||
func (q *Queues) DeleteQueues() string { | ||
if len(q.Elems) == 0 { | ||
println("Null Data") | ||
} | ||
if len(q.Elems) == 0 { | ||
println("Null Data") | ||
} | ||
|
||
element := q.Elems[0] | ||
if len(q.Elems) == 1{ | ||
q.Elems = nil | ||
return element | ||
} | ||
element := q.Elems[0] | ||
if len(q.Elems) == 1 { | ||
q.Elems = nil | ||
return element | ||
} | ||
|
||
q.Elems = q.Elems[1:] | ||
return element | ||
q.Elems = q.Elems[1:] | ||
return element | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
package search | ||
|
||
func BinarySearch(data []int, item int) string { | ||
var low = 0 | ||
var low = 0 | ||
|
||
var high = len(data) - 1 | ||
var high = len(data) - 1 | ||
|
||
for low <= high { | ||
var mid = low + high | ||
var guess = data[mid] | ||
for low <= high { | ||
var mid = low + high | ||
var guess = data[mid] | ||
|
||
if guess == item { | ||
return "Data found" | ||
} else if guess > item { | ||
high = mid - 1 | ||
} else { | ||
low = mid + 1 | ||
} | ||
} | ||
if guess == item { | ||
return "Data found" | ||
} else if guess > item { | ||
high = mid - 1 | ||
} else { | ||
low = mid + 1 | ||
} | ||
} | ||
|
||
return "Data not found" | ||
return "Data not found" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.