# I'm too cold, turn up the temperature

This is my first golf contest.

What you need to do

Build me, in the shortest amount of bytes possible, my AC remote control system. My room is too cold right now, and I'm missing my remote.

Now, I don't want you literally building it or anything, just golf this:

A slow increment of temperature, starting at 40 degrees, and ending at exactly 72. The increment time must always be 500 millis per increment. It can wait another 500ms at the end. I would prefer it to stop however. The increment itself must go up by two each time, like my remote.

You should not clear the screen. You should have newlines.

What should happen

Example output (everything in parentheses shouldn't be outputted).

40
(wait 500 millis)
42
(wait 500 millis)
44
(..repeat until 72..)
72
(stop or wait 500ms)

Keep in mind This is my first golf, so I apologize if this is too hard to golf. :(

Best of luck, golfers!

• Minor thing, but "must always be 500 millis" is fundamentally too strict for any reasonable device. I'd recommend specifying a variance, something like +/-10%. – FryAmTheEggman Dec 24 '16 at 2:52
• Can you wait 500ms before showing initial output? – FlipTack Dec 24 '16 at 11:25
• -1 for using Fahrenheit (not really, but you should at least say you're using it; 40 degrees celsius isn't too cold in the slightest) – John Dvorak Dec 24 '16 at 11:54
• +1 for using Fahrenheit, it has better resolution than Celsius and is just as arbitrary as anything not Kelvin or Rankine – Nick T Dec 24 '16 at 18:20
• @NickT then you're out of luck because this remote's resolution is 2°F which is higher than 1°C. And you can get higher resolution in Celcius than Fahrenheit with a remote that can display 0.5 and much more if it can display to 0.1. Anyway I'm a simple man and can't differentiate between 22 and 23°C so high resolution in this case is useless to me – phuclv Dec 27 '16 at 12:04

# Bash + linux utilities, 19

seq 40 2 72|pv -qlL2

seq generates the numerical output. pv ratelimits it to 2 lines/sec.

• The output -q suppresses goes to STDERR, so I don't think you need it. – Dennis Dec 24 '16 at 3:54
• An excellent demonstration of "do one thing and do it well" with the right tools for the job. :) – Doorknob Dec 24 '16 at 4:08
• Coming close to "anti-golfscript anti-golf" territory. – Vi. Dec 25 '16 at 16:03

# Minecraft 1.9.0+, 204 162 bytes + 58362824 20 blocks = 262240232186 182 blytes

This solution is golfed down, and it can't be seen whole in one, or even two screenshots. Uses two glitches and abuses another two features of the game

This solution uses the same principles as the one below, just a 4 blocks more compact design.

• Abuses the fact that Chain command blocks (green blocks) can't be powered by redstone, only by a singal from a impulse command block (orange).

• Abuses the fact pistons take 0.30 seconds to extend completely, and redstone needs only 0.10s to register a signal.

• Also abuses a twofold glitch to set the timer (TNT) off: the redstone next to the timer (TNT) gets not only powered, but also thinks the TNT is another redstone and powers it.

• On top of all these abuses, the signal shortener (thing under the TNT) is one-use, after it gets powered it changes shape, allowing to pass signal through it to the "incrementer" (topmost orange block)

A bit of explanation on the functionality of it's different parts can be seen in older solutions (but best in the one just below). You can also Try it Offline! (simplified solution incrementing by 4, works only in 1.11+) by running this command in a command block.

### Old solution, Minecraft 1.9.0+, 186 blytes:

Since TNT normally explode after 3.0s in Minecraft, this one has to be placed by a command (/setblock) with a specified fuse. Also uses a more compact design to remove redundant command block (containing 42 bytes) and redstone against the older versions. I'm sure this can't get any lower...

### Older solution, Minecraft 1.9.0+, 232 blytes:

Oops, I found out these older solutions increment by 4...

Uses the 1.9 command block chain feature (green block thing) to save blocks. Also uses a more compact signal shortener then in the older solutions

### Even older solution, Minecraft 1.7.0+, 240 blytes:

Uses a more compact timer (TNT) then the first solution (below).

### Oldest solution, Minecraft 1.7.0+, 262 blytes:

This is so long because of the way Minecraft handles variables:

• To define a variable (int): scoreboard objectives add <variable> dummy

• To set a value to a variable (each entity including players has it's own variable value): scoreboard players set <entity> <variable> <value>

• * can be used as <entity> to select all entities and save bytes.

• only defined variables may be used

• the value of the variable must be set to a number, not a variable

• To increment var1 by var2: scoreboard players operation <entity> var1 += <entity> var2

• <entity> must be a single entity, eg. @p, not *

Screenshots are of my own, dual licenced under WTFPL and what licence SE decides to use today (currently cc by-sa 3.0 with attribution required) :-)

• Wow! You used Minecraft, that is genius! +1 :) – IMustBeSomeone Dec 25 '16 at 17:15
• @IMustBeSomeone Wait, I found a way to golf this :) – RudolfJelin Dec 25 '16 at 19:51
• ...your circuit blows itself up when done. – SuperJedi224 Dec 27 '16 at 13:13
• @SuperJedi224 Yes. Is it wrong? – RudolfJelin Dec 27 '16 at 13:18
• @RudolfL.Jelínek I'm pretty sure it's not actually against the rules, but it is kind of weird. Then again, that's part of what code golf is about. – SuperJedi224 Dec 27 '16 at 13:23

