Skip to main content
added 2 characters in body
Source Link
i_am_david
  • 1.2k
  • 7
  • 33

Five months is too long for a problem like or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to right.

Suppose the input is 5, we should get the following output:...

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get information like:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is

    height + 1 - the initial number of hashes
    
  2. The initial number of hashes is 2.

  3. The number of spaces decreases each row until it becomes 0 in the last row.

  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using this information, we could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (i = 0 to i < height, increment i)
    // draw spaces
    for (j = 0 to j < spaces, increment j)
        print a space

    // draw hashes
    for (j = 0 to j < hashes, increment j)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes

Five months is too long for a problem like or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to right.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get information like:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is

    height + 1 - the initial number of hashes
    
  2. The initial number of hashes is 2.

  3. The number of spaces decreases each row until it becomes 0 in the last row.

  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using this information, we could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (i = 0 to i < height, increment i)
    // draw spaces
    for (j = 0 to j < spaces, increment j)
        print a space

    // draw hashes
    for (j = 0 to j < hashes, increment j)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes

Five months is too long for a problem like or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to right.

Suppose the input is 5, we should get the following output...

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get information like:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is

    height + 1 - the initial number of hashes
    
  2. The initial number of hashes is 2.

  3. The number of spaces decreases each row until it becomes 0 in the last row.

  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using this information, we could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (i = 0 to i < height, increment i)
    // draw spaces
    for (j = 0 to j < spaces, increment j)
        print a space

    // draw hashes
    for (j = 0 to j < hashes, increment j)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
added 4 characters in body
Source Link
kzidane
  • 17.7k
  • 3
  • 28
  • 100

Five months is too long for a problem like mario or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to write as the computer doesright.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get a lot of info such asinformation like:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is height + 1 - the initial number of hashes.

    The initial number of spaces to be printed out in terms of the height (i.e., 5) is

    height + 1 - the initial number of hashes
    
  2. The initial number of hashes is 2.

    The initial number of hashes is 2.

  3. The number of spaces decreases each row until it becomes 0 in the last row.

    The number of spaces decreases each row until it becomes 0 in the last row.

  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

    The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using thesethis information and a little more, Iwe could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (int i = 0;0 to i < height;height, i++increment i)
{
    // draw spaces
    for (int j = 0;0 to j < spaces;spaces, j++increment j)
        print a space

    // draw hashes
    for (int j = 0;0 to j < hashes;hashes, j++increment j)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
}

Kareem

Five months is too long for a problem like mario or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to write as the computer does.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get a lot of info such as:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is height + 1 - the initial number of hashes.
  2. The initial number of hashes is 2.
  3. The number of spaces decreases each row until it becomes 0 in the last row.
  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using these information and a little more, I could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (int i = 0; i < height; i++)
{
    // draw spaces
    for (int j = 0; j < spaces; j++)
        print a space

    // draw hashes
    for (int j = 0; j < hashes; j++)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
}

Kareem

Five months is too long for a problem like or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to right.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get information like:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is

    height + 1 - the initial number of hashes
    
  2. The initial number of hashes is 2.

  3. The number of spaces decreases each row until it becomes 0 in the last row.

  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using this information, we could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (i = 0 to i < height, increment i)
    // draw spaces
    for (j = 0 to j < spaces, increment j)
        print a space

    // draw hashes
    for (j = 0 to j < hashes, increment j)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
added 4 characters in body
Source Link
kzidane
  • 17.7k
  • 3
  • 28
  • 100

Five months is too long for a problem like mario or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to write as the computer does.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get a lot of info such as:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is height + 1 - the initial number of hashes.
  2. The initial number of hashes is 2.
  3. The number of spaces decreases each row until it becomes 0 in the last row.
  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using these information and a little more, I could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (int i = 0; i < height; i++)
{
    // draw spaces
    for (int j = 0; j < spaces; j++)
        print a space

    // draw hashes
    for (int j = 0; j < hashes; j++)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
}

Kareem

Five months is too long for a problem like mario or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to write as the computer does.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get a lot of info such as:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is height - the initial number of hashes.
  2. The initial number of hashes is 2.
  3. The number of spaces decreases each row until it becomes 0 in the last row.
  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using these information and a little more, I could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (int i = 0; i < height; i++)
{
    // draw spaces
    for (int j = 0; j < spaces; j++)
        print a space

    // draw hashes
    for (int j = 0; j < hashes; j++)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
}

Kareem

Five months is too long for a problem like mario or pretty much any other problem in the course.

You could try solving it manually with low-tech tools (e.g., a pencil and a paper) trying to draw half a pyramid row-by-row from top to bottom and left to write as the computer does.

Suppose the input is 5, we should get the following output:

    ##
   ###
  ####
 #####
######

By analyzing the problem, we can get a lot of info such as:

  1. The initial number of spaces to be printed out in terms of the height (i.e., 5) is height + 1 - the initial number of hashes.
  2. The initial number of hashes is 2.
  3. The number of spaces decreases each row until it becomes 0 in the last row.
  4. The number of hashes increases by 1 until it becomes height + 1 in the last row.

Using these information and a little more, I could write the following pseudocode (assuming height is a valid integer inputted by the user):

calculate the initial number of spaces in terms of height
calculate the initial number of hashes in terms of height

// draw the rows
for (int i = 0; i < height; i++)
{
    // draw spaces
    for (int j = 0; j < spaces; j++)
        print a space

    // draw hashes
    for (int j = 0; j < hashes; j++)
        print a hash
    
    move to the next row
    decrement the number of spaces
    increment the number of hashes
}

Kareem

added 39 characters in body
Source Link
kzidane
  • 17.7k
  • 3
  • 28
  • 100
Loading
added 6 characters in body
Source Link
kzidane
  • 17.7k
  • 3
  • 28
  • 100
Loading
Source Link
kzidane
  • 17.7k
  • 3
  • 28
  • 100
Loading