53
\$\begingroup\$

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!

\$\endgroup\$
9
  • 3
    \$\begingroup\$ 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%. \$\endgroup\$ Commented Dec 24, 2016 at 2:52
  • 1
    \$\begingroup\$ Can you wait 500ms before showing initial output? \$\endgroup\$
    – FlipTack
    Commented Dec 24, 2016 at 11:25
  • 35
    \$\begingroup\$ -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) \$\endgroup\$ Commented Dec 24, 2016 at 11:54
  • 20
    \$\begingroup\$ +1 for using Fahrenheit, it has better resolution than Celsius and is just as arbitrary as anything not Kelvin or Rankine \$\endgroup\$
    – Nick T
    Commented Dec 24, 2016 at 18:20
  • 8
    \$\begingroup\$ @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 \$\endgroup\$
    – phuclv
    Commented Dec 27, 2016 at 12:04

53 Answers 53

40
\$\begingroup\$

Minecraft 1.9.0+, 204 162 bytes + 58 36 28 24 20 blocks = 262 240 232 186 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

RUN! MINECRAFT WILL KILL YOU!

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:

MINECRAFT ABUSE

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...

golfcraft

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:

the soulless monster

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

Oldest solution, Minecraft 1.7.0+, 262 blytes:

the old monster


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) :-)

\$\endgroup\$
8
  • 1
    \$\begingroup\$ @IMustBeSomeone Wait, I found a way to golf this :) \$\endgroup\$
    – user60199
    Commented Dec 25, 2016 at 19:51
  • 1
    \$\begingroup\$ ...your circuit blows itself up when done. \$\endgroup\$ Commented Dec 27, 2016 at 13:13
  • \$\begingroup\$ @SuperJedi224 Yes. Is it wrong? \$\endgroup\$
    – user60199
    Commented Dec 27, 2016 at 13:18
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ Commented Dec 27, 2016 at 13:23
  • \$\begingroup\$ @SuperJedi224 Yeah, code golf and Minecraft shouldn't be put together :) . Thanks for noticing, though. \$\endgroup\$
    – user60199
    Commented Dec 27, 2016 at 13:26
39
\$\begingroup\$

Bash + linux utilities, 19

seq 40 2 72|pv -qlL2

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

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

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:

enter image description here

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
\$\endgroup\$
6
  • \$\begingroup\$ The s in ms is optional, you can remove it to save a byte :) \$\endgroup\$
    – user41805
    Commented Dec 24, 2016 at 9:21
  • \$\begingroup\$ @KritixiLithos I knew that! How did I overlook that? Thanks! \$\endgroup\$
    – DJMcMayhem
    Commented Dec 24, 2016 at 14:56
  • 8
    \$\begingroup\$ The student has become the teacher :P \$\endgroup\$
    – user41805
    Commented Dec 24, 2016 at 14:58
  • 1
    \$\begingroup\$ "I'll post a gif and an explanation later once I have access to a computer" waits half a year (not quite) \$\endgroup\$
    – hyperneutrino
    Commented Mar 5, 2017 at 2:56
  • \$\begingroup\$ @HyperNeutrino Hahahahaha, I completely forgot about this answer. Is that better :P \$\endgroup\$
    – DJMcMayhem
    Commented Mar 6, 2017 at 8:07
10
\$\begingroup\$

JavaScript (ES6), 52 bytes

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

f()

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Dec 25, 2016 at 19:01
  • \$\begingroup\$ 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? \$\endgroup\$
    – R. Kap
    Commented Feb 26, 2017 at 21:52
  • 1
    \$\begingroup\$ @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). \$\endgroup\$ Commented Feb 27, 2017 at 1:53
7
\$\begingroup\$

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µṄœS.+2µ⁴¡  Main link. No arguments.

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.
       +2      Add 2.

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

\$\endgroup\$
3
  • \$\begingroup\$ Wow, is that an intended feature, being able to call other languages from Bash in tio? \$\endgroup\$
    – miles
    Commented Dec 24, 2016 at 20:34
  • 2
    \$\begingroup\$ Yes, that's intended. You should be able to do the same from all languages that support system calls or similar features. \$\endgroup\$
    – Dennis
    Commented Dec 24, 2016 at 20:37
  • \$\begingroup\$ 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 :) \$\endgroup\$
    – AlexRacer
    Commented Dec 25, 2016 at 13:28
6
\$\begingroup\$

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*$_}
\$\endgroup\$
4
  • \$\begingroup\$ Do you need the space after 36? \$\endgroup\$ Commented Dec 24, 2016 at 17:03
  • 2
    \$\begingroup\$ .say&sleep(.5) for 40,42...72 29 bytes \$\endgroup\$
    – ugexe
    Commented Dec 24, 2016 at 19:59
  • \$\begingroup\$ @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? \$\endgroup\$
    – smls
    Commented Dec 27, 2016 at 17:25
  • \$\begingroup\$ @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. \$\endgroup\$
    – smls
    Commented Dec 27, 2016 at 17:34
5
\$\begingroup\$

Pyth - 12 bytes

Very simple, uses a for loop from 0-17.

V17+40yN.d.5
\$\endgroup\$
0
4
\$\begingroup\$

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

\$\endgroup\$
4
\$\begingroup\$

TI-Basic (CE or CSE only), 16 bytes