# Vim, 24, 23 bytes/keystrokes

i40<esc>qq:sl500m
Yp2<C-a>q15@q

One byte saved thanks to @Kritixi Lithos!

Written from my phone, tested in mobile vim (which is apparently a real thing).

Here's a gif of it running:

And here is a command-by-command explanation:

i40<esc>            " Insert '40' into the buffer
qq          " Start recording into register 'q'
:sl500m   " Sleep form 500 ms
Y                   " Yank this line
p                  " and paste it on a newline
2<C-a>            " Increment this line twice
q           " Stop recording
15@q       " Callback register 'q' 15 times
• The s in ms is optional, you can remove it to save a byte :) – Cows quack Dec 24 '16 at 9:21
• @KritixiLithos I knew that! How did I overlook that? Thanks! – DJMcMayhem Dec 24 '16 at 14:56
• The student has become the teacher :P – Cows quack Dec 24 '16 at 14:58
• "I'll post a gif and an explanation later once I have access to a computer" waits half a year (not quite) – HyperNeutrino Mar 5 '17 at 2:56

# JavaScript (ES6), 52 bytes

f=(i=40)=>console.log(i)|i-72&&setTimeout(f,500,i+2)

f()

• Here's a more neat re-arrangement of your answer for you: f=(i=40)=>setTimeout(i>70||f,500,i+2,console.log(i)). Sadly, still the same 52 bytes. – Ismael Miguel Dec 25 '16 at 19:01
• Shouldn't this be 50 bytes as you don't need to count the f= based on the meta consensus that anonymous function declarations are allowed? – R. Kap Feb 26 '17 at 21:52
• @R.Kap Good catch, but in this case, the f= is required because the function needs to call itself (as the first parameter to setTimeout). – ETHproductions Feb 27 '17 at 1:53

# Jelly, 13 12 bytes

40µṄœS.+2µ⁴¡

Try it online! The Jelly program is wrapped in a Bash script to prefix each line of output by a timestamp.

### How it works

40             Set the return value to 40.
µ      µ⁴¡  Execute the chain between the two µ 16 times.

Ṅ           Print the return value, followed by a linefeed.
.        Yield 0.5.
œS         Sleep for 0.5 seconds. Yield the previous result.

After the last iteration, the final value of 72 is printed implicitly and the program exits.

• Wow, is that an intended feature, being able to call other languages from Bash in tio? – miles Dec 24 '16 at 20:34
• Yes, that's intended. You should be able to do the same from all languages that support system calls or similar features. – Dennis Dec 24 '16 at 20:37
• For a language that wins golfing challenges and the part of the challenge being incrementing by a constant value, this looks very long to me :) – AlexRacer Dec 25 '16 at 13:28

# Perl 6, 30 bytes

for 20..36 {sleep .5;say 2*$_} Sorry that it looks like un-golfed code, I don't see a way to make it shorter... The version that stops right after the last number, would be 37 bytes: for 20..36 {sleep .5 if$++;say 2*$_} • Do you need the space after 36? – NoOneIsHere Dec 24 '16 at 17:03 • .say&sleep(.5) for 40,42...72 29 bytes – ugexe Dec 24 '16 at 19:59 • @ugexe: Relying on the side-effects of the arguments of non-shortcircuiting operators to happen in order, feels like an implementation-specific hack to me, because AFAIK the language spec doesn't guarantee this. OTOH, maybe for code golf that's okay? – smls Dec 27 '16 at 17:25 • @SeeOneRhino: Yes. A { bracket following another expression without whitespace, is interpreted as the start of a hash ("associative array") subscript. Perl 6 is strict like that, because its grammar was deliberately designed to allow one-pass parsing of source code with (almost) no backtracking. – smls Dec 27 '16 at 17:34 # Pyth - 12 bytes Very simple, uses a for loop from 0-17. V17+40yN.d.5 • Smallest so far, you're tied for first place :) – IMustBeSomeone Dec 25 '16 at 0:58 # TI-Basic (CE or CSE only), 16 bytes :For(A,40,72 :Pause A,.5 :End Note that many commands are single byte tokens. • I see 29 bytes? Is it possible for you to show the 8 byte code? – redstarcoder Dec 24 '16 at 15:26 • TI-Basic has its own character set. For(, Pause , End, and the colons at the beginning of lines are all single bytes. – Julian Lachniet Dec 24 '16 at 16:51 • Strange ... alright, it seems like other answers do that too. – redstarcoder Dec 24 '16 at 16:55 • Our best so far! However, I dunno if I'll count the character set kinda thing. – IMustBeSomeone Dec 25 '16 at 0:58 • – Jordan Dec 25 '16 at 5:02 # MATL, 14 bytes 17:E38+".5Y.@D Try it in MATL Online! You may need to reload the page if it doesn't initially work. ### Explanation 17: % Push array [1 2 ... 17] E % Multiply by 2, element-wise 38+ % Add 38, element-wise. This gives [40 42 ... 72] " % For each k in that array .5Y. % Pause 0.5 seconds @D % Push k and display % End (implicit) ## Old version (before spec change), clearing the screen 17:E38+"5&Xx@D Try it in MATL Online! • You don't need to clear the screen. – Adám Dec 25 '16 at 10:22 • @Adám Thanks. I know, but it took the same number of bytes and it looks nicer :-) – Luis Mendo Dec 25 '16 at 10:24 • @LuisMendo The golf challenge states something about not clearing the screen, after edits/clarifying (possibly after your post) – Thomas Ward Dec 27 '16 at 2:03 • @ThomasWard Thanks for the heads-up! The OP really should have notified answerers about the change – Luis Mendo Dec 27 '16 at 2:08 # Dyalog APL, 20 bytes {⎕DL.5⊣⎕←⍵}¨38+2×⍳17 { the anonymous function ⎕DL delay... .5⊣ half (a second) rather than the value of ⎕← print (with newline) the argument applied to each of 38+ thirty eight plus twice ⍳17 the integers from 1 to 17 # C compiled with Clang 3.8.1 on Linux, 6259 58 bytes 2 bytes saved thanks to @ranisalt s=38;main(){for(;s<74;printf("%d\n",s+=2))usleep(500000);} 59 bytes s=38;main(){for(;s<73;printf("%d\n",s+=2+usleep(500000)));} 62 Bytes s=38;main(){for(;s!=72;){printf("%d\n",s+=2);usleep(500000);}} s=38 # Initializes a global (int) variable, this is only possible in C, in other languages from the C family variables must have an explicit type. main() # Is the main entry point, again as before, in case a type isn't specified C defaults to int printf("%d\n",s+=2) # printf outputs to stdout based on the pattern defined in the first parameter # %d is a placeholder for an int variable # \n appends a newline to stdout # The second parameter increments the s variable and afterwards it goes in the placeholder's spot. usleep(500000) # This function is Linux specific, it takes an int as parameter, it represents how much time the app needs to sleep in microseconds • Thanks for the answer, and welcome to the site. Could you add a bit of explanation for those who aren't as familiar with your language? – isaacg Dec 26 '16 at 9:30 • Thanks for welcoming me. Yeah sure, I can do that. Also, how do I make my post calculate how many bytes it takes? I wrote that myself, but in others' posts it looks different. – Wade Tyler Dec 26 '16 at 10:04 • Everyone writes it themself, there's no auto-calculating feature. Your header uses ** ... ** in markup, whereas the traditional header on this site uses # .... I've edited your answer so you can see how it's done. – isaacg Dec 26 '16 at 10:07 • @isaacg Thanks a lot. It does look better now. – Wade Tyler Dec 26 '16 at 10:15 • Using s<72 saves another byte. – ranisalt Dec 27 '16 at 19:32 # Scratch, 5 blocks (disk space 56.0kb) (sorry for the low resolution!) Self-explanatory, really. The variable value is displayed in a box on the "stage". • Does this not have an increment of 4? (as opposed to 2 as request) – VisualMelon Feb 27 '17 at 12:53 • @VisualMelon Ah, thanks for the notice - I had misunderstood the question before it was edited; I later re-read it and edited my other answer while forgetting this one. Thanks! – RudolfJelin Feb 27 '17 at 18:36 # Mathematica, 34 bytes Pause[Print@#;.5]&/@Range[40,72,2] Full program. Takes no input and outputs to STDOUT. ## R, 49 bytes x=38;while(x<72){Sys.sleep(.5);x=x+2;cat(x,"\n")} Very trivial solution but it does the trick. • Initial x=40 does not print 40 at start. You have to start with x=38. – rnso Dec 24 '16 at 13:06 • Funny, same idea but with a for-loop is exactly the same length. – JAD Dec 24 '16 at 19:42 # Perl 6, 27 bytes sleep .say/2 for 40,42...72 say returns True, which is coerced to a numeric 1 when divided by 2. Unicode shenanigans can get it down to 23 characters: sleep .say/2 for ㊵,㊷…72 But that's 29 UTF-8-encoded bytes. # Python 2, 57 56 55 Bytes import time a=40 while a<73:print a;time.sleep(.5);a+=2 EDIT: -1 Byte thanks to Mega Man -1 Byte thanks to Flp.Tkc • You could save one byte by using .5 instead of 0.5 – Mega Man Dec 24 '16 at 12:13 • @MegaMan Thanks, I hadn't realised that could work – sonrad10 Dec 24 '16 at 16:01 • Why not take off the parenthesis around the print statement and use Python 2? – FlipTack Dec 24 '16 at 19:41 ## Ruby, 33 bytes (40).step(72,2){|n|p n;sleep 0.5} # C#, 95 bytes ()=>{for(int i=40;i<73;i+=2){System.Console.WriteLine(i);System.Threading.Thread.Sleep(500);}}; It is a simple for loop, it waits an extra 500ms at the end. ## QBIC, 21 bytes [44,72,4|?a┘'sleep 1. QBIC starts a FOR-loop, running from 44 to 72 and incrementing the counter by 4 on every loop. It then sleeps for 1 second. QBasic doesn't have a more finegrained control foor sleep, so I've added a . to simulate giving .5 as an argument. # Kotlin, 47 bytes I guess it was not said in the problem statement that solutions should actually contain increment by two, so the 40+2*i is legal here. If written as a regular Kotlin source with main: fun main(args:Array<String>){(0..16).map{println(40+2*it);Thread.sleep(500)}} (77 bytes) UPD: In Kotlin 1.3, args:Array<String> can be removed, so it's 18 bytes less. And in Kotlin Script, the whole program would be (0..16).map{println(40+2*it);Thread.sleep(500)} (47 bytes) • Your first program seems to first wait a long time, then output all the results. – devRicher Dec 27 '16 at 11:11 • @devRicher, seems like you are running it at try.kotlinlang.org. If so, that's a problem of the environment, seems like stdout is not flushed or something. When I run it locally, it behaves as intended. – hotkey Dec 27 '16 at 11:15 # Ruby 31 bytes 20.upto(36){|n|p n*2 sleep 0.5} Try it online! ## Haskell, 67 bytes import System.Posix.Unistd mapM((>>usleep 500000).print)[40,42..70] If you want to go with ghc only, you can save a few bytes by importing GHC.Conc and using threadDelay instead of usleep. # php, 38 bytes for(;35>$t+=2;usleep(5e5))echo\$t+38,_;

uses underscore as delimiter. Run with -nr.

## Clojure, 54 bytes

(doseq[t(range 32 73 2)](println t)(Thread/sleep 500))

Third lisp ftw. Just iterates over the range, printing and sleeping each iteration. Sleeps at the end.

Ungolfed:

(doseq [t (range 32 73 2)]
(println t)

## A version that doesn't sleep at the end, 66 bytes

(doseq[t(range 32 73 2)](println t)(if(< t 72)(Thread/sleep 500)))

Note, these are full programs since the instructions don't specify. Add a byte to each if a function is required.

## Racket 46 bytes

(for((i(range 40 73 2)))(println i)(sleep .5))

Ungolfed:

(define (f)
(for ((i (range 40 73 2)))
(println i)
(sleep .5)))

Command to run: (f)

• Remember, it doesn't have to stop at 72, it can wait another 500ms. :) – IMustBeSomeone Dec 25 '16 at 1:00

# Octave, 38 35 bytes

Saved 3 bytes thanks to @LuisMendo by changing endfor to end

for i=20:36;disp(2*i);sleep(.5);end

Try it online!

I am new to Octave, so this solution still might be golfed further. Any tips are welcome!

for i=20:36
disp(2*i)
sleep(.5)
end

# Python 2, 57 58 Bytes

Edit

Counted as 57 bytes on my handy but TIO says 58 now that I'm back on my own machine so that's my final offer. Interestingly enough TIO doesn't seem to respect the timeout and just waits and then prints out the whole list in one go. Works on QPython for Android and Python 2 on my Ubuntu box so that's good enough for me.

import time
for x in range(40,74,2):print x;time.sleep(.5)

Try it online!

Would be 58 59 in Python 3 so doesn't beat @sonrad10 anyway.

• This would throw a syntax error, you need a colon (not semicolon) after the range(...) – FlipTack Dec 24 '16 at 19:40
• Thanks @Flp.Tkc. It was typed in directly on my handy hense the typo. – ElPedro Dec 24 '16 at 19:44

# R, 44 42 bytes

Straightforward for-loop, there's likely a golfier way. (Also, crossed-out 44 is still regular 44...)

for(i in 20:36*2)cat(i,"\n",Sys.sleep(.5))

# F#, 60 bytes

async{for i in 40..2..72 do printfn"%d"i;do!Async.Sleep 500}

This is an async expression, in order to run it pass it into Async.Start or Async.RunSynchronously.

# Noodel, noncompeting 10 bytes

Cannot compete because Noodel was born after the challenge was created:(

40Ḷ16ñ++ḍh

Try it:)

### How it works

40         # Creates the literal number 40 and places it into the pipe.
Ḷ16      # Loop the following code 16 times.
ñ     # Print what is in the front of the pipe with a new line.
++   # Increment what is in the pipe by two.
ḍh # Delay for a half a second (500ms).

There is not a version of Noodel that supports the syntax used in this answer. Here is a version that is correct:

kȥḶ16ñ⁺2ḍh

<div id="noodel" code="kȥḶ16ñ⁺2ḍh" input="" cols="10" rows="17"></div>

<script src="https://tkellehe.github.io/noodel/noodel-latest.js"></script>
<script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script>