fas fa-trophy missing
1: Drop
fas fa-trophy missing
2: Intersection
fas fa-trophy missing
3: Min
fas fa-trophy missing
4: Bounds
fas fa-trophy missing
5: Replicate
fas fa-trophy missing
6: Double
fas fa-trophy missing
7: Up
fas fa-trophy missing
8: Unique
fas fa-trophy missing
9: Caseless
fas fa-trophy missing
10: X
Your Submissions
LocalStorage is disabled or you are using an old browser. Please register (and log in) to have your solutions saved.
APL Logo

Welcome to the APL Challenge!

The deadline for the current round (2024.2) is Wednesday 31 July 2024 at 23:59 UTC ().

The APL Challenge is a quarterly event where you use APL to solve up to ten problems. Each round runs for three months, after which Dyalog Ltd awards three USD 100 prizes, with your chances of winning increasing based on the number of correct entries you submit.

Don't know APL? APL is an array-oriented programming language that will change the way you think about problems and data. It doesn't take long to learn enough to participate in the challenge. Many people have learnt APL by participating in past competitions – including winners! APL is easy to learn and will allow you to translate your knowledge into computer-based solutions, quickly and efficiently.

Don't have time? If you're interested but don't want to actively participate in this round, please register anyway so that we can notify you of updates and inform you about future rounds. You can opt out at any time.

Overview

The APL Challenge consists of 10 problems:

  • 3 problems, each of which requires you to write an expression that uses a single APL primitive.
  • 3 problems, each of which requires an expression with 2 or 3 primitives.
  • 4 problems that are somewhat more complex, requiring you to write your own one-liner function.

Developing your solutions

TryAPL is sufficient for developing your solutions. A full desktop development environment is also available for common platforms as a free download. Whichever environment you choose, you can produce APL symbols by clicking on them in the language bar above the input area.

When ready to test a solution, paste it into the input field at the bottom of the corresponding problem page and then hit  Test or   Enter. The system will now validate your solution. You can also type your solution directly into the input field.

Although you can begin without registering – most browsers will store your solutions until you register – you must be registered and logged in to submit solutions. When you're happy with a solution, hit  Submit. The system will only allow you to submit valid solutions.

Are you ready to proceed? Click Next .

Prizes

Anyone can win a prize except Dyalog employees and associates. We reserve the right to choose the winners at our sole discretion and will not enter into conversation about our choices.

All prizes are denominated in U.S. dollars, but can be awarded in U.S. dollars (USD), pounds sterling (GBP) or euros (EUR) by electronic transfer to a bank account or a PayPal account. No other forms of payment will be made.

If you are selected as a winner but are unable or unwilling to accept the prize, you cannot transfer the prize or designate someone else as the winner. Prizes must be claimed within three weeks of being notified or you forfeit the right to that prize.

If you accept a prize, you will be solely responsible for all applicable taxes related to accepting that prize.

Sponsors

Detailed rules

Conditions

All participants must submit to these rules.

Multiple registrations to a single round are not allowed. However, until the deadline, participants can submit replacement solutions. Only the last submitted solution for a given problem will be counted.

Participants must provide truthful and accurate information regarding contact and personal information.

Participants must not publish their solutions prior to the end of the challenge round. Doing so will be considered grounds for disqualification from the challenge round.

Only entries that are received by the deadline are eligible. We cannot accept responsibility for entries that are lost, delayed or damaged. Proof of sending an online entry is not proof that we received it.

Entries not submitted in accordance with these terms and all other rules and directions (at the sole discretion of Dyalog Ltd) will be excluded from the challenge round.

Your submission and its contents can be used at the discretion of Dyalog Ltd.

Collaboration

Participants must ensure that all solutions that they submit are produced and owned by them.

You can collaborate with others in learning APL and solving the problems, but each submission must be made by a single person and only that person will be eligible for a prize. Each collaborator can submit an entry.

Frequently Asked Questions (FAQ)

In APL, how do I…?

In fairness to all, we cannot provide answers to challenge-specific questions. Instead, have a look at the Getting Started guide.

Does the possibility of winning prize money classify as commercial use of Dyalog?

No.

What do I do if there is a problem with this website or I have a question about a problem?

Please report any problems or direct any questions to challenge@dyalog.com.

I did not receive an email with a code when registering. What should I do?

Click Register again and wait for 5–10 minutes. Make sure you check your spam folder. If the code still doesn't come through, then please report the problem to challenge@dyalog.com.

Data protection and cookies

We use cookies to keep you logged in and to retain your solutions. By using this site, you agree to this.

We only collect the data necessary for the competition to run, and will use any personal information submitted in accordance with Dyalog Ltd's Privacy Policy.

At any time after you have registered and are logged in, you can erase all data that is stored about you as part of the competition by clicking the user button email@domain.com in the top right corner and selecting Erase account and data.

Consent to usage of information

By participating in the challenge, you consent to the use by Dyalog Ltd of all text and code that you submit, for any purpose, in any media, for an unlimited period, without remuneration. We have the right to publish, display, reproduce, adapt, promote or otherwise use entries in any way we deem fit. You warrant that you are legally entitled to grant these rights to us and agree to indemnify us in the event that we suffer any loss as a result of false information you provide.

By participating in the challenge, you agree that if you win and subsequently participate in any promotional activities or material, you will do so without additional payment or permission.

Disclaimers

We are not liable for any damage, loss or disappointment suffered by you for taking part or not being able to take part in this competition.

In the event of unforeseen circumstances, we may alter, amend or cancel the competition without prior notice.

We reserve the right to change these terms at any time.

These terms are governed by the Laws of England and Wales and all disputes subject to the jurisdiction of the courts of England and Wales.

Technology

This site was constructed with, and runs on,

MiServer, a free, open-source web server implemented in Dyalog APL. It enables the APL user to build sophisticated websites using the power of APL and with minimal knowledge of web technologies like HTML, JavaScript, and CSS.

To safely verify submissions, we use

Safe Execute for Dyalog APL, a tool developed by Adám Brudzewsky that validates APL expressions as non-destructive, covering built-ins if necessary, and executes them in a sandbox environment.

Contact

If you have feedback, or would like to ask a question that is not already answered here, please e-mail challenge@dyalog.com.

image/svg+xml
APL Challenge 2024.2

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


1: Drop Dead

APL's is used to drop elements. (The symbol hints at the direction things fall when dropped.) It takes a number on its left and a list on its right. The number specifies how many elements to drop from the left of the list.

For example, 1 ↓ 3 1 4 1 5 gives 1 4 1 5.

Text is denoted in APL by including single quotation marks before and after the text. For example 'abc' will give a result that looks like abc.


Write a single expression using that turns the text 'allocation' into 'location'.
Solution:Solution:

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


2: Meet Me at the Intersection

The symbol is called Intersection. It keeps items from the list on its left that are also found in the list on its right. Note that the symbol is the same as used in set theory, and its shape is like the letter n as in intersection. For example, 3 1 4 1 5 ∩ 1 2 3 gives 3 1 1 and 'Drake Mallard' ∩ 'dark' gives rakaard.


Write a single expression that uses to find the intersection of 'piece of cake' and 'aeiou'. The result should be ieeoae.

Solution:Solution:

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


3: Minimalism

APL can perform mathematical operations on entire collections of numbers, rather than just on a single number at a time. For example, 10 20 30 + 4 5 6 gives 14 25 36 and 10 × 1 2 3 is 10 20 30.

The symbol implements a mathemetical operation that computes the minimum of two values. Think of as a vertical line with a horizontal indicator tick at the minimum. You could also view it as a styled letter L, since it gives the Lowest of its arguments. When given numbers on both its left and its right, the minimum is the lowest of each pair of numbers. For example, 10 4 ⌊ 2 6 gives 2 4.


Use to write a single expression, without using parentheses, to limit the elements of 1 2 3 4 5 6 7 8 9 10 so they are no greater than 7, that is, elements greater than 7 become 7. The result will be 1 2 3 4 5 6 7 7 7 7.

Solution:Solution:

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


4: Staying In Bounds

The Maximum function is just like Minimum (which you met in problem 3), except that it returns the larger of corresponding elements. In this case, the symbol provides a reminder because the tick is at the top of the vertical bar. For example, 3 1 4 1 5 9 ⌈ 2 7 1 8 2 8 returns 3 7 4 8 5 9.

