text:
Is it true or false?
I cannot believe that this hasn't been done before but I may be wrong. If so, just close as dupe.
This challenge is very similar to Is it truthy or falsy? but, IMO, isn't close enough to be a dupe. That has predefined "falsy" variables that all languages must use, some of which aren't even falsy; this uses your own falsy values.
Your task is to take an input, evaluate it and output whether it is truthy or falsy in your language.
The "evaluate" part is just so that the input isn't always a string containing the input. For example an input of 0 would be falsy in almost all languages even if "0" is truthy. It simply means, "convert it into its native type"
Input
Anything. This can be taken from STDIN or as command line arguments.
Output
Its truthy or falsy value in your language. This should be preferably be denoted by true/false or 1/0. If not, please state what is the output for each.
For example, 1, "hello" and [0,2] are all truthy in Python but the third isn't in MATL (? Correct me if wrong)
Rules

There must be 2 unique identifiers for truthy and falsy. You can't just say numbers are true and symbols are false
Submissions must be full programs
This is a code-golf but I have a feeling that a challenge this trivial might become a catalogue so if that happens, I will update the body to contain normal catalogue rules.
Of course, builtins are allowed but must be part of a full program. For example, bool isn't a valid answer in Python.

Good luck!

This is so trivial it's unbelievable.

Possible duplicate of Is it truthy or falsy?

It isn't a duplicate, and I don't think it's closeable under our current rules (if it does, "unclear" would be the only reasonable choice; because the challenge doesn't explain how it works for languages that don't have a Boolean-equivalent, such as Prolog, Incident, and Three Star Programmer). That said, it might be worth a meta post about what we should do with extremely-trivial-in-practical-language challenges like this.

Why full programs only?

Brainfuck, 10 bytes: ,[[-]+>]<.

Japt, 3 2 bytes
o

Needs the -d flag.
Try it online!

Beat me to it; I've really gotta get my brain thinking in Japt over JS 'round here!

Also o with the -d flag would work. Though it would still be 3 bytes.

@powelles, for some reason flags only count as 1 byte.

Brain-Flak, 14 bytes
({()(<()>)}<>)

Try it online!
Explanation
(        #Set up a push
 {       #Execute if truthy
  ()     #Create 1 value
  (<()>) #Ensure a 0 to exit the loop
 }
 <>      #Switch stacks
)        #Push the value

Convex, 2 bytes
!!

Try it online!

RProgN 2, 2 bytes
¬¬

Try it online!

RProgN, 1 char, 3 bytes
‼

Added this because I've never really gotten a use for the truthy function, and I wanted to.
Try it online!

It's a full program too, right?

Of course. You can see that functionality at the TIO.

Jelly,  4  2 bytes
ṆṆ

Full program returning 1 for Truthy and 0 for Falsy.
Try it online!
How?
ṆṆ - Main link: x
Ṇ  - non-vectorising logical not
 Ṇ - non-vectorising logical not

Python 2, 28 27 bytes
print(input()and 1>0or 0>1)

Less trivial than just print(bool(input())). String input must be given in quotes as per Python 2 requirements.
-1 byte thanks to ovs

print(input()and 1>0or 0>1) for 27 bytes

Wouldn't print(input()!=0) work as well?

@Mr.Xcoder thus would give a false positive for []

@ovs ooo, nice, thanks!

JavaScript (ES6), 6 bytes
i=>!!i

OP wants a full program, not a funciton.

alert(!!prompt()) is more valid.

@Stephen, OP is wrong!


text:
Convert a CSS selector to HTML
A CSS selector is made up of five elements:

The element type (tag name)
The id of the element
The classes of the element
The attributes of the element
Operators to chain these element selectors

This challenge will only involve the first four--also taking into account operators would make more than one element be generated and that's a bit too complex for this challenge. Maybe a future one. ;)
Input: A CSS selector, not including any operators. The element type will always be present, but the rest of the portions may not be.
Output: An html element representing the selector.
Examples:
In: div
Out:

In: div[with-data="cool-data"][foo]
Out:

In: span.nice.tidy.cool
Out:

In: button#great-button.fancy[data-effect="greatness"]
Out: <button id="great-button" class="fancy" data-effect="greatness"></button>

In: custom-element#secret[secret-attribute="secret value!!"]
Out: <custom-element id="secret" secret-attribute="secret value!!"></custom-element>

In: element#id.class1.class2[attribute1][foo="bar"]
Out: <element id="id" class="class1 class2" attribute1 foo="bar"></element>

You may assume that the input selector will always have the different parts in order (element type, id, class, attributes).
You may assume that the provided attribute selectors will never be an attribute text search (^=, $=, *=).
You may assume that the input word characters (element type, attribute names, class names, ids) will always match the regex [a-z0-9_-]
You may have extra whitespace anywhere except for inside strings (attribute values)

This is code-golf, so the shortest answer (in bytes) wins. Standard loop-holes apply.

Are spaces valid input in the selector? I.e., div div.test =>

No, I would count that as an operator. Would also make the challenge much harder. Maybe for a follow-up challenge ;)

Can we aasume that the elements willonly be lowercase letters, digits, or '-'-?

Yes, you may assume that.

I think ids and classes are attributes of HTML elements, right?

In the output are multiple separating spaces allowed? e.g. ...id="id"[space 3 times]class="class"...

@IvankaTodorova yes, they are, technically. # and . are just another syntax for them

@GáborFekete Yes, that's fine

Can we assume that if the selector contains a class, it must also contain an id and that if it contains an attribute, it must also contain a class? If not, could you add another test case or 2 to cover that?

I added the new cases, thanks for the suggestion @Shaggy

Second example's with-data attribute shouldn't be with=data in the output.

All of the parts 1-4 are optional in CSS including #1, the element tag. So #info.sorted is a valid CSS descriptor, but the element name is not present. Your test cases don't cover this. Are we to assume some default element type in this case? Maybe div? Or maybe we can assume the element name will always be present for this challenge?

The element name will always be present in this challenge, for simplicity.

You can have extra whitespace anywhere except for inside attribute values. @ovs

What about elements that explicitly don't have a closing tag, like input?

You can ignore their existence. Would overcomplicate the challenge.

PHP, 125 119 bytes
<?=preg_replace(['/#([\w-]+)/','/\.([^[]+)/','/[.[\]]/','/(\S+).*/'],[' id="$1"',' class="$1"',' ','<$1></$1>'],$argn);

Just regex replacements.

Saved 6 bytes thanks to Christoph.

How does this work for the last test case?

@Neil It works good Try it online!

Aha, I see what it's doing now. (All those \s were confusing me.)

<?=preg_replace(['/#([\w-]+)/','/\.([^\[]+)/','/[.\[\]]/','/(\S+).*/'],[' id="$1"',' class="$1"',' ','<$0></$1>'],$argn); should work.

It seems we don't need to escape [ within []: <?=preg_replace(['/#([\w-]+)/','/\.([^[]+)/','/[.[\]]/','/(\S+).*/'],[' id="$1"',' class="$1"',' ','<$0></$1>'],$argn); another 2 bytes.

I don't know what happens here but <?=preg_replace(['/#([\w-]+)/','/\.([^[]+)/','/[.[\]]/','/(\S+).*/'],[' id="$1"',' class="$1"',' ','<$1></$1>'],$argn); is actually only 119 bytes and my first tip was only 121 bytes (we remove $2(): 4 bytes). Somehow some unprinted chars seem to get counted when copying from the comment.

Retina, 88 76 67 bytes
#([\w-]+)
 id="$1"
