Evaluate a chain of inequalities
Ruby, 71 + 1 = 72

With command-line flag -n, run

p (0..99).none?{|i|~/#{a=i%10}(#{%w/!=|. &lt;?=* &gt;?=*/[a&lt;=&gt;b=i/10]})#{b}/}


Generates all possible failing regular expressions, and checks whether the input string matches any of them. Outputs true if none do, else false. Takes input via STDIN, separated by newlines.

Tricks:


We get all possible pairs of digits by looping from 0 to 99 and extracting the 10s and 1s digits.
The only actual comparison we do is a&lt;=&gt;b, which returns -1,0,or 1 for less than, equal to, or greater. These all slice to different elements of a three-string array, finding the regular expression for comparisons that don't match.