6
\$\begingroup\$

I'm a big music fan, and I'm quite proud of my collection, but it seems some kind of sickness is going around the house, and all my vinyls have gotten quite ill. Can you help me find which ones have gotten sick, so I can quarantine them from the other ones?

Some of the albums, however, are false positives, and thus there is no point in quarantining them. An album is a false positive if:

  • "Ill" does not come at the beginning of any of the words it's featured in
  • A vowel besides "e" comes after the word "Ill" in all of the words it's featured in (y counts as a vowel)

If an album name contains a word that starts with "Ill", as well as meeting the vowel requirements shown above (aiouy cannot come after "Ill"), then output a truthy value. Otherwise, output a falsy value. The input string does not have to be case-sensitive, so Illmatic would be just as valid as illmatic or ILLMATIC, and you may choose whatever input case you please.

Additionally, there are no requirements or restrictions for the type of string that you handle (Ex: ASCII or utf-8), and there will never be adjacent spaces within a given album name (Ex: "Ill Communication").

Test cases:

"Illmatic" -> True

"Licensed to Ill" -> True

"Ill Communication" -> True

"The ILLEST Villains" -> True

"Illumination of the ill man" -> True

"Madvillainy" -> False

"Music Inspired by Illumination & Dr. Seuss' The Grinch" -> False

"The Illyiad" -> False

"Villains are Illuminated" -> False

"Exmilitary" -> False

This is , so shortest answer wins!

\$\endgroup\$
12
  • 3
    \$\begingroup\$ What's the expected result for "Illumination of the ill man"? (I suppose it's true, but the fact that the description focuses on false positives makes it a bit ambiguous.) \$\endgroup\$ Commented 2 days ago
  • 3
    \$\begingroup\$ Would Illyria count as ill according to the rules? You probably need clarification on what letters count as vowels. \$\endgroup\$ Commented 2 days ago
  • 2
    \$\begingroup\$ You should define true positives clearly. Also, does y count as a vowel? \$\endgroup\$ Commented yesterday
  • 1
    \$\begingroup\$ @Arnauld "Illumination of the ill man" would be true, my apologies for not clarifying \$\endgroup\$ Commented yesterday
  • 1
    \$\begingroup\$ @LuisMendo I believe I have defined everything clearer, but please let me know if there's any more clarifications to be made \$\endgroup\$ Commented yesterday

11 Answers 11

7
\$\begingroup\$

Regex (ECMAScript), 19 bytes

/\bill(?![aiouy])/i

Try it online!

Explanation

We look for ...

/             //
  \b          // a word boundary
  ill         // followed by "ill"
  (?![aiouy]) // not immediately followed by a, i, o, u or y
/i            // in case-insensitive mode
\$\endgroup\$
2
  • 1
    \$\begingroup\$ @Themoonisacheese Some regex dialects (such as VimScript) don’t have \b. \$\endgroup\$ Commented yesterday
  • \$\begingroup\$ Retina 0.8.2 version \$\endgroup\$ Commented yesterday
3
\$\begingroup\$

Rust, 117 91 bytes

Requires inputs to be lowercased and it might break horrendously on multibyte characters as per the challenge's allowances. Officially only supports single-byte character input.

|s:&str|s.split(' ').any(|w|w.starts_with("ill")&&(w.len()<4||!"aiouy".contains(&w[3..4])))

Ungolfed and explained:

// Non-regex answer; unless depending on flavor-specific behavior, 
// there's two regex answers already, they're just tagged as JS (ES6)
fn sick(album: &str) -> bool {
  // Rely on implicit returns
  album
    .split(' ') // split on literal space and iterate over the words
    .any(|word| // Check if any of the splits match a predicate
      word.starts_with("ill") // explains itself
      && (
        word.len()<4 // "ill" is the whole word, sick
        // OR the title does not match the pattern of false positives
        || !"aiouy".contains(&w[3..4]) // so it's sick
        // Rust doesn't allow byte indexing of strings, as some indices
        // may not be whole characters, it does allow indexing ranges
        // So this is effectively &w[3], but it panics if the char at
        // this position happens to be more than one byte long
      )
    )
}

