# September 2016 Community Challenge

We've just gotten the August 2016 Community Challenge going, so it's time to pick one for September.

It's time to choose a for September 2016.

• Post your challenge as an answer to this question. Feel free to resubmit non-winning ideas from previous months.
• Vote for those answers which interest you.
• At the end-of-day on Wednesday, August 31st, the top-voted post will become the next challenge.

Once the challenge topic is decided, post your solution as a question on the main site and tag it with . The challenge runs throughout September (but nothing stops you from posting an entry later on).

• After this, community challenges are scheduled to resume in February 2017. – 200_success Sep 26 '16 at 18:18
• @200_success ah, I was wondering what happened. Is there a thread on this decision (not that I have a problem with it)? – Raystafarian Oct 7 '16 at 11:36
• @Raystafarian meta.codereview.stackexchange.com/questions/6011/… – 410_Gone Oct 7 '16 at 16:13

I resubmit Legato's submission for August 2016:

# CRitter Collaboration

Choose a previous community challenge and work with someone(s) to complete it.

Though interest in challenges may be high time can be scarce so this is a way to get more participation! It doesn't even have to be a community challenge as long is it's something you and others agree to work towards for the challenge period.

Definite Benefits:

1. Exercise in effective communication.
2. Getting to know fellow CRitters!
3. Experience in organization / group tasks.
4. Less time-consuming.

Possible Benefits:

1. Practice in another language.
2. Exercise in language agnostic design.
3. Using a VCS such as Git.

Room to find people to work with / discuss implementation, and plan.

• I like the idea, ..but then, it doesn't seem fair that only one of the contributors gets all the rep out of question votes. Perhaps the lowest-rep contributor should post the CR question? – Mathieu Guindon Aug 22 '16 at 20:32
• I was thinking the challenges could be CW, or, if the project is large enough, they could perhaps post two or more. The contributors would have to work this out between them. Maybe they could even do two together and each post one. – Hosch250 Aug 22 '16 at 21:31
• IMO making CW questions does not encourage reviewers to post answers - at least not the new ones, those with lower reputation scores. – Mathieu Guindon Aug 22 '16 at 21:33
• True. I still think it would best be resolved between the contributors, but perhaps we could have a guideline that the lowest-rep contributor post unless they come to a satisfactory conclusion between themselves? – Hosch250 Aug 22 '16 at 21:36
• Is there a inside joke or a running gag I don't get when you say CRitter instead of critter? – Christian Dean Aug 26 '16 at 14:31
• @Mr.goosberry "CR" is the name of the site, so it is a joke that we are "CRitters" because we are members of CR. – Hosch250 Aug 26 '16 at 15:10
• @Hosch250 Oh.... Thanks for answering – Christian Dean Aug 26 '16 at 15:29
• @Mat'sMug I'd say it's more important that questions get posted than who posts them. – Simon Forsberg Sep 4 '16 at 18:04

# Chain (or belt) drive system

