Live data from Hacker News

The ReadyForZero Programming Challenge

readyforzero.com

41–50 of 61 posts

Re: The ReadyForZero Programming Challenge

#43
post #34
post #27

Earlier 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

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 even look at the whole input in constant time.

Re: The ReadyForZero Programming Challenge

#44
post #43
post #34

Earlier 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…

Didn't understand what you meant, care to elaborate?

Re: The ReadyForZero Programming Challenge

#45

My 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.

Why? It's not hard to write a quick and dirty levenshtein function, but when google gets it for me in 1 minute, why do it?

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
When 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

#47
Fun challenge, but not too difficult. The largest challenge was making the intuitive leaps to discover the missing information in the questions, especially for problem two. A bit of trial and error, and a few lines of Python made for quick testing of those assumptions.

Re: The ReadyForZero Programming Challenge

#48

My 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.

They can't overlap! I don't think the problem specifies that?

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

#49

When 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.

Thanks for pointing that out. Yes, we could have checked every single corner case, but our job is to build financial software, not programming challenges, so we did it quick and dirty :)

Re: The ReadyForZero Programming Challenge

#50
post #43
post #34

Earlier 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…

This is a misunderstanding, you must have answered to my reply after ithayer edited his comment, the initial comment said "constant time".
Post reply on HN