I'm dealing with that at the moment, and as far as I can tell the form is
newArray[i] = oldArray[(int)floor(i / factor)]
Then, if factor = 0.5
floor(0/0.5) = 0 /* newArray = oldArray */
floor(1/0.5) = 2 /* newArray = oldArray */
floor(2/0.5) = 4 /* newArray = oldArray */
And so on.
De acuerdo a las especificaciones:
Stored in each element of the matrix should be a tuple, (cost,
operation), where cost is an int and operation is an Operation.
So what does the line of code mean?. Means that we assign the values of the tuple to two variables but the first of them is ignored, only the second value is of interest to us. Sometimes this ...
except for the first element, which is supposed to have no operation, but I gave it an Operation.SUBSTITUTED
And this is probably the problem, since that operation subtracts 1 from i and j, which means when matrix is dealt with, i and j both get set to -1, which will be out of range.
Perhaps you should be using None instead of Substituted for the ...
Here's a really big hint. The right edge and bottom edge pixels are all bad, but the left and top are OK (except top right and bottom left).
Have you taken a careful look at the limits for the right and bottom edges? Also what about how the right edge pixels are set?
I suggest you carefully examine how the top right pixel is calculated vs. what it should ...
Look at the print line:
print(f" " * spaces, "#" * (i + 1), "", "#" * j)
Python will print a space after each element (ie, each item separated from the next by a comma). That means that it's printing the spaces, followed by an extra space. It's also printing a space after the first group of #s. Interestingly, the ...
There are multiple issues with the code. The height has to be between 1 and 8 inclusive. Your code will not allow a height of 8. Also, the user should be asked for the height until a proper number is given. Then, the program should print the two half pyramids. In your code, if there is a wrong input, then you question them once more and then exit. Also, ...
It looks to me like the code is writing the output padding after factor lines have been written out, not after EACH line.
Say that factor is 3. The code writes out the current line of pixels out 3 times, but only writes out the padding after the 3rd line is finished. It should be writing out the padding at the end of each line.
The code needs a little ...
Your problem is different than what you think it is. You don't seem to have scratched the surface. Have you watched the walkthrough?
First, you don't change all the headers you need to change, and the one you change is not to the right value (3 bytes per pixel, and we also have padding per line).
Then, while it's right each input pixel will be written n*n ...
The output shown makes no sense to me, but int will throw an error if the value is not the representation of an integer.
You can for example use it like
user_input = input("Height: ")
# isdigit returns True only if all characters are digits, AKA non-negative integer
h = int(user_input)
if 0 &...
No, the output is not correct, not in all cases. Look closely at how the code executes. The outer for loop appears to be intended to count the letters consumed in the name string, but because of the inner loops, i is actually counting the number of spaces. The inner loop is consuming the letters, counting them with k.
Essentially, the interaction of the ...