Simple Serverless Coding Challenge for Interviews

import osdef create_haystack(idx: int) -> dict:
haystack = ["hay"] * 99999
haystack.insert(idx, "needle")
challenge = {
"At what index is the needle?": haystack
}
return challenge
def stack(request):
INDEX = int(os.environ['CHALLENGE_INDEX'])
return create_haystack(INDEX)
import requestsurl = "https://region-project-id.cloudfunctions.net/function-name"
req = requests.get(url)
data = req.json()
for key, value in data.items():
for index, h in enumerate(value):
if h != "hay":
print(index, h)
$ 86315 needle

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store