40
\$\begingroup\$

Introduction

The current coronavirus disease is officially named COVID-19, from the 3 words corona virus disease, and the year 2019. (Technically it's coronavirus, making 2 words, but whatever...)

Given this example, we can apply this naming convention to name other potential diseases.

Challenge

You will be given 3 words and a year.

  • Take the first letters of the first 2 words, up to and including the first vowel, and append them together.
  • Then, append the first letter of the 3rd word.
  • Finally, append the character -, followed by the last 2 digits of the year.

Thus, corona,virus,disease,2019 -> co + vi + d + - + 19 -> covid-19.

Challenge rules

  • It is guaranteed that each of the three words have at least one vowel. For the purposes of this challenge, vowels are defined as the letters a, e, i, o, u.
  • You may assume that words consist only of lowercase letters a-z, or only uppercase letters A-Z if you prefer. Your output may be in either case.
  • It's guaranteed that the date is exactly four digits.
  • Input may be specified in any format, as long as there is a delimiter between the words. For example, ['corona', 'virus', 'disease', '2019'], corona,virus,disease,2019, [['corona', 'virus'], 'disease', 2019] and corona virus disease 2019 are all valid inputs.

This is , so shortest answer wins.

Example test cases

corona,virus,disease,2019 -> covid-19
computer,addiction,syndrome,1970 -> coas-70
code,golf,fun,2020 -> cogof-20
a,ba,ca,1234 -> abac-34
tree,string,create,9000 -> trestric-00
love,time,cholera,1985 -> lotic-85
\$\endgroup\$
  • 1
    \$\begingroup\$ Can I take input in the format ['corona','virus'], 'disease', 2019? \$\endgroup\$ – Embodiment of Ignorance Mar 18 at 19:07
  • 11
    \$\begingroup\$ Welcome to code golf, thank you for submitting a clear and well specified first challenge. Please consider editing your test cases to be easier to copy and paste without modification (I recommend removing the bullets and putting them in one code block). For future challenges please consider using our sandbox. Good luck :) \$\endgroup\$ – FryAmTheEggman Mar 18 at 19:07
  • 4
    \$\begingroup\$ When you say we may ignore all capitalization, does that mean we can expect input to be lowercase? Or that we have to handle different types of capitalization (but may output whichever capitalization)? \$\endgroup\$ – xnor Mar 18 at 19:07
  • 1
    \$\begingroup\$ OK, can we expect that the three words consist only of letters a-z (or A-Z if we choose)? \$\endgroup\$ – xnor Mar 18 at 19:18
  • 2
    \$\begingroup\$ Golfers might find it useful to look at answers to Spoonerise words, which also involves extracting consonants before (though not including) the first vowel of two words. \$\endgroup\$ – xnor Mar 18 at 22:05

28 Answers 28

20
\$\begingroup\$

Python 3, 83 81 bytes

lambda a,b,c,d:g(*a)+g(*b)+c[0]+"-"+d[2:]
g=lambda c,*s:c[:c in"aeiou"]or c+g(*s)

Try it online!

-2 bytes thanks to @JonathanAllan!

Explanation:

g is a recursive function that takes in a splatted string and return the string, truncated after the first vowel.

  • lambda c,*s gather the splatted string into the first character c and the rest s.
  • c[:c in"aeiou"] or c+g(*s) evaluates to:
    • if c is a vowel, then c[:c in"aeiou"] evaluates to c[:1] which is c. Since c is Truthy, it is returned.
    • if c is not a vowel, then c[:c in"aeiou"] evaluates to c[:0] aka the empty string. The empty string is Falsy, so c+g(*s) (the recursive case) is returned.


Old solution, kept here for sentimental reason

Python 3, 89 bytes

lambda a,b,c,d:g(a)+g(b)+c[0]+"-"+d[2:]
g=lambda s:s[:[x in"aeiou"for x in s].index(1)+1]

Try it online!

|improve this answer|||||
\$\endgroup\$
  • 1
    \$\begingroup\$ Really clever list comprehension! \$\endgroup\$ – RGS Mar 18 at 20:39
  • 3
    \$\begingroup\$ g=lambda c,*s:c[:c in"aeiou"]or c+g(*s) saves 2 \$\endgroup\$ – Jonathan Allan Mar 18 at 20:43
  • 1
    \$\begingroup\$ Wow this is really nice \$\endgroup\$ – Oliver Ni Mar 18 at 20:46
  • 1
    \$\begingroup\$ @JonathanAllan Very clever! Thanks! \$\endgroup\$ – Surculose Sputum Mar 18 at 20:48
