Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
musicinformationretrieval-com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
A.S.
musicinformationretrieval-com
Commits
4dd8f47d
Commit
4dd8f47d
authored
Aug 01, 2018
by
Steve Tjoa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gh-pages' of github.com:stevetjoa/musicinformationretrieval.com into gh-pages
parents
2352f6cd
c4a271d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
dp.html
dp.html
+18
-19
dp.ipynb
dp.ipynb
+14
-4
No files found.
dp.html
View file @
4dd8f47d
...
...
@@ -11776,9 +11776,8 @@ div#notebook {
<div
class=
"prompt input_prompt"
>
In
[1]:
</div>
<div
class=
"inner_cell"
>
<div
class=
"input_area"
>
<div
class=
" highlight hl-ipython2"
><pre><span></span><span
class=
"o"
>
%
</span><span
class=
"k"
>
matplotlib
</span>
inline
<span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
seaborn
</span>
<span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
numpy
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
scipy
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
scipy.spatial
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
matplotlib.pyplot
</span>
<span
class=
"kn"
>
as
</span>
<span
class=
"nn"
>
plt
</span>
<div
class=
" highlight hl-ipython3"
><pre><span></span><span
class=
"o"
>
%
</span><span
class=
"k"
>
matplotlib
</span>
inline
<span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
numpy
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
scipy
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
scipy.spatial
</span><span
class=
"o"
>
,
</span>
<span
class=
"nn"
>
matplotlib.pyplot
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
plt
</span>
<span
class=
"n"
>
plt
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
rcParams
</span><span
class=
"p"
>
[
</span><span
class=
"s1"
>
'
figure.figsize
'
</span><span
class=
"p"
>
]
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
(
</span><span
class=
"mi"
>
14
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
2
</span><span
class=
"p"
>
)
</span>
</pre></div>
...
...
@@ -11800,7 +11799,7 @@ div#notebook {
</div>
<div
class=
"inner_cell"
>
<div
class=
"text_cell_render border-box-sizing rendered_html"
>
<h1
id=
"Dynamic-Programming"
>
Dynamic Programming
<a
class=
"anchor-link"
href=
"#Dynamic-Programming"
>

94;
82;
</a></h1>
<h1
id=
"Dynamic-Programming"
>
Dynamic Programming
<a
class=
"anchor-link"
href=
"#Dynamic-Programming"
>
¶
</a></h1>
</div>
</div>
</div>
...
...
@@ -11817,7 +11816,7 @@ div#notebook {
</div>
<div
class=
"inner_cell"
>
<div
class=
"text_cell_render border-box-sizing rendered_html"
>
<h2
id=
"Example:-min-coin-sum"
>
Example: min coin sum
<a
class=
"anchor-link"
href=
"#Example:-min-coin-sum"
>

94;
82;
</a></h2>
<h2
id=
"Example:-min-coin-sum"
>
Example: min coin sum
<a
class=
"anchor-link"
href=
"#Example:-min-coin-sum"
>
¶
</a></h2>
</div>
</div>
</div>
...
...
@@ -11877,8 +11876,8 @@ min_coin_sum(52) -> 4 # 2*25 + 2*1</code></pre>
<div
class=
"prompt input_prompt"
>
In
[2]:
</div>
<div
class=
"inner_cell"
>
<div
class=
"input_area"
>
<div
class=
" highlight hl-ipython
2"
><pre><span></span><span
class=
"k"
>
def
</span>
<span
class=
"nf"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"o"
>
=
</span><span
class=
"bp
"
>
None
</span><span
class=
"p"
>
):
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"ow"
>
is
</span>
<span
class=
"
bp
"
>
None
</span><span
class=
"p"
>
:
</span>
<div
class=
" highlight hl-ipython
3"
><pre><span></span><span
class=
"k"
>
def
</span>
<span
class=
"nf"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"o"
>
=
</span><span
class=
"kc
"
>
None
</span><span
class=
"p"
>
):
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"ow"
>
is
</span>
<span
class=
"
kc
"
>
None
</span><span
class=
"p"
>
:
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
val
</span>
<span
class=
"o"
>
==
</span>
<span
class=
"mi"
>
0
</span><span
class=
"p"
>
:
</span>
<span
class=
"k"
>
return
</span>
<span
class=
"mi"
>
0
</span>
...
...
@@ -11901,13 +11900,13 @@ min_coin_sum(52) -> 4 # 2*25 + 2*1</code></pre>
</div>
<div
class=
"cell border-box-sizing code_cell rendered"
>
<div
class=
"input"
>
<div
class=
"prompt input_prompt"
>
In
[
3
]:
</div>
<div
class=
"prompt input_prompt"
>
In
[
4
]:
</div>
<div
class=
"inner_cell"
>
<div
class=
"input_area"
>
<div
class=
" highlight hl-ipython
2
"
><pre><span></span><span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"
k"
>
print
</span>
<span
class=
"s1"
>
'
val num_coins
'
</span>
<div
class=
" highlight hl-ipython
3
"
><pre><span></span><span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"
nb"
>
print
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
val num_coins
'
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
for
</span>
<span
class=
"n"
>
val
</span>
<span
class=
"ow"
>
in
</span>
<span
class=
"p"
>
(
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
6
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
42
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
49
</span><span
class=
"p"
>
):
</span>
<span
class=
"
k"
>
print
</span>
<span
class=
"s1"
>
'
</span><span
class=
"si"
>
%3d
</span><span
class=
"s1"
>
</span><span
class=
"si"
>
%d
</span><span
class=
"s1"
>
'
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"p"
>
))
</span>
<span
class=
"
nb"
>
print
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
</span><span
class=
"si"
>
%3d
</span><span
class=
"s1"
>
</span><span
class=
"si"
>
%d
</span><span
class=
"s1"
>
'
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"p"
>
)
))
</span>
</pre></div>
</div>
...
...
@@ -11950,7 +11949,7 @@ min_coin_sum(52) -> 4 # 2*25 + 2*1</code></pre>
</div>
<div
class=
"inner_cell"
>
<div
class=
"text_cell_render border-box-sizing rendered_html"
>
<h3
id=
"Memoization"
>
Memoization
<a
class=
"anchor-link"
href=
"#Memoization"
>

