# CODE REVIEW 2017 Challenge

I want to introduce the Community Oriented Development Extravaganza, Requiring Extreme Vigor Inciting Extraordinary Winners (or CODE REVIEW) 2017 Challenge. Traditionally our Community Challenges are non-competitive, this challenge aims to change that just a bit.

We usually have these challenges run for a month, and we announce them a month in advance except in certain situations where we want to boost participation. This time I'm going to run the announcement for three (3) months and run the challenge another three (3) months. At the end of the 6-month period, I will award a 500 reputation bounty to the winner of the challenge.

Major dates for the challenge are below:

• Thursday, 1 June 2017: Challenge begins accepting suggestions
• Thursday, 31 August 2017 23:59:59 UTC+0000: Challenge finishes accepting suggestions
• Friday, 1 September 2017 00:00:00 UTC+0000: Challenge begins
• Thursday, 30 November 2017 23:59:59 UTC+0000: Challenge ends
• Friday, 1 December 2017: Winner is announced from entries

# How does one win?

In order to support the idea of a winner, we have to make sure that there is something to 'win'. Each challenge suggestion must have a detailed list of possible points to be awarded, and the participants are graded based on how many total points they earned (out of possible points).

The exact details of the awards will be announced later in the season, but at a minimum the following will be awarded:

• The first-place winner will receive a 500-reputation bounty;
• In the case of multiple first-place winners then each winner will receive a 250-reputation bounty;

If participation is high (left to the discretion of the members of the community who are offering the rewards) then an additional tiered reward system may be put in place.

# How should suggestions differ from normal?

The only difference that suggestions require from traditional questions is that they must detail specific features that require implementation and the total point-count for each feature. Challenge suggestions may mark features as 'optional' or 'required', and if a participant fails to implement all 'required' features then they are disqualified.

You may not reuse any previous community challenge selections as normally required, but you may re-suggestion un-selected challenges, and suggest challenges that are somewhat large in scope.

# How does one enter as a participant?

A question with the entry requirements (also included below) and a list of all entries will be posted on Friday, 1 September 2017.

Participating is easy, and simply requires one to meet all criteria below:

You may update your entry at any time (which means you may post iterative reviews as well), all entries will be judged at the end of the challenge season (Thursday, 30 November 2017). Entries may make as many revisions as possible, but the question linked in the entry form at 23:59:59 UTC+0000 on Thursday, 30 November 2017.

Make sure you post the suggestions you have for this extravaganza in this question, the most upvoted answer at the end of the day on 31 August 2017 will become the challenge for this three-month extraordinaire!

