Class 29 — Friday, April 1

Problem solving at its best

The Magnificent – Seven problems for practice – Let's do them today


Look both ways


Agenda


Paired Programming

  • One person poses as the navigator, who is not typing-- this is the person who pitches ideas about how to solve problems, or what line of code to add next.
  • One person is the driver, and they are the only person touching the keyboard. This person is often listening to the ideas that the navigator is laying out, maybe catching a few errors, and translating actions into code.
  • Today, we require that you switch roles at least once, halfway through the class. You are welcome to switch more often!

Requirements


Module magnificent.py


Function future_me( a, y )

a 20 year-old will be 84 in 2086

a 19 year-old will be 96 in 2099


Function manhattan_distance( a1, s1, a2, s2 )


Manhattan distance example


Corners ( 6 , 59 ) and ( 7 , 34 ) are 1.4 miles apart

Corners ( 2 , 47 ) and ( 6 , 238 ) are 10.15 miles apart



Function relate( x, y )

kiwi == Kiwi

apple < banana

orange > melon


Function youngest( y )

a 19 year-old can date a 16 year-old

a 22 year-old can date a 18 year-old


Function is_dateable( y1, y2 )

a 15 year-old can date a 22 year-old is True

a 22 year-old can date a 15 year-old is False

a 19 year-old can date a 18 year-old is True


Function mutually_dateable( y1, y2 )

a 25 year-old can date a 65 year-old and vice-versa is False

a 20 year-old can date a 18 year-old and vice-versa is True


Function middle( s )

Middle of abcde is c

Middle of abcdef is cd

Middle of abcd is bc

  • If n is odd, what is the middle index of s?
  • If n is even, what are the middle indices of s?

magnificent seven poster

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.