Skip to content

Instantly share code, notes, and snippets.

@jkaunert
Forked from erica/Code Challenge.md
Last active February 12, 2020 16:46
Show Gist options
  • Save jkaunert/d7b38e045fcd6f2db73a0ff5c1fde277 to your computer and use it in GitHub Desktop.
Save jkaunert/d7b38e045fcd6f2db73a0ff5c1fde277 to your computer and use it in GitHub Desktop.

iOS/Swift Code Challenges

Morning challenges allow you to jumpstart your brain and get ready for a day of learning. Each morning, your PM will present a short code puzzle. These puzzles are similar to the kind you'll encounter in job interviews. Your job is to code a solution in a playground, in an application, or in REPL.it to satisfy the requirements laid out in the challenge.

These steps simulate a coding interview and are based on expectations set in industry. Even if you are unable to complete (or start) the challenge code, we expect you to work through the steps that mirror how a programmer approaches a new problem.

Your work must be entirely your own. You may not consult or collaborate with others during this challenge. You may use Apple's developer documents and official Swift Language guides (available free on iBooks) but you may not search the web for answers.

These challenges are for your benefit. We care that you're learning the language. It's better to submit working code that shows individual thought and effort but it's okay to submit non-working code that shows individual thought and effort.

You have 45 minutes to develop your approach and your code. You must submit your gist to your Section Lead before reviewing the solution.

Evaluate the Challenge

Start by carefully reading through the challenge. The challenge is often intentionally vague.

Create a new gist on Github.com and write down your assumptions about what the instructions mean. For example, if the challenge states that a function works on positive integers, does that mean that you will never be given negative integers? Or does it mean that you should design your code to filter negative data, to only produce results for positive values?

This clarification reflects the first stage of an interview question and is a mandatory part of your challenge submission.

Test Cases

Most challenges will give you one to a few input samples and present their output. These samples are not sufficient test cases.

Think carefully about the extremes of your function: empty strings or arrays, out-of-bounds values, repeated values, and so forth. List a more exhaustive set of tests that push your function at its limits and add these to your gist, along with the expected result for each input.

Designing test cases are an expected part of your coding interview and you must include them in your challenge submission.

Coding Approach

Think through how you will approach the challenge. Describe it in words using your gist file. Your first approach need not be perfect, clean, or elegant. It just needs to work. Write down how you will do this in your gist before you start coding.

Code

Follow your approach and build the requested function. Test it with your test cases, making note of which items failed. If time permits, you can refine the function. If not, take whatever code you have and the results of your tests and put them in your gist file.

Evaluate

If your code works, evaluate its strengths and weaknesses. If relevant, add brief comments to your gist.

In the unlikely event you have sufficient time to refactor your code to try a better approach, add those notes and code to your gist as well.

Submit

When your 45-minute coding time finishes, stop what you're doing, save your work, and submit it as instructed in the README included with each challenge problem.

Discuss

Your TL will open a Zoom chat to discuss test cases, approaches, and solutions before wrapping up with an overview of possible solution(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment