This file contains hidden or 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
| from math import sqrt | |
| def _sum_of_proper_divisors(n, sum_of_proper_divisors): | |
| _sum = 1 | |
| sqrt_n = int(sqrt(n)) | |
| for i in range(2, sqrt_n+1): | |
| if n % i == 0: | |
| _sum += i | |
| if n // i != i: | |
| _sum += n // i |
This file contains hidden or 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
| from math import sqrt | |
| def sum_of_divisors(number): | |
| _sum = 1 | |
| nsqrt = int(sqrt(number)) | |
| for i in range(2, nsqrt + 1): | |
| if number % i == 0: | |
| _sum += i | |
| if (number / i != nsqrt): |
This file contains hidden or 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
| from math import factorial | |
| numbers = list(range(10)) | |
| nth_perm = 1000000 | |
| total_numbers = len(numbers) | |
| num = '' | |
| def get_factorial_divisor(factorial, dividend): |
This file contains hidden or 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
| largest_num = 1000 | |
| largest_divisor = 3 | |
| longest_cycle = 1 | |
| rdigits = '' | |
| def get_divide_result(i): | |
| seen_remainders = [False] * i | |
| remainder = 10 % i | |
| cycle_count = 0 | |
| while remainder!= 0 and seen_remainders[remainder] is False: |
This file contains hidden or 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
| from math import sqrt | |
| MAX = 999999 | |
| sieve = [True] * (MAX + 1) | |
| sieve[0], sieve[1] = False, False | |
| for i in range(2, int(sqrt(MAX)) + 1): | |
| if sieve[i] is True: | |
| for j in range(2 * i, MAX, i): |
This file contains hidden or 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
| grid_size = 1001 | |
| num = grid_size ** 2 | |
| sum_diagonals = num | |
| for i in range(grid_size - 1, 0, -2): | |
| for _ in range(4): | |
| num -= i | |
| sum_diagonals += num | |
| print(sum_diagonals) |
This file contains hidden or 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
| final_target = 200 | |
| possibilities = [0] * (final_target + 1) | |
| possibilities[0] = 1 | |
| # keeping the coins sorted is the key here | |
| # we want to compute possibilities for lower coins first. | |
| # This helps us to fix one particular coin and | |
| # then find the other possibilites of the change needed | |
| coins = [1, 2, 5, 10, 20, 50, 100, 200] | |
| for coin in coins: | |
| for current_target in range(coin, final_target + 1): |
This file contains hidden or 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 Solution(object): | |
| def __init__(self, matrix, row, col): | |
| self.matrix = matrix | |
| self.row = row | |
| self.col = col | |
| def is_safe(self, i, j, visited): | |
| return ( | |
| 0 <= i < self.row and |
This file contains hidden or 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
| def get_all_substrings(arr, index, subarr, record): | |
| if index == len(arr): | |
| if len(subarr) != 0: | |
| record.append(''.join(subarr)) | |
| else: | |
| get_all_substrings(arr, index + 1, subarr, record) | |
| get_all_substrings(arr, index + 1, subarr + [arr[index]], record) | |
| return record |
This file contains hidden or 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
| [{ | |
| "inputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "internalType": "string", |