Earlier quoted context omitted.
Did anyone else do that one without writing any code?
You mean with smart guessing? That's no fun!
The ReadyForZero Programming Challenge
41–50 of 61 posts
Re: The ReadyForZero Programming Challenge
#42Re: The ReadyForZero Programming Challenge
#43Earlier quoted context omitted.
Can you do it in linear time in the length of the input?
It's not hard to prove that that's impossible
In practice, that would actually be slower on this input, because of the cost of initializing the bitset. But that is not dependent on the input, so computational complexity is unaffected.
edit: Removed description. Yes, you're right, you can't even look at the whole input in constant time.
Re: The ReadyForZero Programming Challenge
#44Earlier quoted context omitted.
It's not hard to prove that that's impossible
It's possible if RAM isn't a constraint, using a bitset of all possible five-letter strings. The bitset would take up 4G of RAM (128G for extended ASCII, more for unicode). In practice, that would actually be slower on this input, because of the cost of initializing the bitset. But that is not dependent on the input, so computational complexity is unaffected. edit: Removed description. Yes, you're right, you can't ev…
Re: The ReadyForZero Programming Challenge
#45My answers in 31 lines of code: https://gist.github.com/1025860 I am either misreading the third problem's description, or I have a bug I can't for the life of me see, because the answer my program puts out is not accepted.
> #pip install python-levenshtein > from Levenshtein import distance That doesn't seem in the spirit of the challenge.
edit: just for fun, as a one-liner:
def levenshtein(a,b): return sum(x!=y for x,y in zip(a, b))
edit 2: and just to clarify, I know this fails if the lengths of the input strings differ, they were guaranteed to be equal in my code.Re: The ReadyForZero Programming Challenge
#46> Forbidden (403)
> CSRF verification failed. Request aborted.
They should've checked that cookie exists. Or, better, not rely on cookies.
Re: The ReadyForZero Programming Challenge
#47Re: The ReadyForZero Programming Challenge
#48My answers in 31 lines of code: https://gist.github.com/1025860 I am either misreading the third problem's description, or I have a bug I can't for the life of me see, because the answer my program puts out is not accepted.
The third problem is looking to partition the entire sequence of numbers into contiguous subsequences, all of which add up to the same sum. In other words, if the list were 23415, you subsequences could be 23, 41 and 5, all equaling 5. But the subsequences have to use up the entire string and they can't overlap.
You have to interpret "break up" to mean "non-overlapping" to claim that the problem means what you're saying it means; I found 341 "contiguous subsequences such that the sums of each of the subsequences are equal", but they overlap.
(If you had said "partition" I suspect I would have got what you meant)
Re: The ReadyForZero Programming Challenge
#49When one has cookies disabled (and those days I believe everyone should) it throws Django error page: > Forbidden (403) > CSRF verification failed. Request aborted. They should've checked that cookie exists. Or, better, not rely on cookies.
Re: The ReadyForZero Programming Challenge
#50Earlier quoted context omitted.
It's not hard to prove that that's impossible
It's possible if RAM isn't a constraint, using a bitset of all possible five-letter strings. The bitset would take up 4G of RAM (128G for extended ASCII, more for unicode). In practice, that would actually be slower on this input, because of the cost of initializing the bitset. But that is not dependent on the input, so computational complexity is unaffected. edit: Removed description. Yes, you're right, you can't ev…