Rust Playground link

New contributor
RivenSkaye is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
4
  • 1
    \$\begingroup\$ My apologies, but "y" does count as a vowel. I have since updated the question to make it more clear. \$\endgroup\$ Commented yesterday
  • 1
    \$\begingroup\$ Additionally, album.to_lowercase isn't necessary, you may input the albums in whatever case you'd like \$\endgroup\$ Commented yesterday
  • 1
    \$\begingroup\$ @MijiGamin1 Thanks for loosening the string types as well, this allows me to golf much more than just lowercasing it \$\endgroup\$ Commented 22 hours ago
  • \$\begingroup\$ of course, the specifications of the string aren't the important part of the challenge \$\endgroup\$ Commented 17 hours ago
3
\$\begingroup\$

Japt , 13 bytes

Takes input in lowercase

pÊè`%ßé[^Ãäu]

Try it

pÊè`...     :Implicit input of string
p           :Append
 Ê          :  Its length
  è         :Count the occurrences of
   `...     :  Compressed string "%bill[^ayiou]"=/\bill[^ayiou]/g
            :Implicit output of result as a boolean (0 is falsey)
\$\endgroup\$
2
  • \$\begingroup\$ I'm sorry I didn't include this in the question earlier, but "y" counts as a vowel. \$\endgroup\$ Commented yesterday
  • \$\begingroup\$ This is the only solution shorter than the GNU sed trickery I came up with. Impressive (ab)use of ASCII characters \$\endgroup\$ Commented 1 hour ago
2
\$\begingroup\$

JavaScript (Node.js), 29 bytes

s=>/\bill[^ayiou]/i.test(s+1)

Try it online!

Obvious

\$\endgroup\$
0
2
\$\begingroup\$

R, 35 bytes

\(x)grepl("\\bIll([^aiouy]|$)",x,T)

Attempt This Online!

grepl(
  "            
  \\b          # a word boundary
  Ill          # followed by "Ill"
  ([^aiouy]|$)  # followed by either a non-aiouy character OR end of string"
  "  
  x,           
  T            # ignore.case = TRUE
)

Obviously we could port the same pattern used in JS answers:

R, 36 bytes

\(x)grepl("\\bIll(?![aiouy])",x,T,T)

Attempt This Online!

\$\endgroup\$
2
  • \$\begingroup\$ My apologies, but "y" does count as a vowel. I have since updated the question to make it more clear. \$\endgroup\$ Commented yesterday
  • 1
    \$\begingroup\$ @MijiGamin1 no worries, thanks for the heads up. Fixed. \$\endgroup\$ Commented yesterday
2
\$\begingroup\$

Lua, 117 bytes

k="ill[bcdefghjklmnopqrstvwxz ]"S=io.read()print(S:find("^"..k)or S:find(" "..k)or S:find("^ill$")or S:find(" ill$"))

Takes lowercase input. Outputs a positive integer or two (truthy) if sick, and the string nil if a false positive is found.

Turns out Lua having nothing resembling regex makes it kind of…bad. I hate this solution and I hope someone finds a way to golf it somehow.

I was going to give Compressed Lua a test run here, but it's still in development :( maybe next time buddy

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Perl 5, 19 bytes

$_=/\bill[^aiouy]/i

Try it online!

This is like @Arnauld's Regex (ECMAScript) answer except:

  • Perl keeps newlines inside inputs, so my RegEx can match on it using just a character class and no negative lookahead
  • -p enables a sed-like input reading and printing loop
  • Perl has 1 as true and "" as false, so inputs must be passed one-at-a-time
  • Test it like echo Illmatic | perl -pe '$_=/\bill[^aiouy]/i'
New contributor
Daniel T is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
1
\$\begingroup\$

05AB1E, 19 bytes

ð.ø'´™ðìAžOÀ¦мðª«åà

Input in full lowercase.

Try it online or verify all test cases.

Explanation:

ð.ø       # Surround the (implicit) input-string with leading/trailing space " "
'´™      '# Push dictionary string "ill"
   ðì     # Prepend a space: " ill"
A         # Push the lowercase alphabet
 žO       # Push the vowels: "aeiouy"
   À¦     # Rotate once and remove the first character, to remove the "e": "iouya"
     м    # Remove all those characters from the alphabet
      ðª  # Convert it to a list of characters, and append a space " "
«         # Merge all those characters to the earlier " ill":
          #  [" illb"," illc"," illd"," ille",...," illx"," illz"," ill "]
 å        # Check for each if it's a substring of the modified input-string
  à       # Check if any is truthy (by taking the maximum)
          # (which is output implicitly as result)

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why '´™ is "ill".

PS: '´™ðì could alternatively be '´™1ú; '´™4j; „ ´™¦; or „´™ Á for the same byte-count.

\$\endgroup\$
1
\$\begingroup\$

Charcoal, 21 bytes

⊙Φ⪪⁺ ↧S illκ⬤aiouy⌕ιλ

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for an ill vinyl, nothing if not. Explanation:

      S                 Input string
     ↧                  Lowercased
   ⁺                    Prepend a space
  ⪪     ill             Split on literal string ` ill`
 Φ         κ            Remove first element
⊙                       Any suffix satisfies
             aiouy      Literal string `aiouy`
            ⬤           All letters satisfy
                   ι    Current element
                  ⌕     Does not begin with
                    λ   Current letter
                        Implicitly print
\$\endgroup\$
1
\$\begingroup\$

Dyalog APL, 36 bytes

I'm sure using the built-in regex library is shorter, but this was more fun

{∨/≠⌿↑((⊂'ill'),¨''⊂⍛,'aiouy')∘.⍷⊂⍵}­⁡​‎‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠‎⁡⁠⁢⁣⁤‏⁠‎⁡⁠⁢⁤⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏⁠‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏⁠‎⁡⁠⁣⁡⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌­
       (⊂'ill'),¨                     # ‎⁡'ill' combined with each of
                 ''⊂⍛,                # ‎⁢An empty string
                      'aiouy'         # ‎⁣and each vowel
      (                      )∘.⍷⊂⍵   # ‎⁤Outer product find with the input
                                      # ‎⁤This gives occurrences of 'ill' followed by the occurrences of every other vowel combination (except 'e') 
     ↑                                # ‎⁢⁡Mix into a matrix
   ≠⌿                                 # ‎⁢⁢XOR down the columns
 ∨/                                   # ‎⁢⁣or-over (i.e. "any")
💎

Created with the help of Luminespire.

\$\endgroup\$
1
\$\begingroup\$

GNU sed 17 16 18 bytes

Thanks to @someone in the comments for pointing out I had this solution backwards, that allowed me to shave off the no-matches check and that I needed a negative match. At first I thought I could skip the negative, but that flags for ill on any input not containing ill

/\bill[^aiouy]/!q1

Explained:

/                  # Start pattern
 \b                # Match word boundaries
   ill             # Match literal "ill" as start of a word
      [^aiouy]     # Match any not[aiouy] directly after
             /     # End pattern
              !    # If not found, execute command
               q1  # exit with status 1. Evaluates to false as per POSIX

q (or Q to silence output) is a GNU extension to the program to set the exit status if a condition is matched. See the GNU sed script overview for examples, and the command list for the command's description.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Based on how the challenge is written, I think everything besides a,i,o,u,y should be matched for here. That just means adding a ^ after the [, which is +1 byte. \$\endgroup\$ Commented 11 hours ago
  • \$\begingroup\$ @Someone oh sharp, I have my outputs backwards in this solution. Luckily the ! is entirely optional, so thanks for shaving off a byte for me! (sed only exits with a non-zero status when it encounters errors, q is a GNU extension to explicitly set it) \$\endgroup\$ Commented 10 hours ago
  • \$\begingroup\$ Never mind, it failed on tests not containing ill, and in my haste I only tested the pattern itself \$\endgroup\$ Commented 1 hour ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.