I am taking into to computers class using python 3 (codeskulptor3). Compiler is using python 3.5.3 . My assignment is uploaded. Also listed are the four test cases that need to pass. My code below is passing 3 test cases except for test case 0.
Test Cases:
Test Case 0 This test case checks output for correct numbers and format.
Debugging Tip: Ensure the number order, formatting, and flip functions are all accurate.
Test Case 1 This test case calls printArray function directly with alternate array and checks output for correct numbers and format.
Debugging Tip: Examine how printArray formats output.
Test Case 2 This test case calls flipVertical function directly with alternate array. It also checks if output contains the correct pattern.
Debugging Tip: See if flipVertical function flips array vertically.
Test Case 3 This test case calls flipHorizontal function directly with an alternate array and checks if the output contains the correct pattern.
Debugging Tip: Determine if flipHorizontal function flips array horizontally.
My Code:
def printArray(N):
for r in N:
for c in r:
print(c,end = " ")
print()
print()
def flipHorizontal(N):
Array = []
for i in range(0,len(N)):
pos = []
for j in range(0,len(N[0])):
pos.append(N[i][len(N[0])-j-1])
Array.append(pos)
print("Flipped horizontally:")
printArray(Array)
def flipVertical(N):
newArray = []
for i in range(0,len(N)):
newArray.append(N[len(N)-i-1])
print("Flipped vertically:")
printArray(newArray)
def main():
#declare the array2D
array2D = [
[0,2,0,0,0],
[0,2,0,0,0],
[0,2,2,0,0],
[0,2,0,2,0],
[0,2,0,0,2]
]
print('The array:')
#call printArray() to print original array2D
printArray(array2D)
array2D = [
[0,2,0,0,0],
[0,2,0,0,0],
[0,2,2,0,0],
[0,2,0,2,0],
[0,2,0,0,2]
]
#call flipHorizontal() to flip the array2D horizontally
flipHorizontal(array2D)
#declare the array2D again
array2D = [
[0,2,0,0,0],
[0,2,0,0,0],
[0,2,2,0,0],
[0,2,0,2,0],
[0,2,0,0,2]
]
#call flipVertical() to flip the array2D vertically
flipVertical(array2D)
if __name__=="__main__":
main() #Calling main function
When I run the above code, following is the output
The array:
0 2 0 0 0
0 2 0 0 0
0 2 2 0 0
0 2 0 2 0
0 2 0 0 2
Flipped horizontally:
0 0 0 2 0
0 0 0 2 0
0 0 2 2 0
0 2 0 2 0
2 0 0 2 0
Flipped vertically:
0 2 0 0 2
0 2 0 2 0
0 2 2 0 0
0 2 0 0 0
0 2 0 0 0
It looks correct, however complier is giving error message that test case 0 is not passing
SUBMISSION STATUS: wrong answer
programming language: Python 3.x (python 3.5.3)
memory: 27712kB
execution time: 0.06s
Test cases
Test 0 - Output - Output is correct - 0
Test 1 - Function - Function printArray prints correct numbers and format - 1
Test 2 - Function - Function flipVertical prints the input array vertically flipped - 1
Flipping horizontally involves only reversing the order of arrays
Test 3 - Function - Function flipHorizontal prints the input array horizontally flipped - 1
Flipping vertically means leaving order of arrays, but reversing items in each array
Assignment 10 Master Judge - Score: 75
Can you help? Thanks