Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c7641c0
update: homework exercise 1
galyym Jul 29, 2024
bcc0aeb
Merge branch 'main' into kemalatdin-galyym
galyym Sep 26, 2024
b084806
Kemalatdin Galym
galyym Sep 28, 2024
5a13f62
Merge branch 'main' into kemalatdin-galyym
galyym Oct 5, 2024
ddf48da
Kemalatdin Galym exercise 3
galyym Oct 6, 2024
d859c19
update: done problem 1
Oct 7, 2024
e1089f0
update: done problem 2
Oct 7, 2024
d27f30c
update: problem 3
Oct 7, 2024
6a6baa3
KemalatdinGalym-exercise3
galyym Oct 7, 2024
909324f
Merge branch 'main' into kemalatdin-galyym
galyym Oct 13, 2024
cfb8a10
Merge branch 'main' into kemalatdin-galyym
Oct 15, 2024
7ee31dc
feat: bot http ping route
Oct 16, 2024
192d4b6
Revert "feat: bot http ping route"
Oct 18, 2024
2c67699
feat: send join request
Oct 18, 2024
446369a
Merge remote-tracking branch 'origin/kemalatdin-galyym' into kemalatd…
galyym Oct 20, 2024
d7b47bf
feat: ping, move
galyym Oct 20, 2024
18e2f5a
\Merge branch 'main' into kemalatdin-galyym
galyym Oct 20, 2024
9b316e7
exercise 4. move logic
Oct 20, 2024
34e87a0
Merge branch 'main' into kemalatdin-galyym
galyym Nov 6, 2024
69c4931
feat: exercise5
galyym Nov 6, 2024
af335e1
Merge pull request #208 from talgat-ruby/exercise6
talgat-ruby Nov 7, 2024
cf97485
feat: exercise5
galyym Nov 9, 2024
ddb8734
Merge branch 'main' into kemalatdin-galyym
galyym Nov 17, 2024
4fbcbfe
Merge pull request #212 from talgat-ruby/exercise6
talgat-ruby Nov 17, 2024
b4e7e89
add lesson7
talgat-ruby Nov 26, 2024
a6474f9
Merge pull request #227 from talgat-ruby/exercise7
talgat-ruby Nov 26, 2024
43345e1
feat: exercise6
galyym Dec 1, 2024
3bc33b2
Merge branch 'talgat-ruby:main' into kemalatdin-galyym
galyym Dec 1, 2024
9f44c3d
Merge branch 'main' into kemalatdin-galyym
galyym Dec 1, 2024
6af7c12
Merge remote-tracking branch 'origin/kemalatdin-galyym' into kemalatd…
galyym Dec 1, 2024
cbdfcfe
feat: exercise7
galyym Dec 4, 2024
5031efd
feat: api handler
Dec 5, 2024
b74fa26
feat: db migrate
Dec 9, 2024
91f1c13
fix: refactoring
Dec 10, 2024
bc0d22c
fix: db init
Dec 12, 2024
75d6dc4
fix: db init
Dec 13, 2024
81641b1
feat: exercise7
galyym Jan 1, 2025
96b9879
feat: exercise8
galyym Jan 14, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ go.work

# Students
students.txt
.env
8 changes: 7 additions & 1 deletion exercise1/problem1/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package main

func addUp() {}
func addUp(num int) int {
sum := 0
for i := 1; i <= num; i++ {
sum = sum + i
}
return sum
}
14 changes: 13 additions & 1 deletion exercise1/problem10/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
package main

func sum() {}
import (
"errors"
"strconv"
)

func sum(a string, b string) (string, error) {
sA, errA := strconv.Atoi(a)
sB, errB := strconv.Atoi(b)
if errA != nil || errB != nil {
return "", errors.Join(errA, errB)
}
return strconv.Itoa(sA + sB), nil
}
6 changes: 5 additions & 1 deletion exercise1/problem2/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package main

func binary() {}
import "fmt"

func binary(num int) string {
return fmt.Sprintf("%b", num)
}
8 changes: 7 additions & 1 deletion exercise1/problem3/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package main

func numberSquares() {}
func numberSquares(num int) int {
var result int
for i := 1; i <= num; i++ {
result = result + (i * i)
}
return result
}
14 changes: 13 additions & 1 deletion exercise1/problem4/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
package main

func detectWord() {}
import (
"unicode"
)

func detectWord(crowd string) string {
var result string
for _, s := range crowd {
if !unicode.IsUpper(s) {
result = result + string(s)
}
}
return result
}
11 changes: 10 additions & 1 deletion exercise1/problem5/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package main

func potatoes() {}
func potatoes(crowd string) int {
var result int
strL := len("potato")
for i := 0; i <= len(crowd)-strL; i++ {
if crowd[i:i+strL] == "potato" {
result++
}
}
return result
}
18 changes: 17 additions & 1 deletion exercise1/problem6/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
package main

func emojify() {}
import "strings"

var emoji = map[string]string{
"smile": "🙂",
"grin": "😀",
"sad": "😥",
"mad": "😠",
}

func emojify(text string) string {
for i, v := range emoji {
if strings.Contains(text, i) {
text = strings.Replace(text, i, v, 1)
}
}
return text
}
20 changes: 19 additions & 1 deletion exercise1/problem7/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
package main

func highestDigit() {}
import "slices"

func highestDigit(num int) int {
if num != 0 {
numS := ItoSlice(num)
return slices.Max(numS)
}
return 0
}

func ItoSlice(n int) []int {
var numS []int
for n >= 1 {
i := n % 10
numS = append(numS, i)
n = n / 10
}
return numS
}
11 changes: 10 additions & 1 deletion exercise1/problem8/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package main

