21
1
Summary
Write a program or function, which doesn't take any input, and outputs all the integer numbers, between -1000 and 1000 in ascending order, to the stdout, one per line, like this:
-1000
-999
-998
-997
...
And after that you need to print the time taken to print these numbers, or the time from the start of the program's execution in milliseconds (if necessary, it can also contain some other things, for example: time taken:xxxms is ok). It can be a float, or an integer (if you print an integer, you need to round down to the nearest).
Example code
using System;
using System.Diagnostics;
class P
{
static void Main(string[] args)
{
Stopwatch st = Stopwatch.StartNew();
for (int i = -1000; i <= 1000; i++)
{
Console.WriteLine(i);
}
Console.WriteLine(st.ElapsedMilliseconds);
}
}
Restrictions
Standard loopholes are not allowed
Other infos
It's code golf, so the shortest submission wins.
@GurupadMamadapur No, sorry – Horváth Dávid – 2017-01-14T18:15:11.327
Why? I think essentially to print those numbers every statement is involved from the start of the program right? – Gurupad Mamadapur – 2017-01-14T18:19:04.403
1@GurupadMamadapur Ok, you're right, I will edit the question accordingly. – Horváth Dávid – 2017-01-14T18:32:26.693
Can the program wait some amount of time from the start, and print that amount? – xnor – 2017-01-15T01:54:05.703
@xnor I think, that would change the challenge, and because there are already lots of answers to the original challenge, I would say no. – Horváth Dávid – 2017-01-15T10:29:55.270
Can I write an answer in Arduino? – SIGSTACKFAULT – 2017-01-17T17:01:30.767
@Blacksilver Yes, why not? – Horváth Dávid – 2017-01-17T19:32:26.553
Arduino has a built-in for time since start. Muahaha! – SIGSTACKFAULT – 2017-01-17T20:53:40.407
@Blacksilver I think, that's fine. – Horváth Dávid – 2017-01-17T21:46:50.343
Can the time output contain anything else besides the raw time in milliseconds? Would "Time taken: 500ms" be ok? – Carcigenicate – 2017-01-18T16:39:57.393
@Carcigenicate Yes, it would be ok. – Horváth Dávid – 2017-01-18T20:28:40.953
@HorváthDávid Oh good. Manually handling time is like a third of my answer. – Carcigenicate – 2017-01-18T20:46:42.057