Find all numbers in the list n which are divisible by a given integer d.
def divisible_by_d(n: list, d: int) -> list:
pass>>> divisible_by_d([1,2,3,4,5,6], 3)
[3, 6]
>>> divisible_by_d([0,1,2,3,4,5,6], 4)
[0, 4]
>>> divisible_by_d([0], 4)
[0]
>>> divisible_by_d([1,3,5], 2)
[]Given a tuple with two indexes that denote the knight position on a matrix board, return the count of all valid moves which the knight can made.
def knight_moves(pos: tuple) -> int:
# pos[0] denotes the knights row
# pos[1] denotes the knights column
pass>>> knight_moves((2, 6))
6
>>> knight_moves((0, 7))
2
>>> knight_moves((5, 0))
4
>>> knight_moves((4, 3))
8
>>> knight_moves((6, 7))
3Consider these graphical examples
Eight legal moves where pos = (4, 3)
| M | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| 0 | ||||||||
| 1 | ||||||||
| 2 | * | * | ||||||
| 3 | * | * | ||||||
| 4 | N | |||||||
| 5 | * | * | ||||||
| 6 | * | * | ||||||
| 7 |
Two legal moves where pos = (7, 7)
| M | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| 0 | ||||||||
| 1 | ||||||||
| 2 | ||||||||
| 3 | ||||||||
| 4 | ||||||||
| 5 | * | |||||||
| 6 | ||||||||
| 7 | * | N |