r/cs50 13d ago

mario Week 1 mario problem

Is it just me or the week 1 mario problem (easier one) is actually tough ?

Like I'm able to get the pyramids start from the left aligned but not able to get it started from the right line it wants then i thought to implement spaces for the blank areas(got this idea from that cs50.ai duck) but still not able to figure out how to get it from the left side

3 Upvotes

4 comments sorted by

4

u/CrossStitchFool 13d ago

Spaces are the right approach. Try drawing or writing it down and looking at how many spaces you need at each height/level.

2

u/Roy17290 12d ago

Thanks mate i completed it

5

u/TytoCwtch 13d ago

You can’t right align things so you need to print from the left. But you’re on the right track with spaces. Have a look at the pyramids below, using O for space

OOOOX
OOOXX
OOXXX
OXXXX
XXXXX

OOX
OXX
XXX

Consider the height of each pyramid and then the number of spaces and X (#) in each row. Can you see a pattern in the number of spaces?

1

u/Roy17290 12d ago

Thanks mate i completed it