Skip to content

Instantly share code, notes, and snippets.

@jsgoller1
Last active June 25, 2021 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsgoller1/e0ac9b45e271bf39f7d0426db750bb65 to your computer and use it in GitHub Desktop.
Save jsgoller1/e0ac9b45e271bf39f7d0426db750bb65 to your computer and use it in GitHub Desktop.
Everyone has to start somewhere....
"""
This was the first challenging programming assignment I ever tried to complete,
given as an early homework question when I took CS220 (Introduction to Programming with Python)
in Fall 2011 at the College of Charleston (we had just learned about conditionals and iteration).
I was 21 years old, and was learning computer programming for the very first time.
The prompt was: "write a program that takes as input a symbol and a number, then prints a center-justified
pyramid of the given symbols and the height of the given number."
I stayed overnight in the computer lab, chugging energy drinks and banging my head against the desk
trying to figure it out. I probably spent around 8 hours staring at the computer screen, mystified by how difficult
it was. I'm not kidding. I went through multiple attempts to figure it out, failing each time and producing probably
30 or 40 lines of code each time. In the morning, one of the seniors came in before class and showed me a solution
(using nested loops).
I retried this problem in August 2020, approximately 9 years after that first attempt. It took 3 minutes,
half of which was spent figuring out how to get the pyramid to look pretty.
Everyone has to start somewhere.
"""
def pyramid(symbol, count):
for level in range(count):
print((level * (symbol + " ")).center(count * 2))
pyramid("", 3)
pyramid("#", 3)
pyramid("$", 5)
pyramid("A", 10)
pyramid("A", 0)
@ahmaazouzi
Copy link

I had similar situations. For example, when I first tried to read the C Programming Language, i struggled with this exercise about drawing a vertical histogram of character frequencies. I Could easily solve the horizontal version, but had no idea where to even start to do the vertical version. A couple years later, I could've easily solve. I didn't read anything specific about that problem or worked with anything similar. The solution just came naturally. I kinda feel like there is some type of learning which we don't and cannot track that somehow happens in the background of our minds from constant exposure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment