From ddc5964327b48e8569af49f5f8b1b5a55ae0af04 Mon Sep 17 00:00:00 2001 From: gorbushka3000 Date: Thu, 30 Oct 2025 15:04:56 +0300 Subject: [PATCH 1/5] first --- .../Gorbushka3000/solution-template.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 challenge-1/submissions/Gorbushka3000/solution-template.go diff --git a/challenge-1/submissions/Gorbushka3000/solution-template.go b/challenge-1/submissions/Gorbushka3000/solution-template.go new file mode 100644 index 00000000..aab16ac4 --- /dev/null +++ b/challenge-1/submissions/Gorbushka3000/solution-template.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" +) + +func main() { + var a, b int + // Read two integers from standard input + _, err := fmt.Scanf("%d, %d", &a, &b) + if err != nil { + fmt.Println("Error reading input:", err) + return + } + + // Call the Sum function and print the result + result := Sum(a, b) + fmt.Println(result) +} + +// Sum returns the sum of a and b. +func Sum(a int, b int) int { + // TODO: Implement the function + return a+b +} From 827008c156cd127f3697cb5492ee4e8e4709ad08 Mon Sep 17 00:00:00 2001 From: gorbushka3000 Date: Thu, 30 Oct 2025 16:12:47 +0300 Subject: [PATCH 2/5] Add solution for Challenge 2 by Gorbushka3000 --- .../Gorbushka3000/solution-template.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 challenge-2/submissions/Gorbushka3000/solution-template.go diff --git a/challenge-2/submissions/Gorbushka3000/solution-template.go b/challenge-2/submissions/Gorbushka3000/solution-template.go new file mode 100644 index 00000000..a8335c45 --- /dev/null +++ b/challenge-2/submissions/Gorbushka3000/solution-template.go @@ -0,0 +1,29 @@ +package main + +import ( + "bufio" + "fmt" + "os" +) + +func main() { + // Read input from standard input + scanner := bufio.NewScanner(os.Stdin) + if scanner.Scan() { + input := scanner.Text() + + // Call the ReverseString function + output := ReverseString(input) + + // Print the result + fmt.Println(output) + } +} + +// ReverseString returns the reversed string of s. +func ReverseString(s string) (result string) { + for _, c := range s{ + result = string(c) + result + } + return result +} From 014571d9ed7f3cdd20dec02bc0caa4152f883cf1 Mon Sep 17 00:00:00 2001 From: gorbushka3000 Date: Thu, 30 Oct 2025 20:03:36 +0300 Subject: [PATCH 3/5] Add solution for Challenge 3 by Gorbushka3000 --- .../Gorbushka3000/solution-template.go | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 challenge-3/submissions/Gorbushka3000/solution-template.go diff --git a/challenge-3/submissions/Gorbushka3000/solution-template.go b/challenge-3/submissions/Gorbushka3000/solution-template.go new file mode 100644 index 00000000..e75b9faa --- /dev/null +++ b/challenge-3/submissions/Gorbushka3000/solution-template.go @@ -0,0 +1,68 @@ +package main + +import "fmt" + +type Employee struct { + ID int + Name string + Age int + Salary float64 +} + +type Manager struct { + Employees []Employee +} + +// AddEmployee adds a new employee to the manager's list. +func (m *Manager) AddEmployee(e Employee) { + m.Employees = append(m.Employees, e) +} + +// RemoveEmployee removes an employee by ID from the manager's list. +func (m *Manager) RemoveEmployee(id int) { + var removeValue []Employee + for i := 0; i < len(m.Employees); i++ { + if m.Employees[i].ID == id { + continue + } else { + removeValue = append(removeValue, m.Employees[i]) + } + m.Employees = removeValue + } +} + +// GetAverageSalary calculates the average salary of all employees. +func (m *Manager) GetAverageSalary() float64 { + if len(m.Employees) == 0 { + return 0 + } + var aveSal float64 + for i := 0; i < len(m.Employees); i++ { + aveSal += m.Employees[i].Salary + } + return aveSal / float64(len(m.Employees)) +} + +// FindEmployeeByID finds and returns an employee by their ID. +func (m *Manager) FindEmployeeByID(id int) *Employee { + for i := 0; i < len(m.Employees); i++ { + if m.Employees[i].ID == id { + return &m.Employees[i] + } + } + return nil +} + +func main() { + manager := Manager{} + manager.AddEmployee(Employee{ID: 1, Name: "Alice", Age: 30, Salary: 70000}) + manager.AddEmployee(Employee{ID: 2, Name: "Bob", Age: 25, Salary: 65000}) + manager.RemoveEmployee(1) + averageSalary := manager.GetAverageSalary() + employee := manager.FindEmployeeByID(2) + + fmt.Printf("Average Salary: %f\n", averageSalary) + if employee != nil { + fmt.Printf("Employee found: %+v\n", *employee) + } +} From 0b356cc6a2842e3855f0d9a9ce9a8b6607fb8d09 Mon Sep 17 00:00:00 2001 From: gorbushka3000 Date: Fri, 31 Oct 2025 02:33:20 +0300 Subject: [PATCH 4/5] Add solution for Challenge 22 by Gorbushka3000 --- .../Gorbushka3000/solution-template.go | 64 +++++++++++++++++++ challenge-3/solution-template.go | 25 ++++++-- 2 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 challenge-22/submissions/Gorbushka3000/solution-template.go diff --git a/challenge-22/submissions/Gorbushka3000/solution-template.go b/challenge-22/submissions/Gorbushka3000/solution-template.go new file mode 100644 index 00000000..458afbf5 --- /dev/null +++ b/challenge-22/submissions/Gorbushka3000/solution-template.go @@ -0,0 +1,64 @@ +package main + +import ( + "fmt" +) + +func main() { + // Standard U.S. coin denominations in cents + denominations := []int{1, 5, 10, 25, 50} + + // Test amounts + amounts := []int{87, 42, 99, 33, 7} + + for _, amount := range amounts { + // Find minimum number of coins + minCoins := MinCoins(amount, denominations) + + // Find coin combination + coinCombo := CoinCombination(amount, denominations) + + // Print results + fmt.Printf("Amount: %d cents\n", amount) + fmt.Printf("Minimum coins needed: %d\n", minCoins) + fmt.Printf("Coin combination: %v\n", coinCombo) + fmt.Println("---------------------------") + } +} + +// MinCoins returns the minimum number of coins needed to make the given amount. +// If the amount cannot be made with the given denominations, return -1. +func MinCoins(amount int, denominations []int) int { + var l int + for i := len(denominations); i > 0; i-- { + for amount-denominations[i-1] >= 0 { + amount = amount - denominations[i-1] + l++ + } + } + if amount < 0 { + return -1 + } else if amount > 0 { + return -1 + } + return l +} + +// CoinCombination returns a map with the specific combination of coins that gives +// the minimum number. The keys are coin denominations and values are the number of +// coins used for each denomination. +// If the amount cannot be made with the given denominations, return an empty map. +func CoinCombination(amount int, denominations []int) map[int]int { + coinCombination := make(map[int]int) + for i := len(denominations); i > 0; i-- { + for amount-denominations[i-1] >= 0 { + amount = amount - denominations[i-1] + coinCombination[denominations[i-1]]++ + } + } + if amount < 0 { + combination := make(map[int]int) + return combination + } + return coinCombination +} diff --git a/challenge-3/solution-template.go b/challenge-3/solution-template.go index 678c1d24..378a3fbb 100644 --- a/challenge-3/solution-template.go +++ b/challenge-3/solution-template.go @@ -15,23 +15,38 @@ type Manager struct { // AddEmployee adds a new employee to the manager's list. func (m *Manager) AddEmployee(e Employee) { - // TODO: Implement this method + m.Employees = append(m.Employees, e) } // RemoveEmployee removes an employee by ID from the manager's list. func (m *Manager) RemoveEmployee(id int) { - // TODO: Implement this method + var removeValue []Employee + for i := 0; i < len(m.Employees); i++ { + if m.Employees[i].ID == id { + continue + } else { + removeValue = append(removeValue, m.Employees[i]) + } + m.Employees = removeValue + } } // GetAverageSalary calculates the average salary of all employees. func (m *Manager) GetAverageSalary() float64 { - // TODO: Implement this method - return 0 + var aveSal float64 + for i := 0; i < len(m.Employees); i++ { + aveSal += m.Employees[i].Salary + } + return aveSal / float64(len(m.Employees)) } // FindEmployeeByID finds and returns an employee by their ID. func (m *Manager) FindEmployeeByID(id int) *Employee { - // TODO: Implement this method + for i := 0; i < len(m.Employees); i++ { + if m.Employees[i].ID == id { + return &m.Employees[i] + } + } return nil } From 1d016e6e4e6e53a94e894188b80a9d5f81baea78 Mon Sep 17 00:00:00 2001 From: gorbushka3000 Date: Tue, 4 Nov 2025 20:38:31 +0300 Subject: [PATCH 5/5] Add solution for Challenge 18 by Gorbushka3000 --- .../Gorbushka3000/solution-template.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 challenge-18/submissions/Gorbushka3000/solution-template.go diff --git a/challenge-18/submissions/Gorbushka3000/solution-template.go b/challenge-18/submissions/Gorbushka3000/solution-template.go new file mode 100644 index 00000000..9a9e3f91 --- /dev/null +++ b/challenge-18/submissions/Gorbushka3000/solution-template.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + // Example usage + celsius := 25.0 + fahrenheit := CelsiusToFahrenheit(celsius) + fmt.Printf("%.2f°C is equal to %.2f°F\n", celsius, fahrenheit) + + fahrenheit = 68.0 + celsius = FahrenheitToCelsius(fahrenheit) + fmt.Printf("%.2f°F is equal to %.2f°C\n", fahrenheit, celsius) +} + +// CelsiusToFahrenheit converts a temperature from Celsius to Fahrenheit +// Formula: F = C × 9/5 + 32 +func CelsiusToFahrenheit(celsius float64) float64 { + c := celsius + return Round(c*1.8+32, 2) +} + +// FahrenheitToCelsius converts a temperature from Fahrenheit to Celsius +// Formula: C = (F - 32) × 5/9 +func FahrenheitToCelsius(fahrenheit float64) float64 { + f := (fahrenheit - 32) * 5 / 9 + return Round(f, 2) +} + +// Round rounds a float64 value to the specified number of decimal places +func Round(value float64, decimals int) float64 { + precision := math.Pow10(decimals) + return math.Round(value*precision) / precision +}