chevron_left chevron_right
Login Register invert_colors photo_library
Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Bronze Python Challenge filter_list
Author
Message
RE: Python Challenge #4
Well, the world will be amazed, I just came up with a stunning solution.
Code:
import sys

def pad(n):
    sys.stdout.write(" " * n)

for a in range(0, 1):
    pad(3)
    for b in range(0, 1):
        sys.stdout.write("*")

    pad(3)
    print("")

    pad(2)
    for b in range(0, 3):
        sys.stdout.write("*")

    pad(2)
    print("")

    pad(1)
    for b in range(0, 5):
        sys.stdout.write("*")

    pad(1)
    print("")

    for b in range(0, 7):
        sys.stdout.write("*")

    print("")

    pad(1)
    for b in range(0, 5):
        sys.stdout.write("*")

    pad(1)
    print("")

    pad(2)
    for b in range(0, 3):
        sys.stdout.write("*")

    pad(2)
    print("")

    pad(3)
    for b in range(0, 1):
        sys.stdout.write("*")

    pad(3)
    print("")
Don't gag... I did. Tongue
No, jk... I will really try in a bit. xD

Hmm... actually I just came up with a compact solution. It follows all your rules, but I don't think it works the way you were intending. It's really funny how simple it is...
Code:
import sys

design = [
    "   *   ",
    "  ***  ",
    " ***** ",
    "*******",
    " ***** ",
    "  ***  ",
    "   *   "
]

for y in design:
    for x in y:
        sys.stdout.write(x)

    print("")
(This post was last modified: 10-19-2015, 04:51 AM by m0dem.)

[+] 1 user Likes m0dem's post
Reply




Messages In This Thread
Python Challenge - by Nil - 10-18-2015, 07:42 PM
RE: *Simple* Python Challenge - by Eclipse - 10-18-2015, 08:12 PM
RE: *Simple* Python Challenge - by Nil - 10-18-2015, 08:21 PM
RE: Python Challenge - by m0dem - 10-19-2015, 04:45 AM
RE: Python Challenge - by Nil - 10-19-2015, 03:23 PM
RE: Python Challenge - by m0dem - 10-19-2015, 03:30 PM
RE: Python Challenge - by Nil - 10-19-2015, 03:43 PM
RE: Python Challenge - by Eclipse - 10-19-2015, 08:06 AM
RE: Python Challenge - by Rick - 11-14-2015, 08:19 PM
RE: Python Challenge - by Megan - 12-12-2015, 01:22 PM
RE: Python Challenge - by Nil - 12-12-2015, 07:59 PM
RE: Python Challenge - by Megan - 12-12-2015, 08:03 PM
RE: Python Challenge - by Nil - 12-12-2015, 08:49 PM
RE: Python Challenge - by Megan - 12-12-2015, 08:52 PM
RE: Python Challenge - by Nil - 12-12-2015, 08:55 PM
RE: Python Challenge - by Megan - 12-12-2015, 08:56 PM



Users browsing this thread: 1 Guest(s)