9
\$\begingroup\$

Java 8, 82 74 71 67 61 bytes

s->s.replaceAll((s="(.*?[aeiou]).*,")+s+"(.).*,..","$1$2$3-")

-8 bytes thanks to @ValueInk.
-6 bytes thanks to @Nevay.

Input as a single comma-separated string like in the challenge description.

Try it online.

Explanation:

s->                // Method with String as both parameter and return-type
  s.replaceAll(    //  Regex-replace the match with the replacement (see below)
                   //   As match:
    (s="(.*?[aeiou]).*,")+s
                  //     Repeat this String twice (re-using the input-variable)
    +"(.).*,..",  //     and append this String
    "$1$2$3-")    //    And as replacement: use this String

Regex explanation:

(.*?[aeiou]).*,(.*?[aeiou]).*,(.).*,..  # MATCH:
 .*                                     #  0 or more characters
   ?                                    #  which are optional to lower their priority
    [aeiou]                             #  followed by a vowel
(          )                            #  Stored in capture group 1
            .*                          #  Followed by some optional characters
              ,                         #  and a comma
               (.*?[aeiou]).*,          #  Same again, with capture group 2
                               .        #  Then a single character
                              ( )       #  Stored in capture group 3
                                 .*     #  Followed by some optional characters
                                   ,    #  and a comma again
                                    ..  #  Followed by 2 characters

$1$2$3-                                 # REPLACEMENT:
$1$2$3                                  #  The contents of groups 1, 2, and 3
      -                                 #  Appended with a literal "-"

Note how the two trailing digits of the input-String aren't touched, and will still be there after the replacement.

|improve this answer|||||
\$\endgroup\$
  • 1
    \$\begingroup\$ Do non-greedy quantifiers like .*? not work in Java? \$\endgroup\$ – Value Ink Mar 18 at 22:45
  • \$\begingroup\$ @ValueInk They do, so thanks for -8. :) \$\endgroup\$ – Kevin Cruijssen Mar 19 at 8:26
  • 1
    \$\begingroup\$ The last capture group can be removed, 61 bytes: s->s.replaceAll((s="(.*?[aeiou]).*,")+s+"(.).*,..","$1$2$3-") \$\endgroup\$ – Nevay Mar 19 at 15:40
  • \$\begingroup\$ @Nevay Smart thanks! Haven't seen you here in a while. :) \$\endgroup\$ – Kevin Cruijssen Mar 19 at 15:56
8
\$\begingroup\$

Retina 0.8.2, 26 bytes

\B.*¶\d.
-
([aeiou]).*¶
$1

Try it online! Link includes test suite. Takes lowercase words and year on separate lines, but test suite splits each test case on commas automatically for the convenience of the user. Explanation:

\B.*¶\d.
-

Truncate the last word after the first character, remove the first two digits of the year, and join the two together with a -.

([aeiou]).*¶
$1

Truncate each of the first two words after the first vowel, and join everything together.

|improve this answer|||||
\$\endgroup\$
6
\$\begingroup\$

Japt v2.0a0 -P, 15 bytes

®¯ÒZb\vÃpVÎ'-W¤

Saved a byte thanks to @Shaggy (s2 -> ¤)

Try it

®¯ÒZb\vÃpVÎ'-W¤           Input: ["corona" "virus"] "disease" "2019"
®      Ã                  Map ["corona" "virus"] to 
   Zb\v                     Index of first vowel in word
  Ò                         Add one
 ¯                          Slice 0..index+1
                          ["co" "vi"]
        p                 Append the following:
         VÎ               A) First letter of third word
           '-             B) "-"
             W¤           C) Last two digits of year
                          ["co" "vi" "d" "-" "19"]
-P                        Implicit join -> "covid-19"
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Don't forget the shortcut for s2. \$\endgroup\$ – Shaggy Mar 18 at 22:12
5
\$\begingroup\$

Jelly,  18  17 bytes

ḣe€ØcM$ḢƊ€⁴Ḣ”-3⁵ṫ

A full program accepting arguments ['word1', 'word2'] 'word3' 'year' which prints the result.

Try it online!

How?