\.([^[]+)
 class="$1"
T`[].`
^(\w+).*
<$&></$1>

Try it online!
-10 bytes thanks to @Neil
-2 bytes thanks to @KritixiLithos

Your result is wrong, it should be class="class1 class-2".

@Neil fixed it.

That last $1$2 can be $&; your class check contains unnecessary ()s; also I think you can optimise some of those single-character replacements into a single T operation. (If not, ] doesn't need to be quoted.)

^(\w+)(.*) can become ^(\w+).* because the second capturing group is not needed

^(\w+).* can become (\S+).* (credits to @user63956).

JavaScript (ES6), 193 bytes
s=>[[/#([\w-]+)/,` id="$1"`],[/((\.[\w-]+)+)/,(_,c)=>` class="${c.split`.`.join` `.trim()}"`],[/(\[.+?\])/g,(_,a)=>" "+a.slice(1,-1)],[/([\S]+)(.*)/,"<$1$2></$1>"]].map(r=>s=s.replace(...r))[3]

Longer than most since I preferred to output the HTML with all proper whitespace. Also works with the selector parts out of order (div[attr].class#id).
Test Snippet

f=
s=>[[/#([\w-]+)/,` id="$1"`],[/((\.[\w-]+)+)/,(_,c)=>` class="${c.split`.`.join` `.trim()}"`],[/(\[.+?\])/g,(_,a)=>" "+a.slice(1,-1)],[/([\S]+)(.*)/,"<$1$2></$1>"]].map(r=>s=s.replace(...r))[3]

;["","div",'div[with-data="cool-data"][foo]',"span.nice.tidy.cool",'button#great-button.fancy[data-effect="greatness"]','custom-element#secret[secret-attribute="secret value!!"]','element#id.class1.class2[attribute1][foo="bar"]'].forEach(s => S.innerHTML += `<option>${s}</option>`);

Test Cases: <select id="S" onchange="I.value=this.value,I.oninput()"></select>

<input id="I" oninput="O.innerText=f(this.value)" size="75">

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Abbreviate that US state!
Given one of the 50 U.S. state names on the left as input, output its two-letter postal code as shown to the right:
Alabama         AL
Alaska          AK
Arizona         AZ
Arkansas        AR
California      CA
Colorado        CO
Connecticut     CT
Delaware        DE
Florida         FL
Georgia         GA
Hawaii          HI
Idaho           ID
Illinois        IL
Indiana         IN
Iowa            IA
Kansas          KS
Kentucky        KY
Louisiana       LA
Maine           ME
Maryland        MD
Massachusetts   MA
Michigan        MI
Minnesota       MN
Mississippi     MS
Missouri        MO
Montana         MT
Nebraska        NE
Nevada          NV
New Hampshire   NH
New Jersey      NJ
New Mexico      NM
New York        NY
North Carolina  NC
North Dakota    ND
Ohio            OH
Oklahoma        OK
Oregon          OR
Pennsylvania    PA
Rhode Island    RI
South Carolina  SC
South Dakota    SD
Tennessee       TN
Texas           TX
Utah            UT
Vermont         VT
Virginia        VA
Washington      WA
West Virginia   WV
Wisconsin       WI
Wyoming         WY

Rules

Input and output are both case sensitive. You many not output e.g. Al for Alabama.
You may assume the input is one of the 50 state names shown above.
You may not access the internet or use built-in state data (looking at you, Mathematica).

Separate lists of inputs and outputs can be found in this snippet (please don't run it, it's just for compressing the post):

Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming

AL
AK
AZ
AR
CA
CO
CT
DE
FL
GA
HI
ID
IL
IN
IA
KS
KY
LA
ME
MD
MA
MI
MN
MS
MO
MT
NE
NV
NH
NJ
NM
NY
NC
ND
OH
OK
OR
PA
RI
SC
SD
TN
TX
UT
VT
VA
WA
WV
WI
WY

(Non-scoring) Brownie points if you can also take District of Columbia as input and produce DC, Virgin Islands, etc etc.
Scoring
This is code-golf, so the shortest code in bytes in each language wins.
(Originally proposed by ETHProductions)

Related (another challenge about US states)

For those curious to know Mathematica's approach: Entity[a="AdministrativeDivision",{#,"UnitedStates"}]@EntityProperty[a,"StateAbbreviation"]&

@BetaDecay Questions that are closed as off-topic are not useful dupe targets.

@DavidC You can save 20 bytes: Entity["AdministrativeDivision",{#,"UnitedStates"}]@"StateAbbreviation"& :)

How is this a Kolmogorov complexity question? I thought this tag is for constant output

@ngenisis,  nice shortcut (that I was not aware of)!

Would've been more interesting if you had included territories and federate states. ;)

@FelixDombek It's more about efficiently generating a set of data, even if not all of it is output.

@FelixDombek https://codegolf.meta.stackexchange.com/a/9909/45941

Offer extra credit for including the other 12 two-character codes in the complete official list of US postal abbreviations:  AA (ARMED FORCES AMERICAS), AE (ARMED FORCES EUROPE), AP (ARMED FORCES PACIFIC), AS (AMERICAN SAMOA), DC (DISTRICT OF COLUMBIA), FM (FEDERATED STATES OF MICRONESIA), GU (GUAM), MH (MARSHALL ISLANDS), MP (NORTHERN MARIANA ISLANDS), PR (PUERTO RICO), PW (PALAU), VI (VIRGIN ISLANDS).

Also, this is a code-golf, while the proposed duplicate was a pop-con

Yeah this is not a dupe.

Also the question listed as a dupe is closed as off topic where this one clearly isn't off topic.

Heh, I only just noticed that someone actually closed this as a dupe. FFS.

@joesnyder I've made clearer in the challenge that non-scoring Brownie points are available for all of those extensions. It says in the guidelines somewhere that bonus points are generally discouraged. Also this isn't my challenge. Also, I prefer this tighter challenge.

Javascript (2023), 88 bytes
This is originally based on HP Williams solution, with some improvements outside the regex, and a couple of tweaks within it, plus a couple of bytes from Primo and Emanresu.
s=>s[0]+s.match`.+ .|.+z|...s.s?|T..|M[i-t]+|[AFINOUW][^o]v?|.+`[0].at(-1).toUpperCase()

It matches a chunk at the start of the name, then returns the capitalised last letter of that chunk appended to the first letter of the name.
Commentary for the regex:
.+ .           // Two word states (NJ, NM, NH, NY, WV, ND, SD, RI,NC,SC)
.+z            // AriZona
...s.s?        // MissiSsippi, MissOuri, MassAchussetts, AlasKa, and KansaS
M[i-t]+        // MonTana, MinNesota, MIchigan
[AFINOUW][^o]v?  // All the other first-two-letter states, avoiding Iowa/Connecticut/Louisiana, plus NeVada
T..            // TeNnessee, TeXas
.+             // Everything else

Alternative regex's (same length):
...(a$|z|s.s?|.* .)|M[i-t]+|T..|[AFINOUW].v?|.*
.*( .|z)|...s.s?|Te.|M[i-t]+|[^GHKMPVo]{2}v?|.*
.*( .|z)|...s.s?|M[i-t]+|[^GHKMPVo]{2}[vnx]?|.*
.+ .|...s.s?|[MNTe]+[i-z]+|.+z|[AFINOUWow]+.|.+
.+( .|z)|...s.s?|[MNT]e?[i-x]+|[AFINOUWow]+.|.+

History
With linebreaks for readability:
90
s=>s[0]+
  /.$/.exec(s.toUpperCase()
    .match`.* .|.*Z|...S.S?|T..|M[I-T]+|[AFINOUW][^O]V?|.*`
  )

92
s=>s[0]+
/.*( .|z)|...s.s?|T..|M[i-t]+|[AFINOUW][^o]v?|.*/
.exec(s)[0].slice(-1).toUpperCase()

94
s=>s[0]+/.*( .|z)|...s.s?|M[io]n?t?|[AFIOUWN][^o]v?|T..|.*/
.exec(s)[0].slice(-1).toUpperCase()

99
s=>s[0]+/.*( .|z|l.*k)|T..|M.ss.s?|M[io]n?t?|[AFIOUWN][^o]v?|.*/
.exec(s)[0].slice(-1).toUpperCase()

101
s=>s[0]+/.+[A-Zz]|Nev?|.*sk|M.ss.s?|M[io]n?t?|[AFIOUW][^o]|Te.|.+/
.exec(s)[0].slice(-1).toUpperCase()

108
 s=>s[0]+/MI(N|SSO|S)|[CDGHKLPV].*|.* .|.*[XZV]|.*?N[NTE]|.*(SK|D$|WA)|../
.exec(s.toUpperCase())[0].slice(-1)

110
s=>s[0]+/MI(N|SSO|S)|[CGHKLPV].*|.* .|.*[XZV]|.*?N[NTE]|.*(SK|[ED]$|WA)|../
.exec(s.toUpperCase())[0].slice(-1)

113
s=>s[0]+/^MI(N|SSO|S)|^[CGHKLPV].*|.*?( .|[XZV])|.*?N[NTE]|.*(SK|[ED]$|WA)|../
.exec(s.toUpperCase())[0].slice(-1)

132
s=>(S=s.toUpperCase(),' ._SSO_^MI[NS]_^[CGHKLPV].*_.V_N[TNE]_SK_[ED]$_WA_Z_X_..'
.split`_`.some(p=>s=S.match(p)),S[0]+s[0].slice(-1))

134
s=>' ._SSO_^MI[NS]_^[CGHKLPV].*_.V_N[TNE]_SK_E$_D$_WA_Z_X_..'.split`_`
.map(p=>s=(z=s.toUpperCase().match(p))?s[0]+z[0].slice(-1):s)&&s

135
s=>' ._SSO_^MI[NS]_LASK_^[CGHKLPV].*_NT_EN_[DE]$_WA_.[XVZ]_..'.split`_`
.map(p=>s=(z=s.toUpperCase().match(p))?s[0]+z[0].slice(-1):s)&&s

137
s=>' ._OWA_SSO_ONT_^MI[NS]_LASK_^[CGHKLPV].*_EN_[DE]$_.[XVZ]_..'.split`_`.
map(p=>s=(z=s.toUpperCase().match(p))?s[0]+z[0].slice(-1):s)&&s

This is just insane, I wish I could upvote again.

Don't look now! 99!

Totally crazy. I discovered this optimisation (...s.s? captures Mississippi, Missouri, Massachussetts and Alaska) by accident. I was actually in the process of moving the .*sk fragment to somewhere else, and the tests just happen to ran and passed, while the fragment wasn't present anywhere. Easiest 5 character gain ever!

Wow, and I just realised that ...s.s? is also inadvertently matching Kansas, and is, by miracle, still giving the right result.

And one more character with M[onti]+. So weird: if the state starts with M, then the second letter is the last in a sequence of at least one o, n, t, or i. A very weird way to capture Michican, Minnesota, or Montana.

One more! M[i-t]+

Doesn't help, but just noticed that [^GHKMPV] is the same length as [AFINOUW]

Slightly better golf (same regex): s=>s[0]+/.$/.exec(s.toUpperCase().match`.* .|.*Z|...S.S?|T..|M[I-T]+|[AFINOUW][^O]V?|.*`)

Awesome, thanks - it's been so long since I've managed to shave anything off it, not for want of trying.

I do not understand your commentary. You wrote that .+ means everything else is first-and-last. However, I was taught that .+ means one or more of any letter or symbol. The dot . signifies any one letter or symbol. The plus sign + signifies one or more of the proceeding token.

Your description of regular expressions makes no sense to me. ( .|z) means somthing close to choose one of the following two options: (1 a space followed by any letter or symbol) (2 exactly one instance of the letter z). If we break it down into pieces, . signifies one instance of any letter, | is like the English word "or", and the letter z simply represents the letter z. Your description of regular expressions makes no sense to me.

@SteveBennett You wrote that T.. matches Tennessee and Texas. However, the regular expression T.. does not match Tennessee or Texas. T.. means T followed by any two letters. For example, T.. matches TOE and TIP and TAB.

All of those segments of the regex are matching some portion of a state name. In the case of Texas and Tennessee, T.. matches either Tex or Ten. The rest of the code then takes the first and last letters of that fragment (Tx or Tn) and uppper cases it to TX or TN.

@SamuelMuldoon I suggest you use a tool like regex101.com to better understand what the regex is doing in this case.

If you're still interested in golfing this <...>.at(-1) is shorter than /.$/.exec(<...>).

Amazing! I had not come across that function before. Very useful for normal coding even - better than .slice(x)[0] In this case it just saves 2 bytes because .exec() was implicitly casting an array to a string, which we have to do explicitly now.

Javascript, 124 117 bytes
(saved 7 bytes thanks to hvd)
x=>/.+[A-Z]|A..[sz]k?|M.ss.s?|M[io]n?t?|Nev?|[AFIOUW][^o]|T..|.+/.exec(x)[0].replace(/(.).*(.)/,'$1$2').toUpperCase()

Explanation:

The regexp finds a match with the first and last letters the two letters of the abbreviation
First part matches states with more than two words (including District of Columbia)
Second part matches Alaska and Arizona
Third part matches Massachusets, Mississippi and Missouri
Fourth part matches Michigan, Minnesota and Montana
Fifth part matches Nebraska and Nevada
Sixth part matches all remaining states abbreviated to their first two letters, with a special case to exclude Iowa
Seventh part matches all remaining states abbreviated to their first and third letters
Eighth part matches everything else, which are abbreviated to their first and last letters
Then it is just a case of stripping of those letters and capitalising
Also matches Puerto Rico and American Samoa, but not Guam, Marianas islands or US Virgin Islands

Wow, this is great! +1!

Nice! Some more opportunities: the initial [A-Z] is not necessary since the input is known to be valid. The Iowa special case can be shortened to [AFIOUW][^o] to exclude it, leaving it for the final .+.

Your regex machinery is so efficient compared to mine...wish there was a way to make it work with my shorter regex. But they're constructed on such different principles.

@SteveBennett interesting that you had Missouri as the oddball, whereas I had trouble with Montana.

Well there are quite a few that are weird in their own ways. There's a nice collection that match both the "first and last" and "first two" rules (Colorado, Delaware, California...), but then Mississippi (MS) ruins it.

I think you missed something in your last edit; the regex is currently not valid (the + at the beginning throws an error).

Yeah, it should be .+ at the start of the regex. I think you did have that when testing, since your byte count is right for that.

Mine is down to 113, with the help of your idea of using regex conditionals instead of looping.

Mine is down to 108, but if you use slice instead of replace in yours, yours becomes 105: f=s=>s[0]+/.+[A-Z]|A..[sz]k?|M.ss.s?|M[io]n?t?|Nev?|[AFIOUW][^o]|T..|.+/.exec(s)[0].slice(-1).toUpperCase()

Oh look, I golfed you down to 102: s=>s[0]+/.+[A-Zz]|Alask|M.ss.s?|M[io]n?t?|Nev?|[AFIOUW][^o]|Te.|.+/.exec(s)[0].slice(-1).toUpperCase()

101: s=>s[0]+/.+[A-Zz]|Nev?|.*sk|M.ss.s?|M[io]n?t?|[AFIOUW][^o]|Te.|.+/.exec(s)[0].slice(-1).toUpperCase() Can we get to 100? :)

Whoa, now down to 94. See my answer.

JavaScript (ES6), 156 136 bytes
s=>s[0]+'.KT..N.VEA.XVL.H.TZ.AA..I.EADATO.JTISRDIYOI.DALA.Y.KE.C.D.R.YAS.NM...C.L...N'[parseInt(s.split` `.join``,36)%359%248*8%99*3%83]

Demo

let f =

s=>s[0]+'.KT..N.VEA.XVL.H.TZ.AA..I.EADATO.JTISRDIYOI.DALA.Y.KE.C.D.R.YAS.NM...C.L...N'[parseInt(s.split` `.join``,36)%359%248*8%99*3%83]

;[
  "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho",
  "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi",
  "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
  "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia",
  "Washington", "West Virginia", "Wisconsin", "Wyoming"
]
.map(s => console.log(s, '-->', f(s)))

Is this bruteforced to be optimal using this method?

@ASCII-only This is bruteforced on arbitral ranges, so it's only guaranteed to be optimal for X MOD[50-1000] MOD[50-1000] MOD[50-100]. But the .slice(1) was a mistake. Currently running again on the whole string.

Could you explain to a newb what this does?

@Hankrecords Sure, will do. (But I'm in a train with limited Internet access right now.)

Damn, my hand-crafted solution is one byte longer :/

now mine is 135!

I found an alternative 76 bytes search string with less modulo operations

@Hankrecords This one has become more complex than I wanted it to be. You may want to have a look at this one, which is using the same principle (a hash function generating an index into a lookup table) but with a simpler formula and a simpler dataset. Does that make sense?

Jelly, 75 bytes
³Oḅ⁹%⁽qġ%14ị⁽"wB¤Ḥ
“¿ØƈṢḍw÷S=)µZṂ÷ĿæÆɱ»Ḳiµ%2+3¢⁸?
e“\B“½ƈN»ȧ5ȯÇ’
i⁶ȯÇ‘ịṭḢŒu

Try it online!
...or see a test suite - Note a small change had to be made to run the full program for multiple inputs in one go (I swapped out the program input atom, ³, for a recall from register, ®, one and set the register to each state name in turn).
How?
Calculates the index to use for the second character of the postal code, appends it to the first character and uppercases the result.
First finds the index of a space character (or 0 if not found);
Else checks if it is Alaska or Missouri (yielding 5 for k or o);
Else finds the index of the input state in the list Arizona Minnesota Mississippi Nevada Montana Texas Tennessee (or 0 if not found) - if so it takes that index mod 2 plus 3 (for z n s v t x n);
Else converts the string to ordinals, converts that from base 256, finds the remainder of that after dividing by 29487, finds the remainder of that after dividing by 14 and uses that to index into the binary representation of 9620 and doubles the result - yielding 0 for states that use their final letter and 2 for those that use their second letter.
All but the very first case are incremented, and the resulting value is decremented (upping the space index found by one).
i⁶ȯÇ‘ịṭḢŒu - Main link: state string
 ⁶         - space character
i          - first index (of a space character in the state) or 0 if not found  (n-1 or 0)
   Ç       - call link 3 as a monad  (get n-1 in other cases)
  ȯ        - logical or  (yielding n-1)
    ‘      - increment   (yielding n)
     ị     - index into the state string (get the nth character)
       Ḣ   - head the state string (get the first character)
      ṭ    - tack
        Œu - convert to uppercase
           - implicit print

e“\B“½ƈN»ȧ5ȯÇ’ - Link 3: n-5 or ... : state string
 “\B“½ƈN»      - ["Alaska","Missouri"]
e              - exists in? (1 if so, 0 if not)
          5    - 5
         ȧ     - logical and
            Ç  - call link 2 as a monad
           ȯ   - logical or
             ’ - decrement

“¿ØƈṢḍw÷S=)µZṂ÷ĿæÆɱ»Ḳiµ%2+3¢⁸? - Link 2: n = 3 or n = 4 or ... : state string
“¿ØƈṢḍw÷S=)µZṂ÷ĿæÆɱ»           - "Arizona Minnesota Mississippi Nevada Montana Texas Tennessee"
                    Ḳ          - split at spaces
                     i         - first index of state string in that list or 0
                      µ        - monadic chain separation (call that i)
                             ? - if:
                            ⁸  -   link's left argument, i
                               - then:
                       %2      -   mod 2
                         +3    -   plus 3  - odd entries to 4: AriZona, MisSissippi, MonTana, TenNessee
                               -            even entries to 3: MiNnesota, NeVada, TeXas
                               - else:
                           ¢   -   call link 1 as a nilad

³Oḅ⁹%⁽qġ%14ị⁽"wB¤Ḥ - Link 1 ...n=2 or n=0: no arguments
³                  - program's 1st input    e.g. Iowa          or Ohio
 O                 - cast to ordinals            [73,111,119,97]  [79, 104, 105, 111]
   ⁹               - 256
  ḅ                - convert from base           1232041825       1332242799
     ⁽qġ           - 29487
    %              - modulo                      15991            20139
        %14        - modulo 14                   3                7
                ¤  - nilad followed by link(s) as a nilad:
            ⁽"w    -   9620                     V       V
               B   -   convert to binary = [1,0,0,1,0,1,1,0,0,1,0,1,0,0]
           ị       - index into                  0                1
                 Ḥ - double                      0                2
                   -   ...0th index of Iowa is 'a', 2nd of Ohio is 'h'

This is the longest Jelly I've ever seen =)

Python 2, 94 90 bytes
lambda s:s[0]+s[(19**9*0x4710b8f6019c1b61deca10eef13b1>>hash(s)%8199472%52*3&7)+1].upper()

Try it online
(Only Python 2 because Python 3 hashes are not stable and also you can't hash a string without turning it into bytes.)
Works with all 50 states, plus as a bonus District of Columbia and Puerto Rico.
It would be possible to save one byte by writing the number in base-36: int("5clu7x0aixb0pelmpugv5iiibphrpf",36). I'm waiting to see if I can think of a more creative solution.
Update:
Since there are 12 unused digit positions in the hash, there are 236 possible numbers which will work. It seemed reasonable to believe that one of them would have a prime factor with a large exponent. For any given prime and exponent, finding a value is quite fast; I managed to find one with a factor of 199, reducing the size of the expression needed to represent the number by four bytes.
This is basically the same procedure as my C answer but using Python. Since the base hash function is different, I had to find a different reduction function, which turns out to be mod 52 instead of mod 54. But the biggest savings over C come from the possibility of using bignums to encode the vector, and of course the fact that the standard for Python seems to be that it's ok to use a lambda literal instead of a complete program.

Python 2, 191 bytes
lambda s:s[0]+("KZD"*5+"HNTD"*5+"AYY"*4+"__L_O_VTA_I__A_T_RS_KA__S_"+"MOO"*5+"I_C_"+"AE"*6+"_I_D__A_"+"EDL"*5+"HV_A"+"IR"*7+"XC"*6+"E____N__YJ_YT___L")[reduce(lambda a,x:a+ord(x)^24,s,0)%174]

Try it online!
Uses a simple hash function to find the second character of the abbreviation.

Retina, 113 81 80 77 70 68 bytes
M1!`.+[A-Zz]|...s.s?|M[io]n?t?|[AFIOUWN][^o]v?|T..|.*
\B.*(?=.)

T`l`L

Try it online! Includes all 51 test cases. Saved 32 bytes by appropriating @JörgHülsermann's regex that finds the second letter (with a tweak to support DC; edit: saved 1 byte thanks to @JörgHülsermann). Saved 3 bytes by switching to @SteveBennett's regex from his comment to @HPWilliam's answer. Saved 7 9 bytes thanks again to @SteveBennett. The other letters are then deleted and the string uppercased.

Very nice, wouldn't have thought you could get a set of fully removable strings.

@ConnorLSW e was the most troublesome, really.

@JörgHülsermann Thanks for the return favour!

@JörgHülsermann Oh, so I'll be able to save another byte then?

Wow, nice. I'm certainly learning a lot about regexes :) It's still counterintuitive to me to have the [v] before the [P], and yet Pennsylvania handles correctly. And looking at it, I'm confused that Indiana doesn't become ID.

Wait, Indiana does become ID. You can probably fix it just by adding $ after the d. (You might want to use automatic testing - I have a script that constantly checks all 50 cases.)

@SteveBennett Oops. JörgHülsermann has since rolled back his edit too. Meanwhile it turns out that I accidentally counted two invisible characters that Stack Exchange inserted into your comment to HPWilliam's answer, so now represents a correct 3-byte saving!

You can save more bytes by using my newer ridiculous 51 character regex. /.+[A-Zz]|...s.s?|M[io]n?t?|[AFIOUWN][^o]v?|T..|.*/

@SteveBennett Impressive!

Shaved 4 more characters off! .*( .|z)|...s.s?|T..|M[i-t]+|[AFINOUW][^o]v?|.*

@SteveBennett I see M[i-t]+ saves 2 bytes but I don't see anything else saved...

Sorry, miscounted.

PHP>=7.1, 113 Bytes
<?=($a=$argn)[0],ucfirst(preg_match('#[vxz]| .|owa|lask|[CGHKLPV].*|ssi?.|n(n|t|[de]$)#',$a,$t)?$t[0][-1]:$a[1]);

Online Version
The strikes are match through a earlier beginning match before
([vxz]) matches
Arizona, Nevada, New Mexico, Pennsylvania, Texas,
(.) (one space before) matches New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Rhode Island, South Carolina, South Dakota, West Virginia
[CGHKLPV].*(.) matches California, Colorado, Connecticut, Georgia, Hawaii, Kansas, Kentucky, Louisiana, New Hampshire, North Carolina, Pennsylvania, South Carolina, Vermont, Virginia, West Virginia
ow(a) match Iowa
las(k) match Alaska
ssi?(.) matches Massachusetts, Mississippi, Missouri, Tennessee
n(n|t|[de]$) matches Connecticut, Kentucky, Maine, Maryland, Minnesota, Montana, Pennsylvania, Rhode Island, Tennessee, Vermont
No match for these states so we take the first two letters
Alabama, Arkansas, Delaware, Florida, Idaho, Illinois, Indiana, Michigan, Nebraska, Ohio, Oklahoma, Oregon, Utah, Washington, Wisconsin, Wyoming
First time that I am use this Regex Subpatter ?| with allows to store the backreferences in one.
Support the District of Columbia
Replace (.) with ([^o]) +3 Bytes
Try it online!
PHP, 150 Bytes
<?=($t=preg_replace("#.\K\w+ |las|ri|nec|eorgi|awa|ow|[aio]ni?|e(?=n|v|x)|ntuck|ouisi|a?in|arylan|issi?|nnsylv|erm|irg#","",$argn))[0],ucfirst($t[1]);

Try it online! Testcases

Isn't n|t| a byte shorter than [nt]|?

C, 148 141 bytes
main(){char s[99];gets(s);printf("%c%c\n",*s,s["-2-1--561-1-62--642138364---4142--1416--67-7131-111-7-246"[*(int*)(s+1)%663694%57]-48]&95);}

*(int*)(s+1) considers the second through fifth character of the input to be an integer; that integer is then hashed into 0-56 using the hash i%663694%57. The hashed value is then looked up in a vector of offsets which represent the location of the second letter of the abbreviation. I chose those particular four bytes because (1) Missouri and Mississippi first differ in the fifth character and (2) some states have only four characters In C you can use the the NUL terminator byte, but nothing beyond that is reliable. (This hashes both Norths to the same value, as well as both Souths. But that doesn't matter because the associated offset is 6 for all of these.)
As it happens, that particular hash yields the correct position for the second letters of the abbreviations of District of Columbia, Puerto Rico and "Virgin Islands" (typed that way, not as "US Virgin Islands", because the algorithm insists that the first character of the abbreviation be the first character of the name).
The constants 663694 and 57 were found with an automated test; 57 was the smallest hash range I found. (The first version used 380085 and 63, but when I extended the test range I found the new one.) It seems that a slightly smaller hash exists if a code is added for "use the last character in the name"; unfortunately, C syntax for selecting the last character is too wordy to make that helpful.
There are only 8 different offsets, so they could have been stored in a 171-bit (3*57) lookup table with three bits per entry. But I couldn't think of a way to insert those bits efficiently into the program. Hex-encoding would require about one character per four bits, plus the 0x prefixes. I couldn't do better than 151 bytes, which is much longer than the string version. If the 171 bits could somehow be inserted as raw octets, they would occupy 22 bytes, so there might be a solution, but reading a file is clunky.

C, 945 937 718 711 660 616 bytes
Saved 219 bytes thanks to ASCII-only.
struct{int*a,b;}m[]={"laba",76,"lask",75,"rizo",90,"rkan",82,"alif",65,"olor",79,"onne",84,"elaw",69,"lori",76,"eorg",65,"awai",73,"daho",68,"llin",76,"ndia",78,"owa",65,"ansa",83,"entu",89,"ouis",65,"aine",69,"aryl",68,"assa",65,"ichi",73,"inne",78,"issi",83,"isso",79,"onta",84,"ebra",69,"evad",86,"ew H",72,"ew J",74,"ew M",77,"ew Y",89,"orth",67,"orth",68,"hio",72,"klah",75,"rego",82,"enns",65,"hode",73,"outh",67,"outh",68,"enne",78,"exas",88,"tah",84,"ermo",84,"irgi",65,"ashi",65,"est ",86,"isco",73,"yomi",89};
i;char b[99];main(){gets(b);putchar(*b);for(;m[i].a;i++)if(!strncmp(m[i].a,b+1,4))puts(&m[i].b);}

Newline unnecessary, only for display purposes. Takes the state as input. Try it online!
How it works:

struct{int*a,b;}m[]=... declares a map m with two values - a four-byte string and one character. This is used in the comparison loop, which compares the second through fifth indexes with char*a in the map.
gets(b) reads a string b. This will be the state to abbreviate.
putchar(*b) prints the first character of that string, since each abbreviation starts with the first letter of the state.
for(;m[i].a;i++) loops through each value of the map. (This might be able to be shortened.)
if(!strncmp(m[i].a,b+1,4)) compares the current map value to the second through fifth characters of b (the state to abbreviate). This is because the only differences are in the first five characters, but we've already printed the first character.
puts(&m[i].b); prints the second letter of the abbreviation (if the state name matches with the current map value), and a newline.

This seems to produce wrong output for the North*/South* states.

PHP, 887 854 bytes
<?=array_combine(['Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming'],['AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY'])[$argv[1]];

Try it online!
First timer, hooray!

This way a little golfed  In the Array are the values with space or where the second letter is correct removed. And $argv[1] is replaced with $argn http://sandbox.onlinephpfunctions.com/code/cbc4cb03939742a6541dabc042ba2e0cb808356f

@JörgHülsermann thanks a lot! I really enjoy your answers here on codegolf in php!

I am only a little light against other people here. The learning effort is good if someone finds an improvement. I hope that you answer more questions in the future

Python 3, 230 bytes
lambda s:chr(s[0])+'IA%%L!NOI!M%!E.N!Y.XR.Z$D.I!.D$DA.D%!.HA!LJ%.N%$T.I%!C!T!.HAAT$.A!.VL.V%$CE%%AEK%.T$!.Y.A!.R.Y$O.S%!.K$!.S'.replace('%','$$').replace('$','!!').replace('!','..')[sum(c*5**i for i,c in enumerate(s[::-1]))%236-5]

Try it online!
Input is expected as a bytes object (a byte string, rather than a Unicode string).
Thanks to Johnathon Allan for an absurd amount of bytes
Explanation
Each state name is hashed to an integer a by applying the hash a = sum(o*5**i) % 236 (where o is a character's ASCII ordinal and i is its index in the string, counting back from the end). The modulus 236 was chosen because it is the smallest modulus that causes all hash values to be distinct for the 50 US state names. These hashes are then mapped to the state abbreviations, and the resulting dictionary (compressed using string substitution) is used to look up the abbreviation given a state name (hashing it to get the appropiate key).

Save 179 bytes with lambda s:chr(s[0])+'.....IA................L..NOI..M..........E.N..Y.XR.Z....D.I...D....DA.D...........HA..LJ.........N............T.I..........C..T...HAAT.....A...VL.V............CE................AEK.........T.......Y.A...R.Y....O.S...........K.......S'[sum(c*5**i for i,c in enumerate(s[::-1]))%236]

...and another 51 on top of that with lambda s:chr(s[0])+'IA%%L!NOI!M%!E.N!Y.XR.Z$D.I!.D$DA.D%!.HA!LJ%.N%$T.I%!C!T!.HAAT$.A!.VL.V%$CE%%AEK%.T$!.Y.A!.R.Y$O.S%!.K$!.S'.replace('%','$$').replace('$','!!').replace('!','..')[sum(c*5**i for i,c in enumerate(s[::-1]))%236-5]

I'm surprised that counting backwards costs fewer bytes than a hash function that counts forwards -- but I can't find one with a little playing

@ChrisH I thought I found one, but the compressed string is more expensive.

Actually, 181 bytes
2"OHCALAGAMAWVFLNVILMNMOMIRINCDEMTMEINWANYTXORNEOKIDAZNMUTNDMDVAKYSDPAARWYNHIAMSALNJAKTNHIKSVTWICOSCCT"╪"âäà♠îÉæô↨→←∟♣áíå*,▓/12│┤94▼╛?DE╞G╚╠╬ST╒WXßb;Θoq╙|⌂"♂┘Z⌠i≈┐⌡MXO;rR5♀ⁿ*:236@%└

This solution expects input as a quoted string.
Try it online!
Explanation
This solution utilizes the same hashing strategy as my Python 3 solution. For brevity, I am going to omit the explanation of how the hash is computed and why it was chosen (go read the other answer if you want that bit).
Also for brevity, I'm going to be leaving out the contents of the very long strings, since otherwise the explanation would be unreadable.
2"..."╪"..."♂┘Z⌠i≈┐⌡MXO;rR5♀ⁿ*:236@%└
2"..."╪                                state abbreviations (push the long string, split into length-2 chunks)
       "..."♂┘                         hash values for the state names (a string of CP437-encoded characters, converted to their CP437 ordinals)
              Z                        zip the two lists
               ⌠i≈┐⌡M                  for each pair:
                i                        flatten the pair
                 ≈                       convert hash value to int
                  ┐                      store abbreviation at the register numbered by the hash value
                     X                 discard the now-empty list
                      O                convert input string to list of ASCII ordinals
                       ;rR             range(len(ordinal_list)), reversed
                          5♀ⁿ          5**i mapped over that range
                             *         dot product of powers of 5 and ordinal list
                              :236@%   mod by 236
                                    └  push value in that register

Python 2, 131 125 bytes
lambda s:s[0]+'CLLKARADEZVAK.T..DETTH.NSAHY...ID.D..O..Y.IRE.X..NALINC.VJM.SY.T..AAOI'[int(s[0]+s[-2:],36)%386%334%181%98%70]

Try it online!
int(s[0]+s[-2:],36) generates a unique large number for each state by parsing the first and the two last characters as a base 36 integer.
%386%334%181%98%70 is a modulo chain generated by a search program that reduces the size of the numbers while not mapping two states with a different second character in the abbreviation to the same number.
These smaller numbers are then used to index into the string 'CL ... OI' to get the second character of the abbreviation.

Would you mind providing a bit of background in what this is doing? Very cool stuff btw

@teepee I've added a short breakdown of what this answer does. Note there is another (better) Python answer which extracts the second character of the abbreviation from the state name using similar methods.

thanks @ovs! I think the one thing I'm most curious about is the modulo chain generated by a search program. Can you point me to some information about how one can derive this chain? I think that's fascinating. Also, did you determine that the first char + last two chars was unique based on inspection, or is there an algorithm to determine that?

@teepee It's been a while since I created this answer, but I think I tried different combinations of substrings of the state name and verified with a program that this one was unique. To find this chain I used a very naïve program which just tries every number in a range as the first modulo, and for each number which did not result in any collision recursively repeats the process on the modified sets of integers. Here is a very basic and slow program that finds this exact chain.

Python 2, 152 bytes
lambda s:s[0]+'.NY.SDS...O.DT..RT.AAYJZE.K.I.X.TI.EL.CMI..E.NA..L....TH.......O....DAAC..VNH.YAI.RVDA..L....A'[int(s.replace(' ','')[1:],36)%358%235%95]

Try it online!
A port of Arnauld's answer.

Mathematica, 138 140 134 Bytes
+2 bytes - found a mistake (needed array offset of 1 not 0)
-6 bytes - found a better hash
#~StringTake~1<>"R_ATE__IN_COI_J_I_SLNAT_Y_Y_HKOAE__SAA_DDLM_RVAH_XDTVA__I_N_EA_T_DY_C_KZL"~StringTake~{1+Hash@#~Mod~89866736~Mod~73}&
Similar to others it takes the name and takes the first letter. Then it applies the default Mathematica hash then applies two modulus to it "Hash@#~Mod~89866736~Mod~73" to get a unique number for each state. This value is then looked up in a string to generate the second letter.
Can probably be golfed more but the search space is huge for Mathematica to find. Duplicated second letters weren't considered in the hash search. _ characters represent wasted values in the string. In theory you could get the string down to only 19 characters but finding the custom hash to produce that would be a nightmare.

///, 619 608 bytes
/2/~M//@/~South //1/~North //!/~New //~/\/\///Alabama/AL~Alaska/AK~Arizona/AZ~Arkansas/AR~California/CA~Connecticut/CT~Delaware/DE~Florida/FL~Georgia/GA~Hawaii/HI~Idaho/ID~Illinois/IL~Indiana/IN~Iowa/IA~Kansas/KS~Kentucky/KY~Louisiana/LA2aine/ME2aryland/MD2assachusetts/MA2ichigan/MI2innesota/MN2ississippi/MS2issouri/MO2ontana/MT~Nebraska/NE~Nevada/NV!Hampshire/NH!Jersey/NJ!Mexico/NM!York/NY1Carolina/NC1Dakota/ND~Ohio/OH~Oklahoma/OK~Oregon/OR~Pennsylvania/PA~Rhode Island/RI@Carolina/SC@Dakota/SD~Tennessee/TN~Texas/TX~Utah/UT~Vermont/VT~Virginia/VA~Washington/WA~West Virginia/WV~Wisconsin/WI~Wyoming/WY/

Try it online!
Since there is no other way of taking input in ///, it goes at the end of the program. Just append the desired input to the program.
Saved 11 bytes by making more replacements, as recommended by @SteveBennett

There's probably some patterns you can replace multiple times at once, like "New " and "akota". Annoying that you can't do much smarter like removing sections of state names, because converting the remaining character to uppercase is so expensive...

@SteveBennett Edited, thanks!

Ruby, 106 103 bytes
->s{s[0]+(s=~/ /?$'[0]:s[(j="()6>P_ac;?.O}AFLKMrS".index((s.sum%136%95+32).chr))?j>7?j/4:-1:1]).upcase}

If the input contains a space, the second output letter is the one after the space. Else...
Hash the sum of all characters in the input to obtain a character whose index in the magic string indicates the index of the second output letter in the input string, according to the formula j>8?j/4:-1 (-1 means the end.). If the hash gives a character that is not in the magic string, second letter is second letter of input.
As an explanation of the magic string, the hash characters and the letter indexes they encode are below. Note that Delaware appears even though the second letter would do - this is because its hash code clashes with Kentucky. Fortunately the last letter of Delaware is the same as the second.
Letter(index)
Last  (-1)  (-MD    )-VA    6-GA-LA  >-DE-KY    P-PA    _-CT    a-KS    c-VT
3rd    (2)  ;-TN    ?-MN    .-TX     O-NV
4th    (3)  }-MS    A-IA    F-MT     L-AZ
5th    (4)  K-MO    M-AK    r-ME     S-HI

Ungolfed in test program
a="Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming".split($/)

f=->s{                                                            #String argument s.
  s[0]+(                                                          #Return character s[0] +
    s=~/ /?$'[0]:                                                 #if s contains a space, 1st character after space, ELSE
      s[(j="()6>P_ac;?.O}AFLKMrS".index((s.sum%136%95+32).chr))?  #if (sum of ascii codes, mod 136 mod 95 +32).chr in the magic string
        j>7?j/4:-1:                                                 #return s[j/4] if j>7 else return s[-1] ELSE
      1]                                                          #if not in the magic string, return s[1].
  ).upcase                                                        #Convert the second character to uppercase if needed.
}

a.map{|i|p [i,f[i]]}

TAESGL, 386 bytes
B=«ōďā,AL,ņćđ,AK,ķċđ,AZ,ćōē,AR,ďċđ,CA,ĭāď,CO,ŕĭ,CT,ćđēą,DE,ĕŕ,FL,īĭ,GA,ńāē,HI,ćĉďą,ID,ĭċď,IL,ľđā,ţ,ńĕĕ,IA,ķő,KS,ŏĝ,KY,ŏĕĕ,LA,ŏđć,ME,ņāē,MD,ńđā,MA,īđą,MI,ļēď,MN,ŕğ,MS,ňė,MO,ććĕĉ,MT,ćċćĉ,NE,ŕēď,NV,ň ćŋā,NH,ň ĩēđ,NJ,ň ğĕċ,NM,ň ĉĝ,NY,ćņ ġĉă,NC,ćņ ńċą,ND,ĩēą,OH,ŋĺ,OK,ļķ,OR,ĺđď,PA,ĉĉğ đēā,RI,ōċ ġĉă,SC,ōċ ńċą,SD,ňďą,TN,ċĕď,TX,ōđą,UT,ćđāā,VT,ğğ,VA,ďĉē,WA,ĉĉć ğğ,WV,ľēđ,WI,ĉĩĕ,WY»Ĵ",";B[BĪA)+1

Interpreter
Very simple compression of the state names, added into an array with the abbreviations.

Japt, 383 bytes
The compression of the first string may be improvable by experimenting with the order of the letters.
g +`lkzÇUaidlnyaÀÍ¥evhjmycdhkÎödnxttaaviy`g`alabaµ
Ã2ka
iza
kÂ6s
Öâfnia
åªv
¬n×©
Ü.Ø
fÓQ»
gegia
°ii
i»
ÅJno
Äa
Å0
kÂ6s
kÀ_cky
lia
Úpe
æ¯À
ÚUaÖ³etts
Úòig
·nÌta
æ«7ppi
æ¬
Úa
ßka
va»
w mp¢i
w jÀ y
w ´xi¬
w yk
Íh ÖÚ¦na
Íh »kota
oo
oklaÊá
eg
pnsylvia
r¸ Ó
Ñh ÖÚ¦na
Ñh »kota
âÊte
x
©ah
vÚ
virgia
Øgn
ØÙ virgia
æÈ;n
wyÇg`·bUv) u

Try it online

Perl 5, 150 148 bytes (147 + 1)
This is by no means optimal, but it does its job. Needs -n command line flag.
s/las//;s/ai?n//;s/[oie]n|ri//;s/e([vx])/$1/;s/issi?//;s/(.).+ /\1/;/(.)(.)/;/^([^W]).*(?:[cogavn][wiku]|[ir][ys][li]|rm)([adyti])$/;print uc"$1$2"

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
My [sub] strings are hiding!
Introduction
A while ago a lost SO user posted a question here and its now been deleted but I think it would make a good challenge so here it goes...
Challenge
Write a full program or function that takes two strings and checks whether any permutation of the first string is a sub-string of the second string.
Input
Two strings, a string and a sub-string to test for (you may choose the order).
Output:
A truthy value if the string contains any permutation of the sub-string.
A falsey value if the string does not contain any permutations of the the sub-string.
The test is case sensitive.
Examples/Test cases
         sub-string    string
input    d!rl          Hello World!
output   truthy

input    Pog           Programming Puzzles & Code Golf
output   falsey

input    ghjuyt        asdfhytgju1234
output   truthy

Must the truthy and falsey value be consistent or just appropriately truthy or falsey?

@EriktheOutgolfer just appropriate is fine.

Brachylog, 2 bytes
sp

Try it online!
Explanation
Input variable = "Hello World!", Output variable = "d!rl"

(?)s        Take a substring of the Input variable
    p(.)    It is a permutation of the Output variable

Right tool for the job.

JavaScript (ES6), 77 bytes
(s,t)=>t&&[...t.slice(0,s.length)].sort()+''==[...s].sort()|f(s,t.slice(1))

Returns 1 or 0.
Snippet

f=

(s,t)=>t&&[...t.slice(0,s.length)].sort()+''==[...s].sort()|f(s,t.slice(1))

console.log(f('d!rl','Hello World!'))                   //1
console.log(f('Pog','Programming Puzzles & Code Golf')) //0
console.log(f('ghjuyt','asdfhytgju1234'))               //1

This is much faster than the versions that use permutations.

05AB1E, 3 bytes
œåZ

Try it online!
-1 byte thanks to Emigna.
Explanation:
œåZ 2 inputs
œ                  permutations of the first input
 å  Is each of the                                 in the second input?
  Z Take the maximum of the resulting boolean list

I don't think you need .

Not sure if it's my phone but TIO seems broken, says language not found.

@Notts90 It's TIO v2 not TIO Nexus, try to clear your cache. It works for me.

@Emigna Apparently "vectorized" means the second argument not the first...

If only you'd put the crossed out 4

@NeilA. The crossed out 4 doesn't appear as a regular 4 at least for me.

Japt, 10 7 6 bytes
á d!øV

Try it online
á d!øV   :Implicit input of sub-string U & string V
á        :Permutations of U
  d      :Any
   !øV   :  Contained in V

Python 2, 67 66 bytes
Takes input as two strings, substring first.
a=sorted
lambda s,S:a(s)in[a(S[n:n+len(s)])for n in range(len(S))]

Save a byte by naming sorted.

Jelly, 5 bytes
Œ!ẇ€Ṁ

Try it online!
-1 thanks to Emigna for encouraging me to retry golfing.
Explanation:
Œ!ẇ€Ṁ Main link, dyadic
Œ!               the permutations of the left argument
  ẇ€  Is each of                                      in the right argument?
    Ṁ Maximum of boolean values

Java 8, 266 244 bytes
import java.util.*;Set l=new HashSet();s->p->{p("",p);for(Object x:l)if(s.contains(x+""))return 1>0;return 0>1;}void p(String p,String q){int n=q.length(),i=0;if(n<1)l.add(p);else for(;i<n;)p(p+q.charAt(i),q.substring(0,i)+q.substring(++i,n));}

Explanation:
Try it here.
java.util.*;                   // Required import for Set and HashSet

Set l=new HashSet();           // Class-level Set

s->p->{                        // Method (1) with two String parameters and boolean return-type
  p("",p);                     //  Put all permutations in the class-level Set
  for(Object x:l)              //  Loop over the permutations:
    if(s.contains(x+""))       //   If the input String contains one of the permutations:
      return 1>0;//true        //    Return true
                               //  End of loop (implicit / single-line body)
  return 0>1;//false           //  Return false
}                              // End of method (1)

void p(String p,String q){     // Method (2) with two String parameters and no return-type
  int n=q.length(),i=0;        //  Two temp integers
  if(n<1)                      //  If `n` is zero:
    l.add(p);                  //   Add this permutation of the String to the Set
  else                         //  Else:
    for(;i<n;                  //   Loop over `n`
      p(p+q.charAt(i),q.substring(0,i)+q.substring(++i,n))
                               //    Recursive-call with permutation parts
    );                         //   End of loop (no body)
}                              // End of method (2)

In C# a void lambda is Action<params> instead of Func<params, returnVal>. I assume it would be something similar.

@TheLethalCoder You're right. Should use Consumer and accept(...) instead of Function and apply(...) when I want to have a lambda with a parameter and no return-type. I'm currently learning Java 8. :) But since I'll have to change void p(String p,String q), p("",p); and p(p+q.ch...,q.sub...) to p->q->, p.apply("").accept(p); and p.apply(p+q.ch...).accept(q.sub...) it is shorter to use a combination of lambda for the main method, and just a Java 7 void p(String p,String q) method for the recursive-method.

Nice, at least you figured it out

I used a Function<String, Predicate<String>> in mine.

Python, 60 bytes
An altered form of TFeld's answer - go give some credit!
s=sorted
f=lambda u,t:s(u)==s(t[:len(u)])or t and f(u,t[1:])

Recursive function returning the boolean True (truthy) or an empty string (falsy).
Try it online!
sorts the substring, u, and the same length of the front of the string, t, (using a slice t[:len(u)]) if they are the same then True is returned, otherwise if t is still truthy (not empty) recurses with a dequeued t (using a slice, t[1:]). If t does become empty the and is not executed and this empty t is returned.

You can also have lambda as parameter : lambda u,t,s=sorted: for an one-liner, no byte saved though

@cat the assignment is required since the function is recursive.

Pyth, 9 8 bytes
sm}dQ.pE

-1 byte thanks to @Erik_the_Outgolfer
Takes two quoted strings, the second of which is the substring.
Try it!

OP said that it can be just truthy/falsey, not necessarily consistent, so you can use s instead of }1.

CJam, 13 12 bytes
le!lf{\#)}:+

Try it online!
I feel like CJam is really limited compared to other golfing languages, but maybe it's just me being bad...
I'm thinking about moving to another. 05AB1E seems fun.
Fixed small bug thanks to Erik the Outgolfer
Cut one bite because non-zero numbers are truthy
Explanation:
l                 Read substring
 e!               Generate all permutations
   l              Read string
    f{            For each permutation
      \#            Check if it is in the string (returns -1 if not found)
        )           Add one
         }        End for
          :+      Sum the whole found/not found array

I think this is invalid, what about inputs a and abc?

@EriktheOutgolfer You are right. It should be a >=0 instead of >0

But you can do W>.

@EriktheOutgolfer would le!lf{\#)}:+ be considered a valid solution? It should output 0 if the string is not found and some positive number otherwise. Is a non-zero number a valid truthy?

You can use ) instead of W>, per OP's clarification.

Mathematica, 55 50 bytes
-5 bytes from user202729
StringFreeQ[#2,""<>#&/@Permutations@Characters@#]&

Returns False if a permutation of the first input is in the second string. Returns True if a permutation of the first input is not in the second string.
Explanation:
                                    Characters@#   - split first string into array of characters
                       Permutations@               - make all permutations
               ""<>#&/@                            - join each array of characters together to form a single string
StringFreeQ[#2,                                 ]& - Check if any of these string is in the second input string

The output only needs to be "truthy/falsey" not literal True/False.

Thanks for reminder about Characters.

Java 9 JShell, 160 bytes
p->q->IntStream.range(0,q.length()-p.length()+1).anyMatch(
    i->Arrays.equals(
        q.substring(i,i+p.length()).chars().sorted().toArray(),
        p.chars().sorted().toArray()))

(newlines inserted for readability)
Try it online!
Note: JShell includes a number of imports by default. As a Java 8 or Java 9 solution, it would be necessary to import:
import java.util.*;import java.util.stream.*;

For an extra 45 bytes, or 205 bytes total. The TIO link above is to a Java 9 program since TIO doesn't currently have JShell (and it's not clear to me how JShell would work on TIO).

Java 9 is a thing now? :|

@CalculatorFeline The early access builds have been available for quite some time, but the official release date is 2017-07-27.

C#, 320 bytes
using System.Linq;s=>u=>p(u.ToArray(),0,u.Length-1).Any(p=>s.Contains(p));w=(c,a,b)=>{if (a!=b)(var t=c[a];c[a]=c[b];c[b]=t;)};System.Collections.Generic.IEnumerable<string>p(char[]l,int k,int m){if(k==m)yield return new string(l);else for(int i=k;i<=m;){w(l,k,i);foreach(var c in p(l,k+1,m))yield return c;w(l,k,i++);}}

I'm sure calculating the permutations can be a lot shorter but I can't see how at the moment.
Formatted/Full version:
void test()
{
    Func<string, Func<string, bool>> f = s => u =>
        p(u.ToArray(), 0, u.Length - 1).Any(p => s.Contains(p));

    Console.WriteLine(f("Hello World!")("d!rl"));
    Console.WriteLine(f("Programming Puzzles & Code Golf")("Pog"));
    Console.WriteLine(f("asdfhytgju1234")("ghjuyt"));
}

System.Collections.Generic.IEnumerable<string>p(char[] l, int k, int m)
{
    Action<char[], int, int> w = (c, a, b) =>
    {
        if (a != b)
        {
            var t = c[a];
            c[a] = c[b];
            c[b] = t;
        }
    };

    if (k == m)
        yield return new string(l);

    else
        for (int i = k; i <= m;)
        {
            w(l, k, i);

            foreach (var c in p(l, k + 1, m))
                yield return c;

            w(l, k, i++);
        }
}

yeah, unfortunately using linq often makes things longer than simple for(..){}

Ruby, 69 bytes
->a,b{r=nil;a.chars.each_cons(b.size){|q|r||=q.sort==b.chars.sort};r}

Try it online!

Perl 6, 48 bytes
{$^a.contains(any $^b.comb.permutations».join)}

Returns an or-junction of each permutation's presence as a substring.  For example, with arguments "Hello World!" and "d!l", returns:
any(False, False, False, False, True, False)

...which "collapses" to True in a boolean context.  That is, junctions are truthy values.

PHP>=7.1, 91 Bytes
for([,$x,$y]=$argv;~$p=substr($y,$i++,strlen($x));)$t|=($c=count_chars)($x)==$c($p);echo$t;

Testcases

Try ~$p instead of a&$p.

When I try to run your code using the link it says unexpected ,

@Notts90 Please use a PHP Version over 7.1

@JörgHülsermann that works, it had defaulted to 7.0.3

Haskell, 54 bytes
import Data.List
s#t=any(`isInfixOf`s)$permutations t

Using the power of Data.List for both isInfixOf as well as permutations.

MATL, 10 bytes
Y@Z{w&Xfma

Try it on MATL Online

R, 103 bytes
function(w,x,y=u(w),z=u(x)){for(i in 1:n(w)){F=F|!sum(setdiff(y[1:n(x)+i-1],z))};F}
u=utf8ToInt
n=nchar

Try it online!
Returns TRUE for truthy and NA for falsey.

Ruby, 43 bytes
->a,b{b.chars.permutation.any?{|c|a[c*""]}}

Attempt This Online!

APL (Dyalog), 18 bytes
{∨/(∧/⍺∊⊢)¨⍵,/⍨⍴⍺}

Try it online!

Factor + math.combinatorics, 35 bytes
[ '[ _ subseq? ] find-permutation ]

Try it online!
Outputs the matching subsequence (which behaves as boolean true in Factor) for truthy and f for falsey.


text:
What color is this?
You are to golf a program that will take a filename as input and you must output what color the file is.
The file will have any one of these extensions but your program only needs to support one. Please say which one in your answer.

.jpg
.png
.svg
.gif
.bmp

And now to the classic layout.
Input
A filename with one of the above extensions.
You may also take an image object or already encoded image instead.
Output
The only color in that file as a 6 digit hex code with an optional leading # e.g. #000000 is black.
You may also output a list/tuple/string containing the decimal or hex values of the RGB color, with a clear, non-numeric delimiter e.g.  , | etc
You may not output the transparency.
If the file isn't all one color, you must output a falsy value that isn't #000000 and terminate without printing anything to STDERR. This is so that you can't simply open the file and get the RGB value of the first pixel.
Rules

The hex code only needs to be outputted if the file is all one color.
The file will be 500x500 pixels
The pixels will all have 0% transparency.
This is code-golf so shortest code wins!

Examples

#16C293
#8B16C2
#959090
#84F00C
Falsy Value

The file all not being one colour just seems like an unnecessary complication to me. And a falsey value in strongly typed languages, e.g. C#, can only be a bool. For this case I'd be returning a string for the normal case and bool for the non-normal case, wrapped in an object. Is this fine or can I return an empty string or similar?

Also I suggest uploading your images to i.stack.imgur.com (my program can't get the image off of pasteboard)

We have a default standard for image input, you can find it on our meta here. It's not significantly different from what you have, but you may want to link to it instead of your provided one.

@TheLethalCoder you could probably get away with returning null, or an empty string.

@Phoenix That's what I'm asking though, is it okay as that is not a falsey value in C# and probably other strongly typed languages.

@TheLethalCoder that's fine. Also the "it may be different colours is so that it isn't to trivial"

@Ilikemydog It does matter. Saying the output is "The only color in that file" leads answerers to assume that the image will contain a single color. Then the rules contradict that. On the other hand, it would be a lot clearer if the output section read something like "The only color in that file, or a falsy value different than... if the image contains more than one color". Or, as xnor so aptly put it, it's confusing when the body of the challenge says one thing but a later part says another

On a side note you can use the sandbox for future challenges to avoid most of this back and forth with clarifications once the challenge has already been posted.

Are we to assume that all files will always be 3 channel (8 bits each) RGB files?

What @LuisMendo says is exactly what caused me to screw up my first attempt at this.

@Octopus yes you shoud

Can we only assume the format?

MATL, 15 12 bytes
Yi6Bed~?2MYm

Tested with the ".png" images given in the challenge. It probably works with other extensions too. Input can be a filename or a URL of the image.
Output is R, G, B decimal values separated by spaces, or the empty string (which is falsy) if there are more than one color.
Example with first and last test cases:

Explanation
Yi      % Implicitly input filename. Read image as an M×N×3 array
6B      % Push [true true false] (6 in binary)
e       % Reshape. This collapses firsts two dimensions. Gives an (M*N)×3 array
d       % Consecutive diferences down each column. Gives an an (M*N-1)×3 array
~?      % If all those differences are zero (this means there is a single color)
  2M    %   Push the (M*N)×3 array again
  Ym    %   Mean of each column
        % Implicit end
        % Implicitly display

Does this have the check for the falsey image?

@TheLethalCoder Solved. Thanks for the heads-up

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

@TheLethalCoder Thanks. I don't think it helps in this answer, unless I could input the M×N×3 array directly, which is probably not what the OP means

12 bytes?! Well, holy hell!

Bash + core-utils + Imagemagick, 60
a=(`convert $1 txt:|sort -uk3`)
((${#a[@]}-9))||echo ${a[2]}

Outputs the colour if there is one colour and nothing if there is more than one colour.

convert $1 txt: reads the input file and outputs as a text file, specifically in this format:

# ImageMagick pixel enumeration: 500,500,255,srgba
0,0: (245,236,236,1)  #F5ECEC  srgba(245,236,236,1)
1,0: (245,236,236,1)  #F5ECEC  srgba(245,236,236,1)
2,0: (245,236,236,1)  #F5ECEC  srgba(245,236,236,1)
3,0: (245,235,235,1)  #F5EBEB  srgba(245,235,235,1)
4,0: (245,235,235,1)  #F5EBEB  srgba(245,235,235,1)

sort -uk3 uniquely sorts this by the third column.  This output is assigned to an array a

((${#a[@]}-9)) tests if the array does NOT have length 9

if the array does NOT NOT have length 9 (i.e. it does have length 9), then output element 2 (0-based) which will be the unique colour.

Oh my, that's impressive.

JavaScript (ES6) + HTML, 315 289 243 218 217 215 211 210 208 bytes
Checking that all pixels were identical added a lot of bytes. Down to it not being much bigger than when I was just checking the colour of the first pixel - happy with that :)
Takes the URL (absolute, relative, data or anything that can be used as the src of an img) of the image file as input. Outputs the RGB colour as a comma separated string or 0 for falsey. Tested with PNG files but should work with JPG & GIF too.
u=>(a=[...Array(c.width=c.height=500)]).map((_,x)=>a.map((_,y)=>(v=""+[(d=g.getImageData(x,y,1,1).data)[0],d[1],d[2]],h=x&y?v!=h?0:h:v)),i.src=u,(g=c.getContext`2d`).drawImage(i,0,0))&&h

<canvas id=c

Try it
Requires the addition of a closing > on the canvas element in order to work in a Snippet. As pulling images in from external sources would cause an error to be thrown, the following will instead take Base-64 data URLs as input. Uncomment the last line to test for different colours using an image consisting of the 4 test colours.

f=
u=>(a=[...Array(c.width=c.height=500)]).map((_,x)=>a.map((_,y)=>(v=""+[(d=g.getImageData(x,y,1,1).data)[0],d[1],d[2]],h=x&y?v!=h?0:h:v)),i.src=u,(g=c.getContext`2d`).drawImage(i,0,0))&&h
console.log(f("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0AQMAAADxGE3JAAAAA1BMVEUWwpMvG5UqAAAANUlEQVR42u3BMQEAAADCIPun9lkMYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5fQAAASJ0bysAAAAASUVORK5CYII"))
//console.log(f("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0AgMAAAC2uDcZAAAADFBMVEWLFsIWwpOVkJCE8Az9F2TyAAABB0lEQVR42uzNIQEAMAwDsEk8ucmTS9xElAwkBlI3cipit9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91uX72/yO+I3W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdPhu1fdT2UdtHbR+1fdT2UdsHs+0AqVGfBnNZ7+UAAAAASUVORK5CYII"))
<canvas id=c>

A filename with one of the above extensions. -> You sure you can take the image as an encoded string instead of loading from a file?

@TheLethalCoder, No! :D And, now that you say it, I can see how I can save a few bytes :)

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

@TheLethalCoder, I was able to chop "data:image/png;base64,"+ out of my code by taking input as a URL instead.

Python 2, 80 bytes
from PIL import Image
i=Image.open(input()).getcolors(1)
print i and i[0][1][:3]

PIL.Image has a getcolors function which returns None if the number of colors is bigger than the parameter and returns a histogram of the colors in a [(pixels, (r,g,b,a)), ...] structure.

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

@TheLethalCoder So then I should assume an already opened image and just write print i and i[0][1][:3]?

I'd assume you'd need the get colours call to

Mathematica, 55 51 Bytes
-4 thanks to CalculatorFeline
+0 for refactoring into full function.
Using Mathematica image object as input - Import["filename.png"].
If[Length@#==1,#,0]&@Union[Join@@ImageData@#]&

Returns 0 if not all one color. Outputs the decimal value of the color if just one.
Explanation:
                                 ImageData@# & - Convert input into 2D array of RGB values
                           Join@@              - Join the array into 1D array f RGB values
                     Union[                 ]  - Union all the RGB values
   Length@#        &@                          - Find length of the union of arrays
If[        ==1,#,0]                            - Check if its 1, return it if true, return 0 if not

a==1==a<2 and Join@@ is equivalent to ~Flatten~1 in this case. (Join breaks if the list contains any nonlists.)

By default, a full function or program is required. For using an already-decoded image object, I believe you'd still need to do something like If[Length@#==1,#,0]&@Union[ImageData@#~Flatten~1]&

I misinterpreted the OP's comment You may also take an image object or already encoded image instead.. Will update.

@CalculatorFeline Thanks for hint about Join@@.

Java 8+, 331 165 119 bytes
i->{Integer j=i.getRGB(0,0),k=500,l;for(;k-->0;)for(l=500;l-->0;)if(i.getRGB(k,l)!=j)return"";return j.toHexString(j);}

-a lot of bytes thanks to @LethalCoder for updating me on a rule change that allowed for a lot of golfing
-46 bytes thanks to @KevinCruijssen and fixed typo

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

@TheLethalCoder Oh perfect. Thanks!

I know it's been a while, but some things to golf (without changing the Java 7 version): Object f(java.awt.image.BufferedImage i){Integer j=i.getRGB(0,0),k=500,l;for(;k-->0;)for(l=500;l-->0;)if(i.getRGB(k,l)!=i)return"";return j.toHexString(j);}. By changing the Java version to 8+, you can also change Object f(java.awt.image.BufferedImage i) to i->. Also, I think you've made a typo: shouldn't if(i.getRGB(k,l)!=i) be !=j instead?

@KevinCruijssen Thanks. And yeah, I think I did :P

@HyperNeutrino You forgot to change it to Java 8 (or higher). ;)

C, 224 205 bytes
m[3],i;
main(c,v)char**v;{
void*s=fopen(v[1],"r");
for(;i<54;i++)getc(s);
m[2]=getc(s);m[1]=getc(s);*m=getc(s);
for(i=0;i<500*500;i++)if((c=getc(s))!=m[i%3]&&~c)exit(puts("0"));
printf("%d,%d,%d",*m,m[1],m[2]);}

Takes a 500x500 bitmap as a command-line argument. Prints the RGB of the file, e.g. 255,255,255, or 0 if the file is not constant. Probably crashes badly if no file is provided.
Interesting points to note:

Uses void* in the place of FILE* to avoid including <stdio.h>
Uses a simple for loop with i%3 to determine if all bytes are the same
Can be very golfed, I golfed 50 bytes while writing this answer
BMP stores colors as BGR so it more/less reads backwards

C#, 163 128 125 bytes
b=>{var c=b.GetPixel(0,0);for(int w=500,h;w-->0;)for(h=500;h-->0;)if(b.GetPixel(w,h)!=c)return"";return c.R+" "+c.G+" "+c.B;}

Saved 3 bytes thanks to @Kevin Cruijssen.
If we didn't have to have the additional check for the image being the same colours this is only 55 bytes:
b=>{var c=b.GetPixel(0,0);return c.R+" "+c.G+" "+c.B;};

I know it's been a while, but: b=>{var c=b.GetPixel(0,0);for(int w=500,h;w-->0;)for(h=500;h-->0;)if(b.GetPixel(w,h)!=c)return"";return c.R+" "+c.G+" "+c.B;} (-3 bytes)

Python 2, 123 85 bytes
from PIL import Image
c=Image.open(input()).getdata()
print len(set(c))<2and c[0][:3]

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

I would expect from PIL import* to save a few bytes(or alternatively, import PIL and then c=PIL.Image ) unless I'm overlooking something

@Foon PIL is a exception to imports, you can't do from PIL import* norPIL.

Thanks; did not know that or at least forgot it

Inconsistency is horrible :(

Mathematica, 112 bytes
image

i=Import@"c:\a.png";

If[Length@DominantColors@i==1,"#"<>StringPadLeft[IntegerString[Most@PixelValue[i,{1,1},"Byte"],16],2,"0"],False]

You may also take an image object or already encoded image instead. OP updated might be able to save bytes...

ok. I made some changes.thanks

Is lowercase hex acceptable?

Most@PixelValue[i, {1, 1}, "Byte"] will save some bytes.

103 bytes: If[Length@Tally[a=i~ImageData~"Byte"]<2,"#"<>StringPadLeft[Most@a[[1,1]]~IntegerString~16,2,"0"],False] - use your ImageData function. Didn't know that existed.

Bash + ImageMagick, 100 bytes
i=$(expr `identify -format "%k" $1` = 1)&&convert $1 -format "%c" histogram:info:-|grep -o "#......"

Tested with .png, should work with the other formats as well. The output for a polychromatic image is simply an empty string.

You can drop the quotes from around the format specifiers.  Also ((\identify -format %k $1`-1))||is shorter thani=$(expr `identify -format "%k" $1` = 1)&&`.

JavaScript + HTML, 143 + 23 = 166 bytes
u=>(i.src=u,s=C.width=C.height=500,c=C.getContext`2d`,c.drawImage(i,0,0),d=c.getImageData(0,0,s,s).data,!d.some((n,i)=>n-d[i%4])&&d.slice(0,3))

<canvas id=C>

Try it:

f=
u=>(i.src=u,s=C.width=C.height=500,c=C.getContext`2d`,c.drawImage(i,0,0),d=c.getImageData(0,0,s,s).data,!d.some((n,i)=>n-d[i%4])&&d.slice(0,3))

console.log(
    f('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0AQMAAADxGE3JAAAAA1BMVEUWwpMvG5UqAAAANUlEQVR42u3BMQEAAADCIPun9lkMYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5fQAAASJ0bysAAAAASUVORK5CYII'),
    f('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0AgMAAAC2uDcZAAAADFBMVEWLFsIWwpOVkJCE8Az9F2TyAAABB0lEQVR42uzNIQEAMAwDsEk8ucmTS9xElAwkBlI3cipit9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91uX72/yO+I3W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdbrfb7Xa73W632+12u91ut9vtdrvdPhu1fdT2UdtHbR+1fdT2UdsHs+0AqVGfBnNZ7+UAAAAASUVORK5CYII')
)
<canvas id=C>

Less golfed:
u => {
    i.src = u
    s = C.width = C.height = 500
    c = C.getContext('2d')
    c.drawImage(i, 0, 0)
    d = c.getImageData(0, 0, s, s).data
    return d.every((n,i) => n == d[i % 4]) && d.slice(0,3)
}

PowerShell, 79 bytes
param($b)if(!($c=499..0*500|%{$b|% G*l $_ $y;$y+=!$_}|gu).Rank){$c.R;$c.G;$c.B}

Less golfed test script:
$f = {

    param($b)
    $c=499..0*500|%{$b.GetPixel($_,$y);$y+=!$_}|gu
    if(!$c.Rank){
        $c.R;$c.G;$c.B
    }

}

@(
    ,("22 194 147", "https://cdn.pbrd.co/images/8bawQk5kM.png")
    ,("139 22 194", "https://cdn.pbrd.co/images/8b9foR0H6.png")
    ,("149 144 144","https://cdn.pbrd.co/images/8baglmIE8.png")
    ,("132 240 12", "https://cdn.pbrd.co/images/8b9Uhhovn.png")
    ,("",           "https://cdn.pbrd.co/images/8bb4DeKx3.png")

) | % {
    $expected,$s = $_

    $binData = [System.Net.WebClient]::new().DownloadData($s)
    $memoryStream = [System.IO.MemoryStream]::new($binData)
    $bitmap = [System.Drawing.Bitmap]::FromStream($memoryStream)

    $sw = [System.Diagnostics.Stopwatch]::StartNew()
    $result = &$f $bitmap
    "$("$result"-eq$expected): $($sw.Elapsed): $result"
}

Note 1: expression 499..0*500 means: repeat 500 times an range from 499 downto 0
Note 2: expression $b|% G*l $_ $y is shortcut for $b.GetPixel($_,$y). This trick is usefull with gofing, but it slows down the code.

Output with $b|% G*l $_ $y:
True: 00:01:45.4904622: 22 194 147
True: 00:01:56.4208157: 139 22 194
True: 00:01:46.7629439: 149 144 144
True: 00:01:48.1999005: 132 240 12
True: 00:01:55.8579935:

Output with $b.GetPixel($_,$y):
True: 00:00:05.7637937: 22 194 147
True: 00:00:06.8743244: 139 22 194
True: 00:00:08.7456055: 149 144 144
True: 00:00:08.5942450: 132 240 12
True: 00:00:06.6495706:

Explanation:

the script creates an array of each pixel color.
the script applies gu (alias for Get-Unique) to the array of color.
if the result of hu is a single element (property rank has value for an array only) then output decimal value of R,G,B of this element

Python 2 + OpenCV + NumPy: 66 characters
colors.py
import numpy as N
def c(i):p=i[0,0];print(p[::-1],"")[N.any(i-p)]

test.py
import cv2
from colors import c

c(cv2.imread('16C293.png'))
c(cv2.imread('84F00C.png'))
c(cv2.imread('8B16C2.png'))
c(cv2.imread('959090.png'))
c(cv2.imread('falsy.png'))

Result:
18:14 ~/colors $ python test.py
[ 22 194 147]
[132 240  12]
[139  22 194]
[149 144 144]

18:15 ~/colors $

OpenCV is able to read an image and return it as an N-dimensional array. NumPy is used to test the first pixel against the others and either print out the RGB values or blank.

PHP, 88 bytes
function($i){return~-imagecolorstotal($i)?0:sprintf("#%06x",imagecolorsforindex($i,0));}

anonymous function takes an indexed PHP image resource as parameter, assumes color in first palette slot, returns color code or 0.
program, 96 bytes
imagecolorstotal($i=imagecreatefromgif($argv[1]))-1||sprintf("#%06x",imagecolorsforindex($i,0));

takes GIF file name from argument, prints color code or nothing. Run with php -r '' <filename.gif>.
for true color images, 113 112 bytes
function($i){for(;$p<25e4;$p++)$r[$c=imagecolorat($i,$p%500,$p/500)]=1;return~-count($r)?0:sprintf("#%06x",$c);}

as above, but requires true color image.
program, 122 116 bytes
for(;$p<25e4;$p++)$r[$c=imagecolorat(imagecreatefrompng($argv[1]),$p%500,$p/500)]=1;count($r)-1||printf("#%06x",$c);

as above, but requires PNG file.


text:
Remind me again?
Introduction
Ever heard of Remind? No? Neither did I until about 2 years ago. Basic premise of it is for teachers to send out reminders and communicate with their students. Pretty neat, right? It even allows you send emotes and react to messages! Which I do on a daily basis.
But, one thing about Remind is that the teachers always send the "Do your homework!" "If you don't, you'll get an F!". But, there is useful stuff too, like "Test on Tuesday", or the occasional "Have a good day!". I almost always reply happy with a thumbs up, but sometimes, I have to put a thumbs down.
Challenge
Your task today is to find out if a message has a certain connotation to it. If it has a positive connotation to it, reply with a thumbs up. If it has a negative connotation, reply with a thumbs down.
How am I supposed to detect connotations?
A positive connotation will normally have 3 words in it. The 3 words are: Happy, Good, and Passed.
A negative connotation will have 3 also. Those 3: Test, Fail, and Homework.
What am I testing for?
You are testing to see if a message contains positive, negative or both connotations.
If a message has positive connotations to it, go ahead and return the unicode code point for thumbs up (U+1F44D).
If it has negative connotations to it, return the unicode code point for thumbs down (U+1F44E).
If the message has both negative and positive connotations, return the code point for a neutral face (U+1F610).
If, for some other reason, it doesn't have either connotations, return a nice ol' shrug (¯\_(ツ)_/¯). If the shrug doesn't show up right, here's the Emojipedia link to the shrug
Constraints

Program must take a message as input.
Positive connotations must return thumbs up code point (U+1F44D)
Negative connotations must return thumbs down code point (U+1F44E).
If the message has both connotations, return the neutral face code point (U+1F610).
If the message has neither connotations, return the shrug (¯\_(ツ)_/¯).
This is code-golf, Shortest bytes win

Test cases.
Input -> Output
Happy Good Friday! -> U+1F44D
Congrats, you just played yourself -> ¯\_(ツ)_/¯
You failed the test. -> U+1F44E
Good job on the test. -> U+1F610

You need to escape it

it's fine, the test case has the full shrug

"If the message has both connotations, return the neutral face code point (U+1F610)." And no, not case sensitive.

To clarify: if the string contains both types of words, return neutral, regardless of if there is more of one type than the other?

@Shaggy yes, just return neutral

You linked to  (U+1F937), but requested "¯\(ツ)/¯", why did you link to that?

@Theraot where does the OP ask for U+1F937? That article is about emojis and emoticons relating to people shrugging. That's why it's called "people shrugging"

@Ilikemydog OP didn't ask for U+1F937, did I say he asked for it? No I didn't. I said OP linked to it. While it is true that the article has emoticons related to people shrugging, that article is about one particular emoji, this one:  (which has the code point U+1F937), and it list the different emoticons different platforms use to represent it. OP didn't ask for that emoji. That is precisely my point. Why did KuanHulio link to it?

It has the shruggie unicode. That's why I linked to it.

Python 3, 182 166 159 151 bytes
c=input().lower().count
print((["¯\_(ツ)_/¯"]+list(""))[any(map(c,["good","happy","passed"]))+any(map(c,["fail","test","homework"]))*2])

Try it online!

you can insert both anys inside the print : d[any(<positive>)+any(<negative>)*2]

I get 182 UTF-8 bytes instead of 169

utf always makes me forget extra bytes, I usually just use python's len() function on my code. Will edit

"" works fine for me. what version of python are you on?

I haven't tested it, but I think you could do print(d[("good"in m or"happy"in m or"passed"in m)+("bad"in m or"test"in m or"homework"in m)*2]) instead

you can drop the r/d vars and map input.count over the words

JavaScript, UTF-8 encoded, 100 bytes
s=>['¯\_(ツ)_/¯',...''][2*/happy|good|passed/i.test(s)+/test|fail|homework/i.test(s)]

Test cases:

const a =
s=>['¯\_(ツ)_/¯',...''][2*/happy|good|passed/i.test(s)+/test|fail|homework/i.test(s)]

console.log(a('Happy Good Friday!'));
console.log(a('Congrats, you just played yourself'));
console.log(a('You failed the test.'));
console.log(a('Good job on the test.'));

Powershell, 190 bytes
"$($s=Read-host;"$s ->";$1=("Test","Fail","Homework"|?{$s-match$_});$2=("Happy","Good","Passed"|?{$s-match$_});if($1-and$2){""}elseif($1){""}elseif($2){""}else{"¯\_(ツ)_/¯"})"

Displays the input and output next to eachother.
Happy Good Friday! ->
Congrats, you just played yourself  -> ¯\_(ツ)_/¯
You failed the test. ->
Good job on the test. ->

PowerShell, 187 bytes
read-host|%{$s=$_;$f=0;0..5|?{$s.indexof((-split'Happy Good Passed Test Fail Homework')[$_],0,$s.length,3)+1}|%{$f=$f-bor(1,2)[$_/3]};$s+' -> '+('¯\_(ツ)_/¯','','','')[$f]}


text:
Create your own Red and Black
In the musical rendition of Les Miserables, a song appears called "Red and Black." Here is part of that song:

Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!

Source.
Your task is to turn input into a resounding "Red and Black" anthem.
Input
Text delimited by newlines, or a similar suitable text input. For example,
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!

Empty input is undefined (out of scope).
Output
If the length (number of lines, or length of input array, or similar) of the input is odd, either output nothing or output falsey. Your submission may not output errors or attempt to output the correct output.
Otherwise, turn the input into a Red/Black lyric. Turn any uppercase letters at the start of a line to lowercase. Add Red plus a delimiter to the front of odd lines, and Black plus a (visible) delimiter to the front of even lines. The delimiter must also be surrounded in spaces, so the output looks uncrowded (and ungolfed ;) ).
You now have your output.
Test Cases
Output delimiter is -.
In:
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!

Out:
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!

In:
test test
1
[][][]
BBB

Out:
Red - test test
Black - 1
Red - [][][]
Black - bBB

In:
I feel my soul on fire!
The color of desire!
The color of despair!
Out:
falsey OR nothing

In:
Red - I feel my soul on fire!
Black - My world if she's not there!

Out:
Red - red - I feel my soul on fire!
Black - black - My world if she's not there!

Sandbox (deleted)

By "or the length of the input is odd", are you talking about lines or characters?

@Tutleman number of lines, I'll clarify

I think this challenge is OK as is, but in general, making submissions handle invalid input doesn't really add a lot. Just for future reference.

@DJMcMayhem since there have been no answers, I'll make empty input undefined - makes more sense, thanks (I want to keep odd length input as is)

Can the delimiter be a space?

@EriktheOutgolfer Output delimiter? No, it must be visible.

Is outputting multiple newlines allowed when length is odd?

@EriktheOutgolfer Yes, it appears to be nothing, which is basically the same

Can we print a extra newline between each "red" and "black"? i.e. red - a\n\nblack - b

How does "output falsey, but not an error" work in languages where the only falsey value is an error value? (Some early Prolog versions work like this – the only way to output false is to throw an error. Later Prolog versions made a distinction between exceptions (which throw an error) and failures (which cause a return of false), so this probably isn't a problem in practice, but the assumption in the question that the two are distinct bothers me a bit.

@ais523 I had it as "terminate unexpectedly", which makes more sense for your question but less sense in general. The falsey is higher priority than the error part.

05AB1E, 26 bytes
Code:
|©v”†¾ƒÏ”#Nè… - yćlìJ®gÈ×,

Uses the 05AB1E encoding. Try it online!
Explanation:
|                               # Take the input as an array of inputs
 ©                              # Keep a copy of this in the register
  v                             # Map over the array
   ”†¾ƒÏ”#                      #   Push the array ["Red", "Black"]
          Nè                    #   Get the Nth element (where N is the iteration index)
            … -                 #   Push the string " - "
                yć              #   Push the current element and extract the first element
                  lì            #   Convert to lowercase and prepend back to it's
                                    original place
                    J           #   Join the entire stack into a single string
                     ®g         #   Get the length of the input
                       È        #   Check if it is even (results in 1 or 0)
                        ×       #   String multiply the result by the string
                         ,      #   Pop and print with a newline

Haskell, 104 120 113 112 111 110 bytes
import Data.Char
f x|odd$length$x=mempty|1<2=Just$zipWith(\(h:t)x->x++toLower h:t)x$cycle["Red - ","Black - "]

Try it online!
Ungolfed with explanation
import Data.Char

f :: [String] -> Maybe [String]
f x
  | even $ length $ x = Just $ zipWith (\(h : t) x -> x ++ toLower h : t) x $ cycle ["Red - ","Black - "]
  | otherwise         = Nothing

f is a function that takes a list of strings (a.k.a. a list of lists of Chars), and returns Maybe the same. Haskell's functions are quite "pure", and so we need to make it clear that this function may not return anything. (A function of type Maybe a returns either Nothing or Just a).
The | operator is a guard - a kind of conditional. The first branch is followed if even $ length $ x (which is another way of writing even (length x)) is True. Otherwise, the second one (1<2 in the golfed example, which is of course always true) is followed and we return Nothing.
zipWith takes a two-argument function and applies it to each element of two lists. The function we're using here is \(h : t) x -> x ++ toLower h : t. h : t implicitly splits the first character off our first argument, which is the kind of nice thing you can do in Haskell. The first list is the input (which we already know contains an even number of lines), and the second is just infinitely alternating "Red - " and "Black - " (infinite lists are another nice thing that's possible, this time because Haskell is lazy - it only cares about as much of something as you use).

(h:t)!x=x++toLower h:t saves some bytes.

Switching the two cases saves another byte: f x|odd$length$x=Nothing|1<2=Just ...

@Laikoni thanks for these! I'm pretty new to Haskell and this is my first time golfing in it - and I'm really liking it!

mempty saves 1 byte compared to Nothing!

You can save another byte by defining c="Red - ":"Black - ":c and using c instead of cycle["Red - ","Black - "]: Try it online!

V, 31, 30 bytes
êuòIRed -
IBlack -
òñFRdH

Try it online!
Hexdump:
00000000: 16ea 75f2 4952 6564 202d 201b 0a49 426c  ..u.IRed - ..IBl
00000010: 6163 6b20 2d20 1b0a f2f1 4652 6448       ack - ....FRdH

This is trivial in V, but the edge case of odd inputs makes it tricky because V doesn't really have conditionals. Thankfully, we can handle this at the relatively small cost of +6 bytes.

Japt, 36 35 34 bytes
Outputs 0 for false. Includes an unprintable after the second R.
èR u ©¡[`R Black`¸gY '-XhXg v]¸}R

Try it online

Jelly, 29 bytes
0
“ZœĠk»ḲṁJżj€“ - ”Y
ỴŒl1¦€LĿ

A full program.
Uses the "falsey" output option for inputs with an odd number of lines.
Try it online!
How?
0 - Link 1, return a falsey value: no arguments
0 - well, yeah, zero - that's falsey.

“ZœĠk»ḲṁJżj€“ - ”Y - Link 2, format the lines: list of lists of characters, the lines
“ZœĠk»             - "Red Black"
      Ḳ            - split at spaces -> ["Red","Black"]
        J          - range(length(lines)) -> [1,2,3,...,nLines]
       ṁ           - mould -> ["Red","Black","Red","Black",...,"Red","Black"]
         ż         - zip with lines -> [["Red",l1],["Black",l2],...]
            “ - ”  - " - " (really I cant find any save :/)
          j€       - join for each -> ["Red - l1","Black - l2",...]
                 Y - join with newlines

ỴŒl1¦€LĿ - Main link: string
Ỵ        - split at newlines
   1¦€   - apply to index 1:
 Œl      -   convert to lower case
       Ŀ - call link at index:
      L  -   length - Note: this is modular, so:
         -                  link 2 is called for even, and
         -                  link 1 is called for odd.

C, 112 107 105 103 99 bytes
-4 thanks to ASCII-only
-2 thanks to Mego
i;main(a,s)char**s;{for(;a%2&++i<a;)printf("%s - %c%s\n",i%2?"Red":"Black",tolower(*s[i]),s[i]+1);}

Takes an "array" as input. Example:
bash$ ./a.out "The blood of angry men!" "The dark of ages past!" "A world about to dawn!"
bash$ ./a.out "The blood of angry men!" "The dark of ages past!" "A world about to dawn!" "The night that ends at last!"
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!

How it works

i creates a variable i outside of all functions, which means it's automatically initialized to 0.
main(a,s)char**s;{ declares the main function, which takes two arguments - an int a (# of command line arguments), and a char ** s (array of command line arguments).
for(;a%2&++i<a;) is a loop that checks if a is even (a%2) and if it's less than the number of command line arguments passed (i<a).
printf("%s - %c%s\n",i%2"Red":"Black",tolower(*s[i]),s[i]+1 prints:

"Red" if i is odd, "Black" if i is even (i%2?"Red":"Black")
The first letter of the current command-line argument in lowercase (tolower(*s[i]))
The string, without the first letter (s[i]+1)

Try it online!

Global variables are default-initialized, so you can omit the =0 part to save 2 more bytes.

@CodyGray Oh yeah, thanks!

Röda, 97 bytes
f a{seq 0,#a-1|[_,a[_1]/""]|[["Red","Black"][_%2],` - `,lowerCase(_[0]),_2[1:]&"",`
`]if[#a%2<1]}

Try it online!

Python 2, 215->184->165 bytes
Saved 31 bytes according to Stephen S' comment
Challenger5 got it down to 165 bytes

l=[]
b=["Red","Black"]
d=" - "
while 1:
 a=raw_input()
 if a:l.append(a)
 else:break
q=len(l)
if q%2<1:
 for i in range(q):n=l[i];print b[i%2]+d+n[0].lower()+n[1:]

Try it online!

Can you save some bytes by using single spaces for indentation? I don't know Python that well but I think that works

@Stephen S : Yes, I think you are right.

Got it down to 163 with some basic golfs

Jelly, 30 bytes
LḂṆẋ@Ỵµ“ZœĠk»ḲṁL;€“ - ”żŒl1¦€Y

Try it online!

Retina, 58 bytes
Tm`L`l`^.
m`^
Red -
(Red - .*¶)Red
$1Black
^(.*¶.*¶)*.*$

Try it online!

JavaScript (ES6), 93 bytes
Takes the song as an array of lines.
S=>S.length%2?0:S.map((L,i)=>(i%2?'Black':'Red')+' - '+L[0].toLowerCase()+L.slice(1)).join`
`

f=
S=>S.length%2?0:S.map((L,i)=>(i%2?'Black':'Red')+' - '+L[0].toLowerCase()+L.slice(1)).join`
`

console.log(f([
  'The blood of angry men!',
  'The dark of ages past!',
  'A world about to dawn!',
  'The night that ends at last!'
]))

console.log(f([
  'The blood of angry men!',
  'The dark of ages past!',
  'A world about to dawn!'
]))

@Stephen-S does this input count as valid?

CJam, 41 bytes
qN/{(el\+}%2/"Red -
Black - "N/f.\:~2/N*

Javascript, 118 bytes
v=s=>(s=s.split`\n`).length%2==0?s.map((l,i)=>(i%2==0?'Red':'Black')+' - '+l[0].toLowerCase()+l.substr`1`).join`\n`:!1

Test

//code
v=s=>(s=s.split`\n`).length%2==0?s.map((l,i)=>(i%2==0?'Red':'Black')+' - '+l[0].toLowerCase()+l.substr`1`).join`\n`:!1

//tests
t0 = "The blood of angry men!\nThe dark of ages past!\nA world about to dawn!\nThe night that ends at last!";
t1 = "test test\n1\n[][][]\nBBB";
t2 = "I feel my soul on fire!\nThe color of desire!\nThe color of despair!";
t3 = "Red - I feel my soul on fire!\nBlack - My world if she's not there!";

console.log( v(t0) );
console.log( v(t1) );
console.log( v(t2) );
console.log( v(t3) );


text:
Find the Odd odds
Given an unordered collection of positive integers by any reasonable input method, return all of the sub-collections that have an odd number of odd elements (i.e. have an odd total).
This is code-golf so you should aim to minimize the byte count of your program.
Since some languages only have ordered collections (lists, arrays, vectors, etc.) or don't have an unordered collection that allows duplicates, you may use ordered collections (regardless of your language choice), however you should not output any duplicate collections with different orders (e.g. [2,3] and [3,2]).  You may output in whatever order you see fit.
Test cases
[2,3,7,2] -> [[3],[7],[2,3],[2,7],[2,2,3],[2,2,7]]
[2,4,6,8] -> []
[4,9]     -> [[9],[4,9]]

Are duplicate subcollections allowed? As in, for [2, 2, 3], may we return [[2, 2, 3], [2, 3], [2, 3]]?

Hint: the sum of such a set can only be odd. Any other variant of these sets can only have an even sum.

@HyperNeutrino No you should only return each one once

Okay. Do the subcollections need to be in ascending order or is it fine to list them in the order provided in the original array?

@HyperNeutrino They may be in any order, (ideally they would be an unordered collection, but many languages don't have such a construct so ordered collections are fine as long as the order is not important)

If we consider an ordered list, [2, 3] isn't necessarily a duplicate of [3, 2] since 2 may occur twice in the original list (like in your example). Should it still output this only once? I would find that strange.

@sigvaldm The challenge is about unordered collections, the two 2s present are not distinguishable.  If you choose to use an ordered collection for this challenge that is fine, but you should treat the input as if it is unordered, in which case those two are duplicates.

Your test case contains only primes. That's a coincidence, yes?

I wouldn't call it a problem, but one might draw conclusions after looking at the test case. A test case with empty output would also be useful.

Can languages with unordered collections use ordered collections?

@CalculatorFeline Yes.

Can we assume that the input is given in order? (Several golfing languages use sorted ordered collections as a substitute for unordered collections, and operations which normally work correctly on both ordered and unordered collections will assume the collection is ordered if the inputs are out of order.)

@ais523 No you may not.

05AB1E, 6 bytes
{æÙʒOÉ

Try it online!
{æÙʒOÉ
{      Sort
 æ     Powerset
  Ù    Uniqufy
   ʒ   Keep elements where
    O                      the sum
     É                             is uneven

-2 bytes thanks to @EriktheOutgolfer

@WheatWizard Yes (comment reply to Jonathan). Thanks for reminding me.

2% can be golfed to É and } can be removed. But your answer seems to have the issue.

Python 3, 93 bytes
f=lambda x,r=[[]]:x and f(x[1:],r+[y+x[:1]for y in r])or{(*sorted(y),)for y in r if sum(y)&1}

Returns a set of tuples. Most likely way too long.
Try it online!

Despite its appearance this is actually pretty good.  Here's my amateurish attempt for reference

Pyth, 10 9 8 bytes
{f%sT2yS

Try it online!
         # implicit input
       S # sort input, this way the subsets will already be sorted
      y  # all subsets
 f       # filter elements when ..
   sT    # the sum ..
  %  2   # is odd
{        # remove all duplicated elements
         # implicit output

{SMf%sT2y saves a byte it seems.

Python 2, 91 bytes
r=[[]]
for n in input():r+=map([n].__add__,r)
print{tuple(sorted(y))for y in r if sum(y)&1}

Prints a set of tuples. If a set of strings is allowed, tuple(sorted(y)) can be replaced with `sorted(y)` for 86 bytes.
Try it online!

Brachylog, 11 bytes
o⊇ᵘ{+ḃt1&}ˢ

Try it online!
I hoped to find a shorter solution, but here's the best I could do.
Explanation
o⊇ᵘ{+ḃt1&}ˢ
o                                        the input, sorted
 ⊇ᵘ           Find all unique subsets of

   {    &}ˢ   Then select only those results where
    +                                          the sum
     ḃ                           the base 2 of
      t        The last digit of
       1                                               is 1.

Yeah, I could've used modulo 2 to check for oddness, but that's not an odd approach ;)

Jelly, 8 bytes
ṢŒPSḂ$ƇQ

Try it online!
Bug-fix thanks to Jonathan Allan.
-1 byte by using the alias for filter thanks to Riolku.

Mathematica 31 44 38 bytes
Among all subsets of the input set, it returns those for which the sum, Tr, is odd.
6 bytes saved thanks to alephalpha.
Select[Union@Subsets@Sort@#,OddQ@*Tr]&

 Select[Union@Subsets@Sort@#,OddQ@*Tr]&[{2,3,7,2}]

{{3}, {7}, {2, 3}, {2, 7}, {2, 2, 3}, {2, 2, 7}}

What's with the space?

Unfortunately, this doesn't meet the spec, as {2,3} and {3,2} should not both be returned (same with {2,7} and {7,2}).

Select[Union@Subsets@Sort@#,OddQ@*Tr]&

Perl 6, 50 bytes
{.combinations.grep(*.sum!%%2).unique(:as(*.Bag))}

To filter out the same-up-to-ordering combinations I filter out duplicates by converting each to a Bag (unordered collection) before comparing.  Unfortunately I couldn't find a way to accept a Bag as input that was as concise.

PHP, 126 bytes
for(;++$i>>$argc<1;sort($t),$s&1?$r[join(_,$t)]=$t:0)for ($t=[],$j=$s=0;++$j<$argc;)$i>>$j&1?$s+=$t[]=$argv[$j]:0;print_r($r);

takes input from command line arguments; run with -nr or try it online.
breakdown
for(;++$i>>$argc<1;             # loop through subsets
    sort($t),                       # 2. sort subset
    $s&1?$r[join(_,$t)]=$t:0        # 3. if sum is odd, add subset to results
    )                               # 1. create subset:
    for ($t=[],$j=$s=0;++$j<$argc;)     # loop through elements
        $i>>$j&1?                       # if bit $j is set in $i
        $s+=$t[]=$argv[$j]:0;           # then add element to subset
print_r($r);                    # print results