• So the idea is to award the cleanest implementation? It feels a bit counterintuitive, given the nature of this site. We are basically awarding the question, that does not need answers. Maybe we can come up with a system to award people who write good reviews to those questions as well? Similar to: codereview.meta.stackexchange.com/questions/7102/… Jun 2, 2017 at 8:52
• @NikitaB "So the idea is to award the cleanest implementation?" No, it's the person that scores the most points from the challenge. Anyway, why should we put bounty's on the winners answers? (assuming there is at least one.) This will function like 'Best Newcomer (question)' anyway.
– Peilonrayz Mod
Jun 2, 2017 at 10:12
• @NikitaB We do want to promote clean code, don't we? Although the one with the most points might not necessarily be the cleaniest one, I would expect that it likely is the cleaniest one. Jun 2, 2017 at 10:39
• @Peilonrayz, I don't think I have to explain why you might want to award answers. It is completely obvious: code review is what this site is about, and it makes perfect sense to award best reviews. Also I did not propose to put "bounty's on the winners answers". Answers should be judged separately from questions, bad entries will probably have the best reviews. We could award people for catching a sneaky bug or making the best improvement to promote reviewing and challenge reviewers. But its ok if you disagree, I'm just throwing ideas out there. Jun 2, 2017 at 10:46
• @SimonForsberg, now that I think of it, it depends on the point system. If you get points by implementing additional features, then it is perfectly possible to get all the points with stylistically awful code. Jun 2, 2017 at 10:54
• @NikitaB Community challenges are like Hacker Rank and other challenge websites. For the same reason I don't think Hacker Rank should award Code Review.SE answers, I don't think Community challenges should either. I do however think, if you think an answer is exemplary you can always put a bounty on it, using normal Code Review.SE guide lines.
– Peilonrayz Mod
Jun 2, 2017 at 10:59
• @Peilonrayz, sure, I can do that. I can even make up the categories, that I would award. It is just weird to me, that this is not a part of official challenge. It looks like a perfect chance to draw more people into reviewing. Jun 2, 2017 at 11:08
• @NikitaB We already bounty answers during Winterbash. The idea of this challenge is to encourage the community to participate in a group-selected competition. We typically don't get much (if any) participations on community challenges as of late, this is sort of a last-ditch effort to change that. It may also help encourage users who never utilize Code Review to join to compete as well. Hell, it may even cause people to try out new languages/environments to learn something new. The basic idea is to encourage community participation. Jun 2, 2017 at 11:42
• I think some languages automatically generate more upvotes on questions than others.. Jun 3, 2017 at 18:07
• Should there be a rule disallowing submissions that users started working on before the competition start date? Jul 13, 2017 at 0:14
• @EthanBierlein what actually counts as starting? I've had the beginnings of nafi (my language) in my head for years now, started banging out a bit of language specs this year, and even did a bit of exploratory coding towards an interpreter. I've since thrown out that code but the ideas remain. I'm writing a library right now I plan to use, does that count? Also, this is like the main reason I might get this to a workable state this year after sitting on it for multiple, I don't want to lose the opportunity for motivation. (tl;dr pls not too strict) Jul 13, 2017 at 7:15
• @EthanBierlein I think a requirement of was-not-functional-before-start-date is fair. (So PPCG users don't get to submit their preexisting golfing languages they built.) After that it's a case-by-case question on whether the work done beforehand is considered a library or exploratory enough that it's not a significant part. In any case, I'd use 1 June 2017 as the start. Jul 13, 2017 at 7:21
• Should this post be [featured]? Aug 10, 2017 at 4:25
• The link to the entry form should probably be updated with something that doesn't just link back to the main meta page. Sep 1, 2017 at 1:50

# Write your own programming language

I think for this challenge we should make the barrier to entry low, the barrier to win high, but most of all it should be fun!

Since we're writing a language, it's always good to know that it works. And so to score each point that adds additional features requires a unit test. All unit test must be provided for you to score the point. To allow all languages to do this, you can verify the programs output in the language you're writing in. And so if you were to write your language in the Python programming language having a unit test such as the following would be valid:

import unittest

class TestStandardArithmetic(unittest.TestCase):
# Replace eval with how you run your code
self.assertEqual(eval('1 + 1'), 2)


## Requirements

• You won't be scored for any use of eval that's provided by your language. Posting input() as your language, and requiring Python 2 is a valid language, however will score you no points.

• When scoring each point, you must use your own implementation for that point to score the point. This allows you to use, say, the LLVM to implement tail recursion in your language by default, however when scoring the point for tail recursion, you have to use your own implementation of it rather than the one provided to you by the LLVM.

• Another person must be able to verify your language works. And so make it runnable from either Windows, Linux, Mac, or via a website.

If it needs another program to run, such as CPython, the JVM, or a browser, that is fine. But it must be runnable on one of the above systems, or via a website.

Since to do this we need to be able to get either a binary, or your code, entries need to produce a GitHub, or any other code sharing service, repository for their language. This allows entries to write Code Review questions on what they want reviewed, rather than a new question of their entire code on each change.
This repository must be provided in the entry meta question on your entry.

## Scoring

Each bullet point is worth one point. 'Functions' may be prefix, infix or postfix operators, normal functions, or any other method that's usable in your language.

For each bullet point that adds an additional function or feature write a test case/suite with at least one unit test for each additional function or feature.

• Implement all standard operators/functions.

• addition (+)
• subtraction (-)
• multiplication (*)
• division (/)
• less than (<)
• less than or equal (<=)
• greater than (>)
• greater than or equal (>=)
• equal (==)
• not equal (!=)
• binary or (|)
• binary xor (^)
• binary and (&)
• binary invert (~)
• binary left shift (<<)
• binary right shift (>>)
• boolean and (&&)
• boolean or (||)
• Implement operator precedence. Perform, say, multiplication and division before addition and subtraction.
• Use lexical analysis to generate a token stream.
• Use syntactic analysis to generate an AST, or related structure.
• Have your language be directly interpreted.
• Have your language compile to an intermediate language.
• Have your language compile to an intermediate language and then be executed by a 'virtual machine'. Your intermediate language must be custom-made in order to gain this point.
• Have your language compile directly to assembly.
• Write a Code Review question in your language.

In addition to the above you may also get points for implementing programming paradigms, according to Scoring of paradigm support. A big thanks to CAD97 for making such a large list, anyone can add to.

I can't think of too many ways to score this, so if you can think of any, drop it as a comment, :)

• I like this idea! Interestingly enough, I was thinking about proposing something similar earlier today, but you beat me to it. :) Jun 7, 2017 at 2:14
• @EthanBierlein Funnily enough, I was originally going to suggest doing a calculator, but that's already been done before ): If you have any ideas I've not posted, then I'd be more more then happy to hear them too, :)
– Peilonrayz Mod
Jun 7, 2017 at 9:19
• A couple of ideas came to my head this morning while re-reading the post. Many of the bullet points seem to focus strongly around OOP and imperative programming, with little regard to other programming paradigms. Perhaps contestants could get a point for each paradigm their language allows? Jun 7, 2017 at 14:06
• @EthanBierlein Fair, I thought I included Functional too, maybe I should add tail recursion for that. I'll try learn a few key features of other paradigms to make bullet points for them. Thank you :) As for per paradigm, I don't really know how to score that, and for contestants to be able to 'prove' that.
– Peilonrayz Mod
Jun 7, 2017 at 14:16
• In regards to proving paradigms, perhaps requiring contestants to submit paradigm-specific unit tests would work? In regards to scoring, +1 point for each paradigm implemented? Jun 7, 2017 at 14:19
• @EthanBierlein That could work, it may be a bit unfair on people that don't know the paradigms, but they're unlikely to implement a paradigm they don't know...
– Peilonrayz Mod
Jun 8, 2017 at 8:11
• I'm already "working" on this for my own gratification, so +1 from me :P (Though I'd suggest avoiding giving points for allowing classes to inherit; e.g. rust doesn't do that, and it'd be less fair if making a OO language got more point potential.) Jun 9, 2017 at 18:57
• @CAD97 My intent is for each paradigm to score points for being implemented, yes I've not included all paradigms, and I need to work on that. Another example of this is 'first-class and higher-order functions' are common in functional languages, but relatively uncommon in non-functional languages.
– Peilonrayz Mod
Jun 9, 2017 at 20:49
• So, could I write an ANTLR file for a subset of C# and just run it with MS's C# tools? Wouldn't that fall under the "needing other programs to run"?
– user34073
Jun 10, 2017 at 15:03
• @Hosch250 I don't know enough about those things to be definitive. If I can download those tools on Windows, Linux or Mac, follow some instructions, and bam you language works, that is perfectly valid. However I first thought you were on about the eval point, do you think that passes the eval requirement? (I know near nothing of the three technology's you're on about)
– Peilonrayz Mod
Jun 10, 2017 at 15:13
• No, it isn't eval, but it is kind of close. Basically, I would just have to write a spec for a subset of an existing language, then run it as if it was a program written in that language.
– user34073
Jun 10, 2017 at 15:16
• @Hosch250 I think if you define a subset language and then run it through the compiler for the superset language that counts as an eval. Because you aren't interpreting the code yourself, you're using a different program to interpret the code. The spirit of the rule is that you can require programs as the platform for your language but you should do the actual transformation of source code into result yourself. However you could use an ANTLR file which did simple arithmetic for some points. Then your required platform software would be the ANTLR interpreter. Jun 11, 2017 at 2:14
• Just checking: the language I've been hacking on on-and-off (I'm working on supporting tooling currently for the next complete-rewrite-refactor stage) has and will have a lot of supporting code as I'm making most of the toolchain from scratch (because the point is to learn about how programming languages work full-stack). How much of the project would be expected to be in the post and how much external? Could I break it into more manageable chunks? Jun 11, 2017 at 2:23
• One better: Here's a list of some paradigms and suggestions for scoring. It's not perfect but it offers some structure and semblance of balance between features inherent to the different paradigms. It's not perfect, and it's definitely not a document for beginners, but just some of the knowledge I've picked up and my personal opinions on language features. Jun 11, 2017 at 4:35
• "Write a Code Review question in your language." I would be wary of this. Languages created for this challenge would be unlikely to be used elsewhere. Do we really want to open another question for it? It might be better to have some concrete thing to implement in your language, such as some sort of List type. Jun 14, 2017 at 21:52

