CS 60 Slides - PowerPoint PPT Presentation

About This Presentation
Title:

CS 60 Slides

Description:

Mailing something at the Claremont Post Office ... Leading a Gray Davis / Gary Coleman / Arnold 'T-800' Schwarzenegger gubernatorial fundraiser ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 81
Provided by: Kel7163
Learn more at: https://www.cs.hmc.edu
Category:

less

Transcript and Presenter's Notes

Title: CS 60 Slides


1
Driving N on the Dalton Highway (though it feels
like it!)
Welcome to Programming Practicum
Victorville, for DARPA's Urban Granc Challenge
Pittsburgh
Putting the C into CS
University of St. Petersburg
Waiting for the snow enveloping you on Route 5 N
to melt
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 arent here
Worldcom Headquarters
On fire just W of here!!
Krispy Kremes 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
dodds_at_cs.hmc.edu
Email
fan of low-tech games
fan of low-level AI
3
ACM Jotto finale Fall '08
Frosh
Sophs
Jrs
Srs
Others
pluto 0
pluto 2
pluto 3
pluto 1
pluto 1
andes 1
andes 1
andes 0
andes 2
andes 1
wired 1
wired 1
wired 1
wired 1
wired 0
xenon 1
xenon 1
xenon 1
xenon 1
xenon 0
tenet 1
tenet 0
tenet 0
tenet 3
tenet 0
clack 2
clack 1
clack 1
clack 0
clack 1
grime 1
grime 1
grime 1
grime 1
grime 0
these 0
these 1
these 0
these 4
these 1
flour 0
flour 2
flour 2
flour 1
flour 1
This set the record for the longest jotto game
I've played at Mudd!
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
What
Program design and implementation
ACM programming contest
Hands-on practice with algorithms and techniques
Why
Familiarity with Javas libraries OR your choice
of language
"reasonable"
Research/prototype programming
Unofficial course name CS -70
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
  • 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