94;
82;
</a></h3>
<h3
id=
"Memoization"
>
Memoization
<a
class=
"anchor-link"
href=
"#Memoization"
>
¶
</a></h3>
</div>
</div>
</div>
...
...
@@ -11965,11 +11964,11 @@ min_coin_sum(52) -> 4 # 2*25 + 2*1</code></pre>
</div>
<div
class=
"cell border-box-sizing code_cell rendered"
>
<div
class=
"input"
>
<div
class=
"prompt input_prompt"
>
In
[
4
]:
</div>
<div
class=
"prompt input_prompt"
>
In
[
5
]:
</div>
<div
class=
"inner_cell"
>
<div
class=
"input_area"
>
<div
class=
" highlight hl-ipython
2"
><pre><span></span><span
class=
"k"
>
def
</span>
<span
class=
"nf"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"o"
>
=
</span><span
class=
"bp
"
>
None
</span><span
class=
"p"
>
):
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"ow"
>
is
</span>
<span
class=
"
bp
"
>
None
</span><span
class=
"p"
>
:
</span>
<div
class=
" highlight hl-ipython
3"
><pre><span></span><span
class=
"k"
>
def
</span>
<span
class=
"nf"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"o"
>
=
</span><span
class=
"kc
"
>
None
</span><span
class=
"p"
>
):
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"ow"
>
is
</span>
<span
class=
"
kc
"
>
None
</span><span
class=
"p"
>
:
</span>
<span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"c1"
>
# Initialize table.
</span>
...
...
@@ -11988,13 +11987,13 @@ min_coin_sum(52) -> 4 # 2*25 + 2*1</code></pre>
</div>
<div
class=
"cell border-box-sizing code_cell rendered"
>
<div
class=
"input"
>
<div
class=
"prompt input_prompt"
>
In
[
5
]:
</div>
<div
class=
"prompt input_prompt"
>
In
[
6
]:
</div>
<div
class=
"inner_cell"
>
<div
class=
"input_area"
>
<div
class=
" highlight hl-ipython
2
"
><pre><span></span><span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"
k"
>
print
</span>
<span
class=
"s1"
>
'
val num_coins
'
</span>
<div
class=
" highlight hl-ipython
3
"
><pre><span></span><span
class=
"n"
>
coins
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
10
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
25
</span><span
class=
"p"
>
]
</span>
<span
class=
"
nb"
>
print
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
val num_coins
'
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
for
</span>
<span
class=
"n"
>
val
</span>
<span
class=
"ow"
>
in
</span>
<span
class=
"p"
>
(
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
6
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
42
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
49
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
52
</span><span
class=
"p"
>
):
</span>
<span
class=
"
k"
>
print
</span>
<span
class=
"s1"
>
'
</span><span
class=
"si"
>
%3d
</span><span
class=
"s1"
>
</span><span
class=
"si"
>
%d
</span><span
class=
"s1"
>
'
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"p"
>
))
</span>
<span
class=
"
nb"
>
print
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
</span><span
class=
"si"
>
%3d
</span><span
class=
"s1"
>
</span><span
class=
"si"
>
%d
</span><span
class=
"s1"
>
'
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
min_coin_sum
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
val
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
coins
</span><span
class=
"p"
>
)
))
</span>
</pre></div>
</div>
...
...
dp.ipynb
View file @
4dd8f47d
...
...
@@ -3,7 +3,12 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true,
"tags": [
"hide_cell"
]
},
"outputs": [],
"source": [
"%matplotlib inline\n",
...
...
@@ -85,7 +90,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def min_coin_sum(val, coins=None):\n",
...
...
@@ -151,7 +158,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def min_coin_sum(val, coins=None):\n",
...
...
@@ -208,6 +217,7 @@
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
...
...
@@ -223,7 +233,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6.4
"
"version": "3.
5.2
"
}
},
"nbformat": 4,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment