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.
52 lines
882 B
52 lines
882 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
|
||
5 years ago
|
student "student"
|
||
|
|
||
4 years ago
|
"github.com/01-edu/public/go/tests/lib"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func nRune(s string, n int) rune {
|
||
|
if n > len(s) || n < 1 {
|
||
|
return 0
|
||
|
}
|
||
|
runes := []rune(s)
|
||
|
return runes[n-1]
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
type node struct {
|
||
|
word string
|
||
|
n int
|
||
|
}
|
||
|
|
||
|
table := []node{}
|
||
|
|
||
|
for i := 0; i < 30; i++ {
|
||
5 years ago
|
wordToInput := lib.RandASCII()
|
||
5 years ago
|
val := node{
|
||
|
word: wordToInput,
|
||
|
n: rand.Intn(len(wordToInput)) + 1,
|
||
|
}
|
||
|
table = append(table, val)
|
||
|
}
|
||
|
|
||
|
table = append(table,
|
||
|
node{word: "Hello!", n: 3},
|
||
|
node{word: "Salut!", n: 2},
|
||
|
node{word: "Ola!", n: 4},
|
||
|
node{word: "♥01!", n: 1},
|
||
|
node{word: "Not", n: 6},
|
||
|
node{word: "Also not", n: 9},
|
||
|
node{word: "Tree house", n: 5},
|
||
|
node{word: "Whatever", n: 0},
|
||
|
node{word: "Whatshisname", n: -2},
|
||
|
)
|
||
|
|
||
|
for _, arg := range table {
|
||
5 years ago
|
lib.Challenge("NRune", student.NRune, nRune, arg.word, arg.n)
|
||
5 years ago
|
}
|
||
|
}
|