The teacher is always wrong, flip his answer
05AB1E, 45 41 40 39 38 bytes
Code:
“‰¦žä¥æ€¸pe…Ü€¸“ð¡2ôDí«D€™«vy`:D_D¹Êiq
Explanation:
It first starts with the compression:
“‰¦žä¥æ€¸pe…Ü€¸“
This is a compressed version of "true false yeah nope yes no"
. After that, we split on the spaces with ð¡
, resulting into:
['true', 'false', 'yeah', 'nope', 'yes', 'no']
We slice this array into pieces of 2 with 2ô
, resulting into:
[['true', 'false'], ['yeah', 'nope'], ['yes', 'no']]
We duplicate this array and reverse each element of it with Dí
. Then we append this to our first array with «
, resulting into:
[['true', 'false'], ['yeah', 'nope'], ['yes', 'no'], ['false', 'true'], ['nope', 'yeah'], ['no', 'yes']]
To get the titlecased words, we duplicate the array again and convert each word to titlecase with €™
. Finally, this is appended to the initial array. So, the final list is:
[['true', 'false'],
['yeah', 'nope'],
['yes', 'no'],
['false', 'true'],
['nope', 'yeah'],
['no', 'yes'],
['True', 'False'],
['Yeah', 'Nope'],
['Yes', 'No'],
['False', 'True'],
['Nope', 'Yeah'],
['No', 'Yes']]
The imporant part here is that Nope
comes before No
. Eventually, we get to this part of the code:
vy`:D_D¹Êiq
Explanation:
v # For each in the array...
y` # Push the array (containing 2 words) and flatten.
: # Replace the first word with the second.
D_ # Duplicate and negate (resulting 0 into 1 and 1 into 0).
If this is not possible, this results into nothing.
D # Duplicate the top of the stack again.
¹Ê # If it's not equal to the inital input string...
iq # Quit the program and implicitly print the processed string.
Uses the CP-1252 encoding. Try it online!.
Pyth, 44 bytes
j\.XXXcz\.`M2)Jc."<unprintables>"\b)rR3J
Hexdump:
00: 6A5C 2E58 5858 637A 5C2E 604D 3229 4A63
10: 2E22 6179 0862 3C40 D23B 9A54 C2B4 A20A
20: FEE7 8701 225C 6229 7252 334A
Test suite.
TI-Basic, 217 bytes
Longer than I thought it would be...
Input Str1
If Str1="0
Then
Disp 1
Stop
End
"e"=sub(Str1,2,1
sub("FalsefalseNopenope",1+5not(Ans)(sub(Str1,1,1)="t")+10Ans+4Ans(sub(Str1,1,1)="y"),5-Ans-2(sub(Str1,3,1)="s"))+sub(" .",1+(sub(Str1,length(Str1),1)="."),1