###############################################################################
# ------------- 15-112 Recitation Week 5: 2D-Lists & Animations ------------- #

# This is a starter file of the problems we did in recitation. A good way to
# use this file is to try to re-write problems you saw in recitation from
# scratch. This way, you can test your understanding and ask on Piazza or
# office hours if you have questions :)

# --------------------------------------------------------------------------- #
###############################################################################
# Code Tracing
###############################################################################

import copy
def ct1(L):
    a = L
    b = copy.copy(L)
    c = copy.deepcopy(L)
    a[0] = b[1]
    b[1][1] = c[0][0]
    c[1].append(b[1][0])
    a[0][0] += b.pop()[0]
    return a,b,c
#   Be  careful to get  the brackets    
#   and commas  right!
#   and draw a box-and-arrow diagram!
L = [[1],[2,5]] 
# for val in ct1(L): # uncomment me :)
#     print(val)     # and me
# print(L)           # and me

###############################################################################
# Best Diagonal
###############################################################################
"""
Write the function bestDiagonal, which given an NxN 2D list of ints, finds the
diagonal the goes down and to-the-right with the biggest sum, and returns a
tuple of (startingRow, startingCol, value) of this diagonal.

Note that we are only considering diagonals that go down and to-the-right.
Hint: Write a helper function that, given the 2D list, a row, and a col,
gives the sum for that diagonal starting at that row and col.
"""
def bestDiagonal(L):
    return (42, 42, 42)

def testBestDiagonal():
    print("Testing bestDiagonal...", end="")
    L1 = [[1,2,3],
          [4,5,6],
          [7,8,9]]
    assert(bestDiagonal(L1) == (0,0,15))
    L2 = [[1,2,42],
           [4,5,6],
           [7,8,0]]
    assert(bestDiagonal(L2) == (0,2,42))
    L3 = [[1,2,3],
          [4,5,6],
          [99,8,9]]
    assert(bestDiagonal(L3) == (2,0,99))
    L4 = [[-1,2,-3],
          [-4,-5,6],
          [-7,-8,-9]]
    assert(bestDiagonal(L4) == (0,1,8))
    L5 = [[27]]
    assert(bestDiagonal(L5) == (0,0,27))
    print("Passed!")


###############################################################################
# Simple Animation
###############################################################################
"""
Write an animation that does the following:
- You have a red circle of radius 40 that begins in the middle of the canvas.
  Do not hardcode this value. Use data.width and data.height. 
- If you press the arrow keys, it moves up, left, right, and down.
- If the circle goes off the screen, it wraps back around to the other side.
- If you click inside the circle, it toggles its color between red and blue.

Be sure to abide by MVC conventions. Animations violating MVC will be penalized
and will make me sad :'(
Please visit the website if you'd like to brush up on MVC before starting!
https://www.cs.cmu.edu/~112/notes/notes-animations-part1.html
"""
from tkinter import *

# copy and cite run function from website:
# https://15112.vsecurity.info/notes/notes-animations-part1.html#starter-code
