1 / 89

Welcome to Programming Practicum

Driving N on the Dalton Highway… (though it feels like it!). Welcome to Programming Practicum. Harbin!. Victorville, for DARPA's Urban Granc Challenge. Pittsburgh. Waiting for the snow enveloping you on Route 5 N to melt. “Putting the C into CS”. University of St. Petersburg.

milton
Download Presentation

Welcome to Programming Practicum

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Fall '09 Jotto: tied for the longest game yet… Sophs Jrs Srs Others icily 0 icily 0 icily 1 icily 1 strep 2 strep 2 strep 2 strep 1 spork 1 spork 3 spork 0 spork 0 spend 2 spend 2 spend 2 spend 2 peeps 2 peeps 1 peeps 2 peeps 1 furls 1 furls 1 furls 0 furls 1 Ghost 2 Ghost 1 Ghost 1 Ghost 0 Tanks 2 Tanks 1 Tanks 2 Tanks 1 Gecko 2 Gecko 1 Gecko 1 Gecko 1

  4. What is this course about?

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

  6. Last year's ACM regional contest

  7. Ice festival!

  8. in the ice!

  9. Class Organization alternating format discussion sessions lab sessions • teams may use 1 machine per person (only the mock contest adheres to ACM rules) • these problems count for each member of the group • 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 a team might want to practice with only 1 machine • sometimes new problems, other times with known ones • 3~ 4 problems given out per week…

  10. Class Organization Feedback from prior semesters… • there should be an opportunity to start coding “cold” • make individual vs. team-based work clear, lectures vs. labs • problems are, in general, individually completed -- except • those done during the lab "mock contest" sessions • provide the code to all team members • you may or may not choose to work as a team afterwards • submit for each person (email me if there are problems…) • 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! • snacks and jotto! • better support for newcomers and for contest problems!!

  11. Course Organization Jan 19 Welcome! ~ 4-5 problems Jan 26 Lab/Mock contest session: 4 problems Feb 2 No class meeting - trip to finals! Feb 9 Discussion session on geometry problems: 4 problems Feb 16 Lab/Mock contest session: 4 problems Feb 23 Discussion session on search and A*: 4 problems Mar 2 Lab/Mock contest session: 4 problems Mar 9 Discussion session on something you haven't seen! Mar 16 Spring break - no class Mar 30 Finale: mock ACM contest, 4:15pm – 8:15pm, 6 problems I may need help here… You may submit problems until the end of exams… Need a serious programming competition…?

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

  13. Grading CS 189 is graded individually... (it’s possible to take it P/F, too) though not for CS elective credit… 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 <file> to submit on knuth • try things out ! the reason for ACM!

  14. 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++ . Problems are also worth double if they are written up for "the book." the team gets credit, up to 3 people Language Choice? Other "standard" languages: C#, Python, Ruby somewhat reasonable alternatives will also be considered…

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

  16. The "book" Overheard at last fall's contest… We will continue a multi-term effort to create an HMC "book" Problems contributed to the book are worth double, but - need a thorough introductory explanation… a secret weapon? - need to be in Java or C++ (or C) - 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.)

  17. Dynamic programming? Action!

  18. Dynamic programming? practice contest…

  19. Dynamic programming? Action!

  20. Dynamic programming!

  21. Excitement from the judges’ room

  22. Excitement from the judges’ room

  23. 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 and some of the others, too…

  24. Dynamic programming the dollar dayz problem, for example: Input 5 3 Output Costs range from 1 up to this value 5 Amount of money that Farmer Ran has… The number of different combinations of items it is possible to purchase how? Ideas?

  25. Dynamic programming the dollar dayz problem, for example: Input 5 3 Output Costs range from 1 up to this value 5 Amount of money that Farmer Ran has… The number of different combinations of items it is possible to purchase 1 + 1 + 1 + 1 + 1 2 + 1 + 1 + 1 2 + 2 + 1 3 + 1 + 1 3 + 2 Ideas?

  26. Dynamic programming the xoinc problem, for example: Input 5 1 3 1 7 2 Output First player can take 1 or 2 coins from the top 9 The highest total amount the first player can acquire (assuming the second player plays optimally) If the prev player took 1 coin, the next player can take 1 or 2. ? If the prev player took 2 coins, the next player can take 1 to 4 coins. If the prev player took N coins, the next player can take 1 to 2*N coins. Ideas?

  27. Jotto! A word-guessing game similar to mastermind… Sophs Jrs Srs Profs pluot 1 pluot 0 pluot 1 pluot 2 pluot 1 pluot 0 pluot 1 pluot 2 Next Tuesday: Lab bring a laptop, if you have one…

  28. 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 the binary-decimal problem, for example: Output 2 6 3 19 0 Input Numbers, N, up to 106 10 1110 111 11001 the smallestdecimal multiple of N with only the digits 0 and 1 ! 0 marks the end of the input Ideas?

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

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

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

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

  33. Dynamic programming Storing intermediate results in a table for fast look-up: input N = 6 possible remainders upon dividing by N (6) 0 1 2 3 4 5 1 1 1 2 10 11 # of digits in answer 1 3 10 11 110 111 4

  34. Dynamic programming Storing intermediate results in a table for fast look-up: input N = 6 possible remainders upon dividing by N (6) 0 1 2 3 4 5 1 1 1 2 10 11 # of digits in answer 1 3 10 11 110 111 1 1110 10 11 110 111 4

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

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

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

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

  39. Pebbles consider all possibilities for pebbling each row - they only depend on the previous row's best scores! DP Idea Subset chosen (pebbles) Input 000 001 010 011 100 101 110 111 0 3 8 6 7 9 1 4 6 1 1 Row # 2 Store the BEST score available for each possible subset. a b c Square array, up to 15x15, of integers from 1 to 99

  40. Pebbles consider all possibilities for pebbling each row - they only depend on the previous row's best scores! DP Idea Subset chosen (pebbles) Input 000 001 010 011 100 101 110 111 6 8 x 3 9 x x 0 0 3 8 6 7 9 1 4 6 1 1 Row # 2 Store the BEST score available for each possible subset. a b c Square array, up to 15x15, of integers from 1 to 99

  41. Pebbles consider all possibilities for pebbling each row - they only depend on the previous row's best scores! DP Idea Subset chosen (pebbles) Input 000 001 010 011 100 101 110 111 6 8 x 3 9 x x 0 0 3 8 6 7 9 1 4 6 1 0+9 9+0 7+6 8+0 1+3 1 x x x 9 9 13 8 4 Row # 2 a b c Store the BEST score available for each possible subset. Square array, up to 15x15, of integers from 1 to 99

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

  43. Pebbles binary-as-decimal problem "pebbles" problem (2007 ACM regionals) Input 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 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 maximum possible sum 572 Square array, up to 15x15, of integers from 1 to 99 Output place "pebbles" on integers, trying to maximize total, but no two pebbles may be adjacent… code

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

  45. Jotto! A word-guessing game similar to mastermind… Sophs Jrs Srs Me pluot 1 pluot 0 pluot 1 pluot 2

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

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

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

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

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

More Related