As Easy As A-B-C

28

2

Input

A string that contains at most one of each of the letters A, B, and C. They may be in any order. The empty string is valid input.

Note: A previous version of this challenge used the letters LEJ instead of ABC and they may still be used if desired.

Output

A string of the A, B, C letters that were not present in the input. They may be in any order.

If the output would be the empty string then simply giving no output is valid, if that makes sense for your implementation. (e.g. you don't need to actually call print on an empty string.)

Examples

  • If the input is B then the output should either be CA or AC since A and C are not present in the input.
  • If the input is the empty string then the output should be ABC or any permutation since none of the three letters are present in the input.
  • If the input is CAB then the output should be the empty string because all three letters are present in the input.

Test Cases

There are so few input cases that we can enumerate all of them:

in -> out1 | out2 | out3 | ...
ABC -> ""
ACB -> ""
BCA -> ""
BAC -> ""
CAB -> ""
CBA -> ""
AB -> C
AC -> B
BC -> A
BA -> C
CA -> B
CB -> A
A -> BC | CB
B -> CA | AC
C -> AB | BA
"" -> ABC | ACB | BCA | BAC | CAB | CBA

All valid outputs for each input are given, separated by |'s. "" represents the empty string

Scoring

The shortest code in bytes wins. But keep in mind that you may get more recognition for solving the challenge in a unique way rather than in a short way ;)

Calvin's Hobbies

Posted 2017-02-16T07:36:26.133

Reputation: 84 000

Is a list of characters acceptable for output, or must it be a string? – Mego – 2017-02-16T07:59:17.683

@Mego It must be a string (or be displayed as a string by default). – Calvin's Hobbies – 2017-02-16T08:01:02.387

1Cumbersome I/O format – Mego – 2017-02-16T08:02:12.633

@Mego It doesn't seem that cumbersome considering the difficulty of the task and shortness of the string. – Calvin's Hobbies – 2017-02-16T08:08:40.620

1The task is set difference between a constant and an input. Requiring that everything be done in strings is cumbersome with regards to the difficulty of the actual task. – Mego – 2017-02-16T08:09:38.903

In fact, since the challenge is really just set difference between a constant and an input, it's a dupe of this challenge.

– Mego – 2017-02-16T08:14:38.467

2I vaguely remember a more exact dupe match where you had to subtract the input from a constant set. – xnor – 2017-02-16T08:26:25.037

@xnor That's the best one I could find. If you find a better dupe target, feel free to change it. – Mego – 2017-02-16T08:37:57.540

@xnor Any chance you're thinking of Helka's recent challenge?

– Martin Ender – 2017-02-16T10:13:12.503

@MartinEnder No, I remember it as being from a while ago. – xnor – 2017-02-16T10:14:28.833

1Can inputs contain letters outside of "ABC"? The specification: "A string that contains at most one of each of the letters A, B, and C" does not exclude such inputs. – theonlygusti – 2017-02-16T13:56:18.530

Related – Adnan – 2017-02-16T13:58:58.837

Do you have to output all combinations or were you just showing all possible outputs separated by "|" ? – Albert Renshaw – 2017-02-16T17:29:06.787

1@theonlygusti The input should only contain ABC – Calvin's Hobbies – 2017-02-16T22:09:35.043

@AlbertRenshaw "All valid outputs for each input are given, separated by |'s." – Calvin's Hobbies – 2017-02-16T22:09:53.520

Related – Destructible Lemon – 2017-02-24T08:31:41.137

Answers

20

Python 3, 29 27 22 bytes

lambda x:{*"ABC"}-{*x}

-2 bytes thanks to Jonathan Allan

-5 bytes thanks to Rod

Trelzevir

Posted 2017-02-16T07:36:26.133

Reputation: 987

print(*{*"LEJ"}-{*input()}) saves 2. (tested on 3.5 and 3.6). – Jonathan Allan – 2017-02-16T08:12:30.227

You can also turn into a lambda for -5 bytes – Rod – 2017-02-16T10:06:58.867

14I love python ❤️ – theonlygusti – 2017-02-16T14:18:35.777

@theonlygusti Whatever happened to <3 and ♥? – wizzwizz4 – 2017-02-17T11:14:52.997

@theonlygusti : I would love python if I can replace lamda with https://en.wikipedia.org/wiki/Lambda

– Fahim Parkar – 2017-02-22T05:50:13.267

10

Jelly, 4 bytes

Thanks to @DuctrTape for the prod about the change and the presence of "ABC" in Jelly's dictionary.

“ḃ»ḟ

Try it online!

“ḃ» looks up the entry "ABC" in Jelly's dictionary, is the filer discard dyad which discards the characters found in the input from that list of characters. The result is implicitly printed.


For a lower case version the dictionary entry to use can be either of "abac" (“c») or "abaca" (“i»).


When the challenge was "LEJ" only 6 bytes could be achieved in the upper case variant, since no dictionary entries exist with that set of characters, leaving us to create the list of characters “LEJ” (or a permutation thereof).

The lowercase variant faired better at 5 bytes due to the presence of the word "jell" (“ẎṄ»).

Jonathan Allan

Posted 2017-02-16T07:36:26.133

Reputation: 67 804

1I like how most of the code just generates the string "ABC", and the actual program itself is one character. Classic jelly. – sagiksp – 2017-02-19T12:10:14.793

6

05AB1E, 6 4 bytes

Saved 2 bytes using the new žR command as suggested by Kevin Cruijssen

žRsм

Try it online! or as a Test Suite

Explanation

   м  # remove the character of
  s   # the input
žR    # from the string "ABC"

Emigna

Posted 2017-02-16T07:36:26.133

Reputation: 50 798

Shouldn't an input of only J return EL, LE? – Magic Octopus Urn – 2017-02-16T14:44:03.943

2Nice! Just as an FYI, inputs can also be represented as """{input}""", which also works for empty strings :). – Adnan – 2017-02-16T14:56:51.660

@carusocomputing: It can return either (in this case it returns LE). – Emigna – 2017-02-16T14:59:14.060

@Adnan: Good point. Never used the triple-string input except with multiline input. Will have to remember that :) – Emigna – 2017-02-16T15:00:12.557

I find it hard to believe there isn't a built in to push ABC that is less than 4 bytes. •CÞ•h is 5... 2ÝAè is lowercase and still 4... – Magic Octopus Urn – 2017-02-16T17:28:43.090

@carusocomputing: ABC or CAB could be pushed in 3 chars as for example '±ì, but it would be lowercase, so converting to uppercase it would still be 4 :( – Emigna – 2017-02-16T17:33:29.823

1Can be 4 bytes now – Kevin Cruijssen – 2019-03-26T14:55:57.860

@KevinCruijssen: Thanks! Do you know if žR has been useful before? – Emigna – 2019-03-26T15:04:50.557

1@Emigna Tbh no. I think it was added because of this challenge perhaps, but I personally haven't used it before. – Kevin Cruijssen – 2019-03-26T15:12:18.857

6

Bash + coreutils, 15 bytes

tr -d x$1<<<LEJ

Try it online!

I'd like to omit the x, but then tr -d would be missing an argument when the input string was empty. (The x doesn't do any harm, since there aren't any x's in the here-string LEJ.) I'd normally write tr -d "$1", but doing it the way I did is one byte shorter than that.

Mitchell Spector

Posted 2017-02-16T07:36:26.133

Reputation: 3 392

I had the same thoughts - even with the quotes - immediately, too. – rexkogitans – 2017-02-16T15:11:49.623

6

Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

$
¶ABC
D`.
A1`

Try it online!

Explanation

$
¶ABC

Append a second line containing ABC.

D`.

Deduplicate the characters. This deletes every character from the second line which already appears in the first line.

A1`

Discard the first line.

Martin Ender

Posted 2017-02-16T07:36:26.133

Reputation: 184 808

How exactly does the `1`` part of the antigrep stage work? – user41805 – 2017-02-16T14:35:12.037

@KritixiLithos Numbers in the configuration string are limits. 1 generally means "only do X once". How exactly limits work (i.e. what X is) depends on the stage type you're using. For antigrep stages, Retina first checks which lines match the regex (here, every line, since the regex is empty), but then the limit means "only discard the first matching line". Similarly, if it was a grep stage it would mean "only keep the first matching line". The semantics of all limits are listed on the wiki.

– Martin Ender – 2017-02-16T14:38:40.540

5

Java 7, 73 58 bytes

String c(String s){return"EJL".replaceAll("[ "+s+"]","");}

15 bytes saved thanks to @KritixiLithos.

Test code:

Try it here.

class M{
  static String c(String s){return"EJL".replaceAll("[ "+s+"]","");}

  public static void main(final String[] a) {
    System.out.print("LEJ=" + c("LEJ") + "; ");
    System.out.print("LJE=" + c("LJE") + "; ");
    System.out.print("EJL=" + c("EJL") + "; ");
    System.out.print("ELJ=" + c("ELJ") + "; ");
    System.out.print("JLE=" + c("JLE") + "; ");
    System.out.print("JEL=" + c("JEL") + "; ");
    System.out.print("LE=" + c("LE") + "; ");
    System.out.print("LJ=" + c("LJ") + "; ");
    System.out.print("EJ=" + c("EJ") + "; ");
    System.out.print("EL=" + c("EL") + "; ");
    System.out.print("JL=" + c("JL") + "; ");
    System.out.print("JE=" + c("JE") + "; ");
    System.out.print("L=" + c("L") + "; ");
    System.out.print("E=" + c("E") + "; ");
    System.out.print("J=" + c("J") + "; ");
    System.out.print("\"\"=" + c(""));
  }
}

Output:

LEJ=; LJE=; EJL=; ELJ=; JLE=; JEL=; LE=J; LJ=E; EJ=L; EL=J; JL=E; JE=L; L=EJ; E=JL; J=EL; ""=EJL

Kevin Cruijssen

Posted 2017-02-16T07:36:26.133

Reputation: 67 575

1Can you do "["+s+"]" instead of s.replaceAll("(.)","$1|")? – user41805 – 2017-02-16T07:55:27.040

@KritixiLithos Smart. It fails for the empty String, but by adding a space (or any other character that isn't EJL) it works again, which is still a lot shorter. :) – Kevin Cruijssen – 2017-02-16T07:59:10.710

5

Actually, 7 bytes

"LEJ"-Σ

Try it online!

"LEJ"-Σ
"LEJ"    the letters
     -   exclude letters present in input
      Σ  concatenate

Mego

Posted 2017-02-16T07:36:26.133

Reputation: 32 998

5

Pyth, 5 bytes

-"ABC

Test it here

Expands to

-"ABC"Q
-       # Filter on absence
 "ABC"  # Literal string 
      Q # Input

Rod

Posted 2017-02-16T07:36:26.133

Reputation: 17 588

abc can be written as <G3 – Maltysen – 2017-02-16T22:25:14.630

@Maltysen yeah muddyfish used that, but it is lowercase anyway =\

– Rod – 2017-02-17T02:34:40.983

4

JavaScript ES6, 41 39 38 Bytes

s=>eval(`'ABC'.replace(/[${s}]/g,'')`)

Saved 2 bytes thanks to Arnauld. Saved 1 bytes thanks to LarsW.

f=s=>eval(`'ABC'.replace(/[${s}]/g,'')`)

console.log(f("AB"));

Tom

Posted 2017-02-16T07:36:26.133

Reputation: 3 078

I'm on mobile, so I can't test my code, but this should work I think: s=>eval\'ABC'.replace(/[${s}]/g,'')`` – LarsW – 2017-02-16T22:08:32.047

Nice work! Being able to say .join\`` saves you two characters over the solution I had come up with: f=s=>"ABC".replace(RegExp(\[${s}]`,'g'),"")` . – nnnnnn – 2017-02-17T06:11:32.750

1@LarsW That exact code didn't seem to work, but adding brackets around the template string did and saved one byte. Thanks! – Tom – 2017-02-17T07:53:15.757

4

MATL, 10 8 bytes

Saved two bytes thanks to Suever. setdiff is shorter than ismember.

'ABC'iX-

Try it here!

Explanation

'ABC'      % Create a string literal
     i     % User input
      X-   % Set difference, between two elements of the stack 

Yes, this might have been a trivial task, but I'm quite satisfied I managed to solve it with MATL all by myself. I never said it was the shortest solution... Thanks Suever!

Stewie Griffin

Posted 2017-02-16T07:36:26.133

Reputation: 43 471

3

V, 10 bytes

CLEJ<ESC>Ó[<C-r>"]

Try it online!

Hexdump:

00000000: 434c 454a 1bd3 5b12 225d                 CLEJ..[."]

Explanation

Input is on the first line of the buffer. So something like:

EL

and the cursor is on the first character. So we delete the input (which stores it in register ") and enter insert mode simultaneously using C.

Once in insert mode, the characters LEJ are inserted, after which I return to normal mode using <ESC>.

Now we have to remove all the characters that are present in the input.

Ó                       " remove every
 [<C-r>"]               "  character that appears in the input
                        " synonym of Vim's :s/[<C-r>"]//g

And once this happens, we are left with the remaining letters in the buffer.

user41805

Posted 2017-02-16T07:36:26.133

Reputation: 16 320

3

Ruby, 27 19 18 bytes

->s{"ABC".tr s,""}

-1 byte thanks to Martin Ender

G B

Posted 2017-02-16T07:36:26.133

Reputation: 11 099

3

Haskell, 27 26 bytes

import Data.List
("ABC"\\)

Try it online! Usage: ("ABC"\\) "CB" yields "A".

\\ is the set difference operator, the parenthesis form a so called section which is a short form for the lamda (\x -> "ABC" \\ x).


Without import: (same byte count thanks to @nimi)

f x=[c|c<-"ABC",all(/=c)x]

Try it online! Usage: f "CB" yields "A".


Other approaches:

f x=filter(`notElem`x)"ABC"
(`filter`"ABC").flip notElem
f x=[c|c<-"ABC",notElem c x]

Laikoni

Posted 2017-02-16T07:36:26.133

Reputation: 23 676

1I hope (\\) will be moved to Prelude soon. – theonlygusti – 2017-02-16T14:25:50.317

@theonlygusti I hope it won't; this isn't really a sensible operation for lists (at least not unless you explicitly state you want list-as-set). The default operation for that task should be Data.Set.difference.

– ceased to turn counterclockwis – 2017-02-16T16:39:27.397

@ceasedtoturncounterclockwis why is it not sensible? Besides, the only reason I desire it moved is because it is useful, frequently. – theonlygusti – 2017-02-16T16:58:26.293

1@theonlygusti it's not sensible in the sense that if you find yourself using it, it's a sign that you're probably using the wrong data structure. Lists can have duplicate elements, an order, and they may be lazily constructed (even infinite). (\\) respects none of this. Data types that are intended for this behaviour have a structure that makes them generally quite a bit more effecient, safer (because no possible stability etc. assumptions can be broken) and exposing a more comfortable interface. – ceased to turn counterclockwis – 2017-02-16T17:05:29.417

@ceasedtoturncounterclockwis what, yes it does. "The first instance of..." but nvm – theonlygusti – 2017-02-16T17:35:27.363

3

Brain-Flak, 120 + 3 = 123 bytes

<>((((((((()()){}){}){}){}){}())())())<>{({}(<()>)){(([({})]<>({}))){(<({}<>{})<>([{}]{}<>)>)}{}}{}{}<>{}{({}<>)<>}{}}<>

It is run with the -c flag, adding 3 bytes

Try it online!

Explanation

Overall this program pretty much does the right stack set minus the left stack with the right stack initialized to CBA and the left stack initialized to the input.

Annotated Code

<>((((((((()()){}){}){}){}){}())())())<> # Switch to right stack, push CBA, switch back
{({}(<()>)){(([({})]<>({}))){(<({}<>{})<>([{}]{}<>)>)}{}}{}{}<>{}{({}<>)<>}{}}<>

More explanation to come...

0 '

Posted 2017-02-16T07:36:26.133

Reputation: 3 439

3

GNU sed, 34 29 bytes

Includes +1 for -r

-5 thanks to Digital Trauma

s/^/ABC/
:
s/(.)(.*)\1/\2/
t

Try it online!

For some reason TIO doesn't work with extended regex (-r), so I had to wrap it in BASH.


s/^/ABC/        # put ABC at the beginning of the string
:               # nameless label
s/(.)(.*)\1/\2/ # remove a duplicate letter
t               # branch to the nameless label if something changed

Riley

Posted 2017-02-16T07:36:26.133

Reputation: 11 345

The newline, -n and P are unnecessary. Also you can wrap this up in bash to get it to work in TIO. No idea why -r doesn't work. https://tio.run/nexus/bash#DcmxDYAwDATA/qdIR4JELCjp7F8jooIFCPubb@/mc5ftLUtOu8yDhhPTam@1r23sNg7Dl0tCB2cg6Agn6AGGy8VSoUwEPZg/

– Digital Trauma – 2017-02-16T18:55:27.833

@DigitalTrauma Thanks! I was thinking there would be characters besides A, B, and C when I wrote this. – Riley – 2017-02-16T18:59:28.807

2

Mathematica, 37 bytes

Complement@@Characters@{"ABC",#}<>""&

Martin Ender

Posted 2017-02-16T07:36:26.133

Reputation: 184 808

Is there a reason you used strings here rather than lists of characters? – Greg Martin – 2017-02-16T18:05:10.547

@GregMartin habit, I guess – Martin Ender – 2017-02-16T18:15:20.550

just that I think it comes out shorter if you can avoid Characters – Greg Martin – 2017-02-16T18:30:03.657

2

Octave, 29 27 bytes

Saved two bytes thanks to Suever, by creating the string 'ABC', inside the ismember call.

@(s)x(~ismember(x='ABC',s))

We use ~ismember() as logical indices to the variable x. The peculiar thing is, we create x='ABC' inside ismember, not in front of it. The order Octave sees this:

@(s)                        % Anonymous function that takes a string s as input
                x='ABC'     % Create a variable x with the characters 'ABC'
       ismember(x='ABC',s)  % True for elements that are in both x and s. False otherwise.
      ~ismember(x='ABC',s)  % Negate this, so that we keep the characters that aren't in s
@(s)x(~ismember(x='ABC',s)) % Use the logical vector as indices to x and return the result

Stewie Griffin

Posted 2017-02-16T07:36:26.133

Reputation: 43 471

2

Carrot, 15 bytes, non-competing

non-competing because of a bug I found with returning matches and empty strings. So I just fixed it

ABC^//[^#]/gS""

Try it online! (copy & paste)

Explanation

ABC^                   //sets stack (just a string, not an array) to "ABC"
    /                  //return match(es) of:
     /[^#]/g           // `#` is the placeholder for the input
                       // so effectively, this returns the matches of any character not present in the input
                       // applied on the stack
                       //this returns an array of all the matches of the regex
            S""        //join all the elements of the array using "", the empty string

user41805

Posted 2017-02-16T07:36:26.133

Reputation: 16 320

2

CJam, 7 bytes

"ABC"l-

Try it online! (As a linefeed-separated test suite.)

Martin Ender

Posted 2017-02-16T07:36:26.133

Reputation: 184 808

2

MATLAB / Octave, 20 bytes

@(x)setdiff('ABC',x)

Online Demo

Suever

Posted 2017-02-16T07:36:26.133

Reputation: 10 257

2

C#, 50 Bytes 32 Bytes 47 Bytes 35 Bytes

where i is the input:

i=>string.Join("","ABC".Except(i));

Full app tested in LINQPad

void Main()
{
    var testcases = new Dictionary<string,string[]>
    {
        ["ABC"] = new[]{""},
        ["ACB"] = new[]{""},
        ["BCA"]  = new[]{""},
        ["BAC"]  = new[]{""},
        ["CAB"]  = new[]{""},
        ["CBA"]  = new[]{""},
        ["AB"] = new[]{"C"},
        ["AC"] = new[]{"B"},
        ["BC"] = new[]{"A"},
        ["BA"] = new[]{"C"},
        ["CA"] = new[]{"B"},
        ["CB"] = new[]{"A"},
        ["A"] = new[]{"BC","CB"},
        ["B"] = new[]{"CA","AC"},
        ["C"] = new[]{"AB","BA"},
        [""] = new[]{"ABC","ACB","BCA","BAC","CAB","CBA"},
    };

    var output = "";

    foreach(var input in testcases.Keys)
    {
        var expect = testcases[input];
        var actual = GetResult(input);
        if(!expect.Contains(actual)) throw new ApplicationException($"{input}:{string.Join(",",expect)}:{actual}");
        output+=$"{input} -> {actual}\n";
    }
    output.Dump();
}

// Define other methods and classes here
private string GetResult(string input){
    return string.Join("","ABC".Except(i));
}

Test results

ABC ->
ACB ->
BCA ->
BAC ->
CAB ->
CBA ->
AB -> C
AC -> B
BC -> A
BA -> C
CA -> B
CB -> A
A -> BC
B -> AC
C -> AB
-> ABC

Michael Coxon

Posted 2017-02-16T07:36:26.133

Reputation: 131

1That's not a valid answer, it has to be a function or a program, not a code snippet. – theonlygusti – 2017-02-17T08:12:38.700

Ah. My bad. First timer here. So i need the print part in it? – Michael Coxon – 2017-02-17T08:31:08.370

@MichaelCoxon: You either need to make the entry into an entire program, which compiles (not recommended in C#, it has a lot of boilerplate), or into a function that can be called multiple times; at the moment it's just a statement. In C#, it's nearly always easiest to make it into a function by creating a lambda, that takes input via its arguments, and returns via its return value. – None – 2017-02-17T21:47:05.093

string.Join("",...) -> string.Concat(...) Saves 1 byte – Embodiment of Ignorance – 2019-03-27T05:47:28.837

1

Japt, 13 12 bytes

"ABC"r"[{U}]

Saved a byte thanks to ETHproductions.

Try it online!

Tom

Posted 2017-02-16T07:36:26.133

Reputation: 3 078

Nice, thanks for using Japt! You can remove the trailing quote to save a byte. – ETHproductions – 2017-02-16T13:54:15.243

1

APL, 7 bytes

'ABC'∘~

~ is set subtraction, is compose, so this is a function that returns ABC minus the characters in its input.

marinus

Posted 2017-02-16T07:36:26.133

Reputation: 30 224

1

Jellyfish, 9 bytes

PNI
 "ABC

Try it online!

In more conventional notation, this program translates to:

P(N("ABC", I))

I is the input, N is list difference, and P is output.

Martin Ender

Posted 2017-02-16T07:36:26.133

Reputation: 184 808

1

Perl 5.9.9 79 38 37 35 bytes

perl -le '$_="ABC";eval"y/$ARGV[0]//d";print'

(not sure of the counting rules here - have included switches but not the perl command).

> perl -le '$_="ABC";eval"y/$ARGV[0]//d";print' AB
C
> perl -le '$_="ABC";eval"y/$ARGV[0]//d";print'
ABC

(adjusted counts after adjudication comment below)

Tom Tanner

Posted 2017-02-16T07:36:26.133

Reputation: 251

Will that work for empty input? – Titus – 2017-02-16T13:44:34.087

Now I fixed the transcription error (had "..", typed {,,} here...) – Tom Tanner – 2017-02-16T13:52:30.690

Your code is 35 bytes long. (34 +1 for the -l flag). :) – Paul Picard – 2017-02-16T13:59:26.630

Thanks. The -l is for prettification (as in a newline at the end of the output.). wasn't sure if that was necessary from the contest rules. – Tom Tanner – 2017-02-16T14:03:26.053

With 5.14+, you can do perl -pe'$_=eval"ABC=~y/$_//dr"' for only 23 bytes (22 + 1 for -p). – ThisSuitIsBlackNot – 2017-02-16T20:28:56.090

1

Common Lisp, 71 bytes

The largest entry at the moment, but at least it is readable ;-)

(lambda(s)(coerce(set-difference'(#\A #\B #\C)(coerce s'list))'string))

coredump

Posted 2017-02-16T07:36:26.133

Reputation: 6 292

1

Pyth, 4 bytes

-<G3

Try it here!

 <G3 -  alphabet[:3]
-    - input-^

Note this uses lower case which might not be acceptable

Blue

Posted 2017-02-16T07:36:26.133

Reputation: 26 661

1

C, 53 bytes

b=64;c(char*a){while(b<67)putchar(++b*!strchr(a,b));}

If implicit declarations of string.h are not allowed, 72 bytes, to add #include<string.h>

Try it online!


or something a bit more fun at 75 bytes

a[128]={};b=64;c(char*d){while(*d)++a[*d++];while(b<67)putchar(b*!a[++b]);}

Try it online!

Ahemone

Posted 2017-02-16T07:36:26.133

Reputation: 608

52 bytes – ceilingcat – 2019-11-14T06:38:09.860

1

Batch, 101 bytes

@set/ps=
@for %%c in (L E J)do @call set d=%%s:%%c=%%&call:c %%c
:c
@if "%d%"=="%s%" set/pd=%1<nul

Takes input on STDIN, which means that %1 is empty when the code falls through into the helper subroutine and nothing gets printed.

Neil

Posted 2017-02-16T07:36:26.133

Reputation: 95 035

1

R, 47 40 bytes

gsub(paste0("[",scan(,""),"]"),"","ABC")

Try it online!

Replaces any letters in the input string with the empty string.

BLT

Posted 2017-02-16T07:36:26.133

Reputation: 931

0

Lua, 41 bytes

print((('LEJ'):gsub('['..(...)..']',''))

Stuart P. Bentley

Posted 2017-02-16T07:36:26.133

Reputation: 131

0

Befunge, 40 39 bytes

~2p~2vv:<_>"C"-#v_@
8p2~p<>,0^g2::+1<*8

Try it online!

James Holderness

Posted 2017-02-16T07:36:26.133

Reputation: 8 298

0

PHP, 43 40 bytes

<?=preg_replace("([Z$argv[1]])","",ABC);

Z added to character class to work around missing terminating ] warning for empty input.

no regex, 43 bytes:

<?=str_replace(str_split($argv[1]),"",ABC);
  • str_split splits input to array of single characters
  • str_replace replaces all occurences of each array element in ABC with the empty string

Titus

Posted 2017-02-16T07:36:26.133

Reputation: 13 814

3Regex like "/[Z$argv[1]]/" seems to work with empty input as well, and saves 3 bytes. – user63956 – 2017-02-17T11:54:17.913

0

VB.Net, 65 bytes

Sub F(s)
Console.Write(String.Join("","ABC".Except(s)))
End Sub

A subroutine (function) that takes the input string, and removes each character present in the input from the string "ABC". Then it joins the resulting characters back into a string, before printing them to the console.

Brian J

Posted 2017-02-16T07:36:26.133

Reputation: 653

0

Pure bash, 59 bytes

If the newline isn't necessary, removing the final "echo" takes it down to 54 bytes.

for i in A B C
{
[ X${1//$i/} = X$1 ] && echo -n $i
}
echo

Marauder

Posted 2017-02-16T07:36:26.133

Reputation: 1

0

Clojure, 39 bytes

#(apply str((group-by(set %)"ABC")nil))

Transforms input string into set of characters, and then uses it as a function by which it groups string "ABC". For example, if the input string is "B" then the result is {nil [\A \C], \B [\B]} and all we have to do is take value by key nil and convert it to string. Beats Common Lisp!

See it online

cliffroot

Posted 2017-02-16T07:36:26.133

Reputation: 1 080

0

Go, 158 153 151 146 bytes

condensed:

package main;import(."os";."fmt");func main(){b:=[3]int{65,66,67};for _,e:=range Args[1]{b[e-65]=1};Print(string(b[0])+string(b[1])+string(b[2]))}

uncondensed:

package main

import (
    ."os"
    ."fmt"
)

func main() {
    //A,B,C are represented as 65,66,67 in int
    b := [3]int{65, 66, 67}
    //Loop through the ABC argument.
    for _,e := range Args[1]{
        //Find the letter that exists. If it's A then b[65-65] -> b[0] -> A
        //We replace the integer, with 1 which is equal to an empty string if converted.
        b[e-65] = 1
    }
    //Covert each int to string.
    Print(string(b[0])+string(b[1])+string(b[2]))
}

kemicofa ghost

Posted 2017-02-16T07:36:26.133

Reputation: 141

0

Scala, 23 bytes

(s:String)=>"ABC"diff s

jaxad0127

Posted 2017-02-16T07:36:26.133

Reputation: 281

0

Mathematica 38 Bytes

""<>Complement@@Characters/@{"ABC",#}&

splits out the characters of the input string and the string "ABC" and performs their complement and a shorthand StringJoin.

Kelly Lowder

Posted 2017-02-16T07:36:26.133

Reputation: 3 225

0

PHP, 61 bytes

<?=implode("",array_diff(["A","B","C"],str_split($argv[1])));

james

Posted 2017-02-16T07:36:26.133

Reputation: 101

0

perl 5.18, 35 bytes

print"ABC"=~s/[@{[shift||" "]}]//gr

Examples:

perl -le'print"ABC"=~s/[@{[shift||" "]}]//gr' A        # BC
perl -le'print"ABC"=~s/[@{[shift||" "]}]//gr' BC       # A
perl -le'print"ABC"=~s/[@{[shift||" "]}]//gr'          # ABC

Kjetil S.

Posted 2017-02-16T07:36:26.133

Reputation: 1 049

0

Perl 6, 38 bytes

say join "","ABC".split(get.split(""))

Example found in close to every "remove substring" answer. EDIT: Fixed the mistake when AC it returns ABC

Håvard Nygård

Posted 2017-02-16T07:36:26.133

Reputation: 341

For input “AC” this outputs “ABC”… ☹ – manatwork – 2017-03-01T10:19:09.260

@manatwork holy cow, well.... I can acctually see how that is happening.. Darn finding a fix now – Håvard Nygård – 2017-03-01T10:20:29.590

0

CJam, 7 bytes

"abc"l-

Explanation:

"abc"l-
"abc"   e#Push ['a','b','c']
     l  e#Push input
      - e#Remove input from ['a','b','c']
        e#Implict output

Roman Gräf

Posted 2017-02-16T07:36:26.133

Reputation: 2 915

0

Gema, 44 characters

\A=@set{r;ABC}
?=@set{r;@subst{?=;$r}}
\Z=$r

Sample run:

bash-4.3$ printf CB | gema '\A=@set{r;ABC};?=@set{r;@subst{?=;$r}};\Z=$r'
A

manatwork

Posted 2017-02-16T07:36:26.133

Reputation: 17 865

0

Bash, 22 bytes

x=ABC
echo ${x//[$1]/}

Try it online!

Zsh, 20 bytes

x=ABC
<<<${x//[$1]/}

Try it online!

Nothing crazy, just remove matches from the string "ABC"

GammaFunction

Posted 2017-02-16T07:36:26.133

Reputation: 2 838

0

Japt, 7 bytes

"ABC"kU

Run it online | Run the testcases


As Embodiment of Ignorance pointed out:

6 bytes if lowercase input/output is acceptable:

`¯b`kU

Run it online

Oliver

Posted 2017-02-16T07:36:26.133

Reputation: 7 160

1

If lowercase is allowed, 6 bytes: https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=YK9iYGtV&input=ImFiIg==

– Embodiment of Ignorance – 2019-03-27T06:03:24.867

0

Japt, 7 bytes

Input & output as strings.

;3îB kU

Try it

Input & output as arrays of characters.

3õdI kU

Try it

Shaggy

Posted 2017-02-16T07:36:26.133

Reputation: 24 623