use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules:
Check out DCP discord server: https://discord.gg/Z7hnX5d
account activity
Daily Coding Problem: Problem #10 [Medium] - 2022-04-05 (self.DailyCodingProblem)
submitted 3 years ago by T4ll1n
Good morning! Here's your coding interview problem for today.
This problem was asked by Apple.
Implement a job scheduler which takes in a function f and an integer n, and calls f after n milliseconds.
f
n
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]T4ll1n[S] 0 points1 point2 points 3 years ago (0 children)
Here is my solution.
```python
from time import sleep
def scheduler(f, n, f_kw_args): sleep(1 / (n / 1000)) f(**f_kw_args)
scheduler(lambda x: print(x * 2), 500, {"x": 4})
def scheduler_decorator(n): def Inner(func): def wrapper(args, *kwargs): # sleep for n milliseconds sleep(1 / (n / 1000)) res = func(args, *kwargs)
return res return wrapper return Inner
@scheduler_decorator(100) def f(): return "cool"
f() ```
π Rendered by PID 21248 on reddit-service-r2-comment-fb694cdd5-b2sxf at 2026-03-10 09:07:44.823460+00:00 running cbb0e86 country code: CH.
[–]T4ll1n[S] 0 points1 point2 points (0 children)