Ways to improve this code?
<p>I have to measure the time it takes with varying L values so I want to optimize my code. What I had to do is fill a cubic box (LxLxL) with periodic points (x,y,z) of diameter d that are identical. So far this is what i have:</p>

<pre><code>L=10
d=2

x,y,z = 0,0,0
counter=0

with open("question1.xyz","w") as f:
    while x&lt;=L-d:
        while y&lt;=L-d:
            while z&lt;=L-d:
                f.write('H {} {} {}\n'.format(x,y,z))
                counter=counter+1
                z=z+d
            z=0
            y=y+d
        z,y=0,0
        x=x+d
</code></pre>

<p>I then have to output the file (the .xyz file) that is in this format:</p>

<pre><code>H 0.000000 0.000000 0.000000
H 0.000000 0.000000 1.000000
H 0.000000 0.000000 2.000000
H 0.000000 0.000000 3.000000
H 0.000000 0.000000 4.000000
</code></pre>

<p>Any ideas or suggestions? Thanks in advance!</p>
