Lend me your brain
-
I'm sure this is easy for someone but it's giving me a headache. I want this code to print the numbers 1 to 49... help!
for (i = 1; i < 50; i++) { for (j = i+2; j < 50; j++) { Console.print(/*Magic*/); } }
-
Could you add another variable?
for (i = 1; i < 50; i++) { for (j = i+2; j < 50; j++) { var ii = ii+1; Console.print(Math.range(ii, 1, 49)); } }
This will print 1:49.... and then print 49 about 200 more times
-
@dustbro Nice idea :) But I need it to print 1-49 as the loops complete naturally. It's for a progress bar, so having it hang on 49 for a while won't work.
-
Huh? Why not just
for (i = 1; i < 50; i++) { Console.print(i); for (j = i+2; j < 50; j++) { // most important loop in the world... } }
-
@d-healey actually you can't in the second loop, simply because it runs only 47 times...
for (i = 1; i < 50; i++) { var flag = true; for (j = i+2; j < 50; j++) { if (flag){ Console.print(i); flag = false; } } }
-
for (i = 1; i < 50; i++) { for (j = i+2; j < 50; j++) { var ii = ii+1; Console.print(Math.round(ii/23)); } }
This would give you 0:49 in series
-
@dustbro cool solution ;)
Just to add anif not 0
and baam… -
@dustbro That's doesn't work. I get 00000000000000000000000,111111111111111111111111,222222222222222222 etc.
@Christoph-Hart said in Lend me your brain:
Huh? Why not just
for (i = 1; i < 50; i++) { Console.print(i); for (j = i+2; j < 50; j++) { // most important loop in the world... } }
Ooo well this might work
-
OK everybody go home, I found the cleanest solution:
inline function getStart() { return Engine.getHostBpm() * Engine.getSamplesForQuarterBeats(800); } inline function getEnd() { return getStart() + 50 * getDelta(); } inline function getDelta() { return Engine.getFilterModeList()[2] + Math.min(Engine.getSampleRate(), Engine.getDeviceType().length); } for (i = getStart() + getDelta(); i < getEnd(); i += getDelta()) { Console.print((i - getStart()) / getDelta()); }
-