1: Exist
2: Compare
3: Picky
4: Partition
5: Scan
6: Leading
7: Word
8: Break
9: Heat
10: Vowel
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 (2024.3) is Thursday 31 October 2024 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. 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.3

In this problem, you're asked to enter a line of APL, including data given to APL symbols. This line will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described in the problem description.


1: Existentialism

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

In APL, yes/no questions are answered with 1 for yes and 0 for no.

The symbol is Exists In (and it looks like E too) because it reports whether letters of the text on its left exist in the text on its right. For example, 'APL' ∊ 'DYALOG' gives 1 0 1 because:

  • 1: yes, 'A' exists in 'DYALOG'
  • 0: no, 'P' does not exist in 'DYALOG'
  • 1: yes, 'L' exists in 'DYALOG'

Note that what we’re looking for goes on the left of the , and where we’re looking goes on its right.


Write a single line of APL that uses to show that each of the letters in the English alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' (← click to copy) is found in the text 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG' (← click to copy). The result should be 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1, that is, 26 1s.

Answer:Answer:

In this problem, you’re asked to enter a single symbol that represents a comparison. The APL Challenge system will check that you entered the correct symbol.


2: Comparing This to That

APL has six symbols that compare the data on their left the data on their on the right. Just like from Problem 1, they give 1 for yes and 0 for no when answering whether the statement is true.

The six comparisons are Smaller Than (<), Smaller Than Or Equal To (), Equal To (=), Bigger Than Or Equal To (), Bigger Than (>), and Not Equal To ().

You can check what each symbol will give in a line like 2 < 3 by using its name instead of its symbol. For example, we could say Is 2 Smaller Than 3? — yes, that's a true statement, so 2 < 3 will give 1 for yes.

APL can compare entire lists of numbers, rather than just single numbers. For example, 1 2 3 = 5 4 3 gives 0 0 1 because:

  • 0: no, 1 is not equal to 5
  • 0: no, 2 is not equal to 4
  • 1: yes, 3 is equal to 3

Which comparison symbol will give 0 1 0 1 0 with 3 5 4 8 6 on its left and 3 4 5 3 9 on its right?

In other words, which symbol would you place in the box (  ) of the APL code 3 5 4 8 6 ⎕ 3 4 5 3 9 (← click to copy) so that the answer will be 0 1 0 1 0?

Answer:Answer:

In this problem, you're asked to enter a line of APL, including data given to APL symbols. This line will be tested by the APL Challenge system to check that it gives the correct result and uses the methods described in the problem description.


3: Picky Picky

The symbol is called Pick because, when given a number (let’s call it n) on its left and a list on its right, it picks item number n from the list. For example, 2 ⊃ 'DYALOG' gives Y and 2 ⊃ 'DYALOG' 'APL' gives APL.

So far, we’ve only used text (in single quotes) and lists of numbers like 'DYALOG APL' and 3 1 4 1 5 9. Both of these are simple lists; one is a list of letters (we count space as a letter), the other is a list of numbers (the spaces between numbers don’t count). APL can also handle lists of lists, and so on. For example, 'DYALOG' 'APL' is a list of two texts, that is, a list of two lists of letters.

If we want additional levels of lists inside lists, we use round brackets to mark each list. For example, (1 2 3)(2 7 1 8) is a list of two lists of numbers, and ('KEN' 'IVERSON')('DYALOG' 'APL') is a list of lists of texts (with each text itself being a list of letters).

If we give Pick a list of numbers (rather than a single number) on the left (we’ll still call it n), then:

  1. the first number from n picks the appropriate item from the list on the right of Pick
  2. the second number from n picks the appropriate item from that list
  3. and so on

For example, 2 1 ⊃ 'DYALOG' 'APL' will pick:

  1. item 2 from 'DYALOG' 'APL', which is 'APL'
  2. item 1 from 'APL', which is 'A'

Write a line of APL using that will pick the 'G' from ('KEN' 'IVERSON')('DYALOG' 'APL') (← click to copy).

Answer:Answer:

In this problem, you are asked to write an APL expression (line of APL), including arguments (data given to APL symbols). This expression will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described in the problem description.


4: Partition Condition

Partition is a function (symbol) that cuts up text into parts: It takes a text as its right argument and a list of numbers as its left argument. The list of numbers has only 1s and 0s, and specifies how to cut the text into parts. Characters (letters and spaces) in the text corresponding to 0s are discarded; a new part is then started. For example, 0 0 1 1 0 1 1 1 1 0 0 1 1 1 ⊆ 'THIS PARTITION' gives:

┌──┬────┬───┐
│IS│PART│ION│
└──┴────┴───┘

We can show what’s going on like this:

0 0 1 1 0 1 1 1 1 0 0 1 1 1
t h i s   p a r t i t i o n

Remember the comparison functions from Problem 2? We used them with single numbers on both sides and with lists of numbers on both sides. However, they can also take a single number on the left and a list on the right. For example, 4 < 3 5 7 gives 0 1 1, because:

  • 0: no, 4 is not less than 3
  • 1: yes, 4 is less than 5
  • 1: yes, 4 is less than 7

Furthermore, we only used the comparison functions with numbers, but two of them, = and , work on characters too. For example, 'APL' = 'ABC' gives 1 0 0, because:

  • 1: yes, A is equal to A
  • 0: no, P is not equal to B
  • 0: no, L is not equal to C

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.


Using , one of the comparison functions, and round brackets, write an expression that will cut the text 'THE QUICK BROWN FOX' into words at the space characters (' '). The answer should be

┌───┬─────┬─────┬───┐
│THE│QUICK│BROWN│FOX│
└───┴─────┴─────┴───┘

(Hint: You will need to use the text 'THE QUICK BROWN FOX' twice, so don’t forget that you can click on it to copy it.)

Answer:Answer:

In this problem, you’re asked to enter a single comparison function. The APL Challenge system will check that you entered the correct symbol.


5: You Can Scan!

The APL symbols you’ve met so far take one data argument on each side. These symbols are called functions. APL also has operators which take a data argument on the right (just like functions), but on the left take a function instead of data. Each operator uses the given function with the given data in a specific way. Scan \ is such an operator. It takes a list on its right, and a function on its left. The function could be Plus (+) or Times (×), or any of the comparison functions you met in Problem 2.

Scan gives an answer of the same length as the given list:

  1. The first item of the answer is the same as the first item in the list
  2. The second item of the answer is calculated by putting the function between the first and second items of the list
  3. The third item of the answer is calculated by putting the function between the first three items of the list
  4. and so on
The first item of the answer is the same as the first item in the list. The second item of the answer is calculated by putting the function between the first and second items of the list. The third item of the answer is calculated by putting the function between the first three items of the list. And so on.

For example, +\ 1 9 2 0 1 2 1 7 gives 1 10 12 12 13 15 16 23, as follows:

1                              →   1
1 + 9                          →  10
1 + 9 + 2                      →  12
1 + 9 + 2 + 0                  →  12
1 + 9 + 2 + 0 + 1              →  13
1 + 9 + 2 + 0 + 1 + 2          →  15
1 + 9 + 2 + 0 + 1 + 2 + 1      →  16
1 + 9 + 2 + 0 + 1 + 2 + 1 + 7  →  23

and <\ 0 0 1 0 1 0 1 gives 0 0 1 0 0 0 0, as follows:

0                          →  0
0 < 0                      →  0
0 < 0 < 1                  →  1
0 < 0 < 1 < 0              →  0
0 < 0 < 1 < 0 < 1          →  0
0 < 0 < 1 < 0 < 1 < 0      →  0
0 < 0 < 1 < 0 < 1 < 0 < 1  →  0

Remember from the previous problem that, when an APL expression contains multiple functions, they are applied from right to left. So, 0 < 0 < 1, which is 0 < (0 < 1), which is 0 < (1), and so on.


Which comparison function, when used with Scan and a right argument of 0 1 1 0 0 1 0 1 0 1 1 0, will give 0 1 0 0 0 1 1 0 0 1 0 0?

In other words, which symbol would you place in the box (  ) of the APL code ⎕\ 0 1 1 0 0 1 0 1 0 1 1 0 (← click to copy) so the expression gives 0 1 0 0 0 1 1 0 0 1 0 0?

Answer:Answer:

In this problem, you are asked to write an APL expression, including arguments. This expression will be tested by the APL Challenge system to check that it gives the correct answer and uses the methods described in the problem description.


6: Leading Question

