2 years ago
marcus platform
customuer consumer banking
retail, like chase
100 engineers
from strip, uber, twitter
aquire
devops, automation
24/7 consumer facing
manage building deployment
relase management
client issue
unix/linux, python, terraform, consol, redhat, appdynamics.
web api
codepad technical
prefer code in pytho
-----------------------------
marcus of CCBD
1. load to american people
marcus loan no fee
charge on interest payback
2. savings account for consumer
dec 2017 combined the two
aquired creditmoney this sunday.
credit line poc
perks of startup
cto talk
300 people in marcus
already lend out 3 billion dollars.
nyc, tx, london, bangalore
sfo 5-10 people
devops:
- core devops
- production engineer (sre)
- process release management. work with vendor
on call once every 3 months
only tx and nyc atm.
# Problem Name is &&& ApacheLog &&& PLEASE DO NOT REMOVE THIS LINE.
"""
Instructions to candidate.
1) Run this code in the REPL to observe its behaviour. The
execution entry point is specified at the bottom.
2) Consider adding some additional tests in do_tests_pass().
3) Implement find_top_ip_address() correctly.
4) If time permits, try to improve your implementation.
"""
def find_top_ip_address(lines):
""" Given an Apache log file, return IP address(es) which accesses the site most often.
Our log is in this format (Common Log Format). One entry per line and it starts with an IP address which accessed the site,
followed by a whitespace.
10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] "GET /a.gif HTTP/1.0" 200 234
Log file entries are passed as a list.
"""
# todo: implement logic
# return "10.0.0.1"
# s = "10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234"
# print s.split()[0]
countd = {}
for line in lines:
ip = line.split()[0]
if ip not in countd:
countd[ip] = 1
else:
countd[ip] += 1
maxcount = 0
maxips = []
for ip, cnt in countd.items():
if cnt > maxcount:
maxcount = cnt
for ip, cnt in countd.items():
if cnt == maxcount:
maxips.append(ip)
# print maxips
return maxips
def do_tests_pass():
"""Returns True if the test passes. Otherwise returns False."""
# todo: implement more tests
lines = ["10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234",
"10.0.0.1 - frank [10/Dec/2000:12:34:57 -0500] \"GET /b.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
"10.0.0.3 - abc [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234"]
result = find_top_ip_address(lines)
if "10.0.0.1" in result and "10.0.0.2" in result:
print("test passed")
return True
else:
print("test failed")
return False
if __name__ == "__main__":
do_tests_pass()
# Problem Name is &&& Second Smallest &&& PLEASE DO NOT REMOVE THIS LINE.
"""
Instructions to candidate.
1) Run this code in the REPL to observe its behaviour. The
execution entry point is main().
2) Consider adding some additional tests in doTestsPass().
3) Implement secondSmallest() correctly.
4) If time permits, some possible follow-ups.
"""
# use heapq?
def secondSmallest(x):
""" Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
# todo: implement here
if len(x) < 2:
return
# x = [2,4,3,5]
x.sort()
return x[1]
import heapq
def secondSmallest(x):
""" Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
# todo: implement here
if len(x) < 2:
return
return heapq.nsmallest(2, x)
def doTestsPass():
""" Returns 1 if all tests pass. Otherwise returns 0. """
testArrays = [ [0], [0,1] ]
testAnswers = [ None, 1, ]
for i in range( len( testArrays ) ):
if not ( secondSmallest( testArrays[i] ) == testAnswers[i] ):
return False
return True
if __name__ == "__main__":
if( doTestsPass() ):
print( "All tests pass" )
else:
print( "Not all tests pass" )
marcus platform
customuer consumer banking
retail, like chase
100 engineers
from strip, uber, twitter
aquire
devops, automation
24/7 consumer facing
manage building deployment
relase management
client issue
unix/linux, python, terraform, consol, redhat, appdynamics.
web api
codepad technical
prefer code in pytho
-----------------------------
marcus of CCBD
1. load to american people
marcus loan no fee
charge on interest payback
2. savings account for consumer
dec 2017 combined the two
aquired creditmoney this sunday.
credit line poc
perks of startup
cto talk
300 people in marcus
already lend out 3 billion dollars.
nyc, tx, london, bangalore
sfo 5-10 people
devops:
- core devops
- production engineer (sre)
- process release management. work with vendor
on call once every 3 months
only tx and nyc atm.
# Problem Name is &&& ApacheLog &&& PLEASE DO NOT REMOVE THIS LINE.
"""
Instructions to candidate.
1) Run this code in the REPL to observe its behaviour. The
execution entry point is specified at the bottom.
2) Consider adding some additional tests in do_tests_pass().
3) Implement find_top_ip_address() correctly.
4) If time permits, try to improve your implementation.
"""
def find_top_ip_address(lines):
""" Given an Apache log file, return IP address(es) which accesses the site most often.
Our log is in this format (Common Log Format). One entry per line and it starts with an IP address which accessed the site,
followed by a whitespace.
10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] "GET /a.gif HTTP/1.0" 200 234
Log file entries are passed as a list.
"""
# todo: implement logic
# return "10.0.0.1"
# s = "10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234"
# print s.split()[0]
countd = {}
for line in lines:
ip = line.split()[0]
if ip not in countd:
countd[ip] = 1
else:
countd[ip] += 1
maxcount = 0
maxips = []
for ip, cnt in countd.items():
if cnt > maxcount:
maxcount = cnt
for ip, cnt in countd.items():
if cnt == maxcount:
maxips.append(ip)
# print maxips
return maxips
def do_tests_pass():
"""Returns True if the test passes. Otherwise returns False."""
# todo: implement more tests
lines = ["10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234",
"10.0.0.1 - frank [10/Dec/2000:12:34:57 -0500] \"GET /b.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234",
"10.0.0.3 - abc [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234"]
result = find_top_ip_address(lines)
if "10.0.0.1" in result and "10.0.0.2" in result:
print("test passed")
return True
else:
print("test failed")
return False
if __name__ == "__main__":
do_tests_pass()
# Problem Name is &&& Second Smallest &&& PLEASE DO NOT REMOVE THIS LINE.
"""
Instructions to candidate.
1) Run this code in the REPL to observe its behaviour. The
execution entry point is main().
2) Consider adding some additional tests in doTestsPass().
3) Implement secondSmallest() correctly.
4) If time permits, some possible follow-ups.
"""
# use heapq?
def secondSmallest(x):
""" Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
# todo: implement here
if len(x) < 2:
return
# x = [2,4,3,5]
x.sort()
return x[1]
import heapq
def secondSmallest(x):
""" Returns second smallest element in the array x. Returns nothing if array has less than 2 elements. """
# todo: implement here
if len(x) < 2:
return
return heapq.nsmallest(2, x)
def doTestsPass():
""" Returns 1 if all tests pass. Otherwise returns 0. """
testArrays = [ [0], [0,1] ]
testAnswers = [ None, 1, ]
for i in range( len( testArrays ) ):
if not ( secondSmallest( testArrays[i] ) == testAnswers[i] ):
return False
return True
if __name__ == "__main__":
if( doTestsPass() ):
print( "All tests pass" )
else:
print( "Not all tests pass" )
Comments
Post a Comment
https://gengwg.blogspot.com/