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

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Consuming RSS feeds from Flink SQL

Low-Level Designing from an interviewers perspective

Lunyr Dev Update — Lunyr Nebula Plans, Search Upgrade, and Upcoming Mobile Release

Enforcing Coding Best Practices using CI

Analyze Jira Issues using BigQuery and Data Studio

Melissa McCarthy in Superintelligence

Witness the (Android) fitness

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
rav3n

rav3n

More from Medium

Mail Server Using Serverless Framework On AWS [Lambda + SES +IAM]

The Serverless Age — Hands-on Introduction of Creating Slack App Interface to Access AWS…

Serverless — What? Why? How?

cx_oracle in AWS lambda layer