r/dailyprogrammer • u/jnazario 2 0 • Mar 02 '18
Weekly #28 - Mini Challenges
So this week, let's do some mini challenges. Too small for an easy but great for a mini challenge. Here is your chance to post some good warm up mini challenges. How it works. Start a new main thread in here.
if you post a challenge, here's a template we've used before from /u/lengau for anyone wanting to post challenges (you can copy/paste this text rather than having to get the source):
**[CHALLENGE NAME]** - [CHALLENGE DESCRIPTION]
**Given:** [INPUT DESCRIPTION]
**Output:** [EXPECTED OUTPUT DESCRIPTION]
**Special:** [ANY POSSIBLE SPECIAL INSTRUCTIONS]
**Challenge input:** [SAMPLE INPUT]
If you want to solve a mini challenge you reply in that thread. Simple. Keep checking back all week as people will keep posting challenges and solve the ones you want.
Please check other mini challenges before posting one to avoid duplications (within reason).
10
u/[deleted] Mar 02 '18
[nth number of Recamán's Sequence] - Recamán's Sequence is defined as "a(0) = 0; for n > 0, a(n) = a(n-1) - n if positive and not already in the sequence, otherwise a(n) = a(n-1) + n." (Note: See this article for clarification if you are confused).
Given: a positive integer n.
Output: the nth digit of the sequence.
Special: To make this problem more interesting, either golf your code, or use an esoteric programming language (or double bonus points for doing both).
Challenge input: [5, 15, 25, 100, 1005]
9
u/chunes 1 2 Mar 03 '18
[Boxes and Conveyors] - You will be given a two-line diagram representing a series of boxes,
#, conveyors,>, and pits_that looks like this:A box on a conveyor will take 1 timestep to move 1 place to the right. Gravity is applied instantly. Therefore, the next timestep for the diagram above would look like this:
Boxes resting on top of boxes will not move until another box collides with it from behind. A box can shove all the boxes in front of it in this manner. There will always be enough boxes so that a box can reach
F. (Ifnis the number of pits, there needs to be greater than2nboxes.)Here's how collisions should be handled. Timestep 0:
Timestep 1:
Timestep 2:
Output: Assuming the input diagram represents timestep 0, print the earliest timestep during which a box is on the
F.Special: This challenge is not about IO. Feel free to hardcode the input, pass it in as two separate strings, or whatever you want to keep it easy.
Challenge input:
2
u/codingkiddotninja Mar 03 '18
[espeak the time] - A similar challenge happened before, but this is specifically for the espeak program on Linux.
Given: the 24-hour time x:y
Output: The "espeak" command reading the (12-hour converted) time in the format "It is a b (am/pm)". It should sound like how one would read a time off a clock. You can also pipe the output of a script into espeak if you wish.
Challenge input
3
u/[deleted] Mar 02 '18
My coworker found this difficult
GIVEN: A start date and end date (could just be ints), and then a selection start and end date
OUTPUT true if any date between start/end date falls during the selection start/end date
1
u/primaryobjects Apr 17 '18
R
Gist | Demo | Screenshot
0
u/[deleted] Mar 02 '18
[deleted] — view deleted comment