g | x | w | all
Bytes Lang Time Link
047Raku Perl 6 rakudo241213T192605Zxrs
061AWK241213T190102Zxrs
013Uiua 0.8.0231227T222601ZTbw
115Scala231231T065600Z138 Aspe
044JavaScript Node.js231219T004414Zl4m2
026Ruby231221T115228ZG B
064Google Sheets231218T180831Zdoubleun
037Bash + core utilities231221T003117Z0x2b3bfa
050Python231220T225512ZKarl Kne
063Excel ms365231220T094051ZJvdV
nanJavaScript ES6231218T194630ZArnauld
015APLDyalog Unicode231219T001451ZTbw
00605AB1E231219T150347ZKevin Cr
009Charcoal231219T093853ZNeil
006Nekomata231219T063003Zalephalp
016Retina 0.8.2231219T005521ZNeil
006Jelly231218T191921ZNick Ken
007Jelly231218T191454ZJonathan
054Python 3.8 prerelease231218T192259Zspooky_s
028Perl 5 p231218T185309ZXcali

Raku (Perl 6) (rakudo), 47 bytes

{$_.subst(/[' '|B][' '|B]?/,"").comb.sort.join}

Attempt This Online!

{$_.subst(/[' '|B][' '|B]?/,"") # get rid of a space or B
.comb                           # chars to array
.sort                           # sort
.join}                          # back together

AWK, 61 bytes

{sub(/B/,"");l=split($0,a,X);for(asort(a);i++<l;)printf a[i]}

Attempt This Online!

{sub(/B/,"");    # delete one B
l=split($0,a,X); # convert to array
for(asort(a)     # sort it
;i++<l;)         # til end of array
printf a[i]}     # print char

Uiua 0.8.0, 13 bytes SBCS

⊏⍏.⊝▽≠⇡⧻,⊗@B.

Try on Uiua Pad!

Scala, 115 bytes

A Port of @spooky_simon's Python answer in Scala.


Golfed version. Attempt This Online!

def g(x:Boolean)=if(x)1 else 0
def f(s:String)={val x=s.contains("C");"A"*g(x)+"B"*g(s.count(_=='B')>1)+"CWY"*g(x)}

Ungolfed version. Attempt This Online!

object Main {
  def main(args: Array[String]): Unit = {
    def f(s: String): String = {
      val hasC = s.contains("C")
      val bCount = s.count(_ == 'B') > 1

      ("A" * (if (hasC) 1 else 0)) +
      ("B" * (if (bCount) 1 else 0)) +
      ("CWY" * (if (hasC) 1 else 0))
    }

    println(f("ABCWY B"))
    println(f("ABCWY"))
    println(f("B"))
    println(f("B B"))
    println(f("ACWY B B"))
    println(f("ACWY B"))
  }
}

JavaScript (Node.js), 44 bytes

s=>s.sort().filter(x=>!~(s[x]=~-s[x]),s.B=1)

Try it online!

JavaScript (Node.js), 49 bytes

s=>[...'ABCWY'].filter(x=>s.split(x)[x=='B'?2:1])

Try it online!

+4 bytes if a trailing delimited is not allowed.

Worse than Arnauld's solution (41, if it use no delimit and output array)

Ruby, 26 bytes

->s{s.sub(?B,'').chars|[]}

Try it online!

Google Sheets, 64 bytes

=join(,ifna(filter({"A","B","CWY"},search({"A","B*B","A"},A1))))

Put the input in cell A1 and the formula in cell B1.

Uses the search() with * wildcard method of JvdV's Excel answer.

The same can be done without arrays using simple string concatenation and regexes (81 bytes):

=let(a,regexmatch(A1,"A"),if(a,"A",)&if(regexmatch(A1,"B.*B"),"B",)&if(a,"CWY",)

Implementation of the same in JavaScript (62 bytes):

t=>(a=/A/.test(t)?'A':'')+(/B.*B/.test(t)?'B':'')+(a?'CWY':'')

(-4 bytes thanks to noodle man)

Bash + core utilities, 37 bytes

sed s/B//|grep -o .|sort -u|tr -d \\n

Explanation

sed s/B// | # remove the first occurrence of B
grep -o . | # insert a newline after every character
sort -u   | # sort lines and remove duplicates
tr -d \\n | # remove newlines inserted for sorting

Python, 50 bytes

lambda s:''.join(sorted(set(s.replace('B','',1))))

Another port of @NickKennedy's answer, approximately. Python doesn't have a built-in multiset or corresponding set-difference operator; it does have collections.Counter, but that takes way too much setup. Instead, I just remove up to one B from the input before uniquifying and sorting (and producing a string from the resulting list). This works in both Python 2 and Python 3. The count argument for the replace method of strings is not commonly discussed, but it's clearly documented.

Excel ms365, 6463 bytes

New:

=CONCAT(IFERROR(MID(A1,SEARCH({"A","B*B","C"},A1),{1,1,3}),""))

Old:

=CONCAT(REPT({"A","B","CWY"},COUNTIF(A1,{"*A*","*B*B*","*A*"})))

JavaScript (ES6), 55 / 48 / 41 bytes

Expects a space-separated string.

s=>[...new Set(s.replace("B",""))].sort().join``.trim()

Try it online!

Or 48 bytes if we take a string with no delimiter.

Or 41 bytes if we return an array.

Method

Given the input string, e.g. "ABCWY ACWY B":

APL(Dyalog Unicode), 1715 bytes SBCS

⎕A∩⊢(/⍨)≠⍲'B'=⊢

Try it on APLgolf!

A tacit function which takes a string on the right using no delimiter or any delimiter that is not a capital letter. The test cases use spaces. (The test case B is written as (⍬,'B') because single characters in quotes are not treated as strings in APL)

⎕A∩⊢(/⍨)≠⍲'B'=⊢­⁡​‎‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌­
          'B'=⊢  # ‎⁡Boolean mask for all Bs
         ⍲       # ‎⁢NAND
        ≠        # ‎⁣Boolean mask for all first instances
   ⊢(/⍨)         # ‎⁤apply Boolean mask (removes first B)
  ∩              # ‎⁢⁡intersection
⎕A               # ‎⁢⁢capital letter alphabet
💎

Created with the help of Luminespire.

Taking the intersection with the alphabet helpfully removes any delimiters and sorts alphabetically.

This solution doesn't work on any of the APL versions on TIO, as @att describes.

05AB1E, 6 bytes

'Bõ.;ê

Port of @NickKennedy's Jelly answer.

Try it online or verify all test cases.

Explanation:

   .;   # In the (implicit) input-string, replace the first
'B     '# "B"
  õ     # with an empty string ""
     ê  # Then sort and uniquify the characters of the string
        # (which is output implicitly)

Charcoal, 9 bytes

Φα›№θι⁼κ¹

Try it online! Link is to verbose version of code. Accepts any character that's not an uppercase letter as a delimiter (some characters may need extra quoting). Explanation:

 α          Predefined variable uppercase alphabet
Φ           Filtered where
   №        Count of
     ι      Current letter
    θ       In input string
  ›         Is greater than
       κ    Current index
      ⁼     Equals
        ¹   Literal integer `1`
            Implicitly print

Nekomata, 6 bytes

"B"∕uo

Attempt This Online!

A port of @Nick Kennedy's Jelly answer.

"B"∕uo
"B"∕    Set difference with "B"
    u   Uniquify
     o  Sort

Retina 0.8.2, 16 bytes

\W

1`B

O`.
D`.

Try it online! Link includes test cases. Accepts any non-\w characters as a delimiter. Explanation:

\W

Join the words together.

1`B

Delete the first B, if any.

O`.

Sort the letters.

D`.

Deduplicate the letters.

Jelly, 6 bytes

œ-”BQṢ

Try it online!

A monadic link taking a string with no delimiter and returning a string.

Explanation

œ-”B   | Set difference with "B"
    Q  | Uniquify
     Ṣ | Sort

Jelly,  8  7 bytes

Note while I did eventually think of using œ- to avoid a byte, I now see that Nick Kennedy actually got there first!

Fœ-”BQṢ

A monadic Link that accepts a list of lists of characters (the vaccines) and yields a list of characters (the fully vaccinated).

Try it online! Or see the test-suite.

How?

Fœ-”BQṢ - Link: list of strings (from "B", "ACWY", "ABCWY"), Vaccinations
F       - flatten
 œ-”B   - multiset difference with 'B'
     Q  - deduplicate
      Ṣ - sort

Alternative TIO:

Taking a non [A-Z] separating string (like " " or ", ", etc):

œ-”BØAf
œ-”B     - multiset difference with 'B'
    ØAf  - "ABC...XYZ" filter keep

Python 3.8 (pre-release), 54 bytes

lambda s:"A"*(x:="C"in s)+"B"*(s.count("B")>1)+"CWY"*x

Try it online!

Python 3, 59 bytes

def f(s):x="C"in s;return"A"*x+"B"*(s.count("B")>1)+"CWY"*x

Try it online!

Perl 5 -p, 28 bytes

$_=A x/A/.B x/B.*B/.CWY x/A/

Try it online!