## Chess!

Last year ended with a board-game spree. Let's continue this year with one.

I think you all know the game of Chess, which is exactly why I just linked to the Wikipedia page. Even though everyone knows it, you might not know all the details about it.

What I like about a Chess challenge is that it can be both a small and a large challenge, depending on what you want to do with it. Let's take a look at some possible challenges for Chess: (feel free to pick the ones you want)

1. Implement logic to determine where/how pieces can move/attack
2. Determine which squares are threatened by what pieces
3. Implement support for some Chess notation (there are a bunch to choose from)
4. Given a history of chess moves, check if all moves are valid and figure out how the board looks like now.
5. Interact with the Lichess API for example use this data and implement the above
6. Make a GUI
7. Make a Chess computer opponent
8. Make a Chess computer opponent that beats Stockfish level 8 (good luck with that)
9. Implement some Chess variant such as Atomic Chess
10. Probably a bunch of other stuff

## Scoring:

Item 1 is required. If you don't have that, it doesn't count as a submission. Items 2, 3, 4, 5, and 6 are worth one point for each variant supported, with another point for each variant implemented (item 9). Item 7 is significantly more difficult, so it gets 2 points for the engine and one point for the scoring system for each variant supported. If you implement item 8, you win outright and get a 500 point bounty from me (SE's limit).

Item 10 is rather vague, so I will give you one point per item implemented, but it has to be a serious feature of at least the complexity of item 1--in other words, don't try to bolster your ratings; if the community feels a player is attempting to do this, it is their responsibility to jointly decide a more fair rating. Additionally, if a player feels one point is too low for a feature's complexity, they can petition the community to grant them a higher score.

# Create an image from any given file.

The objective is to create an image from any file, per instance, text file, audio file, or any other file. This is more of a challenge where people should be creative.

Just imagine see text as an image, or even an assembly! We programmers would finally be able to see code as an image (for the first time in history?).

# Scoring:

1. Your program works on any text file (UTF-8) (1 point)
2. Your program works on any file type (1 point)
3. Your program does not require external libraries (1 point)
4. You are able to generate jpeg files (1 point)
5. You are able to generate png files (1 point)
6. You are able to generate bmp files (1 point)
7. You are able to generate gif files (2 points)
8. The generated image is different if the file type is different (1 point)
9. Relative beauty of generated images (this is a subjective qualification, post your results on your question!)

Total possible score: 9 + beauty

• Could you expand a little on "Your algorithm does not require external libraries". If I make image be a 2D array of pixels, and just mutate that in my language of choice is, then move that to my external data type. Is that allowed? Also, does it mean I can't use use an external library to make all of jpeg, png, bmp, gif?
– Peilonrayz Mod
Jun 13, 2017 at 10:22
• @Peilonrayz You can use them, but you get an additional point if you don't use them. This is only libraries not included with your run-time environment. What this means is that your are allowed to use any libraries offered by your run-time, but not libraries by a git-hub project, nugget, npm, etc Jun 13, 2017 at 10:22
– Peilonrayz Mod
Jun 13, 2017 at 10:26
• @Peilonrayz I thought I would make it a bit less penalizing there's no reason giving it 2 points. Jun 13, 2017 at 10:38
• I'd personally make it like 5 / double points. Without it I can do the rest of your program in like an hour with Python and PIL...
– Peilonrayz Mod
Jun 13, 2017 at 10:41
• @Peilonrayz No worries on that. The challenge is not to create your own image processing libraries. Would like to see your entry on this Jun 13, 2017 at 10:42
• What kind of image do you expect from an audio file? Jun 13, 2017 at 15:58
• @SimonForsberg It's about being creative. You choose how you transform audio into an image or this Jun 13, 2017 at 16:20

# Allocate resources efficiently on a work environment

The company Code42Review demands that their employees are able to handle work items as efficiently as possible.

Those work items are assigned according to the work item chooser that decides which work items get assigned to which employees. The work item chooser takes into account the skills needed by a certain work item and tries to match them as close as possible to the skills of an employee. While some skills are mandatory others are "nice to have". The work item chooser may delay assignment due to not having any employee available with a required skill.

A work item only exists if a work candidate has acquired all resources sucessfully. Acquiring a resource is a process that may require time, in this particular work envoirnment, up to 20 seconds. The process of acquiring a resource is not guarteed to succeed because such resources might not be available. (the successful rate of resource acquisition is tipically under 50%)

In this work enviorment an employee may take up to several minutes to complete a work item. Usually something between 2 and 20 minutes. An employee that is handling a work item is considered to be busy and may not have another work item assigned to him.

A work item should be assigned to an employee within the shortest amount of time possible, if it's not assigned to an employee within a reasonable time, the resources may no longer be available. In this scenario the work item will be replaced by another.

# Scoring

Your job is to create a program that does the following

1. Employees should spend the least amount of time possible waiting for work items (up to 10 points, scored according to the average amount of waiting time, 10 being awarded to the smallest)
2. Work items are discarded as few times as possible (up to 10 points, scored according to the amount of discarded work items, 10 being awarded to the smallest)
3. Work items are assigned to an employee within the shortest amount of time possible (up to 10 points, scored according to the average amount of assignment time, 10 being awarded to the smallest)
4. Work items are assigned to employees according to their skillet while respecting all the above (7 points, optional)
5. Do your own work environment simulator, according to the rules I stated. (if there is anything that is missing please edit, or comment, assume normal distribution) (7 points, optional)

Total score - 44 points.

• The values given are an example and the solution should work for any other given values. Jun 13, 2017 at 18:13