31ph4n70m

Funny_Words_Generator.d

Dec 16th, 2019
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.84 KB | None | 0 0
  1. // D solution to codabbey challenge 72
  2. import std.stdio;
  3. import std.array;
  4. import std.conv;
  5. import std.algorithm;
  6.  
  7. void main() {
  8.     int[] INP1 = readln().split().map!(v => v.to!int).array();
  9.     int[] INP2 = readln().split().map!(v => v.to!int).array();
  10.     string[] RSP;
  11.     string CON = "bcdfghjklmnprstvwxz";
  12.     string VOW = "aeiou";
  13.     int A = 445;
  14.     int C = 700001;
  15.     int M = 2097152;
  16.     int XN = INP1[1];
  17.     int LI = 0;
  18.     for (int i = 0; i < INP1[0]; i++){
  19.         string WORD = "";
  20.         for (int j = 1; j <= INP2[i]; j++) {
  21.             XN = (A*XN + C) % M;
  22.             if(j % 2 == 0){
  23.                 LI = XN % 5;
  24.                 WORD ~= VOW[LI];
  25.             }else{
  26.                 LI = XN % 19;
  27.                 WORD ~= CON[LI];
  28.             }
  29.         }
  30.         RSP ~= WORD;
  31.     }
  32.     writeln(join(RSP, " "));
  33. }
Add Comment
Please, Sign In to add comment