An APL function takes the result of all the code to its right (until the end of the expression) as its right argument. For example, 2×3+4 gives 14 (rather than the 10 as you might expect from traditional mathematics) because the × takes the result of 3+4 as its right argument. Similarly, -2+4 gives ¯6 (APL uses a high minus ¯ to indicate negative numbers) because - negates 2+4.


Use and to write a single expression, without using parentheses, that clamps the elements of 1 2 3 4 5 6 7 8 9 10 between 3 and 7, that is, elements less than 3 become 3 and elements greater than 7 become 7. The result will be 3 3 3 4 5 6 7 7 7 7.

Solution:Solution:

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


5: Self Replication

The Replicate function takes a list of numbers on its left and a list of equal length on its right. For each number in the list on the left, Replicate puts that many copies of the corresponding element of the right argument into the result. For example, 2 0 3 1 2 3 ⌿ 'DYALOG' returns DDAAALOOGGG.

The Index Generator function takes a number on its right and generates the indices from 1 until that number. For example, ⍳3 gives 1 2 3. The symbol is a Greek Iota symbol, which is similar to the letter i for index or indices.

Note that you can use parentheses to govern the order of operations, limiting any right argument so it only goes as far as the nearest closing parenthesis on its right. As explained in problem 4, the code 2×3+4 gives 14 but if you write (2×3)+4 then you get 10 as the right argument of × is limited to be just 3.


Using , , parentheses, and the number 5, write a single expression that returns 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5.

Solution:Solution:

In problems 1–6, you're asked to enter an APL expression, including arguments. This expression will be evaluated by the APL Challenge test framework to validate that it produces the correct result and uses the techniques described in the problem description.


6: Double Vision

Comparison functions like = and < return 1 when the indicated relation is true and 0 when it is false. For example, 'dyalog' = 'analog' returns 0 0 1 1 1 1 and 3 ≥ 1 2 3 4 5 returns 1 1 1 0 0.

Reduce is denoted / and inserts the function on its left between the elements of the array on its right. For example, ×/ 1 2 3 4 5 computes the factorial of 5 (that is, 1×2×3×4×5).

Drop (see problem 1) can take a negative number on its left to remove from the right. For example, ¯1 ↓ 3 1 4 1 5 gives 3 1 4 1. (Remember from problem 4 that we write negative numbers with a high minus).


Write a single expression that uses , =, parentheses, + and / to count the number of times a letter appears immediately after an identical letter in 'bookkeeper'. The result should be 3.

Hint: You can use for analysis of the relationship between adjacent elements in an array. For example, given the array 3 1 4 1 5 9 and the goal of finding out which elements are greater than their predecessor, start by dropping the first and last elements (separately), that is, 1 ↓ 3 1 4 1 5 9 and ¯1 ↓ 3 1 4 1 5 9 giving 1 4 1 5 9 and 3 1 4 1 5 respectively. Now compare their results with 1 4 1 5 9 > 3 1 4 1 5, which returns 0 1 0 1 1. Putting all the pieces together gives the APL expression (1 ↓ 3 1 4 1 5 9) > (¯1 ↓ 3 1 4 1 5 9). Placing the result beneath the original array as shown below illustrates that the goal has been achieved; 1 in the result indicates the pairs of adjacent elements in which the right element is greater than the left one:

3 1 4 1 5 9
 0 1 0 1 1
Solution:Solution:

In problems 7–10, you are asked to enter an APL function, without supplying any arguments. This function/expression will be run by the APL Challenge test framework using several test cases to determine its correctness.


7: Things are Looking Up

You can create your own function by putting an expression in curly braces. Inside this expression, refers to the right argument (it being the right-most letter of the Greek alphabet). For example, a function to subtract one from the square of its argument could be written {(⍵×⍵)-1}.

Time series data is a sequence of data points collected over regular time periods. Examples of time series data include daily or hourly temperature readings or stock prices. Any given data point might be greater than, less than, or equal to the previous data point. APL has a long history of being used for time series data analysis.


Write a function that takes a vector of numbers on its right (representing time series data) and computes how many of the vector's numbers are greater than their predecessor. For example:

      {solution} 10 9 8 7 6 5 4 3 2 1
0

      {solution} 1 2 3 4 5 6 7 8 9 10
9

      {solution} ¯2 ¯2 0 1 4 ¯2 ¯1 ¯1 2 ¯1