ḣe€ØcM$ḢƊ€⁴Ḣ”-3⁵ṫ - Main Link: [word1, word2]
         €        - for each (w in [word1, word2]):
        Ɗ         -   last three links as a monad:
      $           -     last two links as a monad:
  €               -       for each (character, c of w):
 e                -         (c) exists in?:
   Øc             -           vowels = "AEIOUaeiou"
     M            -       maximal indices (i.e (sorted) indices of vowels in w)
ḣ                 -     head to index (vectorises across the list of indices):
       Ḣ          -     head (the first such head-to-index result)
          ⁴       - program's 2nd argument, word3
                  - ...N.B. a nilad here forces Jelly to smash the previous list
                  -         together and print to STDOUT.
           Ḣ      - head - i.e. the first character of the third word
            ”-    - literal '-' character
                  - ...N.B. again a nilad here forces a print of the previous
                  -         result, the first character of the third word.
              3   - literal three
               ⁵  - program's 3rd argument, year
                ṫ - tail from index (i.e. "2019" -> "19")
                  - implicit print (of these two characters)
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Outputs covid19 instead of covid-19. \$\endgroup\$ – rkong Mar 18 at 20:18
  • 1
    \$\begingroup\$ Ah missed that requirement somehow - will fix... \$\endgroup\$ – Jonathan Allan Mar 18 at 20:19
  • 2
    \$\begingroup\$ Fixed, and thanks for notifying :) \$\endgroup\$ – Jonathan Allan Mar 18 at 20:21
4
\$\begingroup\$

Bash + Core utilities, 58 55 bytes

sed -E 's/([aeiou]).*/\1/;3s/\B.*/-/;4s/..//'|tr -d \\n

Try it online!

3 bytes shorter through the use of \B, thanks to user41805.

Accepts newline-delimited input on stdin.

Output on stdout.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Nice thinking on separating by newlines! \$\endgroup\$ – Captain Man Mar 19 at 15:18
  • \$\begingroup\$ You can give sed the -z flag and remove newlines with sed to save a byte. And using \B in your second sed substitution can help save a bit \$\endgroup\$ – user41805 Mar 20 at 11:16
  • \$\begingroup\$ @user41805 Thanks -- I put in the \B improvement. I don't see right away how to use -z in a way that's compatible with the rest of the code; I had looked at that originally and it didn't seem to do what I needed. \$\endgroup\$ – Mitchell Spector Mar 20 at 16:20
  • \$\begingroup\$ Ah my bad, I missed your usage of addresses, so it seems -z doesn't provide a shorter alternative \$\endgroup\$ – user41805 Mar 21 at 8:10
3
\$\begingroup\$

Python 3, 86 bytes

lambda t,c,y:''.join(re.sub('([aeiou]).*',r'\1',s)for s in t)+c[0]+'-'+y[2:]
import re

Try it online!

Inputs the first two words in a tuple followed by the third word and then year as a string.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ This doesn't explicitly check for the vowels; it just appends the first 2 characters of the first 2 words, so it fails on tree,string,create,9000. \$\endgroup\$ – rkong Mar 18 at 19:25
  • 1
    \$\begingroup\$ @rkong Fixed it. \$\endgroup\$ – Noodle9 Mar 18 at 19:31
  • 1
    \$\begingroup\$ beat you to 86 bytes whoops \$\endgroup\$ – Oliver Ni Mar 18 at 20:43
  • 2
    \$\begingroup\$ @OliverNi Just golfed that and then saw you did the same, dropping your helper lambda! :D \$\endgroup\$ – Noodle9 Mar 18 at 20:45
  • 1
    \$\begingroup\$ haha :DD its like pretty much exactly the same \$\endgroup\$ – Oliver Ni Mar 18 at 20:45
3
\$\begingroup\$

Perl 5 -p, 48 bytes

$p='(.*?[aeiou]).*? 'x2;s/$p(.).*(..)/$1$2$3-$4/

Try it online!

Basically, a straight forward regex to pick out the relevant parts and put them back together.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Save three bytes: $p='(.*?[aeiou]).*? 'x2;s/$p(.).* ../$1$2$3-/ \$\endgroup\$ – Abigail Mar 19 at 6:39
3
\$\begingroup\$

QuadS, 33 bytesSBCS

Takes lowercase multi-line input.

∊('-',⍨⊃)¨@3⊢⍵
^.*?[aeiou]|\d.$
&

Try it online!

& Search for and return

