Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // golang solution to codeabbey challenge 72
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strings"
- "strconv"
- )
- func main(){
- reader := bufio.NewReader(os.Stdin)
- i1, _ := reader.ReadString('\n')
- i1 = strings.TrimSuffix(i1, "\n")
- strnums1 := strings.Split(i1, " ")
- i2, _ := reader.ReadString('\n')
- strnums2 := strings.Split(i2, " ")
- INP1 := []int{}
- INP2 := []int{}
- for _, i := range strnums1 {
- j, err := strconv.Atoi(i)
- if err != nil {
- panic(err)
- }
- INP1 = append(INP1, j)
- }
- for _, i := range strnums2 {
- j, err := strconv.Atoi(i)
- if err != nil {
- panic(err)
- }
- INP2 = append(INP2, j)
- }
- CON := []string{"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "z"}
- VOW := []string{"a", "e", "i", "o", "u"}
- A, C, M := 445, 700001, 2097152
- XN := INP1[1]
- LI := 0
- RSP := []string{}
- for i := 0; i < INP1[0]; i++ {
- WORD := ""
- for j := 1; j <= INP2[i]; j++ {
- XN = (A*XN + C) % M
- if j % 2 == 0{
- LI = XN % 5
- WORD += VOW[LI]
- }else{
- LI = XN % 19
- WORD += CON[LI]
- }
- }
- RSP = append(RSP, WORD)
- }
- fmt.Println(strings.Join(RSP[:], " "))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement