-
Notifications
You must be signed in to change notification settings - Fork 79
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
Лабораторная работа №3 - Садовничий #112
base: Sadovnichij_Denis_Vladimirovich
Are you sure you want to change the base?
Changes from all commits
a8f7a64
09e0ed5
81422f9
67901cf
85490e2
42434ed
462abc1
3627c2e
60fcd0a
b53dc6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/.DS_Store | ||
golang/.DS_Store | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package internal | ||
|
||
import ( | ||
"math" | ||
"strings" | ||
) | ||
|
||
// Поольский Алфавит | ||
func PolisAlphabet(text string) string { | ||
var symbols = [][]string{ | ||
{"ą", "a"}, | ||
{"ć", "c"}, | ||
{"ę", "e"}, | ||
{"ł", "l"}, | ||
{"ń", "n"}, | ||
{"ó", "o"}, | ||
{"ź", "z"}, | ||
{"ż", "z"}, | ||
} | ||
for i := 0; i < len(symbols); i++ { | ||
text = strings.Replace(text, symbols[i][0], symbols[i][1], -1) | ||
} | ||
return text | ||
} | ||
|
||
// Find All | ||
func FindAll(arr []int, number int) []int { | ||
var res []int | ||
for i := 0; i < len(arr); i++ { | ||
if arr[i] == number { | ||
res = append(res, i) | ||
} | ||
} | ||
return res | ||
} | ||
|
||
// Sum Min | ||
func SumMin(arr [][]int, m, n int) int { | ||
var res int | ||
for i := 0; i < m; i++ { | ||
min := math.Inf(1) | ||
for a := 0; a < n; a++ { | ||
if float64(arr[i][a]) < min { | ||
min = float64(arr[i][a]) | ||
} | ||
} | ||
res = res + int(min) | ||
} | ||
return res | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
package internal | ||
|
||
func Summ(a, b int) int { | ||
return a + b | ||
// Задача с Четное-Нечетное | ||
func EvenOdd(a int) string { | ||
if a%2 == 0 { | ||
return "Even" | ||
} else { | ||
return "Odd" | ||
} | ||
} | ||
|
||
// Количество овец | ||
func Sheep(arr []bool) int { | ||
var result, i int | ||
for ; i < len(arr); i++ { | ||
if arr[i] && (arr[i] || !arr[i]) { | ||
result++ | ||
} | ||
} | ||
return result | ||
} | ||
|
||
// Подсчет обезьян | ||
func Monkey(number int) []int { | ||
var result []int | ||
for n := 1; n <= number; n++ { | ||
result = append(result, n) | ||
} | ||
return result | ||
} | ||
|
||
// Подсчет бумаги | ||
func Printer(n, m int) int { | ||
if n < 0 || m < 0 { | ||
return 0 | ||
} | ||
return n * m | ||
} | ||
|
||
// Драконы | ||
func Dragons(ammo int, dragons int) bool { | ||
return ammo/2 >= dragons | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,69 @@ | ||||||
package main | ||||||
|
||||||
import "fmt" | ||||||
import ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. файлики .DS_Store добавьте в gitignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Все еще не удалили DS_Store, а без этого не смогу заапрувить PR |
||||||
"fmt" | ||||||
"math" | ||||||
|
||||||
"isuct.ru/informatics2022/internal" | ||||||
) | ||||||
|
||||||
func main() { | ||||||
fmt.Println("Hello world") | ||||||
var masB = []float64{1.16, 1.32, 1.47, 1.65, 1, 93} | ||||||
const a float64 = 2.0 | ||||||
var nx float64 = 1.2 | ||||||
var kx float64 = 4.2 | ||||||
var dx float64 = 0.6 | ||||||
|
||||||
fmt.Println("___Задание А___") | ||||||
fmt.Println(TaskA(a, nx, kx, dx)) | ||||||
fmt.Println("___Задание В___") | ||||||
fmt.Println(TaskB(a, masB)) | ||||||
fmt.Println("___Задачи с CodeWars___") | ||||||
|
||||||
// Задача с Четное-Нечетное | ||||||
fmt.Println(internal.EvenOdd(1703)) | ||||||
// Количество овец | ||||||
fmt.Println(internal.Sheep([]bool{true, false, true, true, true, true, false, false})) | ||||||
// Подсчет обезьян | ||||||
fmt.Println(internal.Monkey(10)) | ||||||
// Подсчет бумаги | ||||||
fmt.Println(internal.Printer(5, 2)) | ||||||
// Драконы | ||||||
fmt.Println(internal.Dragons(5, 2)) | ||||||
|
||||||
// Польский Алфавит | ||||||
fmt.Println(internal.PolisAlphabet("Gdzie jest biały węgorz?")) | ||||||
|
||||||
//FindAll | ||||||
fmt.Println(internal.FindAll([]int{3, 4, 2, 5, 4, 1, 76, 65, 3, 5, 4, 5, 2, 3}, 3)) | ||||||
|
||||||
// Сумма минимальных чисел | ||||||
var numbersArr = [][]int{ | ||||||
{1, 2, 3, 4, 5}, | ||||||
{5, 6, 7, 8, 9}, | ||||||
{20, 21, 34, 56, 100}, | ||||||
} | ||||||
fmt.Println(internal.SumMin(numbersArr, 3, 5)) | ||||||
} | ||||||
|
||||||
func TaskA(a, nx, kx, dx float64) []float64 { | ||||||
var taskA []float64 | ||||||
|
||||||
for x := nx; x <= kx; x += dx { | ||||||
taskA = append(taskA, formula(x, a)) | ||||||
} | ||||||
return taskA | ||||||
} | ||||||
|
||||||
func TaskB(b float64, masB []float64) []float64 { | ||||||
var taskB []float64 | ||||||
for i := 0; i < len(masB); i++ { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
taskB = append(taskB, formula(masB[i], b)) | ||||||
} | ||||||
return taskB | ||||||
} | ||||||
|
||||||
func formula(x float64, a float64) float64 { | ||||||
var y float64 = (math.Log10(a + x)) / ((a + x) * (a + x)) | ||||||
return y | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
package internal_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"isuct.ru/informatics2022/internal" | ||
) | ||
|
||
func TestSumm(t *testing.T) { | ||
summ := internal.Summ(2, 3) | ||
if summ != 5 { | ||
t.Fatalf(`Summ(2,3) = %d, want 5, error`, summ) | ||
} | ||
} | ||
// func TestSumm(t *testing.T) { | ||
// summ := internal.Summ(2, 3) | ||
// if summ != 5 { | ||
// t.Fatalf(`Summ(2,3) = %d, want 5, error`, summ) | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно * добавить **/.DS_Store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну и сам DS_Store надо удалить
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сам бинарный файл все еще присутствует в репозитории
https://stackoverflow.com/questions/13541615/how-to-remove-files-that-are-listed-in-the-gitignore-but-still-on-the-repositor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему опять файлик DsStore попал? мы ж в прошлый раз починили?