Challenge Description:

Write a program that asks the user for input. The user will enter Good or Bad. You do not have to support any other input. If the user enters Good, print Bad and vice versa (to stdout etc).

Notes:

1) You cannot use any other pair of two words.

3) You do not need to display prompt string.

4) The output must appear separated from the input by any means.

5) No function is allowed accepting the value and returning the result; User must interact with the program.

Good luck!

• May we write a function that takes input as argument instead of prompting for it? – Adám Jul 7 '19 at 14:01
• Please edit your question about whether a function is allowed or not. I would highly recommend not restricting input to STDIN, unless you have a very good reason to (and I can't see one) – Jo King Jul 9 '19 at 0:21
• asks the user for input (stdin etc) shows that only STDIN or interactive input is allowed. Please change this to all default I/O methods – MilkyWay90 Jul 9 '19 at 17:05
• "Asks the user for input", should that be some explicit question? Because an empty CLI prompt isn't really asking for anything … – user0721090601 Jul 10 '19 at 13:23
• What is the purpose for this restriction? No function is allowed accepting the value and returning the result; User must interact with the program – mbomb007 Jul 12 '19 at 13:58

Python 3,  32  31 bytes

exit('GBoaodd'['G'<input()::2])


Try it online!

How?

Tests if input is 'Good' by comparing 'G'<input().

Uses the fact that in Python False==0 and True==1 to use the result as the start index of a slice of 'GBoaodd' using an undefined stop and a step of 2 with 'GBoaodd'[start:stop:step].

Prints to STDERR (saving a byte with exit in place of print).

• What a trick! Can't understand how this works. – Ishaq Khan Jul 7 '19 at 15:50
• Can you use a lambda to shorten bytes? – MilkyWay90 Jul 7 '19 at 16:55
• @MilkyWay90 As per the question it must be a program accepting input. – Jonathan Allan Jul 7 '19 at 17:11
• @A__ by default yes, although there is a comment by OP which suggests it could be overruled here. – Jonathan Allan Jul 8 '19 at 7:01
• Too bad that "Good" and "Bad" share a "d", or you could do 'GoodBad'.strip(input()) which is a byte shorter. – xnor Jul 10 '19 at 4:16

APL (Dyalog Unicode), 13 bytesSBCS

Full program that prompts for input from stdin and prints to stdout.

'GooBad'~¯1↓⍞


Try it online!

⍞ prompt for input from stdin; Good or Bad

¯1↓ drop the last character (d); Goo or Ba

'GooBad'~ multiset subtract those characters from these; Bad or Good

• Why the downvote‽ – Adám Jul 7 '19 at 14:39
• Does the code have GooBad or GoodBad? – NoOneIsHere Jul 8 '19 at 1:58
• I think it should have GooBad, as adding a character d will make this post 14 bytes. – user85052 Jul 8 '19 at 2:20
• @NoOneIsHere Thanks. Fixed. – Adám Jul 8 '19 at 4:33

Turing Machine But Way Worse, 405 bytes

0 0 0 1 1 0 0
1 1 1 1 2 0 0
0 2 0 1 3 0 0
0 3 0 1 4 0 0
0 4 0 1 5 0 0
1 5 0 1 6 0 0
0 5 1 1 h 0 0
1 6 1 1 7 0 0
1 7 0 1 8 1 0
0 8 0 1 9 0 0
1 9 1 1 9 0 0
0 9 0 1 a 0 0
1 a 0 1 a 0 0
0 a 0 0 b 0 0
0 b 1 1 c 1 0
0 c 0 0 d 0 0
1 d 0 0 e 0 0
0 e 0 0 f 0 0
0 f 1 1 g 1 1
1 h 1 1 i 0 0
0 i 1 1 j 1 0
0 j 0 1 k 0 0
1 k 1 1 k 0 0
0 k 0 1 l 0 0
0 l 1 1 l 0 0
1 l 1 0 m 1 0
1 m 1 1 n 1 0
1 n 1 1 o 0 0
0 o 0 1 p 1 1


Try it online!

Well, this took a while.

UNFINISHED EXPLANATION:

0 0 0 1 1 0 0 Start going to the sixth bit
1 1 1 1 2 0 0
0 2 0 1 3 0 0
0 3 0 1 4 0 0
0 4 0 1 5 0 0 End going to the sixth bit
1 5 0 1 6 0 0 If the sixth bit is 1, then it is Good. Start transforming "G" to "B" and go to state 6
0 5 1 1 h 0 0 Else, it is Bad. Start transforming "B" to "G" and go to state h
1 6 1 1 7 0 0 Keep on transforming "G" to "B"
1 7 0 1 8 1 0 End transforming and print "B"
0 8 0 1 9 0 0 We are in the first "o" in "Good". Start moving into the 5th bit.
1 9 1 1 9 0 0
0 9 0 1 a 0 0
1 a 0 1 a 0 0 Do some looping magic and start transforming "o" to "a"
0 a 0 0 b 0 0 End looping magic
0 b 1 1 c 1 0 End transforming and print "a"
0 c 0 0 d 0 0
1 d 0 0 e 0 0 Start transforming "a" to "d"
0 e 0 0 f 0 0
0 f 1 1 g 1 1 Stop transforming, print "d", and terminate
1 h 1 1 i 0 0 Continue transforming "B" to "G"
0 i 1 1 j 1 0 Stop transforming and print out "G"
0 j 0 1 k 0 0 Start going into position to print out "oo"
1 k 1 1 k 0 0
0 k 0 1 l 0 0 Move more efficiently using LOOPING MAGIC1!1111111
0 l 1 1 l 0 0 looping magic end, start transforming
1 l 1 0 m 1 0 end transforming and print out out "o"
1 m 1 1 n 1 0 print out "o" again
1 n 1 1 o 0 0 get into the "d" byte
0 o 0 1 p 1 1 print "d" and execute YOU HAVE BEEN TERMINATED

• "Turing-Machine-But-Way-Worse" is, without a doubt, my new favorite esolang. – Mike G Jul 8 '19 at 17:53
• @MikeTheLiar Thanks! – MilkyWay90 Jul 8 '19 at 18:10
• "YOU HAVE BEEN TERMINATED" ArnoldC, is that you? – TemporalWolf Jul 9 '19 at 20:28
• @TemporalWolf It is I, ArnoldC! – MilkyWay90 Jul 9 '19 at 20:36
• @A__ It isn't actually ArnoldC; I just put the exit command as a comment as a joke – MilkyWay90 Jul 10 '19 at 15:41

sed s/$1//<<<GoodBad  Try it online! 8088 Assembly, IBM PC DOS, 25 bytes Unassembled: BA 0110 MOV DX, OFFSET GB ; point DX to 'Good','Bad' string D1 EE SHR SI, 1 ; point SI to DOS PSP (80H) 02 04 ADD AL, [SI] ; add input string length to AL, set parity flag 7B 02 JNP DISP ; if odd parity, input was 'Bad' so jump to display 'Good' 02 D0 ADD DL, AL ; otherwise add string length as offset for 'Bad' string DISP: B4 09 MOV AH, 9 ; DOS display string function CD 21 INT 21H ; call DOS API, write string to console C3 RET ; return to DOS GB DB 'Good$','Bad$'  Explanation: Looks at the length of input string (plus leading space) that DOS stores at memory address 80H, and adds it to AL (initially 0 by DOS). If there is an odd number of 1 bits in the binary representation of the string length, the CPU parity flag is set to odd, and vice-versa. So input string ' Bad' length 4 (0000 0100), is odd parity and input string ' Good' is 5 (0000 0101) is even parity. DX is initially set to point to the string 'Good$Bad$', and if parity is even (meaning input was ' Good') advance the string pointer by that length (5) so it now points to 'Bad$'. If parity is odd, do nothing since it already points to 'Good$'. Then use DOS API to display a $ terminated string to console.

Example:

Download and test GOODBAD.COM or build from xxd dump:

0000000: ba10 01d1 ee02 047b 0202 d0b4 09cd 21c3  .......{......!.
0000010: 476f 6f64 2442 6164 24                   Good$Bad$


Python 3, 383734 33 bytes

exit("C">input()and"Good"or"Bad")


Try it online!

exit() : returns an exit code as output

"C">input() : Checks whether the input is larger than the string C in the alphabetical order

and"Good" : If the result is True, then returns with Good

or"Bad" : Otherwise, returns with Bad

• – Adám Jul 7 '19 at 14:51
• exit(input()[3:]and"Bad"or"Good") also works for the same byte count. – Neil Jul 8 '19 at 9:14

Jelly, 8 bytes

“Ċ³ṫ³»œṣ


Try it online!

A full program expecting a Python formatted string as an argument

How?

“Ċ³ṫ³»œṣ - Main Link: list of characters, S
“Ċ³ṫ³»   - compression of dictionary words "Good"+"Bad" = ['G','o','o','d','B','a','d']
œṣ - split on sublists equal to S
- implicit, smashing print

• Looks like OP responded, input isn't restricted to STDIN. – Erik the Outgolfer Jul 9 '19 at 5:44

brainfuck, 72 bytes

,>+++++>,>,>,>,[<<<<[-<->>---<]<.>>+.>>.>>>]<[<<<[-<+>>+++<]<.>>-..>.>>]


Try it online!

Explanation: ,>+++++>,>,>,>,

Read either: "G", 5, "o", "o", "d" or "B", 5, "a", "d", 0

[<<<<[-<->>---<]<.>>+.>>.>>>] If the last character is not zero:

Substract 5 from the first cell once and from the third cell thrice. Increment cell 3

Output cells 1, 3, 5.

<[<<<[-<+>>+++<]<.>>-..>.>>]

Otherwise add 5 to the first cell once and to the third cell thrice.

Decrement cell 3

Output cells 1, 3, 3, 4

• That's a nice solution. You can shorten it a little bit by not using a newline in the input. ,>+++++>,>,>,[<<<[-<->>---<]<.>>+.>>.>>]<[<<[-<+>>+++<]<.>>-..>.>] – Dorian Jul 9 '19 at 8:29
• yeah, I realized that there is something to optimise there, but I found it hard to interpret what is necessary to comply with rule 4 – Helena Jul 9 '19 at 17:11

C, 39 38 bytes

main(){puts("Good\0Bad"+getchar()%6);}


Try it online!

Saved one byte thanks to @tsh.

• main(){puts("Good\0Bad"+getchar()%6);} 38 bytes – tsh Jul 8 '19 at 1:47
• Shouldn't you add #include<stdio.h>? – polfosol ఠ_ఠ Jul 9 '19 at 11:04
• @polfosolఠ_ఠ If this were anything but code golf, you should, but in C89, you can implicitly declare functions. – pommicket Jul 9 '19 at 11:11
• Can you use a null byte instead of \0? – Hello Goodbye Dec 19 '19 at 14:18

interact g


Try it online!

Edit: -2 bytes thanks to @cole

• 34 bytes – cole Jul 7 '19 at 17:01

R, 423735 32 bytes

-10 thanks to Giuseppe and AkselA!

if(scan(,'')>'C','Bad','Good')


Try it online!

• No problem. I recognize a lot of the other R golfers' names, so I often click on posts if I see their name as the most recent. :-) – Giuseppe Jul 8 '19 at 20:35
• using "C" instead of the first "Bad" as in this answer will save another couple bytes. – Giuseppe Jul 8 '19 at 20:50
• Just out of curiosity, would something like if(readline()>"C","Bad","Good") be a valid answer? I'm new to this game and its rules. – AkselA Jul 9 '19 at 15:33
• @AkselA yes, but I'd also suggest using scan(,"") instead of readline(). Feel free to come to golfR, the R golf chatroom if you have any R-specific questions :-) – Giuseppe Jul 9 '19 at 19:44
• @AkselA also see Tips for Golfing in R for some specific tips; there are hidden gems in there if you read them :-) – Giuseppe Jul 9 '19 at 19:46

sed, 21 16 13 bytes

Thanks @Cowsquack for the hints.

/B/cGood


TIL c will short-circuit the current line's parsing.

• c offers a shorter solution – user41805 Aug 27 '19 at 16:10
• You can still save 3 more bytes using c – user41805 Aug 28 '19 at 5:03
• Had to play around with it a bit, but I figured it out! – GammaFunction Aug 28 '19 at 5:24

JavaScript 31 bytes

I like Arnauld's answer, but I would like it to accept user input and be runnable on StackExchange like so:

alert(prompt()[3]?'Bad':'Good')

Befunge-93, 20 18 bytes

"BadooGB"~-_#@,,<,


Try it online!

-2 bytes thanks to Jo King

Ruby, 22 bytes

->n{n>?F?"Bad":"Good"}


Try it online!

• The question does say "asks the user for input", but the shortest way to do that is replacing the lambda with p gets and so it's the same length. (my original comment said you could save 2 bytes, but I didn't account for printing the result) – DaveMongoose Jul 8 '19 at 10:09
• If we're actually going to be talking about a full program asking user for input, using the -p flag would give the most efficient answer: $_=$_>?F?:Bad:"Good" is 20 bytes. Try it online! – Value Ink Jul 8 '19 at 23:17

05AB1E, 10 9 bytes

”‚¿‰±”áIK


-1 byte thanks to @Emigna.

Explanation:

”‚¿‰±”     # Push dictionary string "Good Bad"
á    # Only keep letters (to remove the space)
IK  # Remove the input
# (output the result implicitly)


See this 05AB1E tip of mine (section How to use the dictionary?), to understand why ”‚¿‰±” is "Good Bad".

• I can see many alternate variations on this, but they all end up at the same byte count :( – Emigna Jul 8 '19 at 9:49
• Actually, you can save a byte with á. – Emigna Jul 8 '19 at 9:52
• @Emigna Ah of course, brilliant. Now that I see á I can't believe I hadn't thought about it, but at the same time I know I would have never thought about it. ;) Thanks! (And yeah, I had a few 10-byte alternatives as well.) – Kevin Cruijssen Jul 8 '19 at 9:54
• Don't even need á, ”‚¿Bad”IK is also a 9. – Grimmy Jul 8 '19 at 10:29

Java (JDK), 124 bytes

interface G{static void main(String[]a){System.out.print(new java.util.Scanner(System.in).next().length()>3?"Bad":"Good");}}


Try it online!

Most likely, there‘s still some room for improvement, but I‘m entirely new to code golfing.

• Welcome! Consider adding an explanation and/or a link to an online interpreter where you can run your code. (See other answers for examples.) Code-only answers tend to be automatically flagged as low-quality. – mbomb007 Jul 8 '19 at 21:38
• The length part could just be !="Bad" – Jo King Jul 9 '19 at 2:14
• 109 bytes – Olivier Grégoire Aug 27 '19 at 14:32

