On June 7th, Five Rosetta Challenge tasks were added to the Dyalog 2010 Programming Contest.
The Rosetta Code page at http://www.rosettacode.org contains solutions to 400 programming
tasks, implemented in a wide variety of programming languages. Currently, only a
few of the tasks have APL solutions. We have selected five tasks which look as if
they might be fun to work on:
For each task, there is a prize of USD 250 for the best solution. Write the
best code for all of them and USD 1,250 could be yours - or your could win the same
amount simply by being recorded as the person who referred a winner to the contest!
Submit solutions to any two of the tasks and you will be eligible to participate
in the draw for 20 consolation prizes worth USD 100 each.
Apart from sharing the same pool of consolation prizes, the five Rosetta Challenge
tasks are completely independent of the main Dyalog Programming Contest: you do
not need to submit solutions to the main contest tasks in order to participate in
the Rosetta Challenge.
For each of the following Rosetta Code tasks, you must write an APL function
which works as described in the following task descriptions. It is only necessary
to solve two tasks - freely selected from those described on this page and those
posed in Dyalog 2010 Programming Contest Task Descriptions, in order
to participate in the draw for consolation prizes.
1. Animate a Pendulum
The task is introduced on the page http://rosettacode.org/wiki/Animate_a_pendulum.
You must write an APL function called AnimatePendulum, which takes
as its right argument a vector of six numbers:
-  Time interval in seconds between successive "frames"
-  Starting angle in degrees (rotating clockwise from vertical)
-  Length of pendulum in metres
-  Gravitational constant in m/s^2
-  Initial velocity in m/s
-  Number of seconds to run the simulation (0=no limit)
The function should produce an animated graphical representation of a swinging pendulum,
in some form of window, using ANY technique available from Dyalog
APL (anything from "ASCII art" via native Dyalog GUI to XAML/WPF is acceptable).
In addition, the function should return a vector containing the angle of rotation
for the first 50 "frames", in order to allow automated verification.
2. Knapsack Problem
Write an APL function called Knapsack, which takes a left argument
which is a maximum weight, and a right argument which is a matrix with three columns
containing item names, weights (in the same units as the left argument) and values
(in other words, data corresponding to the table at the top of the page http://rosettacode.org/wiki/Knapsack_problem/0-1).
The function should return a vector of item names (selected from the first column),
for those items which should be selected to go in the knapsack.
3. Happy Numbers
Write an APL function called HappyNumbers, which returns a vector
containing the first 8 happy numbers. See http://rosettacode.org/wiki/Happy_numbers
for more details.
4. Hofstadter-Conway $10,000 Sequence
Write an APL function named HC10k, which returns a 20-element vector containing
maxima of a(n)/n between successive powers of two up to 2^20, as described on the
5. Monty Hall Problem
Write an APL function MontyHallSim, which takes as its right argument
the number of simulations to run, and returns a 2-element vector containing the
probability of winning if you "stay", and the probability of winning if you "switch".
You can find a description of the Monty Hall problem at http://rosettacode.org/wiki/Monty_Hall_problem.
Except for the production of the graphical user interface in the "pedulum" task,
the solutions may not make use of
any "external" tools or utility libraries
not provided as part of a standard Dyalog APL installation.
For each task, you must write an APL function with the name specified in each of
the task descriptions. You may define as many additional sub-function as you wish.
You should collect all your code into a single namespace, and submit your
solution either as a single UTF-8 file representing the namespace containing your
APL functions (you can create this file using the ]Save user command), or a single
Dyalog workspace containing the namespace. Workspaces must be loadable using the
)LOAD system command, and UTF-8 files must be loadable using the ]Load user command
- in both cases under Dyalog Version 12.1.
Note that the submission format for the Rosetta Challenge is identical to that required
for submissions to the main Dyalog 2010 Programming Contest. If you wish to enter
both parts of the competition, you should submit a single file containing all of
your APL code; the function names that exist in the namespace will be sufficient
to make it clear which tasks you have attempted to solve. See the main contest page for more details
regarding the process for submitting solutions, and the sample submission page for
file in the correct format.
The Judging Criteria for the Rosetta Challange are also the same as for the main
contest. In the event that the judges have a hard time deciding between very similar
solutions, the quality of each contestant's solutions to other Rosetta tasks will
be used as a "tie breaker".
Correct submissions will be evaluated by a panel of judges with considerable experience
in the development of APL-based solutions. The criteria used to evaluate your submission
include, but are not limited to:
- Did you solve the problem and get correct results?
- Clarity and structure of your solution. How well documented and organized
is your solution? Can you pick up the code produced 6 months from now and
still understand what it does?
- Use of APL. Does your solution use array-oriented processing where applicable?
Solutions that look like C# translated into APL will receive less credit.
- Efficiency of your solution. How fast is your solution? You should not sacrifice
clarity for speed.
The judges' determinations are final and cannot
be contested under any circumstances