There are two types of potions:
Growing potion: "A"
Shrinking potion: "B"
- If
"A"
immediately follows a digit, add1
to the proceeding number. - If
"B"
immediately follows a digit, subtract1
from the proceeding number.
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.
mystery_func(152) ➞ 10
You face 1 out of the 4 compass directions: N
, S
, E
or W
.
N (left-turn) ➞ W
.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.
Create a function takes in two lists and returns an intersection list and a union list.
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.
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
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.
round_number(33, 25) ➞ 25
round_number(46, 7) ➞ 49
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.
customers = {
"Batman": [22, 30, 11, 17, 15, 52, 27, 12],