| Bytes | Lang | Time | Link |
|---|---|---|---|
| 041 | AWK | 241205T053008Z | xrs |
| 039 | Rust | 240919T164112Z | cobrexus |
| 031 | JavaScript | 210727T214150Z | cobrexus |
| 009 | Thunno 2 | 230608T133915Z | The Thon |
| nan | 230119T171846Z | The Thon | |
| 105 | Acc!! | 230119T170745Z | DLosc |
| 030 | PHP | 191013T180556Z | Progrock |
| 029 | Factor | 230119T122144Z | chunes |
| 048 | C gcc | 230118T165556Z | Peter |
| 031 | .COM | 230118T150826Z | l4m2 |
| 030 | Python 3 | 220621T171611Z | Zachary |
| 037 | QBasic | 220621T151929Z | DLosc |
| 012 | Pip | 220621T150957Z | DLosc |
| 020 | Zsh | 190827T150117Z | GammaFun |
| 048 | eTeX | 220304T152503Z | plante |
| 032 | APOL | 220303T193132Z | Ginger |
| 023 | FALSE | 210728T191658Z | Joseph W |
| 007 | Vyxal r | 210727T013645Z | lyxal |
| 050 | Javascript | 200813T105805Z | Yaroslav |
| 010 | Retina | 200813T090533Z | ovs |
| 059 | MAWP | 200813T085015Z | Razetime |
| 052 | Kotlin | 200321T093402Z | snail_ |
| 008 | W j | 200321T084410Z | user9206 |
| 103 | Whitespace | 191011T092318Z | Dorian |
| nan | W d | 191208T065203Z | user8505 |
| 038 | TIBASIC | 200119T122228Z | absolute |
| 066 | naz | 200119T044841Z | sporebal |
| 011 | GolfScript | 200118T094733Z | user8505 |
| 013 | Charcoal | 191219T230246Z | Pseudo N |
| 582 | Shakespeare Programming Language | 191219T144256Z | Hello Go |
| 030 | C# Visual C# Interactive Compiler | 191219T135632Z | Jirka Pi |
| 007 | Keg | 190712T075622Z | lyxal |
| 017 | Pushy | 191208T192310Z | FlipTack |
| 030 | Wren | 191208T063606Z | user8505 |
| 013 | sed | 190827T150517Z | GammaFun |
| 034 | GNU Smalltalk | 190827T141608Z | user8505 |
| 031 | PHP | 190803T151838Z | ShiSHcat |
| 028 | Extended BrainFuck | 190713T135837Z | Sylweste |
| 042 | Java OpenJDK 8 | 190803T074051Z | CuttingC |
| 020 | 33 | 190803T051333Z | TheOnlyM |
| 061 | ScPL | 190730T002628Z | pfg |
| 068 | Boolfuck | 190712T130710Z | EdgyNerd |
| 047 | Boolfuck | 190715T014207Z | Jo King |
| 022 | Zozotez | 190713T142845Z | Sylweste |
| 104 | Pepe | 190713T122439Z | RedClove |
| 052 | brainfuck | 190712T055600Z | Jo King |
| 038 | Racket | 190712T050524Z | Winny |
| 016 | Underload | 190711T071712Z | EdgyNerd |
| 022 | Keg | 190711T042731Z | user8505 |
| 020 | PowerShell | 190707T175611Z | Andrei O |
| 032 | R | 190708T202405Z | Robert S |
| 405 | Turing Machine But Way Worse | 190707T174145Z | MilkyWay |
| 077 | Dart | 190709T120118Z | Elcan |
| 028 | Ruby | 190708T112014Z | DaveMong |
| 008 | Jelly | 190707T150712Z | Jonathan |
| 009 | Jelly | 190707T153632Z | Luis Men |
| 124 | Java JDK | 190708T174256Z | Felix Bo |
| 037 | Python 3 | 190708T215433Z | Dat |
| 031 | Python 3 | 190707T145841Z | Jonathan |
| 072 | brainfuck | 190708T195302Z | Helena |
| 025 | 8088 Assembly | 190708T163058Z | 640KB |
| 2623 | PHP | 190708T165108Z | 640KB |
| 046 | Sinclair ZX80 BASIC 4K ROM 46 tokenized BASIC bytes | 190708T163621Z | Shaun Be |
| 021 | Runic Enchantments | 190708T155930Z | Draco18s |
| 035 | F# .NET Core | 190708T003512Z | LSM07 |
| 011 | Japt P | 190708T122617Z | Oliver |
| nan | Windows batch | 190708T034215Z | user8505 |
| 012 | Pyth | 190708T100730Z | Sok |
| 009 | 05AB1E | 190708T080652Z | Kevin Cr |
| 024 | Excel | 190708T093509Z | Wernisch |
| 022 | Ruby | 190708T075511Z | G B |
| 033 | Python 3 | 190708T071728Z | ruohola |
| 018 | Befunge93 | 190707T153816Z | negative |
| 032 | Python 2 | 190708T060434Z | ElPedro |
| 031 | JavaScript | 190708T055717Z | ADJenks |
| 013 | APL Dyalog Unicode | 190707T140533Z | Adá |
| 015 | Perl 5 p | 190708T035346Z | Xcali |
| 038 | C | 190708T012353Z | pommicke |
| nan | Python 3 | 190707T143739Z | user8505 |
| 023 | /// | 190708T005906Z | sporkl |
| 043 | My shortest possible solution in Python | 190707T143639Z | Ishaq Kh |
| 030 | Java | 190707T213529Z | Benjamin |
| 024 | Attache | 190707T204415Z | Conor O& |
| 023 | C# Visual C# Interactive Compiler | 190707T204406Z | Expired |
| 038 | Wolfram Language Mathematica | 190707T155605Z | Roman |
| 008 | Stax | 190707T151444Z | recursiv |
| 016 | K oK | 190707T172523Z | mkst |
| 034 | Haskell | 190707T161245Z | nimi |
| 020 | bash | 190707T160356Z | Doorknob |
| 020 | Retina 0.8.2 | 190707T153956Z | Neil |
AWK, 41 bytes
BEGIN{getline x;print x~/G/?"Bad":"Good"}
Another way to go about it:
$0=/G/?"Bad":"Good"
To Test:
awk '$0=/G/?"Bad":"Good"' <<< "Good"
JavaScript, 35 32 31 bytes
-3 bytes thanks to @xigoi
-1 byte thanks to @l4m2
alert(prompt()[3]?'Bad':'Good')
Thunno 2, 9 bytes
’⁽ȯBad’$o
Explanation
’⁽ȯBad’$o # Implicit input
’⁽ȯBad’ # Compressed string "GoodBad"
$o # Remove the input
# Implicit output
Thunno, \$15\log_{256}(96)\approx\$ 12.35 bytes
"Bad"Dz0=?"Good
"Bad"Dz0=?"Good # Implicit input
"Bad"D # Push the string bad and duplicate (STACK: "Bad", "Bad")
z0 # Push the input (STACK: "Bad", "Bad", input)
=?"Good # If they are equal, push the string "Good" (STACK: "Bad", "Good") IF input == "Bad"
# Otherwise, the stack is left as-is (STACK: "Bad") IF input != "Bad"
# Implicit output of top of stack
Acc!!, 105 bytes
N
Count i while _/71 {
Write 66
Write 97
0
}
Count i while _ {
Write 71
Write 111
Write 111
0
}
Write 100
Explanation
# Read a character from stdin (user must enter a full line)
N
# Loop while the character code int-divided by 71 is nonzero (i.e. G was entered)
Count i while _ / 71 {
# Write Ba
Write 66
Write 97
# Set accumulator to 0 to exit the loop
0
}
# Loop while the accumulator is nonzero (i.e. previous loop did not run)
Count i while _ {
# Write Goo
Write 71
Write 111
Write 111
# Set accumulator to 0 to exit the loop
0
}
# Write d
Write 100
C (gcc), 48 bytes
main(){puts(getchar()-66?"Bad":"Good");}
The program only actually takes one character as input, although getchar reads until a newline is found unlike getch which only lets you input a single character. It checks if there's a difference between that character and the ascii code for 'B' (66), printing "Bad" if there is and "Good" if there isn't.
.COM, 31 bytes
org 0x100
mov dx, 0x100
mov eax, 0xA20 + '$$'*0x10000
int 0x21
inc dx
inc dx
xor dword [0x102], 'Good' xor ('Bad'+0x0d000000)
mov al, 0x20
int 0x29 ; Avoid "Badd"
mov ah, 9
int 0x21
ret
Python 3, 30 Bytes
exit({'Good','Bad'}-{input()})
Uses the same exit trick as the other python 3 solution. It's unclear to me if this solution is necessarily allowed by the problem, but the output is certainly separated from the input, so I think it counts.
QBasic, 37 bytes
INPUT s$
IF"C"<s$THEN?"Bad"ELSE?"Good
Try it at Archive.org
Explanation
Uses string comparison to separate the two cases. Ungolfed:
INPUT s$
IF "C" < s$ THEN PRINT "Bad" ELSE PRINT "Good"
Pip, 12 bytes
"GoodBad"RMq
Explanation
q ; Read a line of input from stdin
RM ; Remove that substring from
"GoodBad" ; This literal string
Zsh, 21 20 bytes
-1 by just defining a variable first instead of using an empty fallback
x=GoodBad
<<<${x/$1}
<<<${${[implicit parameter]:-fallback}/pattern[/implicit empty replacement]}
No coreutils, and nearly as good as the Bash+coreutils answer (which is compatible with Zsh).
(e-)TeX, 48 bytes
\read0to~\expanded{\def\##1~{#1}}\#Good Bad \bye
Output is to dvi/pdf file.
APOL, 32 bytes
Just checks if the input starts with "G".
g(["Good" "Bad"] I(=(g(i) "G")))
FALSE, 23 bytes
^'B=$["Good"]?~["Bad"]?
Explanation
The program gets an input character and checks if it is equal to 'B'. If it is, it prints 'Good', and if it isn't it prints 'Bad'. This makes use of the fact that 'Good' and 'Bad' are easily differentiable based on simply the first character of each word.
^ {Get input character}
'B= {See if input char is equal to 'B'}
["Good"]?~["Bad"]? {If top of stack is TRUE, print "Good", else print "Bad"}
Note: Curly brackets denote comments in FALSE. In the past I've used '//' to comment FALSE code in my explanations, but since it isn't syntactically valid I'm now trying to use FALSE's comment syntax.
Vyxal r, 7 bytes
`ƛ⁋«Ṫ`-
This is irony in a nutshell.
Explained
`...`-
`...` # the string "GoodBad"
- # ^ - input (removes it)
In the spirit of my Keg answer, here's the compiled code:
global stack, register, printed, output, MAP_START, MAP_OFFSET, _join, _vertical_join, use_encoding, input_level, raw_strings, retain_items, reverse_args, this_function
stack.append("GoodBad")
rhs, lhs = pop(stack, 2); stack.append(subtract(lhs, rhs))
Javascript 50 bytes
alert((305786-parseInt(prompt(),26)).toString(26))
Retina, 10 bytes
:`GoodBad
: swaps the input and the regex, so this computes 'GoodBad'.replace(input, '').
W j, 8 bytes
Still doesn't tie with Keg. Help!
♥d←╖←I¡%
Uncompressed:
G'%Av%?S,
Explanation
% Implcitly start a compressed string
G' % "good" in the dictionary
% % Capitalize
Av % "bad" in the dictionary
% % Capitalize
? % End compressed string
S % Swap so that the input comes to the top
, % Split the string on the input
Flag:j % Implicit smash on output list
```
Whitespace, 114 104 103 bytes
(much whitespace)
-5 bytes thanks to Jo King.
-5 bytes by determining if the input is odd or even instead of subtracting "B"
-1 byte thanks to Kevin Cruijssen by using the initial 3 as address for reading characters
sssttl push "d"
sls dup (address for "retrieve")
sls dup (address for "readc")
tlts readc
ttt retrieve
ssstsl push 2
tstt mod (determine if input is even or odd)
ltssl jz good
sssl push "a"
ssttttttl push "B"
lsll jmp print
lsssl lbl good
ssstttsl push "o"
sls dup
sstttstsl push "G"
lssl lbl print
sssttsssstl 97
tsss add
tlss printc
lsll jmp print
W d, 12 11 9 bytes
Realized that I could use the implicit quote system. Still can't beat Keg with the decompression. (Alternative 9-byter:§D⑺y⒁v⑼z¬; but that's the same bytecount)
☺DΩy±v∞z↓
Explanation
% Sample input: "Bad"
% Implicitly prepend a quote for this string
GooBa" % Stack: ["Bad","GooBa"]
S % Stack: ["GooBa","Bad"]
t % "GooBa".trim("Bad"), which is "Goo"
'd % Stack: ["Goo","d"]
% Stack: ["Good"]
% Implicit output
```
TI-BASIC, 38 bytes
Input Str1:"GoodBad
sub(Ans,abs(inString(Ans,Str1)-5)+1,4
Prompts the user to input the string, then prints the other string as specified in the challenge.
Explanation:
Input Str1 ;get the input
"GoodBad " ;leave "GoodBad " in Ans. closing quote
; is added for clarity (isn't in program)
inString(Ans,Str1) ;get the 1-indexed position of the input
; in "GoodBad "
abs( -5)+1 ;subtract 5, get the absolute value,
; then add 1
sub(Ans, ... ,4 ;get the substring of "GoodBad " starting
; at the position just calculated with
; a length of 4. leave the result in Ans
;implicit print of Ans
naz, 66 bytes
9a7m4a2x1v1x1f1r3x1v2l5s1o2d3m2s1o3a1o0x1x2f5a1o2d3m6a2o9s2s1o0x1f
Explanation (with 0x commands removed)
9a7m4a2x1v # Set variable 1 equal to 67 ("C")
1x1f # Function 1
1r3x1v2l # Read the first byte of input
# Jump to function 2 if it's less than variable 1
5s1o2d3m2s1o3a1o # Otherwise, output "Bad"
1x2f5a1o2d3m6a2o9s2s1o # Function 2
# Output "Good"
1f # Call function 1
GolfScript, 11 bytes
"GoodBad"\/
Explanation
"GoodBad" # Define the lookup table "GoodBad"
\ # Swap the input so that it can be used by /
/ # Split the lookup table by occurences of the input
# Implicit print, smashing
Charcoal, 13 bytes
¿⁻LS³Ba¦Goo¦d
Explanation:
¿⁻LS³ If length of input minus 3 is truthy:
Ba¦ print Ba
Goo¦ else print Goo
d print d
Shakespeare Programming Language, 582 bytes
(Whitespace added for readability)
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.
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.
Keg, -rt 20 17 15 13 8 7 bytes (SBCS)
-᠀‘5ƳP↫
Transpiles to:
from KegLib import *
from Stackd import Stack
stack = Stack()
printed = False
iterable(stack, 'GoodBad')
string_input(stack)
maths(stack, '-')
if not printed:
printing = ""
for item in stack:
if type(item) in [str, Stack]:
printing += str(item)
elif type(item) == Coherse.char:
printing += item.v
elif item < 10 or item > 256:
printing += str(item)
else:
printing += chr(item)
print(printing)
It's a port of the 05AB1E answer. Essentially, it:
- Pushes the string
"GoodBad" - Takes input as a string
- Subtracts the input from the pushed string. This works by replacing the first instance of the input within
GoodBadwith nothing. - Implicitly prints the resulting string.
- The
-rtflag tells Keg to read tokens from right to left.
Answer History
?G=[øBad|ø‘5Ƴ
Transpiles to the following:
from KegLib import *
from Stackd import Stack
stack = Stack()
printed = False
Input(stack)
character(stack, 'G')
comparative(stack, '=')
if bool(stack.pop()):
empty(stack)
character(stack, 'B')
character(stack, 'a')
character(stack, 'd')
else:
empty(stack)
iterable(stack, 'Good')
if not printed:
printing = ""
for item in stack:
if type(item) is Stack:
printing += str(item)
elif type(item) is str:
printing += custom_format(item)
elif type(item) == Coherse.char:
printing += item.v
elif item < 10 or item > 256:
printing += str(item)
else:
printing += chr(item)
print(printing)
Explanation
?G=[øBad|ø‘5Ƴ
? #Get input from user
G= #If the first letter is "G"
[øBad #Clear the stack and push "Bad"
| #Else,
ø‘5Ƴ#Clear the stack and push the compressed string "Good"
Pushy, 17 bytes
.F`Goo`x?c`Ba`;H"
Explanation:
\ Implicit: input on main stack.
.F \ Pop last letter, and move to auxiliary stack.
`Goo` \ Push 'Goo' to main stack.
x? ; \ If the stacks are equal:
c`Ba` \ Replace 'Goo' with 'Ba'
H \ Push 'd', as char(d) = 100 = H
" \ Print stack
Wren, 30 bytes
Fn.new{|x|"GooBa".trim(x)+"d"}
Explanation
Fn.new{|x| } // New anonymous function with parameter x
// Sample input: "Bad"
"GooBa" // Define a string
.trim(x) // Trim out all characters in the input string
// "GooBa" - "Bad" = "Goo"
+"d" // Return the string joined with a "d": "Good"
sed, 21 16 13 bytes
Thanks @Cowsquack for the hints.
/B/cGood
cBad
Try it online!
Try it online!
Try it online!
TIL c will short-circuit the current line's parsing.
GNU Smalltalk, 34B
Please forgive me for submitting a code snippet if Smalltalk does have input. I am a complete novice to Smalltalk.
i<'C'ifTrue:['Good']ifFalse:['Bad']
You replace the name i with the intended input.
PHP, 31 bytes
readline()=="Bad"?"Good":"Bad";
Another way, 41 bytes
["Bad"=>"Good","Good"=>"Bad"][readline()];
Extended BrainFuck: 29 28
,>,,,[>|"Bad">>]<[>|"Good">]
-1 bytes thanks to @JoKing
The compiled bf code can run on an interpreter that expects stream end after the last letter and a interpreter that uses 0 as the EOF value. eg. bf -n or beef. eg
> bf ebf.bf < GoodBad.ebf > GoodBad.bf
> echo Bad | bf -n GoodBad.bf
Good
> echo Good | bf -n GoodBad.bf
Bad
Java (OpenJDK 8), 51 42 bytes
g->{if(g=="Bad")return"Good";return"Bad";}
Checks if input is Bad.
-9 to @JoKing
33, 20 bytes
Itj71m"Good"'Bad'ntp
I don't have it on TIO yet, I'll update this when I do.
Explanation:
It | Get input
j71m n | If the first character is 'G'
"Good" p | - Print "Good"
'Bad' tp | Else, print "Bad"
ScPL, 61 bytes
ChooseFromMenu''[Good Bad]
Case
Text'Bad'
Case
Text'Good'
End
The first argument to ChooseFromMenu is the title, which doesn't matter so we put an empty string. The second argument is the list of choices.
Cases do not require a label, they go based on order.
Seperators between things are only required when they are not seperated some other way, for example a b needs a space because ab is one argument, but a'b' does not because the ' starts another argument.
Boolfuck, 110 68 bytes
,+;+[;+;;;;+;+;+;<;]>+;;[+;;;+;+;+;;;;+;+;;+;+;;;;+];+;;+;;;+;+;;+;;
Thanks to Jo King for the massively improved solution!
Boolfuck, 47 bytes
+>,+;>,;,+;>;;;+;+;+[;<;;;,;+;;+;<];;+;+;;+;;+;
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
Zozotez: 22
(?(=(r)'Bad)'Good'Bad)
Pepe, 104 bytes
rEEeREeEeeeEEErrEEreeEeeeEEEreeEEeEEEEreeEEeEEEEreeEEeeEeeREerREEreeEeeeeEereeEEeeeeEreeEEeeEeeREeReEree
With comments
# Prepare stacks
rEEe # r ← Input
REeEeeeEEE # R ← 'G'
# Create label i (outputs "Good")
rrEE { reeEeeeEEE reeEEeEEEE reeEEeEEEE reeEEeeEee } REe
# Create label 'G' (outputs "Bad")
rREE { reeEeeeeEe reeEEeeeeE reeEEeeEee } REe
# Compare values
ReE # If the first letter of input is 'G', go to label 'G'
ree # Otherwise, go to label i
brainfuck, 52 bytes
,>,,<<,[>-----.<---.+++.<<]>[+++++.+[-<-->]<-..>>.>]
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
>[ If it is Bad instead
+++++. Increment 'B' to 'G' and print
+[-<-->]<-.. Manipulate into 'o' and print twice
>>. Print 'd'
>] End loop
Racket, 38 bytes
(write(match(read)['Bad'Good][_'Bad]))
Underload, 26 25 16 bytes
(Bad)(Good)Bad^S
Since Underload has no input instructions, input is hard-coded (The ‘Bad’ on the right).
Really proud of this one: Underload has no way to check strings, so I had to go off of the fact the ‘Bad’ contains an a, which is an instruction that puts brackets around the top thing in the stack.
Edit: Saved 9 bytes over my old one by getting rid of 2 pairs of brackets, only using one S and getting rid of some !s and ^s
Keg, 22 bytes
?^_^_o=[^aB^_|^ooG^]
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
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
Dart, 77 bytes
import'dart:io';main()=>print('BadGood'.replaceAll(stdin.readLineSync(),''));
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!
Jelly, 8 bytes
“Ċ³ṫ³»œṣ
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
Jelly, 9 bytes
“GooBa”œ^
Explanation
Multiset symmetric difference between the input and the string “GooBa”.
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");}}
Most likely, there‘s still some room for improvement, but I‘m entirely new to code golfing.
Python 3, 32 31 bytes
exit('GBoaodd'['G'<input()::2])
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).
brainfuck, 72 bytes
,>+++++>,>,>,>,[<<<<[-<->>---<]<.>>+.>>.>>>]<[<<<[-<+>>+++<]<.>>-..>.>>]
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
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$
PHP, 26 23 bytes
A ternary is just cheaper:
<?=$argn==Bad?Goo:Ba?>d
Original answer, 26 bytes
<?=[Ba,Goo][$argn==Bad]?>d
Or 21 bytes (but this is basically Arnauld's answer)
<?=$argn[3]?Ba:Goo?>d
Sinclair ZX80 BASIC (4K ROM) - 46 tokenized BASIC bytes
1 INPUT A$
2 IF A$="GOOD" THEN PRINT "BAD"
3 IF A$="BAD" THEN PRINT "GOOD"
Sinclair ZX81 BASIC (Also Timex TS 1000/1500 or ZX80 with 8K ROM upgrade) - 45 tokenized BASIC bytes
1 INPUT A$
2 PRINT "GOOD" AND A$="BAD";"BAD" AND A$="GOOD"
Runic Enchantments, 21 bytes
"Bad":i≠7*?~"Good"@
Prints Good when the input is Bad and prints Bad for all other inputs.
F# (.NET Core), 50 35 bytes
Down to 35 thanks to @Expired Data
fun a->if a>"B"then"Bad"else"Good"
Original:
F# (.NET Core), 50 bytes
printf(if stdin.ReadLine()>"B"then"Bad"else"Good")
Japt -P, 11 bytes
"GoodBad"qU
Explanation:
"GoodBad"qU U = Input "Good" "Bad"
"GoodBad" String literal "GoodBad" "GoodBad"
qU Split at U ["","Bad"] ["Good",""]
-P Join into a string "Bad" "Good"
Alternative
"GoodBad"rU
r replaces U with ""
Windows batch, 53 48 47 bytes
-1 bytes, thanks to @Neil for noticing the trivialness of the space before else.
set/pa=
if %a%==Bad (echo Good)else (echo Bad)
set/pa= prompt for input and set a to that input
if %a%==Bad (echo Good)else (echo Bad) antonym for Good and Bad. Unfortunately Windows batch requires whitespace...
Pyth, 12 bytes
+-"GooBa"z\d
+-"GooBa"z\d Implicit: z=input()
-"GooBa"z Keep letters in "GooBa" which do not appear in z
+ \d Append "d", implicit print
05AB1E, 10 9 bytes
”‚¿‰±”áIK
-1 byte thanks to @Emigna.
Try it online or verify both test cases.
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".
Excel, 24 bytes
=IF(A1>"C","Bad","Good")
Using @MilkyWay90's <C suggestion.
Python 3, 33 bytes
exit(['Bad','Good'][input()<'G'])
Prints to stderr, to save one byte over print().
Python 2, 32 bytes
print('Good','Bad')['C'<input()]
Using exit requires extra brackets around the whole expression so in this case print is 1 byte shorter.
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')
APL (Dyalog Unicode), 13 bytesSBCS
Full program that prompts for input from stdin and prints to stdout.
'GooBad'~¯1↓⍞
⍞ 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
Python 3, 38 37 34 33 bytes
exit("C">input()and"Good"or"Bad")
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
///, 23 bytes
/#Good/Bad//#Bad/Good/#
There is no other way to take input in /// so it is hard-coded:
/#Good/Bad//#Bad/Good/#<INPUT HERE>
My shortest possible solution in Python (43 bytes)
print({'Good':'Bad','Bad':'Good'}[input()])
And MilkyWay90 further golfed version (-2 bytes)
print({'G':'Bad','B':'Good'}[input()[0]])
Attache, 24 bytes
$Good'$Bad^^Stdin[]|Echo
Explanation
$Good'$Bad^^Stdin[]|Echo
$Good'$Bad an array of the strings "Good" and "Bad"
^^ remove from this array
Stdin[] standard input
this leaves us with a singleton array of the swapped element
|Echo pipe the Echo function to each member of this array
(in this case, only prints the one element)
Alternatives
25 bytes: $Good'$Bad⩓Stdin[]|Echo
26 bytes: [$Good,$Bad]^^Stdin[]|Echo
29 bytes: Echo@If[Stdin[]@3,$Bad,$Good]
29 bytes: Echo@[$Bad,$Good][Stdin[]<$G]
37 bytes: [4875396,32943]^^STN@Stdin[]|Echo@NTS
44 bytes: Good:=$Bad;Bad:=$Good;Print@EvalHere@Stdin[]
Wolfram Language (Mathematica), 48 44 38 bytes
If[$ScriptInputString=="Bad",Good,Bad]
-4 bytes thanks to Jonathan Allan: using symbols instead of strings as output
-6 bytes by removing Print@, which is implicit in the command-line version of WolframScript and can be simulated on TIO with the -print argument
Stax, 9 8 bytes
çEF♫a║▬h
Essentially replace("BadGood", input, "").
Multiset xor with "GooBa". Algorithm copied verbatim from Luis Mendo
K (oK), 16 bytes
Solution:
$`Bad`Good"Bad"~
Returns "Good" if input is "Bad" otherwise returns "Bad" for all other inputs.
Haskell, 36 34 bytes
interact g
g"Bad"="Good"
g _="Bad"
Edit: -2 bytes thanks to @cole
Retina 0.8.2, 20 bytes
oo
o
T`G\oaB`Ro
o
oo
Try it online! Link includes test suite. Explanation:
oo
o
Turn Good into God.
T`G\oaB`Ro
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.
