Advertisement
31ph4n70m

Funny_Words_Generator.go

Dec 16th, 2019
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.40 KB | None | 0 0
  1. // golang solution to codeabbey challenge 72
  2. package main
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7.     "strings"
  8.     "strconv"
  9. )
  10.  
  11. func main(){
  12.     reader := bufio.NewReader(os.Stdin)
  13.     i1, _ := reader.ReadString('\n')
  14.     i1 = strings.TrimSuffix(i1, "\n")
  15.     strnums1 := strings.Split(i1, " ")
  16.    
  17.     i2, _ := reader.ReadString('\n')
  18.     strnums2 := strings.Split(i2, " ")
  19.    
  20.     INP1 := []int{}
  21.     INP2 := []int{}
  22.    
  23.     for _, i := range strnums1 {
  24.         j, err := strconv.Atoi(i)
  25.         if err != nil {
  26.             panic(err)
  27.         }
  28.         INP1 = append(INP1, j)
  29.     }
  30.    
  31.     for _, i := range strnums2 {
  32.         j, err := strconv.Atoi(i)
  33.         if err != nil {
  34.             panic(err)
  35.         }
  36.         INP2 = append(INP2, j)
  37.     }
  38.    
  39.     CON := []string{"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "z"}
  40.     VOW := []string{"a", "e", "i", "o", "u"}
  41.     A, C, M := 445, 700001, 2097152
  42.     XN := INP1[1]
  43.     LI := 0
  44.     RSP := []string{}
  45.    
  46.     for i := 0; i < INP1[0]; i++ {
  47.         WORD := ""
  48.         for j := 1; j <= INP2[i]; j++ {
  49.             XN = (A*XN + C) % M
  50.             if j % 2 == 0{
  51.                 LI = XN % 5
  52.                 WORD += VOW[LI]
  53.             }else{
  54.                 LI = XN % 19
  55.                 WORD += CON[LI]
  56.             }
  57.         }
  58.         RSP = append(RSP, WORD)
  59.     }
  60.    
  61.     fmt.Println(strings.Join(RSP[:], " "))
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement