day1/exercise/arm.py
author Christopher Burns <chris.d.burns@gmail.com>
Tue, 29 Jun 2010 00:30:21 -0500
branchscipy2010
changeset 431 9126059d6b37
parent 425 5afcfce15e71
permissions -rw-r--r--
DOC: Add slide about __module__ attribute.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
cubes = []
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
for i in range(10):
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
    cubes.append(i ** 3)
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
for i in range(100, 1000):
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     6
    ones = i % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     7
    tens = (i / 10) % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     8
    hundreds = (i / 100) % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     9
    if i == cubes[ones] + cubes[tens] + cubes[hundreds]:
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
        print "Armstrong Number: ", i