- more like dICK
- Feb 15, 2010
-
This is inevitable.
|
Goonamatic posted:
Im currently interviewing.
Trying to do as many online tests as possible.
Found this one which Im having trouble with -- -- got the test but couldnt get the answer in the self certification test
http://codility.com/
Anyone else able to give this a go & see how they go?
Assuming you got the equilibrium index one, as that's the one that popped up for me.
Here's a brute force approach in Python. There's probably a better solution though:
code:def equi ( A ):
# write your code here
for i in range(len(A)):
lower = sum(A[:i])
upper = sum(A[i+1:])
if (upper == lower):
return i
return -1
more like dICK fucked around with this message at 02:34 on Feb 9, 2011
|
#
¿
Feb 9, 2011 02:26
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 2, 2024 06:08
|
|
- more like dICK
- Feb 15, 2010
-
This is inevitable.
|
_aaron posted:
I did that one like this:
code:upper = sum(A)
lower = 0
for i in range(len(A)):
upper -= A[i]
if upper == lower:
return i
lower -= A[i]
return -1
Seems to break on large lists. This should give equilibrium at i=50000
code:>>> for i in range(100001):
x.append(1)
>>> def equi(A):
upper = sum(A)
lower = 0
for i in range(len(A)):
upper -= A[i]
if upper == lower:
return i
lower -= A[i]
return -1
>>> equi(x)
-1
more like dICK fucked around with this message at 05:17 on Feb 9, 2011
|
#
¿
Feb 9, 2011 05:10
|
|
- more like dICK
- Feb 15, 2010
-
This is inevitable.
|
I really wouldn't use Windows unless I was actually writing Windows software.
|
#
¿
Jan 4, 2014 03:13
|
|
- more like dICK
- Feb 15, 2010
-
This is inevitable.
|
Tries are legitimately my favourite data structure, because I love word games so much.
|
#
¿
Jan 9, 2014 22:16
|
|
- more like dICK
- Feb 15, 2010
-
This is inevitable.
|
I'm surprised this hasn't been mentioned but there are plenty of emotional benefits of working for a startup:
Power, authority, excitement, sense of purpose and responsibility. All of those trump being a cog.
When the CEO consults with you personally before doing anything major.
Personally, I've worked for small, medium, and fortune 100 companies. I prefer medium as the perfect balance.
None of those trump going home at five and being paid real money.
|
#
¿
Dec 5, 2014 05:09
|
|