I propose a variation on this challenge by Ell over on PCG - minus the golfing requirement, of course. (Disclosure: I've already done this challenge in JavaScript)

To quote the original:

Your program will be given a list of sprockets, specified as (x, y, radius) triplets. The resulting chain drive system is comprised of these sprockets, connected together by a closed taut chain passing over each of them, in order. [...]

For example, given the input

(0, 0, 16),  (100, 0, 16),  (100, 100, 12),  (50, 50, 24),  (0, 100, 12)


the output should look something like

The original challenge is to generate a fully animated chain drive system, but that's quite a mouthful, so I propose that it can be solved to different degrees:

• Analysis without visual output (e.g. calculating the total chain length, whether the chain crosses itself, the rotational offset from one sprocket to the next that's necessary for the chain to mesh, time taken for a link in the chain to make one full circuit, etc.)

• Simplified, static visualization showing the spatial layout and chain path

• Full-on animation, as per the original challenge

• Interactive visualization (animated or not), e.g. with customizable settings or even click and drag sprockets

And the chain doesn't need to be a chain nor do the sprockets need to be sprockets; it could just be a belt drive system, i.e. plain circles and lines. This would add a lot of flexibility as things won't need to mesh (and radii and placements won't be constrained), but you'd still be calculating tangent points etc.. Animation wouldn't be as fun, but one could add indicators to the wheels and belt to show the movement.

Or one could go the other way, and have the chain be properly segmented into links like a bike chain, instead of drawing a smooth arc around the sprockets.

I admit that the challenge appears a little daunting, but it's actually not that bad. If the goal is simply to do that analysis part (i.e. no animation or graphical output), it can be done in pretty much any language. All that's needed is a bit of vector math (to work out tangent points), and basic geometry (to work out arc lengths).

Still, the task does look daunting, which presents a bit of a barrier to entry so I don't know if it's the best fit for a community challenge. But personally I found it to be an interesting (and fun!) task, with plenty of "meat" on its bones.

• That challenge was literal art, oh my god. – cat Aug 12 '16 at 15:44
• Would whoever downvoted care to post their criticism? Just curious – Flambino Aug 16 '16 at 12:15
• The gears image is offensive to me - why's it gotta go clockwise? You got something against counter-clockwise motion? But seriously, I didn't downvote, but I imagine it's probably due to exactly what you mention at the end of the post, or at least similar. Personally I like pretty simple challenges that can be increased in complexity by choice rather than that barrier to entry. In the same breathe, I think this is distinct enough from other challenges that it sticks out and will probably end up on the backlog to be used in the future. +1 – Raystafarian Aug 16 '16 at 16:08
• @Raystafarian Yeah, you're probably right. I should maybe add a little about what's required to solve the task just at a basic, non-graphical way (some simple vector math and trig). It's really not as daunting as it might seem. Anyway, time for commercials: "Flambino is the pro-clockwise choice this election. Raystafarian, with his twisted rhetoric, defines himself only in opposition to what's right (-turning) and natural! (Paid for by Clockmakers for Truth 2016)" – Flambino Aug 16 '16 at 17:10
• "Do you live in the northern hemisphere? Are you Ancient Egyptian? Then why are you stuck in the past? Sundials have been moving clockwise for more than 5,000 years - why not a change? You don't want people thinking you support global warming, do you? Change is the future! Counter humankind's past mistakes this year by going with the future - Raystafarian. (Paid for by Antique Jewelers Across the Globe) – Raystafarian Aug 16 '16 at 18:35
• @Raystafarian "Is Raystafarian a communist? Some say yes. (Paid for by Asinine Insinuations Meant to Derail the Public Discourse)"... This is going to get out of hand isn't it? – Flambino Aug 16 '16 at 18:40
• @Flambino dangit, this look complex. Where you you even start?! especially this - Interactive visualization (animated or not), e.g. with customizable settings or even click and drag sprockets. WHAT ?! – Christian Dean Aug 26 '16 at 3:33
• @Mr.goosberry It's not as bad as you might think. When I first saw the challenge, I thought it was ridiculously complicated too. I'm not saying it's simple, but like with anything, if you go one step at a time, you'll figure it out. As for making it interactive: If you can draw the system from static input, you can also draw it from dynamic input. Most of the extra code would be likely user-input handling - not the actual sprocket system. – Flambino Aug 26 '16 at 11:04
• @Flambino hmm... Maybe I can use Python's Pygame to whip something up. I can probably make the gear animation, but that user interactivity thing is gonna make me think. Despite this, your idea looks very challenging, which is good. +1 – Christian Dean Aug 26 '16 at 12:55
• @Mr.goosberry Not my idea! All credit goes to Ell over at PCG :) And yeah, pygame might be a good fit. As for interactive, there you can either re-render everything for every change (in which case it's the same as rendering the given test input), or you can optimize to only render affected parts of the system. The first option is of course simpler, and good place to start – Flambino Aug 26 '16 at 14:09
• @Oh. You sneaky thing, trying farm extra rep, are we? ͡(° ͜ʖ ͡°) . Anyway I'll shoot over and look at the original post by ELL at PCG. – Christian Dean Aug 26 '16 at 14:17
• @Mr.goosberry Honest answer: Nobody complains about extra rep, but I didn't suggest this challenge with that as an ulterior motive. It was more that I am pretty happy of the solution I came up with over on PCG, but I'd like to see it discussed. Can't really request a review of ~1800 bytes of golfed gibberish, but an ungolfed version could be fun to post for review. And I'd like to see other approaches than my own too. – Flambino Aug 26 '16 at 14:26
• @Flambino I know dude. I was just kidding. But I do have a question: do the gears have to be that complex in terms of graphics? Could they just be circles? – Christian Dean Aug 26 '16 at 14:29
• @Mr.goosberry Sure - the fun is in "solving" the system. That's what I meant when I wrote it can be a belt drive. No segmented chain, just a line, and not sprockets, just wheels – Flambino Aug 26 '16 at 14:32
• Great! I'll get started on something to enter, just in case this is picked. goodbye and cheers!. – Christian Dean Aug 26 '16 at 14:34

I re-submit Heslacher's proposal from August 2015:

In image processing, a contour is a closed curve forming the boundary of a region of the image (or a union of closed curves, if the region has holes). For example, given this image:

The contour of the black region is the pair of orange curves shown here:

Implement an algorithm that finds the contour of a region in an image.

You may assume, if you wish, that the image is represented as a two-dimensional array of Booleans (indexed by $x$ and $y$, say), with array entries containing true for the region of interest.

Possible choices of algorithm include:

# Combinations Calculator

### What is a combination?

A combination is a selection of all or part of a set of objects, without regard to the order in which objects are selected.

For example, suppose we have a set of three letters: A, B, and C. We might ask how many ways we can select 2 letters from that set. Each possible selection would be an example of a combination. The complete list of possible selections would be: AB, AC, and BC.

source

### The challenge

You are to take input of

• n non-numeric elements in whatever format you'd like
• r size of combination groups

And output how many distinct combinations of r elements are possible from the total n population, without regard for the order of the elements. So as to say that both AB and BA cannot both be counted because they are the same combination with different permutations.

### Sample data points

As an example of input to output, you can use these data points

(n,r) = c

7   1    7
7   2    21
7   3    35
7   4    35
7   5    21
7   6    7
7   7    1
15  1    15
15  2    105
15  3    455
15  4    1,365
15  5    3,003
15  6    5,005
15  7    6,435
15  8    6,435
15  9    5,005
15  10   3,003
15  11   1,365
15  12   455
15  13   105
15  14   15
15  15   1


## Bonus round

If you feel like it, instead of output of the number of combinations, output the actual combinations in a legible form e.g.

Note: (n=34, r=17) > 231

This question is about entering in the colors of a Rubik's cube with four squares (2x2) per side. It uses a text interface.

I was thinking that we could have a challenge to create a graphical interface for a 3x3 Rubik's cube.

There are six sides, each with a 3x3 grid. Parts of the cube can be rotated, mixing up the colors. The center of each grid always stays the same color. The corners are shared between three sides. For example, one corner is red, white, and blue. Some pairings for colors are impossible because the colors are on opposite sides.

Opposite color pairs when solved: green/blue; red/orange; yellow/white.

As I said, the base problem could be a graphical interface to choose the colors for each square. A simple interface might just show each of the six sides. A more advanced program could show them as a cube and allow the user to rotate the cube to choose the colors on a different side. Bonus points if the program could check that the chosen colors are actually possible in a solvable cube. A really advanced program could solve the cube.