Vacancy or no vacancy?

Javascript (ES6), 60 bytes

(Open your browser's console while running the snippet to see the colored result.)


n=>console.log((n>199?'%cNO':'NO%c')+' VACANCY','color:red')
<input oninput=f(this.value)>

Ruby (*nix style terminal), 54 48 45 44 43 bytes

1 byte saved thanks to Value Ink

stands in for a literal esc byte (ASCII 27)

->x{"#{x>199?"␛[31m":p}NO␛[31m VACANCY␛[m"}

A port of my python answer, that is a byte several bytes shorter. I'm new to ruby golf but eager to learn so feedback is appreciated.

Jelly, 29 26 bytes


This uses <CSI> (0x9b), which is shorter than <ESC>[ (0x1b 0x5b).

It resets the foreground color with <CSI>m instead of <CSI>0m, as the 0 is implicit.


Note that your terminal emulator (e.g., Konsole) must be set to ISO 8859-1 or similar.


How it works

<200o-“NO“ɓ31m”m“=ȤŻ»Œu“ɓm  Main link. Argument: n (integer)

<200                        Compare with 200, yielding 1 if true, 0 if not.
    o-                      Logical OR -1; map 0 to -1 (and 1 to 1).
      “NO“ɓ31m”             Yield ["NO", "\x9b31m"].
               m            Take the list "modulo" 1 or -1, keeping it as is for 1,
                            reversing it for -1.
                “=ȤŻ»       Implicitly print the previous result and yield the
                            string " vacancy". This is achieved by indexing into
                            Jelly's in-built dictionary.
                     Œu     Convert to uppercase.
                       “ɓm  Implicitly print the previous result and yield the
                            string "\x9bm", which is printed on exit.