8
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 12 (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!!

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 100am, 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
Nov 7 _at_ RCC
You may submit problems until the end of exams
Sat. Nov. 7 will be the regional contest
10
Course webpage
references
problem statements and sample data
problems you have solved
administrative info
11
Grading
CS 189 is graded individually... (its 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 ltfilegt to submit on knuth
  • try things out !

the reason for ACM!
12
Problem credits
Problems are worth double if
  • You solve them during the 415 - 530 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
13
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
2
8 (2)
13 (10)
14 (9)
1
21 (16) (4)
1
1
15 (14)
number of 2x scores
number of 4x scores
python 82 java 60 C 40
d 8 ruby 6 scheme 3
lua 2 awk 2 js 2
sql cobol basic x86 asm pascal mathematica sh,
latex
Tallies per problem and per language (thus far)
1 each
14
The "book"
Overheard at last fall's contest
We will begin a multi-term effort to create an
HMC "book"
Problems contributed to the book are worth
triple, 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.)
15
Dynamic programming?
No action shots?
16
Dynamic programming!
17
Excitement from the judges room
18
Excitement from the judges room
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
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 smallest decimal multiple of N with only the
digits 0 and 1 !
0 marks the end of the input
Ideas?
22
One way
Count up to the solution, starting from 1
insight from CS 60!
adding digits changes the error (remainder) in
predictable ways
23
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
24
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
25
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
26
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
111
110
4
27
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
111
110
1
1110
111
110
10
11
4
28
DP!
Only checking values for which a remainder has
not yet been used
Fast
29
Problem Set 0
(3-4 problems)
0-multiple, too!
In teams of 23, read over these
Only students new to ACM may do this one for
credit
I need a picture of Farmer Ran!
30
Problem Set 0
(3-4 problems)
In teams of 23, 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 !

31
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
32
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?
33
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
34
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
6
8
x
3
9
x
x
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
35
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
6
8
x
3
9
x
x
0
3 8 6 7 9 1 4 6 1
09
13
90
76
80
1
x
x
x
9
4
9
13
8
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
36
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
6
8
x
3
9
x
x
0
3 8 6 7 9 1 4 6 1
09
13
90
76
80
1
x
x
x
9
4
9
13
8
Row
x
x
x
2
c13
b9
a9
013
?
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?
37
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
38
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!
39
Jotto!
A word-guessing game similar to mastermind
Sophs
Jrs
Srs
Me
pluot 1
pluot 0
pluot 1
pluot 2
40
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
41
Problem Set 1
(6 probs, 3 wks)
Input
4 4 tow cat row care ... .. ... . 0 0
Problem 1 cat ao row e Problem 2 no
layout is possible.
either the solution OR a statement that it can't
be solved
Output
42
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
43
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
44
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
45
Problem Set 1
(6 probs, 3 wks)
Input
list of traits, R "recessive" D "dominant"
D traits are passed if EITHER parent has them
RDDR Speedy M 0101 Jumper F 0101 Slowpoke M
1101 Terror F 1100 Shadow F 1001 Frisky
0101 Sleepy 1101
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
list of traits, R "recessive" D "dominant"
D traits are passed if EITHER parent has them
RDDR Speedy M 0101 Jumper F 0101 Slowpoke M
1101 Terror F 1100 Shadow F 1001 Frisky
0101 Sleepy 1101
R traits are passed if BOTH parents have them
all of the parents, gender, and traits
the baby bunnies
Deduce their possible parents!
Frisky by Jumper-Slowpoke or Jumper-Speedy or
______ Sleepy by _________
Output
47
Problem Set 1
(6 probs, 3 wks)
Input
list of traits, R "recessive" D "dominant"
D traits are passed if EITHER parent has them
RDDR Speedy M 0101 Jumper F 0101 Slowpoke M
1101 Terror F 1100 Shadow F 1001 Frisky
0101 Sleepy 1101
R traits are passed if BOTH parents have them
all of the parents, gender, and traits
the baby bunnies
Deduce their possible parents!
Frisky by Jumper-Slowpoke or Jumper-Speedyor
Shadow-Speedy Sleepy by Shadow-Slowpoke
Output
48
Problem Set 1
(6 probs, 3 wks)
Read these three problems then
Decide which problem is the easiest and which one
is the hardest (to code, not to compute!)
49
Problem Set 1
(6 probs, 3 wks)
my estimates
important heuristic Im always wrong
hardest
easiest
50
See you next Tuesday in the CS labs !
51
Driving N on the Dalton Highway (though it feels
like it!)
Welcome to Programming Practicum
Pittsburgh
Putting the C into CS
University of St. Petersburg
Waiting for the snow enveloping you on Route 5 N
to melt
Engineering dept.
exploring martian soil
On the 405, in traffic, being chased by police
(and TV) helicopters.
You arent here
Worldcom Headquarters
Krispy Kremes drive through
writing clinic reports
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
52
What is this course about?
  • A chance to improve your programming skills

Algorithm analysis and insight
optimizing coding time
What
Program design and implementation
ACM programming contest
Hands-on practice with algorithms and techniques
Why
Familiarity with Javas libraries OR your choice
of language
Research/prototype programming
Unofficial course name CS -70
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!
2 per team
2/team
3 per team
1-4 / team
You may submit problems until the end of exams
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
problem statements and test data
problems your team has solved
administrative info
56
Grading
CS 189 is graded individually... (its 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 ltfilegt to submit
  • try things out !

the reason for ACM!
57
Choose your language
Java is almost the universal choice for the
competition
  • extensive library of data structures and
    algorithms available
  • I/O made simpler with 1.5s Scanner and printf

Input from stdin Output to stdout
the C in CS!
58
Choose your language
Python is nice
C
Whatever language you choose needs to be able to
run on the Macs in the CS labs (and preferably
knuth, as well)
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) DDij
min(Dij, Dik Dkj) DD, D
D, DD return D
Ill likely need your help to get things set up
for testing
Others ?
Marty prolog!
59
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
60
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
61
Problem Set 1
(6 probs, 3 wks)
Input
list of traits, R "recessive" D "dominant"
D traits are passed if EITHER parent has them
RDDR Speedy M 0101 Jumper F 0101 Slowpoke M
1101 Terror F 1100 Shadow F 1001 Frisky
0101 Sleepy 1101
R traits are passed if BOTH parents have them
all of the parents, gender, and traits
the baby shrews
Deduce their possible parents!
Frisky by Jumper-Slowpoke or Jumper-Speedy or
______ Sleepy by _________
Output
62
Problem Set 1
(6 probs, 3 wks)
Read these three problems then
Decide which problem is the easiest and which one
is the hardest (to code, not to compute!)
63
Coaches Room
64
Choose your language
Java/Cthe universal choice for the competition
  • extensive library of data structures and
    algorithms available
  • I/O made simpler with 1.5s Scanner and printf

Input from stdin Output to stdout
the C in CS!
65
Choose your language
Python is nice
Postscript!
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) DDij
min(Dij,
Dik Dkj) DD, D D, DD
return D
Ruby -)
Marty prolog!
66
Driving N on the Dalton Highway (though it feels
like it!)
Welcome to Programming Practicum
Victorville, for DARPA's Urban Granc Challenge
Pittsburgh
Putting the C into CS
University of St. Petersburg
Waiting for the snow enveloping you on Route 5 N
to melt
Engineering dept.
exploring martian soil
On the 405, in traffic, being chased by police
(and TV) helicopters.
You arent here
Worldcom Headquarters
Krispy Kremes drive-through
writing clinic reports
Waiting in line to vote in the Florida primaries
rebooting knuth (or turing or)
Waiting in line to vote in the Florida primaries
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
67
What is this course about?
  • A chance to improve your programming skills

Algorithm analysis and insight
optimizing coding time
What
Program design and implementation
ACM programming contest
Hands-on practice with algorithms and techniques
Why
Familiarity with Javas libraries OR your choice
of language
Research/prototype programming
Unofficial course name CS -70
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
  • 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 (or email me)
  • problems per person per week?
  • 2 in the fall
  • 3 in the spring
  • snacks and jotto!

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
Sat. Mar 8 and Sat. Apr 19 external competitions
www.ieee.org/web/membership/students/scholarshipsa
wardscontests/ieeextreme.html
72
Course webpage
references
problem statements and test data
problems you have solved
administrative info
73
Grading
CS 189 is graded individually... (its 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 ltfilegt to submit
  • try things out !

the reason for ACM!
74
Problem multipliers
Problems are worth double if
  • You solve them during the 415 - 530 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

the team gets credit, up to 3 people
languages already used
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
Output
2 6 3 19 0
Input
10 1110 111 11001
the smallest decimal multiple of N with only the
digits 0 and 1 !
Numbers, N, up to 106
0 marks the end of the input
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)
0
1
2
3
4
5




1
1
1
2
10
11
of digits in answer
1
3
10
11
111
110
1
1110
111
110
10
11
4
78
DP!
Only checking values for which a remainder has
not yet been used
79
Problem Set 1
(4 problems)
- divide up with one problem per group -
In teams of 3, think about
- how would you solve this problem?
- is it a dynamic programming problem?
- how could you most simplify the programming ?
- think of a 5-letter jotto word !
80
Competition Options
www.ccsc.org/southwestern/2008/contest.html
Sat. Mar 8 and Sat. Apr 19 external competitions
www.ieee.org/web/membership/students/scholarshipsa
wardscontests/ieeextreme.html
Write a Comment
User Comments (0)
About PowerShow.com