Ruby, 30 28 bytes

puts %w|Good Bad|-gets.split


Not the golf-iest, but I like the abuse of split to remove the trailing newline and convert to an array in one call.

EDIT -2 bytes thanks to Value Ink's suggestion!

• This prints "Good" or "Bad" (with quotes); I'm not sure that's allowed. – Jordan Jul 8 '19 at 16:29
• Abuse the fact that puts prints each element of an array on a separate line. It's 3 bytes more expensive than p, but it evens out since you take out the [0] and then save 2 more bytes by no longer needing parens. Try it online! – Value Ink Jul 8 '19 at 23:22
• @ValueInk thanks! Jordan's issue also gets resolved by this change so it's a win-win. – DaveMongoose Jul 9 '19 at 11:20

Shakespeare Programming Language, 582 bytes

G.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:
Open mind.Be you nicer the sum ofa big cat the cube ofa big big cat?If solet usScene V.
You is the sum ofthe sum ofyou a big big cat a cat.Speak thy.You is the sum ofyou twice twice twice the sum ofa big big cat a cat.Speak thy.Speak thy.You is the square oftwice the sum ofa big big cat a cat.Let usScene X.
Scene V:.Ajax:
You is the sum ofthe sum ofyou a big big pig a pig.Speak thy.You is the sum ofyou the sum ofa big big big big big cat a pig.Speak thy.You is the sum ofyou the sum ofa big cat a cat.
Scene X:.Ajax:Speak thy.


Try it online!

I get the first letter of the input with Open mind. Then I need to determine what it is. Of all the numbers between B=66 and G=71, my brute forcer says 66 is the shortest to write (the sum ofa big cat the cube ofa big big cat), so I compare the first letter of the input to 66. Scene I continues to print Good, or Scene V prints Bad.

Retina, 10 bytes

:GoodBad



Try it online!

: swaps the input and the regex, so this computes 'GoodBad'.replace(input, '').

Retina 0.8.2, 20 bytes

oo
o
TG\oaBRo
o
oo


Try it online! Link includes test suite. Explanation:

oo
o


Turn Good into God.

TG\oaBRo


Transpose the letters GoaB with the reverse of that list, thus exchanging G with B and o with a, i.e. exchanging God with Bad.

o
oo


Turn God into Good.

• 17 bytes, but less creative – pbeentje Jul 8 '19 at 14:38

Stax, 9 8 bytes

çEF♫a║▬h


Run and debug it

Essentially replace("BadGood", input, "").

Multiset xor with "GooBa". Algorithm copied verbatim from Luis Mendo

Excel, 24 bytes

=IF(A1>"C","Bad","Good")


Using @MilkyWay90's <C suggestion.

PHP, 26 23 bytes

A ternary is just cheaper:

<?=$argn==Bad?Goo:Ba?>d  Try it online! Original answer, 26 bytes <?=[Ba,Goo][$argn==Bad]?>d


Try it online!

Or 21 bytes (but this is basically Arnauld's answer)

<?=$argn[3]?Ba:Goo?>d  Try it online! • Judging by the phrasing of the question, readline() is likely more appropriate than $argn. – Progrock Oct 14 '19 at 15:55

Jelly, 9 bytes

“GooBa”œ^


Try it online!

Explanation

Multiset symmetric difference between the input and the string “GooBa”.

• @JonathanAllan Thanks. Edited – Luis Mendo Jul 7 '19 at 16:53
• I don't see any indication that the input has to come through STDIN... – Erik the Outgolfer Jul 7 '19 at 18:37
• @EriktheOutgolfer Unfortunately the whole way the question is written implies we must have a program which, when run, asks for input (even though no prompt must be displayed). See the OPs own answer too. If you want to get them to change it go for it (although do note that they haven't answered the first, similar although slightly different, question in the comments) – Jonathan Allan Jul 7 '19 at 20:29
• Looks like OP responded, input isn't restricted to STDIN. – Erik the Outgolfer Jul 9 '19 at 5:43
• @EriktheOutgolfer Thanks! Rolled back – Luis Mendo Jul 9 '19 at 6:25

PowerShell, 22 20 bytes

'Good','Bad'-ne\$args


Try it online!

-2 bytes thanks to mazzy

• 20 bytes – mazzy Jul 7 '19 at 19:57

Keg, 22 bytes

?^_^_o=[^aB^_|^ooG^]


brainfuck, 52 bytes

,>,,<<,[>-----.<---.+++.<<]>[+++++.+[-<-->]<-..>>.>]


Try it online!

Relies on Bad being one letter shorter than Good, so the last input is empty.

Explanation:

,>,,<<,       Get input into the first three cells
[             If the last letter was not empty (i.e. Good)
>-----.      Decrement 'G' to 'B' and print
<---.        Decrement 'd' to 'a' and print
+++.         Increment back to 'd' and print
>>]           End loop
+++++.       Increment 'B' to 'G' and print
+[-<-->]<-.. Manipulate into  'o' and print twice
>>.          Print 'd'
>]            End loop



Boolfuck, 47 bytes

+>,+;>,;,+;>;;;+;+;+[;<;;;,;+;;+;<];;+;+;;+;;+;


Try it online!

Uses the fact that you can basically just take in the input as bits and then invert certain bits to turn it into the opposite letter.

Explanation:

+>,+;>,;,+;>;;;+;+;+    Print the first letter by inverting the first and third bits of the input
'B' = 01000010
'G' = 11100010
This leaves the tape as
1 1 1 1' in the case of Bad
1 0 0 1' in the case of Good
By making the center cells the inverted bits
[;<;;;,;+;;+;<]         Print the center letters by looping over the two pairs of cells
0 1' results in 'a' = 10000110
1 1' results in 'o' = 11110110 by printing the 1 in the 2-4th places
1 1 1 1' loops twice, while 1 0 0 1' only loops once
;;+;+;;+;;+;            Finally print 'd' = 00100110



Boolfuck, 110 68 bytes

,+;+[;+;;;;+;+;+;<;]>+;;[+;;;+;+;+;;;;+;+;;+;+;;;;+];+;;+;;;+;+;;+;;


Thanks to Jo King for the massively improved solution!

Try it with Online!

• 68 bytes. I think it can be better though – Jo King Jul 15 '19 at 0:51
• Wow, how were you able to save so many bytes over my answer? – EdgyNerd Jul 15 '19 at 6:26