This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Write a function solution that, given integer N, returns the smallest non-negative | |
integer whose individual digits sum to N. | |
Examples: | |
1. Given N = 16, the function should return 79. There are many numbers whose | |
digits sum to 16 (for example: 79, 97, 808, 5551, 22822, etc.). | |
The smallest such number is 79. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matrix: | |
def __init__(self, matrix_string): | |
self.matrix_string = matrix_string | |
def row(self, index): | |
row = list(self.matrix_string.split("\n")) | |
return row[index] | |
""" | |
My logic is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list1 = [-6, -91, 1011, -100, 84, -22, 0, 1, 473] | |
def solution(A): | |
answer = [num for num in A if num in range(-9,10)] | |
return max(answer) | |
print(solution(list1)) |