Skip to content

Instantly share code, notes, and snippets.

View ZechCodes's full-sized avatar
🏄‍♂️
Surfing on a space-time bubble

Zech Zimmerman ZechCodes

🏄‍♂️
Surfing on a space-time bubble
View GitHub Profile

Challenge #28 - Growing & Shrinking Potions

There are two types of potions:

Growing potion: "A" Shrinking potion: "B"

  • If "A" immediately follows a digit, add 1 to the proceeding number.
  • If "B" immediately follows a digit, subtract 1 from the proceeding number.
@ZechCodes
ZechCodes / challenge-29.md
Created June 15, 2020 23:45
Challenge #29 - Swimming Pools

Challenge #29 - Swimming Pools

Suppose a swimming pool blueprint can be represented as a 2D list, where 1s represent the pool and 0s represent the rest of the backyard.

[[0, 0, 0, 0, 0, 0, 0, 0],
 [0, 1, 1, 1, 1, 1, 0, 0],
 [0, 1, 1, 1, 1, 1, 0, 0],
 [0, 1, 1, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0]]
@ZechCodes
ZechCodes / challenge-30.md
Created June 16, 2020 23:59
Challenge #30 - Reverse Coding

Challenge #30 - Reverse Coding

This is a reverse coding challenge. Normally you're given explicit directions of how to create a function. Here, you must create your own function to satisfy the relationship between the inputs and outputs.

Your task is to create a function that, when fed the inputs below, produces the sample outputs shown.

Examples

mystery_func(152) ➞ 10
@ZechCodes
ZechCodes / challenge-31.md
Created June 17, 2020 23:32
Challenge #31 - Mini Peaks

Challenge 31 - Mini Peaks

Write a function that returns all the elements in an array that are strictly greater than their adjacent left and right neighbors.

Examples

mini_peaks([4, 5, 2, 1, 4, 9, 7, 2]) ➞ [5, 9]

mini_peaks([1, 2, 1, 1, 3, 2, 5, 4, 4]) ➞ [2, 3, 5]
@ZechCodes
ZechCodes / challenge-32.md
Last active June 19, 2020 01:26
Challenge #32 - Compass Directions

Challenge #32 - Compass Directions

You face 1 out of the 4 compass directions: N, S, E or W.

  • A left turn is a counter-clockwise turn. e.g. N (left-turn) ➞ W.
  • A right turn is a clockwise turn. e.g. N (right-turn) ➞ E.

Create a function that takes in a starting direction and a sequence of left and right turns, and outputs the final direction faced.

Examples

@ZechCodes
ZechCodes / challenge-33.md
Last active June 20, 2020 01:35
Challenge #33 - Union & Intersection of Lists

Challenge #33 - Union & Intersection of Lists

Create a function takes in two lists and returns an intersection list and a union list.

  • Intersection List: Elements shared by both.
  • Union List: Elements that exist in first or second list, or both (not exclusive OR).

While the input lists may have duplicate numbers, the returned intersection and union lists should be set-ified - that is, contain no duplicates. Returned lists should be sorted in ascending order.

@ZechCodes
ZechCodes / challenge-34.md
Last active June 21, 2020 16:37
Challenge #34 - Intersecting Intervals

Challenge #34 - Intersecting Intervals

Create a function that takes in a list of intervals and returns how many intervals overlap with a given point.

An interval overlaps a particular point if the point exists inside the interval, or on the interval's boundary. For example the point 3 overlaps with the interval [2, 4] (it is inside) and [2, 3] (it is on the boundary).

To illustrate:

count_overlapping([[1, 2], [2, 3], [1, 3], [4, 5], [0, 1]], 2) ➞ 3
# Since [1, 2], [2, 3] and [1, 3] all overlap with point 2
@ZechCodes
ZechCodes / challenge-35.md
Created June 21, 2020 23:49
Challenge #35 - Round to Nearest N

Challenge #35 - Round to Nearest N

Creates a function that takes two integers, num and n, and returns an integer which is divisible by n and is the closest to num. If there are two numbers equidistant from num and divisible by n, select the larger of the two.

Examples

round_number(33, 25) ➞ 25

round_number(46, 7) ➞ 49

Challenge #36 - Pizza Points

We're launching a network of autonomous pizza delivery drones and want you to create a flexible rewards system (Pizza Points) that can be tweaked in the future. The rules are simple: if a customer has made at least N orders of at least Y price, they get a FREE pizza!

Create a function that takes a dictionary of customers, a minimum number of orders and a minimum order price. Return a list of customers that are eligible for a free pizza.

Examples

customers = {
 "Batman": [22, 30, 11, 17, 15, 52, 27, 12],

Challenge 37 - Match the Last Item

Create a function that takes a list of items and checks if the last item matches the rest of the list.

Examples

match_last_item(["rsq", "6hi", "g", "rsq6hig"]) ➞ True
# The last item is the rest joined.

match_last_item([1, 1, 1, "11"]) ➞ False