Merge pull request #138 from madeirak/master

modification of question No.74
This commit is contained in:
Nicolas P. Rougier 2021-01-05 09:43:35 +01:00 committed by GitHub
commit 93bb2f70a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 7 deletions

View File

@ -1101,7 +1101,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### 74. Given an array C that is a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)"
"#### 74. Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)"
]
},
{
@ -1476,7 +1476,25 @@
"source": []
}
],
"metadata": {},
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View File

@ -194,7 +194,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
#### 73. Consider a set of 10 triplets describing 10 triangles (with shared vertices), find the set of unique line segments composing all the triangles (★★★)
#### 74. Given an array C that is a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
#### 74. Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
#### 75. How to compute averages using a sliding window over an array? (★★★)

View File

@ -194,7 +194,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
`hint: array[[]] = array[[]]`
#### 73. Consider a set of 10 triplets describing 10 triangles (with shared vertices), find the set of unique line segments composing all the triangles (★★★)
`hint: repeat, np.roll, np.sort, view, np.unique`
#### 74. Given an array C that is a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
#### 74. Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
`hint: np.repeat`
#### 75. How to compute averages using a sliding window over an array? (★★★)
`hint: np.cumsum`

View File

@ -778,7 +778,7 @@ G = F.view( dtype=[('p0',F.dtype),('p1',F.dtype)] )
G = np.unique(G)
print(G)
```
#### 74. Given an array C that is a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
#### 74. Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
```python

View File

@ -49,7 +49,25 @@
]
}
],
"metadata": {},
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View File

@ -983,7 +983,7 @@ G = np.unique(G)
print(G)
< q74
Given an array C that is a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)
< h74
hint: np.repeat