Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting.

Similar presentations


Presentation on theme: "Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting."— Presentation transcript:

1 Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting knuth (or turing or…) installing Debian 3.1 the dumpster University of St. Petersburg On the 405, in traffic, being chased by police (and TV) helicopters. Mailing something at the Claremont Post Office Waiting for the snow enveloping you on Route 5 N to melt Krispy Kreme’s drive-through Teaching Honors English for Janice Barbee at Pomona High School Worldcom Headquarters Leading a Gray Davis / Gary Coleman / Arnold “T-800” Schwarzenegger gubernatorial fundraiser exploring martian soil Being dragged off-course 18 miles into a marathon race by a crazed spectator Massey University Palmerston North, NZ Pittsburgh Driving N on the Dalton Highway… (though it feels like it!) Victorville, for DARPA's Urban Granc Challenge Waiting in line to vote in the Florida primaries… Denver, CO or Minneapolis, MN DC for the inauguration On fire just W of here!!

2 Introductions! Zach Dodds dodds@cs.hmc.edu Office Olin 1255 Email fan of low-tech games fan of low-level AI

3 FroshSophsJrsSrsOthers pluto 0pluto 2pluto 3pluto 1 andes 1 andes 0andes 2andes 1 wired 1 wired 0 xenon 1 xenon 0 tenet 1tenet 0 tenet 3tenet 0 clack 2clack 1 clack 0clack 1 grime 1 grime 0 these 0these 1these 0these 4these 1 flour 0flour 2 flour 1 ACM Jotto finale: Fall '08 This set the record for the longest jotto game I've played at Mudd!

4 What is this course about?

5 A chance to “improve” your programming skills Algorithm analysis and insight Program design and implementation optimizing coding time ACM programming contest What Why Research/prototype programming Hands-on practice with algorithms and techniques Unofficial course name: CS -70 Familiarity with Java’s libraries OR your choice of language "reasonable"

6 Last year's ACM regional programming contest Aaron Pribadi, Stuart Persteiner, and Daniel Lubarov Anak Yodpinyanee + Jason GarretGlaser Kevin Oelze, Andrew Hunter, and Kwang Ketcham Marquis Wang, Josh Ehrlich, and Daniel Fielder

7 Class Organization alternating format discussion sessions lab sessions problem and program analysis discussion of strategy and coding tips deciding on functional decomposition, data structures, language facilities, and algorithms to use in teams of 2-3 teams may use 1 machine per person (only the mock contest adheres to ACM rules) these problems count for each member of the group sometimes new problems, other times with known ones 3~ 4 problems given out per week… a team might want to practice with only 1 machine

8 Class Organization Feedback from prior semesters… make individual vs. team-based work clear, lectures vs. labs problems are, in general, individually completed -- except there should be an opportunity to start coding “cold” snacks and jotto! problems per person per week? about 1~2 (if you work on a team in lab) and consider all of the weeks of the term! those done during the lab "mock contest" sessions submit for each person (email me if there are problems…) provide the code to all team members you may or may not choose to work as a team afterwards better support for newcomers and for contest problems!!

9 Course Organization Sep 1 Welcome! Review? of dynamic programming: 3 problems Sep 8 Lab/Mock contest session: 4 problems Sep 15 Discussion session on graph problems: 3 problems Sep 22 Lab/Mock contest session: 4 problems Sep 29 Discussion session on geometry problems: 3 problems Oct 6 Lab/Mock contest session: 4 problems Oct 13 Discussion session on search problems: 3 problems Oct 20 Mock ACM contest, 9pm – 1:00am, 6 problems Oct 27 Lab/Mock contest session: 2 problems Nov 3 Regional participants' -- preparation meeting Nov 10 Discussion and wrap-up for the semester You may submit problems until the end of exams…Sat. Nov. 7 will be the regional contest Nov 7 @ RCC

10 Course webpage references administrative info problem statements and sample data problems you have solved

11 Grading CS 189 is graded individually... (it’s possible to take it P/F, too) Coding Guidelines problems can be done any time during the semester discussion of algorithms always OK coding should be within teams you may use any references except an existing solution or partial solution… one person should take the lead on each problem use /cs/ACM/acmSubmit to submit on knuth try things out ! the reason for ACM! though not for CS elective credit…

12 Problem credits Problems are worth double if You solve them during the 4:15 - 5:30 lab sessions It's one of the "extra difficult" problems, which may be determined as we go… Any standard language is OK -- but do keep in mind that the competition allows only Java, C, and C++. Other "standard" languages: the team gets credit, up to 3 people somewhat reasonable alternatives will also be considered… C#, Python, Ruby Language Choice? Problems are also worth double if they are written up for "the book."

13 A prior term's summary: languages python 82 java 60 C++ 40 Tallies per problem and per language (thus far)… 17 (+2) 8416 (+2) 1 (+1) 6 (+1) 20 (+12) (+2) 3 (+1) 11211 (+1) 1 (+1) 17 (+9) (+2) 4 (+2) 1 228328 (+2) 13 (+10) 14 (+9) 121 (+16) (+4) 1115 (+14) number of 2x scores number of 4x scores d 8 ruby 6 scheme 3 lua 2 awk 2 js 2 sql cobol basic x86 asm pascal mathematica sh, latex 1 each

14 The "book" Overheard at last fall's contest… We will begin a multi-term effort to create an HMC "book" - need to be in Java or C++ (or C) a secret weapon? Problems contributed to the book are worth triple, but - need to be beautifully formatted - need to be fully commented - need to be useful for people who did not write it! - variable names and other constructs ~ evident Sign up for a problem if you want to do this. (It's OK to work in a team of 2 or 3, as well.) - need a thorough introductory explanation…

15 Dynamic programming? No action shots?

16 Dynamic programming!

17 Excitement from the judges’ room

18

19 Backpacks not permitted…

20 Dynamic programming When a seemingly intractable problem has lots of repeated substructure, go DP! Build a table of partial results. Replace computation with table look-up when possible For example:

21 Dynamic programming Build a table of partial results. Replace computation with table look-up when possible the binary-decimal problem, for example: 2 6 3 19 0 Numbers, N, up to 10 6 Input 0 marks the end of the input 10 1110 111 11001 the smallest decimal multiple of N with only the digits 0 and 1 ! Output Ideas? When a seemingly intractable problem has lots of repeated substructure, go DP!

22 One way… Count up to the solution, starting from 1… adding digits changes the error (remainder) in predictable ways insight: from CS 60!

23 Dynamic programming Storing intermediate results in a table for fast look-up: input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4

24 input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4 1 Dynamic programming Storing intermediate results in a table for fast look-up:

25 input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4 1 1011 1 Dynamic programming Storing intermediate results in a table for fast look-up:

26 input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4 1 111110 1011 1 1011 1 Dynamic programming Storing intermediate results in a table for fast look-up:

27 input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4 1 111110 1011 1 1011 1 1110 111110 1011 1 Dynamic programming Storing intermediate results in a table for fast look-up:

28 DP! Only checking values for which a remainder has not yet been used… Fast

29 Problem Set #0 (3-4 problems) In teams of 2~3, read over these… I need a picture of Farmer Ran! Only students new to ACM may do this one for credit… 0-multiple, too!

30 Problem Set #0 (3-4 problems) In teams of 2~3, read over these & discuss: Where might the structure of the problem depend on similar (but smaller!) substructure? Think of your class's next 5-letter jotto word or guess… ! How might you build up a table of values toward an overall solution? How difficult are they? Which might be DP?

31 Jotto! SophsJrsSrsProfs A word-guessing game similar to mastermind… pluot 1pluot 0pluot 1pluot 2 Next Tuesday: Lab bring a laptop, if you have one… pluot 1pluot 0pluot 1pluot 2

32 Another example binary-as-decimal problem "pebbles" problem (2007 ACM regionals) Square array, up to 15x15, of integers from 1 to 99 Input Output Idea place "pebbles" on integers, trying to maximize total, but no two pebbles may be adjacent… maximum possible sum 14? 3 8 6 7 9 1 4 6 1 vertically, horizontally, or diagonally 3 8 6 7 9 1 4 6 1 naïve running time?

33 Pebbles 3 8 6 7 9 1 4 6 1 Square array, up to 15x15, of integers from 1 to 99 Input DP Idea consider all possibilities for pebbling each row - they only depend on the previous row's best scores! Subset chosen (pebbles) 000001010011100101110111 Row # 0 1 2 abc Store the BEST score available for each possible subset.

34 3 8 6 7 9 1 4 6 1 Square array, up to 15x15, of integers from 1 to 99 Input DP Idea consider all possibilities for pebbling each row - they only depend on the previous row's best scores! Subset chosen (pebbles) 000001010011100101110111 Row # 0 1 2 abc Store the BEST score available for each possible subset. 0 68x39xx Pebbles

35 3 8 6 7 9 1 4 6 1 Square array, up to 15x15, of integers from 1 to 99 Input DP Idea consider all possibilities for pebbling each row - they only depend on the previous row's best scores! Subset chosen (pebbles) 000001010011100101110111 Row # 0 1 2 abc Store the BEST score available for each possible subset. 0 68x39xx 9 0+9 4 1+3 9 9+0 13 7+6 8 8+0 xxx Pebbles

36 3 8 6 7 9 1 4 6 1 Square array, up to 15x15, of integers from 1 to 99 Input DP Idea consider all possibilities for pebbling each row - they only depend on the previous row's best scores! Subset chosen (pebbles) 000001010011100101110111 Row # 0 1 2 abc Store the BEST score available for each possible subset. 0 68x39xx 9 0+9 4 1+3 9 9+0 13 7+6 8 8+0 xxx xxx 0+13 c +13 b +9 a +9 ? running time? What is the best here? Pebbles

37 binary-as-decimal problem "pebbles" problem (2007 ACM regionals) 71 24 95 56 54 85 50 74 94 28 92 96 23 71 10 23 61 31 30 46 64 33 32 95 89 Square array, up to 15x15, of integers from 1 to 99 Input Output 71 24 95 56 54 85 50 74 94 28 92 96 23 71 10 23 61 31 30 46 64 33 32 95 89 Idea place "pebbles" on integers, trying to maximize total, but no two pebbles may be adjacent… maximum possible sum 572 code Pebbles

38 Thanks, Martijn! Scanner sc = new Scanner(System.in); even a bit easier! Martijn is shifty! Martijn is VERY shifty! Where is the table? This sure is sum code… to the max

39 Jotto! SophsJrsSrsMe A word-guessing game similar to mastermind… pluot 1pluot 0pluot 1pluot 2

40 Problem Set #1 (6 probs, 3 wks) Input 4 tow cat row care....#.....## 0 # of words in the puzzle (to follow) # of rows in the puzzle (after the words) the words the puzzle this indicates the end of the input…

41 Problem Set #1 (6 probs, 3 wks) Input 4 tow cat row care....#.....## 0 either the solution OR a statement that it can't be solved… Output Problem 1 cat a#o row e## Problem 2: no layout is possible.

42 Problem Set #1 (6 probs, 3 wks) Input 6 5 1 1 2 2 3 4 5 1 3 2 1 4 2 1 0 0 # of empty boxes on the form # of clerks in the office (three lines each) clerk #0 this indicates the end of the input… the box(es) CHECKED the box(es) ERASED the clerks who get a copy clerk #1 clerk #2 clerk #3 clerk #4 012345 the form

43 Problem Set #1 (6 probs, 3 wks) Input 6 5 1 1 2 2 3 4 5 1 3 2 1 4 2 1 0 0 # of empty boxes on the form # of clerks in the office (three lines each) clerk #0 this indicates the end of the input… the box(es) CHECKED the box(es) ERASED the clerks who get a copy clerk #1 clerk #2 clerk #3 clerk #4 012345 the form let's try it…

44 Problem Set #1 (6 probs, 3 wks) Input 6 5 1 1 2 2 3 4 5 1 3 2 1 4 2 1 0 0 # of empty boxes on the form # of clerks in the office (three lines each) clerk #0 this indicates the end of the input… the box(es) CHECKED the box(es) ERASED the clerks who get a copy clerk #1 clerk #2 clerk #3 clerk #4 012345 the form Output 1 3 4 5 the boxes checked the last time it leaves clerk #0's desk…

45 Problem Set #1 (6 probs, 3 wks) Input RDDR Speedy M 0101 Jumper F 0101 Slowpoke M 1101 Terror F 1100 Shadow F 1001 *** Frisky 0101 Sleepy 1101 *** list of traits, R == "recessive" D == "dominant" D traits are passed if EITHER parent has them R traits are passed if BOTH parents have them all of the parents, gender, and traits the baby shrews… Deduce their possible parents!

46 Problem Set #1 (6 probs, 3 wks) Input RDDR Speedy M 0101 Jumper F 0101 Slowpoke M 1101 Terror F 1100 Shadow F 1001 *** Frisky 0101 Sleepy 1101 *** list of traits, R == "recessive" D == "dominant" D traits are passed if EITHER parent has them R traits are passed if BOTH parents have them all of the parents, gender, and traits the baby bunnies… Deduce their possible parents! Output Frisky by Jumper-Slowpoke or Jumper-Speedy or ______ Sleepy by _________

47 Problem Set #1 (6 probs, 3 wks) Input RDDR Speedy M 0101 Jumper F 0101 Slowpoke M 1101 Terror F 1100 Shadow F 1001 *** Frisky 0101 Sleepy 1101 *** list of traits, R == "recessive" D == "dominant" D traits are passed if EITHER parent has them R traits are passed if BOTH parents have them all of the parents, gender, and traits the baby bunnies… Deduce their possible parents! Output Frisky by Jumper-Slowpoke or Jumper-Speedy or Shadow-Speedy Sleepy by Shadow-Slowpoke

48 Problem Set #1 (6 probs, 3 wks) Decide which problem is the easiest and which one is the hardest … (to code, not to compute!) Read these three problems… then

49 Problem Set #1 (6 probs, 3 wks) my estimates… hardest easiest important heuristic: I’m always wrong

50 See you next Tuesday in the CS labs… !

51 Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting knuth (or turing or…) installing Debian 3.1 Engineering dept. the dumpster University of St. Petersburg On the 405, in traffic, being chased by police (and TV) helicopters. Mailing something at the Claremont Post Office Waiting for the snow enveloping you on Route 5 N to melt Krispy Kreme’s drive through Teaching Honors English for Janice Barbee at Pomona High School Worldcom Headquarters Leading a Gray Davis / Gary Coleman / Arnold “T-800” Schwarzenegger gubernatorial fundraiser exploring martian soil Being dragged off-course 18 miles into a marathon race by a crazed spectator Massey University Palmerston North, NZ Pittsburgh Driving N on the Dalton Highway… (though it feels like it!)

52 What is this course about? A chance to “improve” your programming skills Algorithm analysis and insight Program design and implementation optimizing coding time ACM programming contest What Why Research/prototype programming Hands-on practice with algorithms and techniques Unofficial course name: CS -70 Familiarity with Java’s libraries OR your choice of language

53 Course Organization Jan 16 Welcome! Random teams of 3: 6 problems, 3 weeks Jan 23 Lab session to work on problems (Beckman B102 or 105) Jan 30 Discussion session on the first set of problems Feb 6 Lab session with new problems: 4 problems, 2 weeks Feb 13 Discussion session on the second set of problems Feb 20 Lab session with new problems: 6 problems, 3 weeks Feb 27 Discussion session on the third set of problems Mar 6 No class - Fall break Mar 20 Mock ACM contest, 9pm – 1am, teams of 3, 6 pr, 4 hours Mar 27 No class (out of town) Apr 3 Discussion session on the mock contest + Finale! You may submit problems until the end of exams… 2 per team 2/team 3 per team 1-4 / team

54 Class Organization alternating format discussion sessions lab sessions problem and program analysis discussion of strategy and coding tips deciding on functional decomposition, data structures, language facilities, and algorithms to use in teams of 2-3 teams should use 1 terminal per person (only the mock contest adheres to ACM rules) these problems count for each member of the group sometimes new problems, other times with known ones ~1 problem per week per person…

55 Course webpage reference links administrative info problem statements and test data problems your team has solved

56 Grading CS 189 is graded individually... (it’s possible to take it P/F, too) Coding Guidelines problems can be done any time during the semester discussion of algorithms always OK coding should be within teams you may use any references except an existing solution or partial solution… one person should take the lead on each problem use /cs/ACM/acmSubmit to submit try things out ! the reason for ACM!

57 Choose your language… extensive library of data structures and algorithms available Java is almost the universal choice for the competition… I/O made simpler with 1.5’s Scanner and printf the C in CS! Input from stdin Output to stdout

58 Choose your language… Python is niceC# Whatever language you choose needs to be able to run on the Macs in the CS labs (and preferably knuth, as well…) I’ll likely need your help to get things set up for testing… def floyd_warshall(W, infinity): n = matrix.get_num_rows(W) D = matrix.clone(W) DD = matrix.make(n,n) for k in xrange(n): for i in xrange(n): for j in xrange(n): DD[i][j] = min(D[i][j], D[i][k] + D[k][j]) DD, D = D, DD return D Others ? Marty: prolog!

59 Problem Set #1 (6 probs, 3 wks) Input 4 tow cat row care....#.....## 0 # of words in the puzzle (to follow) # of rows in the puzzle (after the words) the words the puzzle this indicates the end of the input…

60 Problem Set #1 (6 probs, 3 wks) Input 6 5 1 1 2 2 3 4 5 1 3 2 1 4 2 1 0 0 # of empty boxes on the form # of clerks in the office (three lines each) clerk #0 this indicates the end of the input… the box(es) CHECKED the box(es) ERASED the clerks who get a copy clerk #1 clerk #2 clerk #3 clerk #4 012345 the form Output 1 3 4 5 the boxes checked the last time it leaves clerk #0's desk…

61 Problem Set #1 (6 probs, 3 wks) Input RDDR Speedy M 0101 Jumper F 0101 Slowpoke M 1101 Terror F 1100 Shadow F 1001 *** Frisky 0101 Sleepy 1101 *** list of traits, R == "recessive" D == "dominant" D traits are passed if EITHER parent has them R traits are passed if BOTH parents have them all of the parents, gender, and traits the baby shrews… Deduce their possible parents! Output Frisky by Jumper-Slowpoke or Jumper-Speedy or ______ Sleepy by _________

62 Problem Set #1 (6 probs, 3 wks) Decide which problem is the easiest and which one is the hardest … (to code, not to compute!) Read these three problems… then

63 Coaches’ Room

64 Choose your language… extensive library of data structures and algorithms available Java/Cthe universal choice for the competition… I/O made simpler with 1.5’s Scanner and printf the C in CS! Input from stdin Output to stdout

65 Choose your language… Python is nice def floyd_warshall(W, infinity): n = matrix.get_num_rows(W) D = matrix.clone(W) DD = matrix.make(n,n) for k in xrange(n): for i in xrange(n): for j in xrange(n): DD[i][j] = min(D[i][j], D[i][k] + D[k][j]) DD, D = D, DD return D Ruby :-) Marty: prolog! Postscript!

66 Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting knuth (or turing or…) installing Debian 3.1 Engineering dept. the dumpster University of St. Petersburg On the 405, in traffic, being chased by police (and TV) helicopters. Mailing something at the Claremont Post Office Waiting for the snow enveloping you on Route 5 N to melt Krispy Kreme’s drive-through Teaching Honors English for Janice Barbee at Pomona High School Worldcom Headquarters Leading a Gray Davis / Gary Coleman / Arnold “T-800” Schwarzenegger gubernatorial fundraiser exploring martian soil Being dragged off-course 18 miles into a marathon race by a crazed spectator Massey University Palmerston North, NZ Pittsburgh Driving N on the Dalton Highway… (though it feels like it!) Victorville, for DARPA's Urban Granc Challenge Waiting in line to vote in the Florida primaries…

67 What is this course about? A chance to “improve” your programming skills Algorithm analysis and insight Program design and implementation optimizing coding time ACM programming contest What Why Research/prototype programming Hands-on practice with algorithms and techniques Unofficial course name: CS -70 Familiarity with Java’s libraries OR your choice of language

68 Class Organization alternating format discussion sessions lab sessions problem and program analysis discussion of strategy and coding tips deciding on functional decomposition, data structures, language facilities, and algorithms to use in teams of 2-3 teams should use 1 machine per person (only the mock contest adheres to ACM rules) these problems count for each member of the group sometimes new problems, other times with known ones ~3 problems per week per person…

69 Class Organization Feedback from prior semesters… make individual vs. team-based work clear, lectures vs. labs problems are, in general, individually completed, except there should be an opportunity to start coding “cold” snacks and jotto! problems per person per week? ~2 in the fall ~3 in the spring those done during the lab "mock contest" sessions submit for each person (or email me…) provide the code to all team members you may or may not choose to work as a team afterwards

70 Course Organization Jan 29 Welcome! Review of dynamic programming: 4 problems Feb 5 Lab/Mock contest session: 4 problems Feb 12 Discussion session on geometry problems: 4 problems Feb 19 Lab/Mock contest session: 4 problems Feb 26 Lab/Mock contest session: 4 problems Mar 4 Discussion session on search problems: 4 problems Mar 11 No class… need to be away Mar 18 No class - Spring break Mar 23 Mock ACM contest, 9pm – midnight, 6 problems Mar 25 Discussion and wrap-up of the semester You may submit problems until the end of exams… Sat. Mar 8 and Sat. Apr 19 external competitions…

71 Competition Options www.ccsc.org/southwestern/2008/contest.html www.ieee.org/web/membership/students/scholarshipsawardscontests/ieeextreme.html Sat. Mar 8 and Sat. Apr 19 external competitions…

72 Course webpage references administrative info problem statements and test data problems you have solved

73 Grading CS 189 is graded individually... (it’s possible to take it P/F, too) Coding Guidelines problems can be done any time during the semester discussion of algorithms always OK coding should be within teams you may use any references except an existing solution or partial solution… one person should take the lead on each problem use /cs/ACM/acmSubmit to submit try things out ! the reason for ACM!

74 Problem multipliers Problems are worth double if You solve them during the 4:15 - 5:30 lab sessions You are the first person to use a particular language - though there is an additional responsibility here: to set up the testing system to handle that language! It's one of the "extra difficult" problems, which will be determined as we go… languages already used: the team gets credit, up to 3 people python 56 ruby 12 java 6 c++ 11 perl 2 postscript 2 c# 8 haskell 1 prolog 2 c 5 php 1 These multipliers may be accumulated…

75 Dynamic programming When a seemingly intractable problem has large amounts of repeated or redundant substructure, DP can sometimes provide an efficient solution. Build a table of partial results. Replace computation with table look-up when possible For example: 2 6 3 19 0 Numbers, N, up to 10 6 Input 0 marks the end of the input 10 1110 111 11001 the smallest decimal multiple of N with only the digits 0 and 1 ! Output Ideas?

76 One way… Count up to the solution, starting from 1…

77 Dynamic programming Storing intermediate results in a table for fast look-up: input N = 6 possible remainders upon dividing by N (6) # of digits in answer 012345 2 1 3 4 1 111110 1011 1 1011 1 1110 111110 1011 1

78 DP! Only checking values for which a remainder has not yet been used…

79 Problem Set #1 (4 problems) In teams of ~3, think about - how would you solve this problem? - how could you most simplify the programming ? - think of a 5-letter jotto word… ! - is it a dynamic programming problem? - divide up with one problem per group -

80 Competition Options www.ccsc.org/southwestern/2008/contest.html www.ieee.org/web/membership/students/scholarshipsawardscontests/ieeextreme.html Sat. Mar 8 and Sat. Apr 19 external competitions…


Download ppt "Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports clinic liaison phone call coding chunky strings rebooting."

Similar presentations


Ads by Google