2018-03-29 HW

posted Mar 29, 2018, 6:16 AM by Konstantinovich Samuel   [ updated Apr 8, 2018, 6:04 AM ]
HW1 server slot: Hanoi
Submit hanoi sometime today. (It should have been done already)
Your program should not print anything when run, I will run my own tests.

Make sure the following command would work:
hanoi(2,"A","B","C")

Make sure the output is EXACTLY:
move from A to B
move from A to C
move from B to C

HW2:
fill out the google doc: (fill out your period correctly to get credit)

Extra:
Trees:
I will have an extra credit slot for the tree!



Classwork Complete at home:

Since a list can be modified, it is sometimes useful to write functions that change the contents of a list. 
***Sadly these kinds of functions cannot be tested on codingbat, so you need to thoroughly test your code to be sure that it works. 

1. Write a function that takes a list of strings and MODIFIES IT by swapping the first and last words.
w = ["a", "b", "c", "j", "k"]
swapStuff(w)
print w # shows:  ["k", "b", "c","j","a"]

2. Write a function that takes a list of integers and MODIFIES IT by deleting all negative values
s = [-9,1,-2,3,-4,-3,5,6,-7,-12,8]
removeNegs( s )
print s  #shows [1,3,5,6,8] 

y = [-21,-2,13,3,-14,12,5,6,-7,8]
removeNegs( y )
print y  #shows [13,3,12,5,6,8]

The function does not return a value. 

3. Write a function that takes a list of integers and MODIFIES IT by moving all negative values to the end of the list (in the same order)
s = [1,-2,3,-4,5,6,-7,8]
moveNegsToEnd( s )
print s  #shows [1,3,5,6,8,-2,-4,-7] 

y = [-21,-2,13,3,-14,12,5,6,-7,8]
moveNegsToEnd( y )
print y  #shows [13,3,12,5,6,8,-21,-2,-14,-7]

The function does not return a value. 


Comments