:For(A,40,72
:Pause A,.5
:End

Note that many commands are single byte tokens.

\$\endgroup\$
4
  • \$\begingroup\$ I see 29 bytes? Is it possible for you to show the 8 byte code? \$\endgroup\$ Commented Dec 24, 2016 at 15:26
  • 1
    \$\begingroup\$ TI-Basic has its own character set. For(, Pause , End, and the colons at the beginning of lines are all single bytes. \$\endgroup\$ Commented Dec 24, 2016 at 16:51
  • \$\begingroup\$ Strange ... alright, it seems like other answers do that too. \$\endgroup\$ Commented Dec 24, 2016 at 16:55
  • 2
    \$\begingroup\$ Relevant: meta.codegolf.stackexchange.com/questions/1541/… \$\endgroup\$
    – Jordan
    Commented Dec 25, 2016 at 5:02
4
\$\begingroup\$

C compiled with Clang 3.8.1 on Linux, 62 59 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
\$\endgroup\$
11
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – isaacg
    Commented Dec 26, 2016 at 9:30
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Wade Tyler
    Commented Dec 26, 2016 at 10:04
  • \$\begingroup\$ 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. \$\endgroup\$
    – isaacg
    Commented Dec 26, 2016 at 10:07
  • 1
    \$\begingroup\$ @isaacg Thanks a lot. It does look better now. \$\endgroup\$
    – Wade Tyler
    Commented Dec 26, 2016 at 10:15
  • 1
    \$\begingroup\$ Using s<72 saves another byte. \$\endgroup\$
    – ranieri
    Commented Dec 27, 2016 at 19:32
4
\$\begingroup\$

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!

\$\endgroup\$
4
  • \$\begingroup\$ You don't need to clear the screen. \$\endgroup\$
    – Adám
    Commented Dec 25, 2016 at 10:22
  • \$\begingroup\$ @Adám Thanks. I know, but it took the same number of bytes and it looks nicer :-) \$\endgroup\$
    – Luis Mendo
    Commented Dec 25, 2016 at 10:24
  • 1
    \$\begingroup\$ @LuisMendo The golf challenge states something about not clearing the screen, after edits/clarifying (possibly after your post) \$\endgroup\$ Commented Dec 27, 2016 at 2:03
  • \$\begingroup\$ @ThomasWard Thanks for the heads-up! The OP really should have notified answerers about the change \$\endgroup\$
    – Luis Mendo
    Commented Dec 27, 2016 at 2:08
3
\$\begingroup\$

Mathematica, 34 bytes

Pause[Print@#;.5]&/@Range[40,72,2]

Full program. Takes no input and outputs to STDOUT.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Initial x=40 does not print 40 at start. You have to start with x=38. \$\endgroup\$
    – rnso
    Commented Dec 24, 2016 at 13:06
  • \$\begingroup\$ Funny, same idea but with a for-loop is exactly the same length. \$\endgroup\$
    – JAD
    Commented Dec 24, 2016 at 19:42
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You could save one byte by using .5 instead of 0.5 \$\endgroup\$
    – univalence
    Commented Dec 24, 2016 at 12:13
  • \$\begingroup\$ @MegaMan Thanks, I hadn't realised that could work \$\endgroup\$
    – AvahW
    Commented Dec 24, 2016 at 16:01
  • \$\begingroup\$ Why not take off the parenthesis around the print statement and use Python 2? \$\endgroup\$
    – FlipTack
    Commented Dec 24, 2016 at 19:41
3
\$\begingroup\$

Ruby, 33 bytes

(40).step(72,2){|n|p n;sleep 0.5}
\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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)

\$\endgroup\$
2
  • \$\begingroup\$ Your first program seems to first wait a long time, then output all the results. \$\endgroup\$
    – devRicher
    Commented Dec 27, 2016 at 11:11
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – hotkey
    Commented Dec 27, 2016 at 11:15
3
\$\begingroup\$

Ruby 31 bytes

20.upto(36){|n|p n*2
sleep 0.5}

Try it online!

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

php, 38 bytes

for(;35>$t+=2;usleep(5e5))echo$t+38,_;

uses underscore as delimiter. Run with -nr.

\$\endgroup\$
2
\$\begingroup\$

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)
    (Thread/sleep 500)))

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.

\$\endgroup\$
2
\$\begingroup\$

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)

\$\endgroup\$
0
2
\$\begingroup\$

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!

Ungolfed

for i=20:36
  disp(2*i)
  sleep(.5)
end
\$\endgroup\$
0
2
\$\begingroup\$

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.

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

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))
\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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>

\$\endgroup\$
2
\$\begingroup\$

Windows Batch - 65 62 61 bytes

btw this is my first PPCG answer

@for /l %%p in (40,2,72)do @echo %%p&@ping 1.1 -n 1 -w 10>nul

This exits when the degree reaches 72.


76 75 bytes - Does not sleep at end

@for /l %%p in (40,2,72)do @echo %%p&if %%p lss 72 @ping 1.1 -n 1 -w 10>nul

Ungolfed and explanation:

@echo off                           - Turns of the prompt(C:\Foo\Bar\Baz>)
for /l %%p in (40,2,72) do (        - For loop that loops from 40 to 72, increase 2 each
    echo %%p                        - Outputs the loop counter(which is the temp.)
    
if %%p lss 72 (                     - If loop counter is less than 72,
        ping -n 1 -w 10 1.1 >nul    - ping an non-existing IP to make delay
                                    
                                    - note: ping will always make 500ms delay
                                    - if waiting time is less than 500ms
    )                               - Closing bracket(if statement)

)                                   - Closing bracket(for statement)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.