Hot answers tagged

3

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[0] = oldArray[0] */ floor(1/0.5) = 2 /* newArray[1] = oldArray[2] */ floor(2/0.5) = 4 /* newArray[2] = oldArray[4] */ And so on.


2

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 ...


2

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[0][0] 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 ...


1

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 ...


1

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 ...


1

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, ...


1

It looks like your blur function is trying to access a non-existent pixel at image[height-1][width]. If so, that's probably not the only reference outside the boundary of image.


1

I found the solution, it turns out I was supposed to create a copy of the original image to work on.


1

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 ...


1

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 ...


1

I think your insertCost is actually your deleteCost and the other way around.


1

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 while True: user_input = input("Height: ") # isdigit returns True only if all characters are digits, AKA non-negative integer if user_input.isdigit(): h = int(user_input) if 0 &...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible