Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thank you very much, actually i understood the theory, i also made a solution i am not entirely happy with, but i was actually trying to understand your recursive generator function pow_variants(), awesome actually
Number of divisors (D) of every number (N) can be calculated as:
D = (pow_0 + 1)*(pow_1 + 1)* ... *(pow_n + 1) (1)
where
pow_{i}
are powers of prime numbers in the source number (N
) factorization (N = prime_0**pow_0 + prime_1**pow_1 + ... + prime_m**pow_m
). Our task is to minimizeN
with fixedD
, so we should check all possible variants of powers which correspond to (eq. 1) and use the minimum possible prime number for maximum power.pow_variants
- returns all possible variants of powers which correspond to (eq. 1) sorted in descending order.math.prod(PRIMES[i]**p for i, p in enumerate(powers))
- returns minimal possible number for current powers combinationcan you explain please?
yes
This comment is hidden because it contains spoiler information about the solution
learnt this from a previous kata. Glad I remembered it and got to use it.
This comment is hidden because it contains spoiler information about the solution
For some reason I did not think of this. I feel humbled.
For some reason i assumed the array would be longer than 3 values
FYI: You could replace the implementation of
_to_bin
withreturn bin(number)[2:].rjust(INT_LEN, '0')
.My solution as well...
I think this is clever but it's not something I would leave without comment or in production code