^.*?[aeiou]|\d.$ initial letters ending with a vowel, or a trailing digit with another character

⊢⍵ on that

()¨@3at the third match:

 pick the first character

'-',⍨ prepend a dash

ϵnlist (flatten)

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

Python 3, 86 bytes

lambda a,c,d:''.join(re.sub("([aeiou]).*",r"\1",x)for x in a)+c[0]+"-"+d[2:]
import re

Accepts input like ["corona", "virus"], "disease", "2019"

Try it online!

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

JavaScript (ES6),  65  63 bytes

Takes input as 4 distinct strings.

(a,b,[c],[,,d,e])=>a.match(r=/.*?[aeiou]/)+b.match(r)+c+'-'+d+e

Try it online!


JavaScript (ES6), 71 bytes

Takes input as ["word1", "word2", "word3", "year"].

a=>'012-3'.replace(/\d/g,i=>a[i].match([,,/./,/..$/][i]||/.*?[aeiou]/))

Try it online!

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ y.slice(-2) -> y[2]+y[3] for -2 bytes \$\endgroup\$ – Embodiment of Ignorance Mar 18 at 20:43
  • \$\begingroup\$ @EmbodimentofIgnorance Thanks. I've just noticed that the year is guaranteed to be made of 4 digits and was already editing to another 63. \$\endgroup\$ – Arnauld Mar 18 at 20:45
2
\$\begingroup\$

Icon, 95 bytes

procedure f(a,b,c,d)
return a[1:1+upto(t:='aoeiu',a)]||b[1:1+upto(t,b)]||c[1]||"-"||d[3:0] 
end

Try it online!

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

perl -anE, 65 bytes

s/[aeiou]\K\w+// for@F[0,1];$F[2]=~s/.\K.*//;$F[3]=~s/../-/;say@F
|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

Zsh, 41 bytes

<<<${(Mj::)@[1,2]#*[aeiou]}${3[1]}-${4:2}

Try it online!

Normally ${param#pattern} is prefix removal, adding the (M) flag keeps the prefix instead.

<<<${(Mj::)@[1,2]#*[aeiou]}${3[1]}-${4:2}
   ${      @[1,2]         }                 # first two args
   ${(M   )      #*[aeiou]}                 # match shortest prefix ending with a vowel
   ${( j::)               }                 # join the resulting words on empty string
                           ${3[1]}          # third param, first char
                                   ${4:2}   # fourth param, starting at third char

If the first two words can be given as a single space seperated argument (as in corona virus disease 2019), then one byte can be saved for 40 bytes:

<<<${(Mj::)${=1}#*[aeiou]}${2[1]}-${3:2}

Try it online!

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

Ruby, 48 bytes

->a,b,c,d{a[r=/.*?[aeiou]/]+b[r]+c[0]+?-+d[2,2]}

Try it online!

|improve this answer|||||
\$\endgroup\$
2
\$\begingroup\$

APL (Dyalog Unicode), 44 40 bytes

Original (and more fun): {t←{⍵↑⍨⊃⍸⍵∊'aeiou'} ⋄ ,/⍎¨'tt12',¨' ↑↓',¨⍵}

Improved: {d←2∘↓⋄t←{⍵↑⍨⊃⍸⍵∊'aeiou'}⋄,/⍎¨'tt⊃d',¨⍵}

Try it online!1

Takes input of form: '''word''' '''word''' '''word''' '''dd-dd'''

This one is just a lot of fun and rather unconventional. Not necessarily the shortest, but that's the price of fun! Have a feeling t function can be further golfed but haven't managed to. The rest I'll leave as is because it's primarily neat; concision is secondary for once. Plus, who could possibly stomach messing with 42 bytes!

I'll add the full explanation tomorrow, however in short it's all just an abuse of the fact that we were trusted to determine the input format. Thus, one can pass it to the function as data and prepend (with a couple zips) the necessary manipulations, before evaluating the pieces of the list. This requires taking strings of strings as input; In Dyalog APL, quotes are escaped by doubling them, so printing '''Hello world''' yields 'Hello world'.

Before each element is evaluated and concatenated: {'tt12',¨' ↑↓',¨⍵} yields t 'corona' , t 'virus' , 1↑'disease' , 2↓'20-19'. The two strings in the function are zipped together with the input to yield a piece of code containing the manipulations we desire for each piece. To clarify, t is the function which takes a string and returns the first elements until a vowel is spotted. The function t is defined in the right half of the code.


1Due to the dangerous 'execute' () operator, I've only gotten it to run online in TIO under dzaima's dialect, which is the TIO page linked above. However, as long it's downloaded, it'll work in any old flavor of Dyalog, so I'm insisting on marking it as such in the title!

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ You can use monadic instead of ,/. Btw, isn't an issue on TIO (only on TryAPL), so it works fine. \$\endgroup\$ – Adám Mar 23 at 9:36
  • \$\begingroup\$ I'm not sure including - in the input is quite in the spirit of the challenge. \$\endgroup\$ – Adám Mar 23 at 9:40
2
\$\begingroup\$

Erlang (escript), 124 bytes

f(A,B,C,D)->g(A)++g(B)++[hd(C)]++"-"++string:slice(D,2).
g([H|T])->case"aeiou"==("aeiou"--[H])of true->[H]++[g(T)];_->H end.

Try it online!

Explanation

f(A,B,C,D)->g(A)++g(B)                                            % Slice things up to vowels for A and B
                      ++[hd(C)]                          % Add the head of C
                                        ++"-"++string:slice(D,2). % Add a - and tail of D

g([H|T])-> % Recursive function for the vowel slicing
case"aeiou"==("aeiou"--[H])of true-> % If head isn't vowel:
[H]++[g(T)];                         % Return head + slicing (tail)
_->H end.                            % Else: return head
```
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Charcoal, 26 bytes

⭆E²S…ι⌊ΦEaeiou⊕⌕ιλλ§S⁰-✂S²

Try it online! Link is to verbose version of code. Takes lowercase words either space or newline-separated. Explanation:

⭆E²S

For the first two words...

…ι⌊ΦEaeiou⊕⌕ιλλ

... find the positions of the vowels, and take the minimum of those that exist, and truncate the word after that point.

§S⁰

Print the first letter of the third word.

-

Print a -.

✂S²

Input the year as a string and print the last two digits.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 55 bytes

1(UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R?

Try it online!

I'm sure this can be optimized in so many different ways, but I'll throw it in here anyway.

|improve this answer|||||
\$\endgroup\$
  • 1
    \$\begingroup\$ "I'm sure this can be optimized in so many different ways" You're indeed correct. I'm not sure where to begin with giving optimization-tips tbh, so let me instead start by welcoming you to CGCC! :D Anyway, I made a start with some optimizations, including explanation why, here in this pastebin. If you have any questions, feel free to ask. \$\endgroup\$ – Kevin Cruijssen Mar 18 at 21:27
  • \$\begingroup\$ Thanks! Using the global array I'm saving the first index of each vowel, then filtering out -1s and taking the minimum \$\endgroup\$ – Command Master Mar 19 at 4:40
  • \$\begingroup\$ Ah ok. Hmm, in that case the ʒ2+≠} can be ®K as well, to just remove all -1. :) PS: There is also a +2 (and -2) builtin, which is Ì. \$\endgroup\$ – Kevin Cruijssen Mar 19 at 8:14
1
\$\begingroup\$

R, 106 bytes

function(a,b,c,y,s=substr,f=function(x)s(x,1,regexpr("[aeiou]",x)))paste0(f(a),f(b),s(c,1,1),"-",s(y,3,4))

Try it online!

Say hello to R's atrocious handling of strings. I wouldn't be surprised if this could be golfed significantly.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Red, 94 92 bytes

func[a b c d][g: func[t][head clear find/tail t
charset"aoeiu"]rejoin[g a g b c/1"-"at d 3]]

Try it online!

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 64 bytes

(a,[b],c)=>a.map(x=>/.*?[aeiou]/.exec(x)).join``+b+'-'+c[2]+c[3]

Try it online!

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 22 bytes

εžMySkd0šÅ¡н}Iн'-I¦¦)S

Inputs as ["corona","virus"], disease, and 2019.
Output as a list of characters.

Try it online or verify all test cases. (Feel free to remove the Join in the footer to see the actual output-list.)

Explanation:

ε                      # Map over the first (implicit) input-list of strings:
 žM                    #  Push the vowel constant "aeiou"
   y                   #  Push the current word we're mapping over
    S                  #  Convert it to a list of characters
                       #   i.e. "virus" → ["v","i","r","u","s"]
     k                 #  Get the index of each character in the string (-1 if not found)
                       #   → [-1,2,-1,4,-1]
      d                #  Check for each index if it's non-negative (>= 0)
                       #   → [0,1,0,1,0]
       0š              #  Prepend a 0 to this list
                       #   → [0,0,1,0,1,0]
         Å¡            #  Split the string we're mapping over on the truthy indices
                       #   → ["vi","ru","s"]
           н           #  And only leave the first part
                       #   → "vi"
            }I         # After the map: push the second input-string
              н        # Pop and push just its first letter
                       #  i.e. "disease" → "d"
               '-     '# Push a literal "-"
                 I     # Push the third input-integer
                  ¦¦   # Remove its first two digits
                       #  i.e. 2019 → 19
                    )  # Wrap all values on the stack into a list
                       #  → [[["c","o"],["v","i"]],"d","-","19"]
                     S # And convert it to a flattened list of characters
                       #  → ["c","o","v","i","d","-","1","9"]
                       # (after which it is output implicitly as result)
|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

Perl 6, 44 bytes

{S:g/<[aeiou]><(.*?\s//}o{S/\S<(\S*\s\d./-/}

Try it online!

Combination of two substitution regexes, the first to replace the third word and year with the letter dash date, and the second to remove anything between a vowel and a space (removing the space as well).

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

ssed -R, 70 bytes

Expects input through stdin in lowercase separated by spaces, e.g., corona virus disease 2019.

s_(.+?(?![aeiou])).*? (.+?(?![aeiou])).*? (.).*? \d\d(\d\d)_\1\2\3-\4_

ssed, known as "super sed", has PCRE which gives us non-greedy matchers.

(.+?(?![aeiou])).*?<space>
                ^^^^^^^^^^: Eats the rest of the word before the space
    ^^^^^^^^^^^: Before a character that is a vowel
 ^^^: Match fewest number of characters

The rest is simple enough once you understand the above. If anyone is interested I can go into more depth but I think this is enough.

The try-it-online thing doesn't have ssed installed in Bash. To try it locally you can install ssed through Homebrew by brew install ssed if you're on a mac. If anyone knows a way to get a working try-it-online I'll add it.

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

C (gcc), 96 bytes

#define z write(1,*a++,strcspn(*a,"aeiou")+1)
f(a,y)char**a;{z;z;printf("%c-%.2d\n",**a,y%100);}

-13 bytes and all concerns resolved thanks to ceilingcat!

Try it online!

|improve this answer|||||
\$\endgroup\$
1
\$\begingroup\$

dirt, 38

([^,]*[aeiou]{[^,]*,})*.{[^,]*,..}'-..

Accepts a comma-separated list of strings and outputs the disease name.

e.g. dirt disease.dirt -i "corona,virus,disease,2019" prints covid-19.

Non-competing because the language was created after the question was posted.

Explanation

(
 [^,]*      # match and output any number of non-comma characters
 [aeiou]    # match and output a vowel
 {          # with no output:
  [^,]*     # - match any number of non-comma characters
  ,         # - match a comma
 }
)*          # run the above any number of times.
.           # match and output 1 character.
{           # with no output:
 [^,]*      # - match any number of non-comma characters
 ,          # - match a comma
 ..         # - match 2 characters
}
'-          # output a hyphen
..          # match and output 2 characters
|improve this answer|||||
\$\endgroup\$
  • 1
    \$\begingroup\$ The non-competing rule for newer languages doesn't apply any more, so this submission is all good to go! \$\endgroup\$ – Lyxal Mar 24 at 7:14
0
\$\begingroup\$

Python 3, 128 124 122 119 bytes

a,b,c,d=input().split()
def g(a):
 for i in a:
  if i in'aeiou':return a[:a.find(i)+1]
print(g(a)+g(b)+c[0]+'-'+d[2:])

Try it online!

Pretty new, probably overcomplicated.

edit 1: saved four bytes by moving a part from print() to function

edit 2: saved two more bytes thanks to @surculose-sputum

edit 3: another three bytes thanks to @surculose-sputum

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ 109 bytes by: (1) use Python2, so input() is evaluated implicitly and print doesn't require parentheses. (2) replace a.index(i) by a.find(i). (3) remove redundant whitespaces. \$\endgroup\$ – Surculose Sputum Mar 24 at 15:28
  • \$\begingroup\$ @SurculoseSputum, thanks! don't plan to switch to python 2, but will gladly use the other tips! \$\endgroup\$ – Dion Mar 24 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.