Inspired by
this article from SKB Kontur, we decided to conduct
Code Retreat in our faculty (Tomsk State University, Faculty of Informatics). True, our goal was not to learn any specific technologies, but rather just to get to know (half of the participants from 1-2 courses), a fan and a bit of abnormal programming.
Briefly about the format of the event
- Sessions of 45 minutes (in total there were 4 sessions + introductory quest).
- Between sessions a break of 15 minutes with coffee and buns.
- One task for all sessions, but each session is declared a restriction for this round.
- Programming is performed in pairs (Encoder and Navigator), the pair have one computer, at the same time only one person writes code (Encoder).
- Every session pairs change.
- Every 11 minutes, the pair change roles.
The format-standard restriction “after each session the code is deleted” was decided not to be entered at our event, since there was no great confidence that everyone would cope with the task within the prescribed period (after all, the participants are not professional programmers, but mostly younger students).
In addition, to increase the FpM (fun per minute), additional restrictions were introduced that are not related to the Code Retreat format:
- Each round is announced one more general entertainment restriction.
- Each team receives a personal entertainment restriction.
The task
We now turn to the specifics. The task is to write an interpreter of the esoteric programming language
HQ9 + . The task for the 0th round was to determine the task. To do this, in social networks (Twitter, Google+, Vkontakte) under the tag # coderetreat4csd published tips (text and pictures). In total there were 3 branches of tips, which ended with the answers “Hello, world!”, “Quine”, “99 bottles of beer” (3 main components of the HQ9 + language), which should lead to the correct answer. I will not enumerate the quests of the quest themselves, I will just say that it was aimed at studying the features of various technologies: rarjpg, base64, obfuscation of the code (using js for example), quer codes with pictures (serious guys, do not skeptical forehead - for the first or second the course is rather unobvious things, especially when you have never met them before, and the time for the 0th round was limited to 30 minutes).
In the end, the quest for the allotted time, no one decided, although individually each branch of the quest passed at least one team. With the help of leading questions, the task was conveyed to the participants, after which everyone went to eat and tell each other what the interpreter is, because some started to panic.
1 round
There are no restrictions. There is no fan assignment. There are no individual tasks.
Populated by robots .
Nothing special happened here, everyone sat down in teams and started coding. I must say that almost all the teams spent most of the allotted time, because slowly drove in, taught the younger ones, morning,
and indeed, the ping is big and mother called . But in the end, everyone managed (someone even managed to automatically get rid of the tests we had prepared, which was absolutely not necessary to do), and went to eat sandwiches.
')
2 round
Restriction: do not use the characters H, Q, 9, + in the source code of the program. The fun task: the background music plays, you need to change not once every 11 minutes, but for each song. Individual restrictions are (in all subsequent rounds, too).
Everything has become more fun. The ability to reuse the code did not help much, because you got behind the new computer, saw the code for the first time, and often did not even know how to program in the language in which it was written. But still very few people wrote the code again, everyone tried to somehow adapt to what was written. The most amusing in this sense was the code with patterns that someone managed to write in the first round. This was the only case when other teams sitting at this computer were really comfortable.
The restriction was much more interesting than we had planned. The inability to use string literals with the letters H, Q, 9, + forced to put all the lines into files or use ASCII codes. The inability to use while, then (for pascal), throw, catch, made the encoding process much more fun than in round 1, although when we came up with round 2, it seemed to us not very difficult.
Music delivered. The playlist was chosen in such a way as to bring the maximum amount of fun, distracting only occasionally. It is necessary to say that the participants were persistent for us, neither Ranetki nor Kirkorov, they did not get through. All coded intently.
Individual assignments were also excellent. The most interesting of them are:
- The encoder uses only the keyboard, and the navigator uses only the mouse.
- As identifiers use only kosher names.
var cashrut = new StreatReader("input.txt"); string halacha = ""; string jewish;
- Write code with one finger.
- Write code with included caps.
As a result, individual tasks did not hinder much, but added fun to both the participants themselves and those around them. In general, this task also completed almost everything. And, as always, food.
3 round
Restriction: do not use arithmetic operators (including bitwise) and comparison operators. Fun assignment: participants take turns writing a fairy tale about a programmer on Code Retreat.
The restriction was not as difficult as we thought. We thought everyone would rush to write a long addition, and not here it was. As a result, the solutions were 3: put in a string and take Length, add using .NET Expressions, count the number of “+” characters in the input file using Count extension from LINQ (not a very fair decision, but the tests pass, and we are very liked).
The tale turned trash. Some kind of mixture of philosophy, zen and hopelessness. Then we collect and lay out.
Of the fun individual limits in this round, I only remember "For each successful build, shout" YA! "And dance the dance of little ducks." But it amused not only the team itself, but all around.
Food.
4 round
Restriction: do not use loops, goto and collections (except for strings). Fun assignment: no.
The main idea was to push the guys to use recursion. Strings were allowed only to simplify working with string literals (so as not to read a line from a file each time, because in the recursive version this is generally some kind of trash). As a result, because of this relief, there was an amusing decision on String.Replace, but we are not worried, we also liked it very much. Almost all the teams came to recursion, some of them in half the time, we offered them to solve the stack overflow problem on a very large sequence of commands. Here it was necessary to get to the idea of using new threads or even processes when reaching a large stack depth, and some even came up with this solution, but nobody had enough time to implement it.
We did not add the task for this round, because believed that the main limitation is already complicated. As a result, the participants coped with this round on average even faster than the previous ones, apparently rocked in 4 hours.
Interesting individual limitations:
- Navigator blindfolded.
- Use only "_" for identifiers.
case '9': { var __________ = new StreamReader("lyrics.txt"); string _________ = __________.ReadToEnd(); __________.Close(); ________.WriteLine(_________); break; } } if (_.Length == 1) return ______; else { _ = _.Remove(0, 1); ______=__(_, ___, ______); return ______; } }
- Identifiers in Chinese.
static void Main(string[] args) {輸入 = File.ReadAllText("input.txt"); FileStream 作為故事講述 = new FileStream("output.txt", FileMode.Create); FileStream 用故事畫裝飾 = new FileStream("counter.txt", FileMode.Create);閱讀 = new StreamWriter(作為故事講述); StreamWriter 他編造了他的學歷經歷 = new StreamWriter(用故事畫裝飾);表(輸入);他編造了他的學歷經歷.Write(計數器);他編造了他的學歷經歷.Close();閱讀.Close(); }
- Do not use spaces and tabs.
private static void ReadSymbol(in i) { char[] c=new char[1]; if(file.Read(c,i,1)<=0) return; i++; switch(c[0]) { case 'H':file1.WriteLine("Hello,world!");break; case 'Q':file1.WriteLine(file);break; case '9':file1.WriteLine(stih);break; case '+':count++;break; } } } }
The end. Cleaning. Valim.
The event was very fun and not very difficult. 16 participants (from all courses, from 1 bachelor degree to 2 magistracies), 8 organizers, a lot of food, 5 hours of coding, 3 programming languages (Object Pascal, C #, C ++). Everyone is happy, so are we. We will conduct more. Program more and with pleasure!