In the past 3 years, I’ve been learning Rust in Decembers for Advent of Code, and each time, I learned something new.
In the most recent Advent of Code (2019), I did not finish all the challenges, but I enjoyed it a lot! My early decision to modularize some repetitive function really paid off in the later puzzles.
The most important concept of Rust language is borrowing. After things have been borrowed, it must be returned. As simple as this concept is, there may be lots of times one get frustrated by the compile errors of the Rust compiler. Oh, Rust compiler is so strict that Rust beginners will be very relieved if their codes compiles!
In the past few weeks, I suddenly recalled of an interesting problem I faced during my days in Competitive Programming world. It was called “Make*me-an+[integer!]“, a problem posted in Internet Problem Solving Contest 2015 problemset (link to problem)
The gist of the problem statement is as such:
Output a list of valid ECMA-262 expression of the number 0 to 1000 (inclusive) using only the characters !, [, ], +, –, and/or *, in which the correctness is determined by the value and the type of the expression itself.
For example, !! evaluates to the number 0 (this is a valid output), and +!!+[+] evaluates to string “10” (this is invalid, as the output type need to be evaluated as type number too).
The problem has two subtasks: the easy subtask is to produce the outputs where each expression uses no more than 200 characters; and the hard subtask limits the expression to use no more than 75 characters.
During the competition itself, I solved the easy subtask, but now I was quite interested in solving the hard subtask because … why not? Hahaha. In total, I spents around 2 weeks (including the many off days in between as I wasn’t in the mood for coding).
So, let’s get into the problem.
15 December 2013
This week, I joined a 4-day full-day workshop called “HTML5 and Firefox Mobile OS Bootcamp”.