Skip to main content
21 events
when toggle format what by license comment
Dec 13, 2017 at 17:07 comment added WhipStreak23 @Kareem Don't be mean and say "Five months is too long for a problem like mario or pretty much any other problem in the course." Put yourself in the other persons shoes
Aug 12, 2015 at 6:04 comment added kzidane @Dani it depends on the situation. you do what you need. in this case, I needed to calculate the initial number of spaces before hand, so I did. but yeah, you should definitely initialize variables before using them.
Aug 12, 2015 at 5:54 comment added user8127 Hi Kareem, thank you for the thorough solution! Is it specific to this Mario problem, or is it common throughout programming, to initialize first and then implement the for loops? I never thought to initialize the number of spaces and hashes THEN to implement the for loops. Is that common elsewhere?
Jul 24, 2015 at 1:25 history edited i_am_david CC BY-SA 3.0
added 2 characters in body
Jun 12, 2015 at 9:55 history edited kzidane CC BY-SA 3.0
added 4 characters in body
Jun 12, 2015 at 9:51 comment added kzidane @OreonutNardlee sorry! that wasn't really correct. edited! thanks for the heads-up!
Jun 12, 2015 at 9:50 history edited kzidane CC BY-SA 3.0
added 4 characters in body
Jun 12, 2015 at 9:16 comment added user7362 Hi Kareem! Thank you so much for providing the answer i have struggled with this for a week and been trying a lot of different methods to try to get it to work. you mentioned "The initial number of spaces to be printed out in terms of the height (i.e., 5) is height - the initial number of hashes." which is 5-2 = 3.. is that suppose to be right? there's supposed to be 4 spaces right? because the end line is 6 hashes
Jun 10, 2014 at 22:11 comment added kzidane There's nothing called an if loop. An if statement is just a condition that its body executed "once" if its true. A loop, on the other hand, has what's known as the loop continuation condition. A loop is different from an if statement in the sense that a loop keeps (repeats) executing its body as long as the loop continuation condition remains true.
Jun 10, 2014 at 22:06 comment added user1175 So an if loop can work as well?
Jun 10, 2014 at 22:02 comment added kzidane At any point where you can add a single statement, you can add a control statement (e.g., if statements and loops).
Jun 10, 2014 at 21:54 comment added user1175 I was talking about the for loops actually. Thank you :)
Jun 10, 2014 at 21:49 comment added kzidane If you're talking about the for loops, then of course yes! :)
Jun 10, 2014 at 21:47 comment added user1175 Is it possible to nest this? I've tried doing it but I got a whole bunch of errors.
Jun 10, 2014 at 21:45 comment added kzidane @user1175, I once was in your place facing troubles building a pyramid so this is familiar. But I can ensure you that over time you'll be familiar with problem solving in general and when you take a look back at this you'll find it pretty simple :) Good luck!
Jun 10, 2014 at 21:39 comment added nickgilling Spend a bit of time thinking about Kareem's algorithm. The relationship between the height and the width (i.e. the number of hashes on the base row) is the first thing to work out, from that you can work out how many spaces are needed for each row and how many hashes.
Jun 10, 2014 at 20:00 comment added user1175 The problem is that I've done it on pen and paper and windows notepad. I've worked on greedy.c as well and I have a much harder time than that. I know 5 months is a long time, mind you, I'm still new to programming and new to the C language. I appreciate the help.
Jun 10, 2014 at 7:48 history edited kzidane CC BY-SA 3.0
added 39 characters in body
Jun 10, 2014 at 7:23 history edited kzidane CC BY-SA 3.0
added 6 characters in body
Jun 10, 2014 at 7:03 review First posts
Jun 27, 2014 at 14:36
Jun 10, 2014 at 6:43 history answered kzidane CC BY-SA 3.0