| Bytes | Lang | Time | Link |
|---|---|---|---|
| 076 | Go | 241014T142057Z | bigyihsu |
| 1413 | Uiua | 241014T125126Z | nyxbird |
| 013 | Vyxal | 241014T000222Z | emanresu |
| 054 | Forth gforth | 180813T164643Z | reffu |
| 037 | R | 180124T215923Z | rturnbul |
| 034 | C preprocessor macro | 160218T193247Z | Digital |
| 025 | Hexagony | 180809T111922Z | Adyrem |
| 052 | C++ | 180809T103636Z | Toby Spe |
| 045 | C | 180809T101409Z | Toby Spe |
| 041 | C | 160221T160449Z | ugoren |
| 039 | SMBF | 160218T231205Z | mbomb007 |
| 016 | FALSE | 180124T205115Z | 12Me21 |
| 032 | SmileBASIC | 180124T204109Z | 12Me21 |
| 028 | Java | 160323T222506Z | Andreas |
| 120 | Go | 160322T165201Z | EMBLEM |
| 035 | D | 160323T025655Z | cat |
| 031 | Ruby | 160322T192119Z | Value In |
| 124 | ForceLang | 160322T144812Z | SuperJed |
| 110 | NTFJ | 160218T195934Z | Conor O& |
| 043 | Javascript | 160225T054137Z | toastrac |
| 027 | Nustack | 160223T140657Z | BookOwl |
| 4231 | C | 160222T235535Z | Ray |
| 034 | QBIC | 160222T204057Z | steenber |
| 423 | ArnoldC | 160222T034532Z | Kat |
| 1823 | 𝔼𝕊𝕄𝕚𝕟 | 160219T034559Z | Mama Fun |
| 054 | C | 160221T200115Z | Ruud Hel |
| 076 | C | 160218T210402Z | MegaTom |
| 027 | Caché ObjectScript | 160220T115521Z | adaptun |
| 026 | beeswax | 160219T182901Z | M L |
| 028 | MATLAB | 160220T033249Z | Tom Carp |
| 025 | JavaScript ES6 | 160218T182400Z | Conor O& |
| nan | Perl | 160219T160337Z | nwellnho |
| 019 | Pyth | 160218T193615Z | Blue |
| 030 | ><> Fish | 160219T154742Z | Thijs te |
| 031 | Python 3 | 160218T181751Z | Morgan T |
| 015 | CJam | 160218T215034Z | Luis Men |
| 065 | Brainfuck | 160219T041403Z | Ray |
| 029 | DUP | 160219T032439Z | Mama Fun |
| 014 | Jelly | 160219T031822Z | Dennis |
| 026 | Vitsy | 160219T001339Z | Addison |
| 019 | PHP 4.1 | 160219T003129Z | Ismael M |
| 023 | Mouse2002 | 160219T002701Z | cat |
| 015 | MATL | 160218T185022Z | Luis Men |
| 050 | Kotlin | 160218T235229Z | TheNumbe |
| 043 | Brainbash | 160218T233745Z | Conor O& |
| 028 | Haskell | 160218T230942Z | nimi |
| 037 | K | 160218T222841Z | kirbyfan |
| 016 | Jolf | 160218T221206Z | Conor O& |
| 040 | PowerShell | 160218T215804Z | AdmBorkB |
| 038 | JavaScript | 160218T182207Z | username |
| 019 | Japt | 160218T200037Z | ETHprodu |
| 020 | 05AB1E | 160218T195250Z | Adnan |
| 023 | Perl | 160218T193757Z | Andreas |
| 022 | Retina | 160218T195108Z | Andreas |
| 025 | CJam | 160218T194650Z | GamrCorp |
| 021 | GNU Sed | 160218T194350Z | Digital |
| 020 | Y | 160218T190012Z | Conor O& |
| 030 | Mathematica | 160218T181502Z | LegionMa |
| 016 | Pyth | 160218T183521Z | isaacg |
| 021 | Pyth | 160218T181853Z | Denker |
Go, 76 bytes
func(a,b bool)(s string){if a{s="AB"}else if b{s="ACD"}else{s="ACE"}
return}
Implements the idiom as a chain of conditionals.
Go, 86 bytes
func(a,b bool)string{s:="A"
if a{return s+"B"}
s+="C"
if b{return s+"D"}
return s+"E"}
This implementation more closely matches the pseudocode.
Uiua, 14 (13?) bytes
+@A⊂0⨬(⊂2-:4)1
If we can take input as 0 for true and 1 for false, then we can save a byte.
+@A⊂0⨬(⊂2-:4)1
⨬ # switch on a:
( -:4) # 0: subtract b from 4
(⊂2 ) # and prepend 2
1 # 1: push 1
⊂0 # prepend 0
+@A # convert to letters
Vyxal, 13 bytes
[‛EDi‛ACp|‛AB
[ # If a
‛ACp # "AC" plus
‛EDi # "D" if b else "E"
| # Otherwise
‛AB # "AB"
Forth (gforth), 54 bytes
I had orignally planned on using emit for this, but realized that direct string output was shorter (61 vs 54 bytes)
: f if ." AB" else if ." ACD" else ." ACE" then then ;
Explanation
If C1 is true, it prints AB, otherwise it prints ACD if C2 is true, and ACE if C2 is false
Code Explanation
: f \ start a new word definition
if \ if c1 is true
." AB" \ print "AB"
else \ if c1 is false
if \ if c2 is true
." ACD" \ print "ACD"
else \ if c2 is false
." ACE" \ print "ACE"
then \ end the inner if
then \ end the outer if
; \ end the word defintion
R, 41 39 37 bytes
pryr::f(c("ACD","ACE","AB")[1+a+a^b])
In R, TRUE and FALSE are coerced to 1 and 0 respectively when you attempt to use them as numbers. We can convert these numbers to indices 1, 2, and 3 through the formula 1+a+a^b.
a | b | 1+a+a^b
TRUE | TRUE | 1+1+1^1 = 3
TRUE | FALSE| 1+1+1^0 = 3
FALSE| TRUE | 1+0+0^1 = 1
FALSE| FALSE| 1+0+0^0 = 2
These values are then used to index the list ACD, ACE, AB to yield the correct output.
Saved two bytes thanks to JayCe.
If instead you prefer a version with an if statement, there's the following for 41 bytes:
pryr::f(`if`(a,"AB",`if`(b,"ACD","ACE")))
C preprocessor macro, 34
- 1 byte saved thanks to @TobySpeight
#define f(a,b)a?"AB":b?"ACD":"ACE"
Hexagony, 28 26 25 bytes
A;?.));?~..>);@</E"+;@}/>
-2 bytes by moving up the printing of AB
-1 byte by incrementing to C instead
Expanded:
A ; ? .
) ) ; ? ~
. . > . ; @
< / E " + ; @
} / > . . .
. . . . .
. . . .
Uses the value of the second input to get the last char, removing the need for another costly branch:
"E" + (-1*C2)
Credit to @JoKing
Alternatively I could have also just subtracted the value which doesn't save any bytes though:
"E" - C2
C++, 57 52 bytes
[](auto c,auto&s){s="AC";c[0]?--s[1],s:s+='E'-c[1];}
First argument should be an indexable collection (vector, array, etc) of conditions, and second argument is the string to write to.
Assumes that the runtime character set has B and C contiguous, and D and E also contiguous (both are true for common codings such as ASCII and EBCDIC).
Demo
auto const f = [](auto c,auto&s){s="AC";c[0]?--s[1],s:s+='E'-c[1];};
#include<array>
#include<iostream>
#include<string>
int main()
{
std::string s;
for (bool c1: {true, false})
for (bool c2: {true, false})
f(std::array{c1, c2}, s),std::cout << s << '\n';
}
C, 47 45 bytes
Since there are only 3 different outcomes, we can pick one of three strings like this:
char*f(c,d){return"AB\0 ACE\0ACD"+(!c<<d+2);}
Thanks to Herman L for 2 bytes
Demo
#include<stdio.h>
int main()
{
printf("%s\n%s\n%s\n%s\n",
f(1,1),
f(1,0),
f(0,1),
f(0,0));
}
C, 41 bytes
I'm not sure if the question requires a program, a function or a code snippet.
Here's a function:
f(a,b){a=a?16961:4473665|b<<16;puts(&a);}
It gets the input in two parameters, which must be 0 or 1 (well, b must), and prints to stdout.
Sets a to one of 0x4241, 0x454341 or 0x444341. When printed as a string, on a little-endian ASCII system, gives the required output.
SMBF, 39 bytes
Each _ represents a null literal \x00 and is used for readability. I've successfully tested it for all test cases.
except the third, because I haven't found a way to test that input on my interpreter, since I'd need stdin to be \x00\x01. I know it works, though, because I used the exact same method for testing C2 as I did for testing C1.
<.<,[<]<<.[>]>[<<<]<<<<,[<]<<.DE__BC__A
Explanation:
<. print A
<, read C1
[<] if true, move left one
<<. move left 2 and print (C if false, B if true)
[>]> move to C1
[<<<] if true, our output is done, so move all the way left, so further code is NOP
<<<<, move left 4 and read C2
[<] if true, move left one
<<. move left 2 and print (E if false, D if true)
DE_ BC_ A data on the tape
I think this will do the same for the same byte count, reusing B and C by adding 2 to each:
<.<,[<]<<.[>]>[<<]<<++<++>>,[<]<<.BC__A
FALSE, 16 bytes
$"A"'C+,~['E+,]?
Input values are on the stack (first C2 then C1), false is 0 and true is -1 (this is normal in FALSE)
SmileBASIC, 32 bytes
INPUT A,B?"A"+"CB"[A]+"ED"[B]*!A
Java, 28 bytes
Same boilerplate as a lot of the answers. type is BiFunction<Boolean,Boolean, String>.
(c,d)->c?"AB":d?"ACD":"ACE"
Go, 120 bytes
func w(b bool,d bool)(r string){
for i:=true;i;i=!i{
r+="A"
if b{r+="B"
break}
r+="C"
if d{r+="D"
break}
r+="E"}
return}
Go has only one loop structure, for, but you can simulate a do-while loop with for i := true; i; i = expr.
Edit: It also happens that Go's switch statement is flexible enough to replicate this.
switch {
case true:
r += "A"
if b {
r += "B"
break
}
r += "C"
if d {
r += "D"
break
}
r += "E"
}
D, 35 bytes
(int a,int b)=>a?"AB":"AC"+"ED"[b];
Hey, look, D has lambdas.
Hey, look, D is JavaScript, but longer. :^(
Copied verbatim from Conor's ES6 answer. c:
Ruby, 31 bytes
Anonymous function; assign to a variable to test its output.
->x,y{?A+(x ??B:?C+(y ??D:?E))}
ForceLang,124 bytes
def f io.readnum()
set w io.write
set g goto
w "A"
if f
g L
w "C"
if f
g M
w "E"
g N
label L
w "B"
g N
label M
w "D"
label N
NTFJ, 110 bytes
##~~~~~#@|########@|~#~~~~~#@*(~#~~~~#~@*########@^)~#~~~~##@*##~~~~~#@|########@|(~#~~~#~~@*):~||(~#~~~#~#@*)
More readable:
##~~~~~#@|########@|~#~~~~~#@*(~#~~~~#~@*########@^)~#~~~~##@*##~~~~~#@|########@|(~#~~~#~~@*
):~||(~#~~~#~#@*)
That was certainly entertaining. Try it out here, using two characters (0 or 1) as input.
Using ETHProduction's method for converting to 0, 1 (characters) to bits, this becomes simpler.
##~~~~~#@|########@|
This is the said method. Pushing 193 (##~~~~~#@), NANDing it (|) with the top input value (in this case, the first char code, a 48 or 49). This yields 254 for 1 and 255 for 0. NANDing it with 255 (########@) yields a 0 or 1 bit according to the input.
~#~~~~~#@*
This prints an A, since all input begins with A. * pops the A when printing, so the stack is unchanged from its previous state.
(~#~~~~#~@*########@^)
Case 1: the first bit is 1, and ( activates the code inside. ~#~~~~#~@* prints B, and ########@^ pushes 255 and jumps to that position in the code. This being the end of the program, it terminates.
Case 2: the first bit is 0. ( skips to ) and the code continues.
~#~~~~##@*
This prints a C, because that's the next character.
##~~~~~#@|########@|
This converts our second input to a bit.
(~#~~~#~~@*)
If our second bit is a 1, we proceed to print an E.
:~||
This is the NAND representation of the Boolean negation of our bit: A NAND (0 NAND A) = NOT A.
(~#~~~#~#@*)
This now activates if the bit was a 0, and prints E.
Javascript, 43 Bytes
A different (more intuitive?) way to do it in JS. The name parseInt is not inductive of Code Golfing :P
"A"+["CE","CD","B","B"][parseInt(x+""+y,2)]
Test:
var cases = ["00","01","10","11"];
for (i=0;i<4;i++) {
var x = cases[i][0];
var y = cases[i][1];
document.write("A"+["CE","CD","B","B"][parseInt(x+""+y,2)]+"<br>")
}
Nustack, 27 bytes
a"AB"*"AC"b{"E"}{"D"}if + |
Thanks to Morgan Thrapp and her Python answer for giving me the inspiration for this one.
Explanation:
a"AB"* /* Repeat "AB" 0 or 1 times, depending on if a is #t or #f. The result ("" or "AB") is put on the stack */
"AC" /* Put "AC" on the stack */
b{"E"}{"D"}if /* If b is true, push "E", else push "D" */
+ /* Concatenate the top two strings on the stack, push the result ("ACE" or "ACD") */
| /* Right now the stack looks like (x y). If x is truthy (not empty), keep x, else keep y */
C, 42 bytes (long version); 31 (short version)
The existing submissions seem inconsistent with regards to whether the variables must be named C1 and C2, and whether actually printing the results is required, so I've done a long and short version.
This approach takes advantage of the fact that most of the possibilities for each index differ by only one bit.
Long version:
char s[4]={65,67-C1,69*!C1&69-C2};puts(s);
Short version:
char s[4]={65,67-a,69*!a&69-b};
QBIC, 39 34 bytes
EDIT: Found out that QBasic (and by extension QBIC) doesn't need an =1 to test if an input is true, so removed those.
_!_!~a_>?@AB._X]~b_>?@ACD._E?@ACE.
Original answer:
_!_!~a=1_>?@AB._X]~b=1_>?@ACD._X]?@ACE.
Takes two numerical inputs and tests these in straight-forward IF's. No fancy OR logic and array indexes here, unfortunately.
ArnoldC, 423 bytes
IT'S SHOWTIME
HEY CHRISTMAS TREE a
YOU SET US UP 0
HEY CHRISTMAS TREE b
YOU SET US UP 0
BECAUSE I'M GOING TO SAY PLEASE a
BECAUSE I'M GOING TO SAY PLEASE b
TALK TO THE HAND "ABD"
BULLSHIT
TALK TO THE HAND "ABE"
YOU HAVE NO RESPECT FOR LOGIC
BULLSHIT
BECAUSE I'M GOING TO SAY PLEASE b
TALK TO THE HAND "ACD"
BULLSHIT
TALK TO THE HAND "ACE"
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE BEEN TERMINATED
Since ArnoldC doesn't seem to have formal input, just change the first 2 YOU SET US UP values to either 0 or 1 instead.
Explanation
This is just a whole bunch of conditional statements which account for all the possible outputs. Why, you may ask? Well, ArnoldC doesn't really have string comprehension. It can't even concatenate strings! As a result, we have to resort to the more... inefficient... method.
𝔼𝕊𝕄𝕚𝕟, 18 chars / 23 bytes
`A⏜î?⍘B:`C⏜í?⍘D:⍘E
It's pretty much a fusion of conditional statements.
Note: ⏜ basically takes all code up to an optional ⏝, interprets the code, and replaces that block in the code with the result. This is the first time I've used this in a submission, but it works quite well. Self-modifying code FTW!
C, 54 bytes
Since the story started with a loop, I decided to stick to that. Not the shortest of solutions; but certainly one of the more obscure ones.
Function f takes two integer parameters as input (1 = true, 0 = false), and outputs AB, ACD or ACE to stdout.
f(a,b){for(int x=64;~putchar(++x)<<a&4;x+=x&2?!b:!a);}
C, 76 bytes
I renamed c1 to c, c2 to C and result to r. C programmers go to extremes to avoid goto. If you ever have a problum with absurd syntax in C, it is most likely to be because you did not use goto.
char r[4]="A";if(c){r[1]=66;goto e;}r[1]=67;if(C){r[2]=68;goto e;}r[2]=69;e:
Ungolfed
char r[4] = "A";
if(c1){
r[1] = 'B';
goto end;
}
r[1] = 'C';
if(c2){
r[2] = 'D';
goto end;
}
r[2] = 'E';
end:
Caché ObjectScript, 27 bytes
"A"_$s(x:"B",y:"CD",1:"CE")
beeswax, 26 bytes
Interpreting 0 as false, 1 as true.
E`<
D`d"`C`~<
_T~T~`A`"b`B
Output:
julia> beeswax("codegolfdowhile.bswx",0,0.0,Int(20000))
i1
i1
AB
Program finished!
julia> beeswax("codegolfdowhile.bswx",0,0.0,Int(20000))
i1
i0
AB
Program finished!
julia> beeswax("codegolfdowhile.bswx",0,0.0,Int(20000))
i0
i1
ACD
Program finished!
julia> beeswax("codegolfdowhile.bswx",0,0.0,Int(20000))
i0
i0
ACE
Program finished!
Clone my beeswax interpreter from my Github repository.
MATLAB, 31 28 bytes
@(x,y)[65,67-x,~x*(69-y),'']
This anonymous function will match all the test cases. The first input is condition 1 and the second input is condition 2. The string will be returned.
The function also works with Octave. You can try it online here.
Simply create the anonymous function by running the command above, then call the function. Running this for example:
ans(0,1)
Will return:
ACD
JavaScript ES6, 30 26 25 bytes
A simple anonymous function taking two inputs. Assign to a variable to call.
Update: Let's jump on the index bandwagon. It saves 4 bytes. I have secured my lead over Python. Saved a byte by currying the function; call like (...)(a)(b). Thanks Patrick Roberts!
a=>b=>a?"AB":"AC"+"ED"[b]
Old, original version, 30 bytes (included to not melt into the python answer (;):
(a,b)=>"A"+(a?"B":b?"CD":"CE")
Perl, 19 + 1 (-p switch) = 20 bytes
$ perl -pe '$_=l.$_^-su;s/B./B/'
00
ACE
01
ACD
10
AB
11
AB
Uses string XOR and a bareword with leading hyphen. Ungolfed:
$_ = ('l' . $_) ^ '-su';
s/B./B/;
Pyth, 13 chars, 19 bytes
.HC@"્««"iQ2
Takes input in form [a,b]
Explanation
- autoassign Q = eval(input())
iQ2 - from_base(Q, 2) - convert to an int
@"્««" - "્««"[^]
C - ord(^)
.H - hex(^)
><> (Fish), 30 bytes
"A"o$1+.
"<"DC"v"CE
o "B"|>oo;
This code uses the two variables (using the initial stack) to move the pointer to (C2, C1+1) You can try it here
Python 3, 31
Saved 1 byte thanks to xnor.
Only one byte away from ES6. :/ Stupid Python and its long anonymous function syntax.
Hooray for one liners!
lambda x,y:x*"AB"or"AC"+"ED"[y]
Test cases:
assert f(1, 1) == "AB"
assert f(1, 0) == "AB"
assert f(0, 1) == "ACD"
assert f(0, 0) == "ACE"
CJam, 15 16 17 bytes
'Ali'B'C'Eli-+?
One byte off thanks to @randomra, and one byte off thanks to @Dennis
Explanation:
'A e# push "A"
li e# read first input as an integer
'B e# push "B"
'C e# push "C"
'E e# push "E"
li- e# leave "E" or change to "D" according to second input
+ e# concatenate "C" with "E" or "D"
? e# select "B" or "C..." according to first input
Old version (16 bytes):
'Ali'B{'C'Eli-}?
Explanation:
'A e# push character "A"
? e# if-then-else
li e# read first input as an integer. Condition for if
'B e# push character "B" if first input is true
{ } e# execute this if first input is false
'C e# push character "C"
'E e# push character "E"
li e# read second input as an integer
- e# subtract: transform "E" to "D" if second input is true
e# implicitly display stack contents
Brainfuck, 65 bytes
This assumes that C1 and C2 are input as raw 0 or 1 bytes. e.g.
echo -en '\x00\x01' | bf foo.bf
Golfed:
++++++++[>++++++++<-]>+.+>+>,[<-<.>>-]<[<+.+>>,[<-<.>>-]<[<+.>-]]
Ungolfed:
Tape
_0
++++++++[>++++++++<-]>+.+ print A 0 _B
>+>, read C1 0 B 1 _0 or 0 B 1 _1
[<-<.>>-]< print B 0 B _0 0 or 0 B _1 0
[<+.+>> print C 0 D 1 _0
, read C2 0 D 1 _0 or 0 D 1 _1
[<-<.>>-]< print D 0 D _0 0 or 0 D _1 0
[<+.>-] print E 0 D _0 or 0 E _0
]
I believe it worth noting that this solution is in fact based on breaking out of while loops.
DUP, 29 bytes
['A,^['B,]['C,$['D,]['E,]?]?]
Anonymous lambda. Usage:
1 0['A,^['B,]['C,$['D,]['E,]?]?]!
Explanation
[ ] {lambda}
'A, {output A}
^ {check if arg1 is truthy}
[ ][ ]? {conditional}
'B, {if so, output B}
'C, {otherwise, output C...}
$ {...and check if arg2 is truthy}
[ ][ ]? {conditional}
'D, {if so, output D}
'E, {otherwise, output E}
Jelly, 14 bytes
Ḥoị“ACD“AB“ACE
This expects the Booleans (1 or 0) as separate command-line arguments. Try it online!
How it works
Ḥoị“ACD“AB“ACE Main link. Left input: C1. Right input: C2.
Ḥ Double C1. Yields 2 or 0.
o Logical OR with C2.
2o1 and 2o0 yield 2. 0o1 and 0o0 yield 1 and 0, resp.
“ACD“AB“ACE Yield ['ACD', 'AB', 'ACE'].
ị Retrieve the string at the corresponding index.
Vitsy, 26 bytes
Expects inputs as 1s or 0s through STDIN with a newline separating.
W([1m;]'DCA'W(Zr1+rZ
'BA'Z
I actually discovered a serious problem with if statements during this challenge. D: This is posted with the broken version, but it works just fine. (I'll update this after I fix the problem) Please note that I have updated Vitsy with a fix of if/ifnot. This change does not grant me any advantage, only clarification.
Explanation:
W([1m;]'DCA'W(Zr1+rZ
W Get one line from STDIN (evaluate it, if possible)
([1m;] If not zero, go to the first index of lines of code (next line)
and then end execution.
'DCA' Push character literals "ACD" to the stack.
W Get another (the second) line from STDIN.
( If not zero,
do the next instruction.
Z Output all of the stack.
r1+r Reverse the stack, add one (will error out on input 0, 1), reverse.
Z Output everything in the stack.
'BA'Z
'BA' Push character literals "AB" to the stack.
Z Output everything in the stack.
PHP 4.1, 19 bytes
I was expecting it to be harder, but well. It was really fun!
<?=A,$A?B:C.($B^t);
This expects 2 parameters/values, passed as strings over POST/GET/SESSION/COOKIE... The key A will have the first value, the key B will have the 2nd.
The result will be sent to STDOUT.
Mouse-2002, 23 bytes
??"A"["B"|"C"["D"|"E"]]
Switches on two inputs, which each should be either 0 for false or anything else for true.
Ungolfed, as a function:
#Y,?,?;
$Y 1% a: 2% b:
"A"
a [
"B"
|
"C"
b [
"D"
|
"E"
]
]
$
Brackets just test if the top of the stack is true, and | is else.
This is a translation of @Cᴏɴᴏʀ O'Bʀɪᴇɴ's ES6 answer.
MATL, 15 17 bytes
?'AB'}'AC'69i-h
Inputs are 0 or 1 on separate lines. Alternatively, 0 can be replaced by F (MATL's false) and 1 by T (MATL's true).
? % if C1 (implicit input)
'AB' % push 'AB'
} % else
'AC' % push 'AC'
69 % push 69 ('E')
i- % subtract input. If 1 gives 'D', if 0 leaves 'E'
h % concatenate horizontally
% end if (implicit)
Kotlin, 50 bytes
It is interesting what one can do with string templates.
{a,b->"A${if(a)"B" else "C${if(b)"D" else "E"}"}"}
Brainbash, 43 bytes
----[>+<----]>++.>#{<+.>}-{<++.+>#-{<+>}<.}
Brainbash is BF with two tapes and more stuff. We're only using one this time. Let's take a look:
----[>+<----]>++.
This sets the first cell to A and outputs it.
>#
This move to the next cell and takes numeric input
{<+.>}
This is an if statement. If the numeric input is one, then we'll increment the previous cell and output it, outting B.
-
This transforms 1 to 0 (falsey) and 0 to 255. It's effectively a boolean NOT as far as the next if statement is concerned.
{<++.
If the current bit, output a C.
+>#
Change it do a D and take some input
-
"Negate it"
{<+>}
If it was a zero, output an increment and return to input cell.
<.}
Move to destination cell and out it.
I could use the "heat death of the universe" to save two bytes, using >+[+[<]>>+<+]>, but that didn't complete in the online interpreter, which can be found in the link in the header.
Haskell, 28 bytes
x#y|x="AB"|y="ACD"|1<2="ACE"
Usage example: False # True -> "ACD".
Using the input values directly as guards.
K, 37 bytes
{?"ABCDE"@0,x,(1*x),(2*~x),(~x)*3+~y}
Jolf, 16 bytes
+'A?j'B+'C."DE"J
Simple. Try this one here!
Aother one, using that other Pyth answer's approach:
11 characters, 18 UTF-8 bytes. You can try this one here.
~T."્««"Ιj
^-- that's a capital Iota, converting input to binary
PowerShell, 40 bytes
param($x,$y)(("ACE","ACD")[$y],"AB")[$x]
Nested arrays indexed by input. In PowerShell, $true / 1 and $false / 0 are practically equivalent (thanks to very loose typecasting), so that indexes nicely into a two-element array. This is really as close to a ternary as PowerShell gets, and I've used it plenty of times in golfing.
Examples
PS C:\Tools\Scripts\golfing> .\do-while-false.ps1 1 1
AB
PS C:\Tools\Scripts\golfing> .\do-while-false.ps1 1 0
AB
PS C:\Tools\Scripts\golfing> .\do-while-false.ps1 0 1
ACD
PS C:\Tools\Scripts\golfing> .\do-while-false.ps1 0 0
ACE
JavaScript, 38 bytes
Use no-delimiter 0 or 1 instead of false/true
_=>"ACE ACD AB AB".split` `[+('0b'+_)]
Japt, 19 bytes
"A{U?'B:'C+(V?'D:'E
Fun fact: This would be 16 bytes if it weren't for a bug:
"A{U?"B:C{V?"D:E
Perl, 23 bytes
say<>>0?AB:<>>0?ACD:ACE
Requires the -E|-M5.010 flag and takes input as 1 and 0:
$ perl -E'say<>>0?AB:<>>0?ACD:ACE' <<< $'0\n0'
ACE
$ perl -E'say<>>0?AB:<>>0?ACD:ACE' <<< $'0\n1'
ACD
$ perl -E'say<>>0?AB:<>>0?ACD:ACE' <<< $'1\n0'
AB
Alternative solution that requires -p and is 22 + 1 = 23 bytes:
$_=/^1/?AB:/1/?ACD:ACE
perl -pe'$_=/^1/?AB:/1/?ACD:ACE' <<< '0 1'
Y, 20 bytes
In the event that the first input is one, only one input is taken. I assume that this behaviour is allowed. Try it here!
'B'AjhMr$'C'E@j-#rCp
Ungolfed:
'B'A jh M
r$ 'C 'E@ j - # r
C p
Explained:
'B'A
This pushes the characters B then A to the stack.
jh M
This takes one input, increments it, pops it and moves over that number of sections.
Case 1: j1 = 0. This is the more interesting one. r$ reverses the stack and pops a value, 'C'E pushes characters C and E. @ converts E to its numeric counterpart, subtracts the second input from it, and reconverts it to a character. r un-reverses the stack. Then, the program sees the C-link and moves to the next link p, and prints the stack.
Case 2: the program moves to the last link p, which merely prints the entire stack.
Mathematica, 35 30 bytes
If[#,"AB",If[#2,"ACD","ACE"]]&
Very simple. Anonymous function.
Pyth, 16 bytes
+\A?Q\B+\C?E\D\E
Ternaries!
Explanation:
+\A Start with an A
?Q\B If the first variable is true, add a B and break.
+\C Otherwise, add a C and
?E\D If the second variable is true, add a D and break.
\E Otherwise, add a E and finish.
Input on two consecutive lines.
Pyth, 21 bytes
@c"ACE ACD AB AB"diz2
Input is taken as 0 or 1 instead of true/false while C1 comes first.
Explanation
Just using the fact that there are only 4 possible results. Works by interpreting the input as binary, converting it to base 10 and using this to choose the right result from the lookup string.
@c"ACE ACD AB AB"diz2 # z= input
iz2 # Convert binary input to base 10
c"ACE ACD AB AB"d # Split string at spaces
@ # Get the element at the index