5

      {solution} 5 10
1

Hint: See Problem 6.

Solution:Solution:

In problems 7–10, you are asked to enter an APL function, without supplying any arguments. This function/expression will be run by the APL Challenge test framework using several test cases to determine its correctness.


8: Unique Characters in APL

The Unique Mask function takes an array as its right argument and returns a 1 marking the first occurrence of an element, 0 for subsequent occurrences. For example, ≠ 3 1 4 1 5 returns 1 1 1 0 1 and ≠ 'DYALOG' returns 1 1 1 1 1 1.

The Boolean/mathematical And function (symbol taken from formal logic) returns 1 if both left and right arguments are 1, but 0 if either is 0. For example, 1 1 0 0 ∧ 0 1 0 1 returns 0 1 0 0.


Write a function that takes a vector as its argument and returns 1 if the elements are all unique, 0 otherwise.

      {solution} 'DYALOG APL'
0

      {solution} 1 2 3 4 5 6
1

      {solution} 3 1 4 1 5 9 2 6
0

      {solution} 3.1415926 'DYALOG' 42 'APL'
1

Hint: and combined with / (see problem 6) can be useful here.

Solution:Solution:

In problems 7–10, you are asked to enter an APL function, without supplying any arguments. This function/expression will be run by the APL Challenge test framework using several test cases to determine its correctness.


9: Caseless Sorting

Brackets [] select elements from the vector immediately to the left of [ using indices between [ and ]. For example: 'SYIM'[4 3 1 1 2] returns MISSY and 4 25 1 12 15 7[3 1 6 4 5 2] returns 1 4 7 12 15 25.

The Grade function is useful for sorting arrays. For a given array, it returns the indices you need when you want to sort that array. For example, ⍋ 4 25 1 12 15 7 returns 3 1 6 4 5 2. Putting the result of Grade inside brackets 4 25 1 12 15 7[⍋ 4 25 1 12 15 7] returns the sorted array 1 4 7 12 15 25.

The system function ⎕C converts uppercase letters into their lowercase equivalents. This is useful for comparing texts. For example, ⎕C 'Hello World!' gives hello world!.


Write a function that uses ⎕C, , and brackets to sort the given vector of character vectors, without considering letter case.

      {solution} 'Morten' 'brian' 'Adám' 'Bjørn' 'michael'
 Adám  Bjørn  brian  michael  Morten 

      {solution} 'ANN' 'ida' 'RAY' 'aMY' 'aMY'
 aMY  aMY  ANN  ida  RAY 

      {solution} 'eVA' 'FAY' 'Ray' 'Eve'
 eVA  Eve  FAY  Ray 

Solution:Solution:

In problems 7–10, you are asked to enter an APL function, without supplying any arguments. This function/expression will be run by the APL Challenge test framework using several test cases to determine its correctness.


10: X Marks the Spot

The Reverse function reverses a given array. For example, ⌽ 1 2 3 returns 3 2 1. The symbol evokes reflection in a vertical mirror.

Complementing the And function from problem 8, the Or function (symbol also taken from formal logic) returns 1 if its left or right argument is 1 (or both are 1), but 0 if both are 0. For example, 1 1 0 0 ∨ 0 1 0 1 gives 1 1 0 1.

If you put ∘. ("jot dot") to the immediate left of a function, then it produces a Table of that function applied between all the combinations of elements from the arguments. Its left argument forms the row headings (down the left side) and its right argument forms the column headings (across the top). Here's a multiplication-table in APL form – and as you might see it in a book:

      1 2 3 ∘.× 1 2 3 4
1 2 3  4
2 4 6  8
3 6 9 12
×1234
11234
22468
336912

Write a function that takes a positive integer, n, as its argument and returns an n×n Boolean table (matrix) that uses 1s to depict an "X" along its diagonals (everything else is 0).

      {solution} 5
1 0 0 0 1
0 1 0 1 0
0 0 1 0 0
0 1 0 1 0
1 0 0 0 1

      {solution} 4
1 0 0 1
0 1 1 0
0 1 1 0
1 0 0 1

      {solution} 1
1

Hint: (see problem 5), , , and = combined with ∘. can be useful here.

Solution:Solution:

You must be logged in to view submitted solutions!

PLEASE WAIT