1: 1-2-3
2: Larger
3: Where
4: Greatest
5: Table
6: Identity
7: Identities
8: Spell
9: How Many
10: Histogram
Your Answers
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 (2025.1) is Wednesday 30 April 2025 at 09:00 UTC.

APL is a programming language that will change the way you think about solving problems. You don’t need to know any APL or programming at all to participate in this challenge; the question texts will teach you everything you need to know to progress. To do this, we have kept what we teach very simple, even though APL is slightly more complicated than what we describe.

There are four rounds of the APL Challenge each year. You don’t need to participate in an earlier round to participate in the current one. Each round has ten problems and runs for three months, after which Dyalog Ltd awards three USD 100 prizes. You don’t have to answer every question, but your chance of winning increases as you answer more questions. A list of winners of previous rounds is available on the Dyalog website.

If you’re interested but don’t want to participate in this round, please register anyway (using the button at the top) so that we can notify you of updates and tell you about future rounds. You can ask us to stop sending you emails at any time.

Let’s get started…

Use TryAPL to experiment and find your answer. You can write APL symbols by clicking on them in the language bar above the area where you write APL code.

Although you can begin without registering – most browsers will store your answers until you register – you must be registered and logged in to submit (send in) your answers. When you’re happy with your answer, hit  Submit. The system will only allow you to submit correct answers.

Several problems include some data you need. You should be able to copy text that is written with code letters like this by clicking on it, but note that not all browsers allow this.

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.

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.

Why is my correct answer not accepted?

The purpose of the APL Challenge is to teach specific parts of APL, so we require solutions that use the techniques we teach. Most problems can be solved in many ways, and the techniques we teach here do not necessarily lead to the best code. If you want to explore alternative answers, then you can use TryAPL to do so.

Why can I not change my answer?

When you test or submit a correct answer, we lock it down for you, so it isn’t accidentally overwritten with an incorrect answer. All correct answers are equally eligible for winning. If you want to explore alternative answers, then you can use TryAPL to do so.

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 2025.1

Note: In this problem, you’re asked to enter some APL code, including an APL symbol and the data (text or numbers) given to it. Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


1: Easy as 1-2-3

It is easy to count in APL. Just write the symbol (iota, a Greek letter), to the left of a number; this will give you all the whole numbers from 1 to the number that you wrote. (Iota is like an i for integers, which means whole numbers.) For example, ⍳ 7 gives 1 2 3 4 5 6 7


Write some APL code that uses to get the numbers from 1 to 12. The result should be 1 2 3 4 5 6 7 8 9 10 11 12

Answer:Answer:

In this problem, you’re asked to enter some APL code, including an APL symbol and the data (text or numbers) given to it. Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


2: I’m Larger than You

In APL, we use the symbol (up-stile) to find which of two numbers is the largest. The symbol looks like a vertical line with a mark at the highest value. This is because it compares the number on its left with the number on its right, and gives the one that is highest. For example, 5 ⌈ 2 gives 5 because 5 is a higher value than 2.

APL users usually call Maximum. Maximum – and all other basic mathematical symbols of APL – can work on multiple numbers at once. For example, 5 ⌈ 2 7 1 8 gives 5 7 5 8 because:

  • 5 ⌈ 2 is 5 as 5 is larger than 2
  • 5 ⌈ 7 is 7 as 7 is larger than 5
  • 5 ⌈ 1 is 5 as 5 is larger than 1
  • 5 ⌈ 8 is 8 as 8 is larger than 5

Write some APL code that uses a single to change the numbers 31 41 59 26 into 50 50 59 50.

Answer:Answer:

In this problem, you’re asked to enter some APL code, including an APL symbol and the data (text or numbers) given to it. Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


3: Where Are You?

In APL, text must appear between single quotes ('). For example, 'ABC' will give a result that looks like ABC.

Equal To (=) can be used to check whether letters are the same. It gives 1 when letters are the same and 0 when letters are different. For example, 'B' = 'C' will give 0 and 'D' = 'D' will give 1.

As well as comparing single letters, APL can also compare lists of letters (also called as texts). For example, 'HELLO' = 'WORLD' gives 0 0 0 1 0 because:

0: no, H is not equal to W
0: no, E is not equal to O
0: no, L is not equal to R
1: yes, L is equal to L
0: no, O is not equal to D

You can also compare a single letter with a whole text. APL will compare the single letter to each letter of the text.


Write some APL code using Equal To that shows where the Rs are in 'RASPBERRY'. The answer should be 1 0 0 0 0 0 1 1 0.

Answer:Answer:

Note: In this problem, you’re asked to enter an APL expression (some APL code), including arguments (data given to APL symbols). Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


4: The Greatest Number

The APL symbols you’ve met so far take either one data argument on the right or a data argument on each side. These symbols are called functions. APL also has operators. These are similar to functions, but, on the left, they take a function instead of data. Each operator uses the given function with the given data in a specific way.

Insert (/) is such an operator. It takes a list on its right, and a function on its left. The function could be a common mathematical function (like + or ×) or, for example, = (Equal To) from problem 3. Insert inserts the symbol between the items of the list. For example, you can use Insert to add up all the numbers in a list: +/ 1 2 3 4 gives 10 because it is the same as 1 + 2 + 3 + 4.


Using Maximum () from problem 2, find the largest number in the list 2 7 1 8 2 8 1 8 2 8 4 6. The result should be 8.

Answer:Answer:

In this problem, you’re asked to enter an APL expression (some APL code), including arguments (data given to APL symbols). Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


5: Cards on the Table

If you put ∘. (jot dot, but sometimes called Table) immediately to left of a function, then it produces a table for that function. It does this by inserting the function between all the combinations of numbers from the arguments. If the resulting table had row and column headings, the left argument would be used as the headings for the rows (down the left side) and the right argument would be used as the headings for the columns (across the top). Here’s a multiplication table (times table) in APL form – and as you might see it in a book (showing the row and column headings, even though they are not table data):

      2 3 4 ∘.× 2 3 4 5
4  6  8 10
6  9 12 15
8 12 16 20
×2345
246810
3691215
48121620

As in the above example, when we write APL code and its result together, we often write the code above the result, with six spaces to the left of the code.


Using Table (∘.), create an addition table (plus table) for the numbers 3, 1, and 4. The result should look like this:

6 4 7
4 2 5
7 5 8
Answer:Answer:

In this problem, you’re asked to enter an APL expression (some APL code), including arguments (data given to APL symbols). Your code will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described below.


6: Identity Matrix

An APL function takes the answer of all the code to its right as its right argument. For example, 2×3+4 gives 14, rather than the 10 that you might expect. This is because the × takes the answer of 3+4 as its right argument. However, you can use round brackets to change the order in which things are calculated, limiting any right argument so it only goes as far as the nearest closing bracket ) on its right: (2×3)+4 gives 10.

