###############################################################################
# ---------------- 15-112 Recitation #11: Midterm 1 Review ---------------- #

# 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 :)

# --------------------------------------------------------------------------- #
import string
import copy

###############################################################################
# Reasoning Over Code
###############################################################################
# LEARNING OBJECTIVES
# Review string indexing
# Review approaching reasoning over code problems

import string
def roc1(s):
      L = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] 
      assert(sorted(s) == L)
      for i in range(len(s) // 2):
             assert(ord(s[i]) == ord(s[len(s) - 1 - i]) - 1) 
      subS = "" 
      for i in range(0, len(s), 3): 
             subS += s[i] 
      return (subS == "gabh")


###############################################################################
# nthLitNumber
###############################################################################
# LEARNING OBJECTIVES
# Review the nth template
# Review how to manipulate numbers without strings

'''
Write the function nthLitNumber(n) that takes an integer value n (where we start 
counting from n = 0) and returns the n’th lit number, where a lit number 
(a coined term) is a positive integer with the property that the sum of the 
digits of the number added to the reverse of the number is a perfect square. 

For example, 27 is a lit number because the sum of its digits is 2 + 7 = 9. 
27 reversed is 72, and now 9+72 = 81 which is a perfect square. 32 is not lit 
because 3+2 = 5 and 5 + 23 = 28 which is not a perfect square. The ﬁrst few lit 
numbers are 2, 8, 20, 27, and 68. 

Here are some test cases to further clarify the problem.

assert(nthLitNumber(0) == 2) 
assert(nthLitNumber(1) == 8) 
assert(nthLitNumber(2) == 20) 
assert(nthLitNumber(3) == 27) 
assert(nthLitNumber(4) == 68) 


'''

def nthLitNumber(n):
	return 42

###############################################################################
# Largest Rect of N
###############################################################################
# LEARNING OBJECTIVES
# Review 2D list response questions
# Review approaching free response questions in an exam setting.

'''
Write the function largestRectOfN(L, n) that takes 2 parameters L and n as input. 
The first parameter L is guaranteed to be a non-empty rectangular 2d list filled 
with integers. Your function must find the largest rectangle in L that is filled 
with only n’s. (where n is the second input to the function and is guaranteed to 
be an integer) 

NOTE: Largest is defined in terms of “area”, where the rectangle with the most
 number of n’s is considered to be the largest rectangle.

This function must return a tuple of 4 elements in the form (startRow, startCol, 
endRow, endCol), which correspond to the starting row, starting column and the 
ending row and ending column of the largest rectangle full of n’s in the board. 
(this is inclusive of the start and the end) If no such rectangle exists your 
function must return None.

Here is a test function to further clarify the problem:

def testLargestRectOfN(L, n):
  print(“Testing largestRectOfN…”)
  b1 = [[ 1,2,1,2,1], 
         [ 3,6,6,6,3], 
        [ 2,6,6,6,1],
        [ 1,2,2,3,4]]

  b2 = [[ 1,2,1,2,1], 
        [ 3,6,-1,6,3], 
        [ 2,6,6,6,1],
        [ 1,2,2,3,4]]

  assert(largestRectOfN(b1, 6) == (1, 1, 2, 3))
  assert(largestRectOfN(b1, 4) == (3, 4, 3, 4))
  assert(largestRectOfN(b2, 6) == (2, 1, 2, 3))
  assert(largestRectOfN(b2, 7) == None)
  print(“Passed!”)

'''

def largestRectOfN(L, n):
	return (42)