Every APL function you’ve met to far, has taken two arguments, but some functions only take one argument. For those, the single argument goes on the right. The Not function ~ is an example of such a function. It swaps 1s and 0s, turning each 1 (yes) in its right argument into a 0 (no) and each 0 (no) into a 1 (yes): ~ 1 1 0 1 0 0 1 gives 0 0 1 0 1 1 0.

In the last problem you learned about the Scan operator. The related Reduce operator / returns the last item of what would have been Scan’s result. For example, +/ 1 9 2 0 1 2 1 7 returns 23 (that is, 1+9+2+0+1+2+1+7).

You can use the And function to see whether both of two statements are true. This gives 1 (yes) if both its left and right arguments are 1 (yes); if any of its arguments are 0 (no), it gives 0 (no).


Using Plus (+), Reduce (/), And (), Scan (\), Not (~), and Exists In (), write an APL expression that counts how many consonants (non-vowels) are at the beginning of the word 'SCHNITZELS' (← click to copy), before the first vowel (which is I).

(Use 'AEIOU' as your list of vowels.)

Answer:Answer:

In this problem, you are 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.


7: You Have My Word

You can create your own function by putting an expression in curly brackets. Within this expression, if needed, (alpha) refers to the argument to the left of { and (omega) refers to the argument to the right of }. (This is because alpha and omega are the left-most and right-most letters of the Greek alphabet, respectively.) For example, a function that adds its arguments and then multiplies by two could be written {2×⍺+⍵}.


Using Pick () and your answer for Problem 4, write a function that takes a number n as its left argument and a text that has words (with spaces between them) as its right argument, and gives word number n from the text. For example:

      1 {answer} 'THE QUICK BROWN FOX'
THE

      3 {answer} 'THE QUICK BROWN FOX'
BROWN

      5 {answer} '   EXTRA    SPACES DO NOT MATTER   '
MATTER

(The text will have at least n words.)

Answer:Answer:

In this problem, you are 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: Give Me a Break!

In Problem 4, you learnt how to cut text into parts based on the location of space characters. You will now take that a step further by cutting a text into parts based on the location of characters from a list. Remember from Problem 3 that a text is just a list of characters.


Using Not (~), Exists In () and Partition (), write a function that takes a text on its right and a list of characters on its left and cuts the text at those characters. For example:

      ':- ,()' {answer} 'THREE-CHARACTER ANIMALS: CAT,DOG,ELK,EEL (AND BAT)'
┌─────┬─────────┬───────┬───┬───┬───┬───┬───┬───┐
│THREE│CHARACTER│ANIMALS│CAT│DOG│ELK│EEL│AND│BAT│
└─────┴─────────┴───────┴───┴───┴───┴───┴───┴───┘

      ':/.?=' {answer} 'HTTPS://WWW.BLOOFO.COM:8080?NAME=VALUE'
┌─────┬───┬──────┬───┬────┬────┬─────┐
│HTTPS│WWW│BLOOFO│COM│8080│NAME│VALUE│
└─────┴───┴──────┴───┴────┴────┴─────┘
Answer:Answer:

In this problem, you are 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: Turning up the Heat

Remember from Problem 7 that refers to the left argument of your own function, but you also learnt in Problem 6 that not all functions need a left argument. Such functions do not need an . For example, a function to multiply its sole (right) argument by itself and then subtract one could be written {(⍵×⍵)-1}.


Write a function that describes a temperature given in degrees Fahrenheit: If the temperature is below 32 (you don’t need to handle negative temperatures) it is 'FREEZING', while if it is 32 or higher, but below 50, it is merely 'COLD'. From 50 it becomes 'CHILLY', then from 70 it is 'PLEASANT', from 85 it is 'HOT' and at or above 95 it is 'HELLISH'. For example:

      {answer} 33
COLD

      {answer} 14
FREEZING

      {answer} 83
PLEASANT
Answer:Answer:

In this problem, you are 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: Pick a Vowel


Using the techniques you have learnt so far, write a function that takes a word as its right argument and gives the word’s first vowel as its answer. For example:

      {answer} 'SPHRAGISTIC'
A

      {answer} 'SEAL'
E

      {answer} 'ICONOGRAPH'
I

(The given word will have at least one vowel. Use 'AEIOU' as your list of vowels.)

Answer:Answer:

Your Answers

You must be logged in to view submitted solutions!

PLEASE WAIT