func countVowels() {}
func countVowels(text string) int {
var count int
for _, v := range text {
switch v {
case 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U':
count++
}
}
return count
}
12 changes: 9 additions & 3 deletions exercise1/problem9/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package main

func bitwiseAND() {}
func bitwiseAND(a int, b int) int {
return a & b
}

func bitwiseOR() {}
func bitwiseOR(a int, b int) int {
return a | b
}

func bitwiseXOR() {}
func bitwiseXOR(a int, b int) int {
return a ^ b
}
9 changes: 8 additions & 1 deletion exercise2/problem1/problem1.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package problem1

func isChangeEnough() {
var cents = []float32{0.25, 0.10, 0.05, 0.01}

func isChangeEnough(changes [4]int, total float32) bool {
var sum float32
for key, index := range changes {
sum += cents[key] * float32(index)
}
return sum >= total
}
10 changes: 9 additions & 1 deletion exercise2/problem10/problem10.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package problem10

func factory() {}
func factory() (map[string]int, func(brand string) func(int)) {
result := make(map[string]int)
return result, func(brand string) func(int) {
result[brand] = 0
return func(i int) {
result[brand] = result[brand] + i
}
}
}
12 changes: 11 additions & 1 deletion exercise2/problem11/problem11.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
package problem11

func removeDups() {}
import "slices"

func removeDups[T comparable](nums []T) []T {
result := make([]T, 0)
for _, v := range nums {
if !slices.Contains(result, v) {
result = append(result, v)
}
}
return result
}
31 changes: 30 additions & 1 deletion exercise2/problem12/problem12.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
package problem11

func keysAndValues() {}
import (
"fmt"
"sort"
)

func keysAndValues[K comparable, V any](m map[K]V) ([]K, []V) {
if m == nil {
return []K{}, []V{}
}

keys := make([]K, 0, len(m))
for k := range m {
keys = append(keys, k)
}

sort.Slice(keys, func(i, j int) bool {
return stringify(keys[i]) < stringify(keys[j])
})

values := make([]V, len(keys))
for i, k := range keys {
values[i] = m[k]
}

return keys, values
}

func stringify[T any](v T) string {
return fmt.Sprintf("%v", v)
}
13 changes: 12 additions & 1 deletion exercise2/problem2/problem2.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
package problem2

func capitalize() {
import "strings"

func capitalize(names []string) []string {
for i, v := range names {
if v == "" {
continue
}
firstLetter := strings.ToUpper(string(v[0]))
lowerS := strings.ToLower(v[1:])
names[i] = firstLetter + lowerS
}
return names
}
40 changes: 39 additions & 1 deletion exercise2/problem3/problem3.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,43 @@ const (
lr dir = "lr"
)

func diagonalize() {
func diagonalize(n int, d dir) [][]int {
matrix := make([][]int, n)
switch d {
case ul:
count := 0
getMatrix(count, matrix, n, true, true)
break
case ll:
count := n - 1
getMatrix(count, matrix, n, true, false)
break
case ur:
count := n - 1
getMatrix(count, matrix, n, false, true)
break
case lr:
count := (n - 1) * 2
getMatrix(count, matrix, n, false, false)
break
}
return matrix
}

func getMatrix(count int, matrix [][]int, n int, o bool, countChecker bool) {
for i := range n {
matrix[i] = make([]int, n)
for j := range n {
if o {
matrix[i][j] = count + j
} else {
matrix[i][j] = count - j
}
}
if countChecker {
count++
} else {
count--
}
}
}
9 changes: 8 additions & 1 deletion exercise2/problem4/problem4.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package problem4

func mapping() {
import "strings"

func mapping(inp []string) map[string]string {
intM := make(map[string]string)
for _, v := range inp {
intM[v] = strings.ToUpper(v)
}
return intM
}
43 changes: 42 additions & 1 deletion exercise2/problem5/problem5.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
package problem5

func products() {
import "sort"

type Catalog struct {
Key string
Value int
}

type CatalogList []Catalog

func (c CatalogList) Len() int {
return len(c)
}

func (c CatalogList) Less(i, j int) bool {
if c[i].Value == c[j].Value {
return c[i].Key < c[j].Key
}
return c[i].Value > c[j].Value
}

func (c CatalogList) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}

func products(catalog map[string]int, minPrice int) []string {
prices := make(CatalogList, len(catalog))
i := 0

for k, v := range catalog {
if v > minPrice {
prices[i] = Catalog{k, v}
i++
}
}
sort.Sort(prices)
result := make([]string, 0)
for _, v := range prices {
if v.Key != "" {
result = append(result, v.Key)
}
}
return result
}
10 changes: 9 additions & 1 deletion exercise2/problem6/problem6.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
package problem6

func sumOfTwo() {
func sumOfTwo(first []int, second []int, sum int) bool {
for _, fv := range first {
for _, sv := range second {
if fv+sv == sum {
return true
}
}
}
return false
}
3 changes: 2 additions & 1 deletion exercise2/problem7/problem7.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package problem7

func swap() {
func swap(a *int, b *int) {
*a, *b = *b, *a
}
9 changes: 4 additions & 5 deletions exercise2/problem8/problem8.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ func simplify(list []string) map[string]int {
var indMap map[string]int

indMap = make(map[string]int)
load(&indMap, &list)

load(indMap, list)
return indMap
}

func load(m *map[string]int, students *[]string) {
for i, name := range *students {
(*m)[name] = i
func load(m map[string]int, students []string) {
for i, name := range students {
m[name] = i
}
}
Loading