Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Try screeps.
Helped me learn to code faster and "wing it" getting rough ideas into code as fast and loose as possible. I think my ability to think of and code entire methods quickly and effectively has vastly improved from this game.
Warning: I quit that shit like crack because all I wanted to do was play screeps like 17 hours per day. -
Root825084y@jespersh That would be correct about as often as winning a game of solitaire without any move planning. Decently often, but by no means guaranteed.
If the array was all integers, the chance would approach (and reach) 100% as the percentage of 1’s increased.
You could guarantee it by an exhaustive O(n^2) or worse approach, but that’s probably not what they want to see. -
I hate these stupid fucking interview questions. Let's not kid ourselfs, not a single human being can just randomly come up with a good solution for a problem like this out of the blue. They all have to study for hours on end so they can answer a question that's 100% irrelevant to any problem in the real world. What an unnecessary waste of time for everyone involved
-
I would do what @jespersh did and divide by three but then you’d have to find those numbers that sum to that value. I can only think of a brute force way. You can skip searching for the final third and take what’s left if the first two sets are found bc obviously that would sum to the required value. Impossible if the sum won’t divide by 3. You’d have to put the remainder somewhere.
-
I wouldn't be able to solve that on the fly. That's not how you measure programming skills anyways.
-
There is no such code in general - see the array [1, 2, 3] as counter-example, or [1, 1, 1, 1, 1, 1, 42]. Even though it is divisible by 3, there are no such three sub-arrays with the same sums.
To get close to such a solution, I would:
1) sort the array in descending order
2) put the current number into the sub-array that has the lowest sum
3) fetch the next number.
Probably not guaranteed to be optimal, but feasible in O(N log N). -
Actually I might’ve misunderstood the requirements. If you want to split it without changing indexes of values, then divide sum by three, then add up the numbers from the beginning until you get to the sum divided by three. Then add numbers starting from the end of the array until you get the sum divided by three. If you find the sum both ways without letting the pointer starting from the right go below the last index the left pointer stopped at, then all that’s left in between is numbers that add up to the same value (you already found 2/3 of the sum going from the start and end of the array) and you win
-
cb21910194yIf I'm not mistaken that would be the subset-sum problem, higher scaled ... or the 3-partition problem, whatever.
Solution is DP-based in 3 dimensions. -
@12bitfloat
> not a single human being can just randomly come up with a good solution for a problem like this out of the blue.
Of course you can, it's just a really terrible question. -
skydhash1344yI've done the Turing application and everything went great. But I kinda lost the motivation for them as the only thing I wanted them to do was to get the contract and assign me to it (I don't even care about the percentage they get as long as I got a fair wage). But it was even more work than me closing my own freelance projects.
Just did my interview with Turing & OMG!
2 questions, total of 30 mins to answer both questions, and there's a dude with access to your screen, camera & microphone watching your every move.
Went horribly. Utter failure. Not expecting to hear back from them.
Questions weren't related to the skills I said I had. They were general questions that could be answered in any language. I honestly wasn't ready to write code to split an array of numbers into 3 equal parts whose values when added would equal.
FML. Fuck this shit. I'm tired of all the bullshit (mine included)!
rant