Skip to content

Print a clean Pascal's triangle without list artifacts#4

Draft
learnwithallen wants to merge 1 commit into
mainfrom
cursor/pascals-triangle-clean-print-aa1f
Draft

Print a clean Pascal's triangle without list artifacts#4
learnwithallen wants to merge 1 commit into
mainfrom
cursor/pascals-triangle-clean-print-aa1f

Conversation

@learnwithallen

Copy link
Copy Markdown
Owner

Summary

Revises the uploaded triangle.py so it prints a proper Pascal's triangle instead of raw Python lists.

Problem

The original script stored each row as a zero-padded list and left the output as raw lists, so results showed brackets, commas, and padding zeros (e.g. [0, 1, 0]) rather than a readable triangle.

Changes

  • pascals_triangle(num_rows) builds the triangle cleanly, with each interior value being the sum of the two values above it — no zero padding.
  • print_triangle(...) renders each row as space-separated numbers, centered, with no brackets, commas, or padding zeros.

Example output (n = 5)

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1
Open in Web Open in Cursor 

Co-authored-by: learnwithallen <learnwithallen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants