3 桁の走行距離計として機能するサイズ N のリストのすべての可能な出力を生成したいと考えています。たとえば、N = 4 の場合、次の出力が必要です。
0000 1000 2000 3000 0100 1100 ... 3332 3333.
これが私のコードです。どんな助けも大歓迎です!
odom = [0]*N ## initialize odometer
print odom
while odom[N-1] <= 3:
idx = 1
odom[0] += 1
if odom[0] > 3:
while odom[idx] > 3:
idx += 1
for i in range(idx):
odom[i] = 0
print odom