fas fa-trophy missing
1: Reshape
fas fa-trophy missing
2: Max
fas fa-trophy missing
3: Slice of Pi
fas fa-trophy missing
4: Which
fas fa-trophy missing
5: Summation
fas fa-trophy missing
6: Multiply
fas fa-trophy missing
7: Total
fas fa-trophy missing
8: Racecar
fas fa-trophy missing
9: Odds
fas fa-trophy missing
10: Frequencies
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.1) is Tuesday 30 April 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.1

1: Reshaping Your World

APL's is called Reshape. The symbol is a Greek Rho which is like r for reshape. Reshape takes a list of dimension lengths on its left and some data on its right, then reshapes the data into the specified shape.

For example, to get a table with 4 rows and 2 columns, filled with 1s, you'd write 4 2 ⍴ 1.

When APL deals with text data, it uses single quotation marks before and after the text. For example 'abc' will give a result that looks like abc.


Write an expression using that reshapes 'Dyalog' into
Dya
log
Solution:Solution:

2: Maxing Out

APL performs 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 computes the maximum. When given numbers on both its left and its right, the maximum is the larger of corresponding numbers. Therefore, 10 4 ⌈ 2 6 gives 10 6. Think of as vertical line with a horizontal indicator tick at the maximum.


Write an expression that adjusts the values 1 6 1 8 0 3 so all the numbers are equal to or greater than 5, that is, gives the result 5 6 5 8 5 5.

Solution:Solution:

3: A Slice of

When the Circle symbol is on the left of one or more numbers, it multiplies these numbers by pi (π). The symbol is hinting at pi being the ratio between a circle's circumference and its diameter.


Write a single expression that computes the circumference of circles with diameters of 2, 7, 1 and 8 units, giving the result 6.283185307 21.99114858 3.141592654 25.13274123.

Solution:Solution:

4: Which of Me is in You?

The Element Of function returns a 0 or 1 for every element in the array on its left; 1 indicates that the corresponding element was found as an element of the array on the right, while 0 indicates that it wasn't. For example, 1 16 12 ∊ 4 25 1 12 15 7 gives 1 0 1. For this reason, the Element Of symbol is derived from the Greek letter Epsilon, which is like e for element.

The Indices function takes an array of 1s and 0s on its right, and returns a list of the indices of all 1s, ignoring any 0s. For example, ⍸ 1 0 1 returns 1 3. The function uses the underscored Greek Iota symbol, similar to an underscored letter i for indicators into indices.

An APL function takes the result of all 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 you might expect) because the × takes the result of 3+4 as its right argument. Similarly, -2+4 gives ¯6 because - negates 2+4.


Write an expression that identifies the characters of 'BEAUTIFUL' that also appear in 'SQUIGGLES' by listing their positions in 'BEAUTIFUL', that is, 2 4 6 8 9 (corresponding to E U I U L).

Solution:Solution:

5: In Summation

In APL, we can have entire lists be elements of other lists. Consider 1 ((2 3 4) (10 20)) (4 2). This is a 3-element list. The first element is the number 1 and the last element is the list 4 2. The middle element is itself a 2-element list consisting of the lists 2 3 4 and 10 20.

You've already met the symbol in the previous problem, but that was with an array on each side. If there's only an array on its right, then it means Enlist: It flattens whatever intricate array of arrays it is given into a simple list. Thus, is also like e for enlist. An example of its usage is with the above list: ∊ 1 ((2 3 4) (10 20)) (4 2) gives the simple list 1 2 3 4 10 20 4 2.

Reduce is denoted / which 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).


Write an expression that computes the sum of all the numbers in (1 6 1) ((3 1 4 1 5) (2 7 1 8)) 2, namely 42.

Solution:Solution:

6: Go Forth and Multiply

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.

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). Remember from problem 2 that is Maximum? Here's a maximum-table in APL form – and as you might see it in a book:

      3 1 4 ∘.⌈ 2 7 1 8
3 7 3 8
2 7 1 8
4 7 4 8
2718
33738
12718
44748

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 we 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.


The challenge here is to produce a multiplication table for the numbers up to 12:

 1  2  3  4  5  6  7  8   9  10  11  12
 2  4  6  8 10 12 14 16  18  20  22  24
 3  6  9 12 15 18 21 24  27  30  33  36
 4  8 12 16 20 24 28 32  36  40  44  48
 5 10 15 20 25 30 35 40  45  50  55  60
 6 12 18 24 30 36 42 48  54  60  66  72
 7 14 21 28 35 42 49 56  63  70  77  84
 8 16 24 32 40 48 56 64  72  80  88  96
 9 18 27 36 45 54 63 72  81  90  99 108
10 20 30 40 50 60 70 80  90 100 110 120
11 22 33 44 55 66 77 88  99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144
Solution:Solution:

7: The Sum Total

You can create your own function by putting an expression in curly braces. Inside this expression, denotes 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}.

In a function that takes two arguments, denotes the left argument (it being the left-most letter of the Greek alphabet). For example, a function that computes twice the sum of its arguments could be written {2×⍺+⍵}.

Consider using Reduce / from problem 5.


Write a function that takes a list of prices for some goods as left argument and a list of corresponding quantities for these goods as right argument, then computes the total price for the purchase:

      4 5 2 {solution} 3 6 0
42

The above should compute (4×3) + (5×6) + (2×0) to arrive at the answer 42.

      18.65 19.26 19.71 20.19 {solution} 6 0 2 2
191.7
Solution:Solution:

8: Jump into Your Racecar

The Reverse function reverses lists; ⌽ 1 2 3 gives 3 2 1. The symbol evokes reflection in a vertical mirror.

In APL, comparisons are normal functions, and apply to elements (just like arithmetic), returning 1s when true and 0s when false. For example, 2 7 1 8 2 8 = 2 gives 1 0 0 0 1 0.

Did you know that you can use multiplication to check if two conditions are both true? 0 1 0 1 × 0 0 1 1 gives 0 0 0 1 indicating that only in the last position did we have true (1) in both arguments.


Write a function which takes a lowercase word and answers whether it is a palindrome, that is, it remains unchanged when reversed:

      {solution} 'racecar'
1

      {solution} 'kayak'
1

      {solution} 'dragster'
0

      {solution} 'canoe'
0
Solution:Solution:

9: What are the Odds?

The Remainder function | computes the remainder when the integers on the right are divided by the integers on the left. For example, 4|14 gives 2 because 4 goes into 14 a total of 3 times with 2 remaining.

The Compress function takes a list of 1s and 0s on its left. It filters the array on the right so that only those elements that match up to a 1 on the left array remain.


Write a function that takes a list of positive integers on its right, and removes all the even numbers, leaving only the odd numbers. For example:

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

      {solution} 3 5 7 11
3 5 7 11

No odd numbers here so it looks like there's no result:

      {solution} 42 48

Solution:Solution:

10: Frequent Fliers

The Unique function removes any duplicates from its argument, leaving only unique items. For example, ∪ 'abracadabra' gives 'abrcd'. The symbol is of course a stylised letter u for unique.

Note that when +/ is applied to a table, it sums each row and returns a list of the sums. Remember the ∘. construct from problem 6? You might want to use that.


Write a function which takes a list on its right, and computes, for each unique element, how many times it appears in the whole list:

      {solution} 4 4 4 4 4
5

      {solution} 'BAABCCACDA'
2 4 3 1

      {solution} 2 7 1 8 2 8 1 8
2 1 2 3
Solution:Solution:

You must be logged in to view submitted solutions!

PLEASE WAIT