solutions update from 92b0e36

This commit is contained in:
rougier
2026-08-26 10:29:27 +00:00
committed by github-actions[bot]
parent 92b0e363de
commit 8ca28aaefc
6 changed files with 214 additions and 214 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -232,7 +232,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
#### 92. Consider a large vector Z, compute Z to the power of 3 using 3 different methods (★★★)
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B? (★★★)
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain at least one element of each row of B regardless of the order of the elements in B?
#### 94. Considering a 10x3 matrix, extract rows with unequal values (e.g. [2,2,3]) (★★★)

View File

@@ -232,7 +232,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
`hint: np.core.records.fromarrays`
#### 92. Consider a large vector Z, compute Z to the power of 3 using 3 different methods (★★★)
`hint: np.power, *, np.einsum`
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B? (★★★)
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain at least one element of each row of B regardless of the order of the elements in B?
`hint: np.where`
#### 94. Considering a 10x3 matrix, extract rows with unequal values (e.g. [2,2,3]) (★★★)
`No hints provided...`

View File

@@ -1181,7 +1181,7 @@ x = np.random.rand(int(5e7))
%timeit x*x*x
%timeit np.einsum('i,i,i->i',x,x,x)
```
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B? (★★★)
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain at least one element of each row of B regardless of the order of the elements in B?
`hint: np.where`
```python

View File

@@ -1181,7 +1181,7 @@ x = np.random.rand(int(5e7))
%timeit x*x*x
%timeit np.einsum('i,i,i->i',x,x,x)
```
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B? (★★★)
#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain at least one element of each row of B regardless of the order of the elements in B?
```python

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "261c7cb9",
"id": "0853fe0e",
"metadata": {},
"source": [
"# 100 numpy exercises\n",
@@ -18,7 +18,7 @@
},
{
"cell_type": "markdown",
"id": "b0ffec6a",
"id": "042c5a4b",
"metadata": {},
"source": [
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
@@ -26,7 +26,7 @@
},
{
"cell_type": "markdown",
"id": "30434163",
"id": "021cd2a9",
"metadata": {},
"source": [
"Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
@@ -36,7 +36,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8f632d6c",
"id": "762ccffd",
"metadata": {},
"outputs": [],
"source": [
@@ -46,7 +46,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6cfc4341",
"id": "61737701",
"metadata": {},
"outputs": [],
"source": [