wes d2a2ba9e15 first commit | %!s(int64=4) %!d(string=hai) anos | |
---|---|---|
.. | ||
README.md | %!s(int64=4) %!d(string=hai) anos | |
code.cpp | %!s(int64=4) %!d(string=hai) anos | |
unitTest.cpp | %!s(int64=4) %!d(string=hai) anos |
by Helen Yu tags: arrays, math, loops
This is a reverse coding challenge. Normally you're given explicit directions with how to create a function. Here, you must generate 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, produce the sample outputs shown. Examples [5, 7, 8, 2, 1], 2 ➞ [1, 1, 0, 0, 1] [
This is a reverse coding challenge. Normally you're given explicit directions with how to create a function. Here, you must generate 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, produce the sample outputs shown.
[5, 7, 8, 2, 1], 2 ➞ [1, 1, 0, 0, 1]
[9, 8, 16, 47], 4 ➞ [1, 0, 0, 3]
[17, 11, 99, 55, 23, 1], 5 ➞ [2, 1, 4, 0, 3, 1]
[6, 1], 7 ➞ [6, 1]
[3, 2, 9], 3 ➞ [0, 2, 0]
[48, 22, 0, 19, 33, 100], 10 ➞ [8, 2, 0, 9, 3, 0]
If you get stuck, see Comments for a hint.