Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # R solution to codeabbey challenge 72
- INP1 = c(22, 1838911)
- INP2 = c(3, 5, 5, 4, 6, 8, 8, 5, 3, 5, 4, 7, 6, 4, 3, 5, 5, 7, 7, 5, 8, 6)
- CON = unlist(strsplit("bcdfghjklmnprstvwxz", ""))
- VOW = unlist(strsplit("aeiou", ""))
- A = 445
- C = 700001
- M = 2097152
- XN = INP1[2]
- LI = 0
- RSP = list()
- for (wl in INP2) {
- WORD = ""
- for (i in 1:wl) {
- XN = (A*XN + C) %% M
- if ( i %% 2 == 0){
- LI = XN %% 5
- WORD = paste(WORD, VOW[LI+1], sep="", collapse=NULL)
- }else{
- LI = XN %% 19
- WORD = paste(WORD, CON[LI+1], sep="", collapse=NULL)
- }
- }
- RSP[length(RSP)+1] = WORD
- }
- cat(unlist(RSP))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement