Skip to main content
13 of 16
added 1 character in body
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

Japt v1.4.5, 61 59 92 85 84 70 68 bytes

Assumes number inputs will always contain multiple digits. Outputs 0 for invalid string inputs.


"OIREASGTBP"
"%v"²
Ñ?UsV eW,_ínuÃeWu _íuu:UnV *!Uè["[^{V}NU]"WWu]q|

Try it (Includes all test cases)


  • 2 4 bytes saved thank to obarakon, who also convinced me to take this up again after I abandoned it earlier. I wish he hadn't!
  • 33 26 25 23(!) bytes sacrificed to check input validity.

\n"..."\n"%v"²\nÑ?UsV eW,_ínuÃeWu _íuu:UnV *!Uè["[^{V}NU]"WWu]q|     :Implicit input of integer or string U
\n                                                                   :Prevent input value of U from being overridden
  "..."\n                                                            :Assign the string "OIREASGTBP" to variable V
         "%v"²                                                       :"%v" duplicated, giving the Japt RegEx class for /[AEIOU][AEIOU]/g
              \n                                                     :Assign to variable W
                Ñ                                                    :Multiply the input by 2
                 ?                                                   :If truthy (not NaN)
                  UsV                                                :  Convert U to a string in custom base V
                      eW                                             :  Recursively replace all occurrences of W
                         _                                           :  By passing them through the following function
                          í                                          :    Interleave with
                           n                                         :      Literal "n"
                            u                                        :      Uppercase
                             Ã                                       :  End replace
                              eWu                                    :  Recursively replace all occurrences of W uppercased (RegEx /[^AEIOU][^AEIOU]/g)
                                  _                                  :  By passing them through the following function
                                   íuu                               :    Interleave with "u" uppercased
                                      :                              :Else
                                       UnV                           :  Convert U from a base-V string to an integer
                                           *!                        :  Multiply by the logical NOT of
                                             Uè                      :    Count the occurrences in U of
                                               [                     :      Construct an array containing
                                                "[^{V}NU]"           :        Literal string with V interpolated,
                                                          WWu        :        W & uppercase W
                                                             ]       :      End array
                                                              q|     :      Join with "|", giving "[^OIREASGTBPNU]|%v%v|%V%V"=/[^OIREASGTBPNU]|[AEIOU][AEIOU]|[^AEIOU][^AEIOU]/g
Shaggy
  • 43.5k
  • 4
  • 36
  • 94