mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.0 KiB
72 lines
1.0 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
5 years ago
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"./student"
|
||
|
)
|
||
5 years ago
|
|
||
5 years ago
|
func drawLine(x int, s string) {
|
||
|
beg := s[0]
|
||
|
med := s[1]
|
||
|
end := s[2]
|
||
5 years ago
|
if x >= 1 {
|
||
5 years ago
|
fmt.Printf("%c", beg)
|
||
5 years ago
|
}
|
||
|
if x > 2 {
|
||
|
for i := 0; i < (x - 2); i++ {
|
||
5 years ago
|
fmt.Printf("%c", med)
|
||
5 years ago
|
}
|
||
|
}
|
||
|
if x > 1 {
|
||
5 years ago
|
fmt.Printf("%c", end)
|
||
5 years ago
|
}
|
||
5 years ago
|
fmt.Println()
|
||
5 years ago
|
}
|
||
|
|
||
|
func printTheLines(x, y int, strBeg, strMed, strEnd string) {
|
||
|
if y >= 1 {
|
||
|
drawLine(x, strBeg)
|
||
|
}
|
||
|
if y > 2 {
|
||
|
for i := 0; i < y-2; i++ {
|
||
|
drawLine(x, strMed)
|
||
|
}
|
||
|
}
|
||
|
if y > 1 {
|
||
|
drawLine(x, strEnd)
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
func raid1a(x, y int) {
|
||
5 years ago
|
if x < 1 || y < 1 {
|
||
|
return
|
||
|
}
|
||
|
printTheLines(x, y, "o-o", "| |", "o-o")
|
||
|
}
|
||
5 years ago
|
|
||
|
func main() {
|
||
|
// testing examples of subjects
|
||
|
table := []int{
|
||
|
5, 3,
|
||
|
5, 1,
|
||
|
1, 1,
|
||
|
1, 5,
|
||
|
}
|
||
|
|
||
|
// testing special cases and one valid random case.
|
||
|
table = append(table,
|
||
|
0, 0,
|
||
|
-1, 6,
|
||
|
6, -1,
|
||
|
lib.RandIntBetween(1, 20), lib.RandIntBetween(1, 20),
|
||
|
)
|
||
|
|
||
|
// Tests all possibilities including 0 0, -x y, x -y
|
||
|
for i := 0; i < len(table); i += 2 {
|
||
|
if i != len(table)-1 {
|
||
|
lib.Challenge("Raid1a", raid1a, student.Raid1a, table[i], table[i+1])
|
||
|
}
|
||
|
}
|
||
|
}
|