Superstitious hotel elevator
Bash + common utils, 51
seq 9$1|sed 13d\;/4/d\;1i-1|rs 0 2|sed $[$1/2]q|tac
seq
generates ascending integers from 1 to N with an extra 9 digit in front - more than enough for 64bit integer inputsed
filters out the unlucky floors and inserts-1
before line 1rs
reshapes into two tab-separated columnssed
stops after N/2 linestac
reverses output line order
JavaScript ES6, 236 234 233 210 195 188 bytes
Saved a whole bunch 'a bytes thanks to usandfriends!
Uses the function*
for generators. Probably a shorter way to do this, but it was fun. Way fun. I'll bet some golfing can be done. Those weird whitespace things are tabs.
z=prompt(i=x=0,l=[]);y=(function*(){while(i<z-x)yield(i?(/4/.test(i)||i==13?--x&&".":i):-1)+(0*++i)})();while(a=y.next().value)+a&&l.push(a);l.join` `.match(/-?\d+ \d+/g).reverse().join`
`
Pyth, 27 bytes
jjLC9_c+_1.f&!@\4`ZnZ13tQ)2
Try it online here.
Gets .f
irst Q-1
numbers that match the filter !=13
and 4
isn't in the string representation of the number. Then it prepends -1
, chops in half, joins each by tabs(C9
) and joins by newlines.