When you used Equal To (=) in problem 3, you were using it to compare letters in a text. However, it also works on numbers. For example:

      1 = 3 1 4 1 5 9
0 1 0 1 0 0

Using round brackets, (iota from problem 1), =, and ∘. (Table from problem 5), create a 5-by-5 table that has 1s on the diagonal from the top left to the bottom right, with all other numbers being 0s. This is known as an identity matrix of size 5 and looks like this:

1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Answer:Answer:

Note: In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your code will be checked by the APL Challenge system using several tests to see whether it is correct.


7: More Identity Matrices

You can create your own function by putting an expression (for example, ⍳10) in curly brackets (for example, {⍳10}). Within this expression (in our example, ⍳10), any (omega, the right-most letter of the Greek alphabet) is replaced by the argument to the right of the closing curly bracket ( } ).

For example, a function that multiplies its argument by two could be written {2×⍵}, so {2×⍵} 5 gives 10.


Using what you learnt in problem 6, write a function that gives an identity matrix of the given size. For example:

      {answer} 5
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1

      {answer} 2
1 0
0 1

      {answer} 6
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
Answer:Answer:

In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.


8: Spell it Out

You can select specific letters from a text by putting square brackets ( [] ) to the right of the text. Inside the square brackets, you put numbers that say which letters you want to get from the text. For example, 'ABCDE'[1] gives you the letter A because that’s the 1st letter of 'ABCDE'. Similarly, 'ABCDE'[5 2 2] gives you EBB, because:

  • The 5th letter of 'ABCDE' is E
  • The 2nd letter of 'ABCDE' is B
  • The 2nd letter of 'ABCDE' is B

Write a function that takes a list of numbers and returns a text that consists of the corresponding uppercase letters from the English alphabet. For example:

      {answer} 1 2 3 2 1
ABCBA

      {answer} 1 16 12
APL

      {answer} 4 25 1 12 15 7
DYALOG
Answer:Answer:

In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.


9: How Many of Each?

When using a function with Insert (/ from problem 4) on a table, it inserts the function between the items in each row in the table. For example, take the multiplication table from problem 5:

      2 3 4 ∘.× 2 3 4 5
4  6  8 10
6  9 12 15
8 12 16 20

Now we put +/ in front of the table:

      +/ 2 3 4 ∘.× 2 3 4 5
28 42 56

This tells us that:

  • the first row had a sum of 28 (from +/ 4 6 8 10 which is 4 + 6 + 8 + 10)
  • the second row had a sum of 42 (from +/ 6 9 12 15) which is 6 + 9 + 12 + 15)
  • the third row had a sum of 56 (from +/ 8 12 16 20 which is 8 + 12 + 16 + 20)

Using + with / and ∘. with = (Equal To from problem 3), write a function that takes an uppercase text and, for each of the three letters A, P, and L, counts how many there are in the text. For example:

      {answer} 'DYALOG APL'
2 1 2

This tells us that 'DYALOG APL' has 2 As, 1 P, and 2 Ls.

      {answer} 'MISSISSIPPI'
0 2 0

      {answer} 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG!'
1 1 1
Answer:Answer:

In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.


10: Histogram

You have used = in several earlier questions, but APL has additional comparison functions, such as Less Than (<), Less Than Or Equal To (), Greater Than Or Equal To (), Greater Than (>), and Not Equal To (). All these functions give 1 for yes and 0 for no.


Using everything that you’ve learnt so far, write a function that takes a list of numbers between 1 and 6 (representing dice throws) and draws a histogram (bar chart) showing how many times each number was thrown. Use dashes (-) to show how many times each number was thrown, with the number of 1s shown on the first line, the number of 2s shown on the second line, and so on. Use spaces ( ) to fill out the table so it becomes rectangular. For example:

      {answer} 6 2 1 3 5 6 6 4 1 2
-- 
-- 
-  
-  
-  
---

      {answer} 3 4 3 4 6
  
  
--
--
  
- 

      {answer} 5 3 6 6 3 5 5 4 1 6 1 6 4 6 3 2 3 2 6 3 1 4 4 3 5
---   
--    
------
----  
----  
------
Answer:Answer:

Your Answers

You must be logged in to view submitted solutions!