Advertisement
31ph4n70m

Funny_Words_Generator.R

Dec 17th, 2019
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.68 KB | None | 0 0
  1. # R solution to codeabbey challenge 72
  2. INP1 = c(22, 1838911)
  3. INP2 = c(3, 5, 5, 4, 6, 8, 8, 5, 3, 5, 4, 7, 6, 4, 3, 5, 5, 7, 7, 5, 8, 6)
  4. CON = unlist(strsplit("bcdfghjklmnprstvwxz", ""))
  5. VOW = unlist(strsplit("aeiou", ""))
  6. A = 445
  7. C = 700001
  8. M = 2097152
  9. XN = INP1[2]
  10. LI = 0
  11. RSP = list()
  12. for (wl in INP2) {
  13.     WORD = ""
  14.     for (i in 1:wl) {
  15.         XN = (A*XN + C) %% M
  16.         if ( i %% 2 == 0){
  17.             LI = XN %% 5
  18.             WORD = paste(WORD, VOW[LI+1], sep="", collapse=NULL)
  19.         }else{
  20.             LI = XN %% 19
  21.             WORD = paste(WORD, CON[LI+1], sep="", collapse=NULL)
  22.         }
  23.        
  24.     }
  25.     RSP[length(RSP)+1] = WORD
  26. }
  27. cat(unlist(RSP))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement