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!! Harbin!

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

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

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, not running 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 contest

7 Ice festival!

8 in the ice!

9 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

10 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!!

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 You may submit problems until the end of exams… Need a serious programming competition…? I may need help here…

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

13 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…

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++. 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."

15 A prior term's summary: languages python 82 java 60 C++ 40 Tallies per problem and per language… 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

16 The "book" Overheard at last fall's contest… We will continue 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 double, 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…

17 Dynamic programming? Action!

18 Dynamic programming? practice contest…

19 Dynamic programming? Action!

20 Dynamic programming!

21 Excitement from the judges’ room

22

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: 5 3 The number of different combinations of items it is possible to purchase Input Amount of money that Farmer Ran has… 5 Output Ideas? Costs range from 1 up to this value how?

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

26 Dynamic programming the xoinc problem, for example: 513172513172 The highest total amount the first player can acquire (assuming the second player plays optimally) Input If the prev player took 1 coin, the next player can take 1 or 2. 9 Output Ideas? First player can take 1 or 2 coins from the top ? 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.

27 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

28 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!

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

30 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

31 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:

32 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:

33 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:

34 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:

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

36 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!

37 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?

38 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?

39 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.

40 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

41 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

42 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

43 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

44 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

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

46 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…

47 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.

48 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

49 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…

50 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…

51 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!

52 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 _________

53 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

54 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

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

56 See you next Tuesday in the CS labs… !

57 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!)

58 Excitement from the judges’ room

59 Backpacks not permitted…

60 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

61 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

62 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…

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

64 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!

65 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

66 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!

67 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…

68 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…

69 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 _________

70 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

71 Coaches’ Room

72 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

73 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!

74 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!

75 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…

76 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

77 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…

78 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

79 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…

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…

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

82 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!

83 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…

84 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?

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

86 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

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

88 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 -

89 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