Post History
Combine loops Suppose you have a for loop in another, maybe a couple of times, and nothing else inside of the outer for loops (except for the first for loop since anything outside won't be involve...
#1: Initial revision
# Combine loops
Suppose you have a `for` loop in another, maybe a couple of times, and nothing else inside of the outer `for` loops (except for the first `for` loop since anything outside won't be involved at all). It's probably a `range()` problem again.
If you're doing something like this:
<!-- language-all: lang-python -->
<pre><code>x=10;y=15
for i in range(x):
	for j in range(y):
		print(i,"-",j)
</code></pre>
[Try it online!][TIO-ktfugtxg]
[TIO-ktfugtxg]: https://tio.run/##K6gsycjPM/7/v8LW0MC60tbQlCstv0ghUyEzT6EoMS89VaNC04qLEySWhRCrBIlxFhRl5pVoZOoo6SrpZGn@/w8A "Python 3 – Try It Online"
You can simply set the loop as one:
<!-- language-all: lang-python -->
x=10;y=15
for i in range(x*y):print(i//y,"-",i%y)
[Try it online!][TIO-ktfujaan]
[Python 3]: https://docs.python.org/3/
[TIO-ktfujaan]: https://tio.run/##K6gsycjPM/7/v8LW0MC60tbQlCstv0ghUyEzT6EoMS89VaNCq1LTqqAoM69EI1Nfv1JHSVdJJ1O1UvP/fwA "Python 3 – Try It Online"
Golfing 16 bytes in total. You can do this with more loops, but this is what's functional for now.
