Skip to content

APL Quest 2021 Problems

2021-1: Are You a Bacteria?:

Write a function that has a right argument that is a non-empty character vector representing a DNA string and returns the percentage of GC-content in the string.

2021-2: Index-Of Modified:

Write a function that behaves like the APL index-of function `R←X⍳Y` except that it returns `0` instead of `1+≢X` for elements of `Y` not found in `X`.

2021-3: Multiplicity:

Write a function that finds which elements of Y are multiples of each element of X and returns them as a vector (in the order of X) of vectors (in the order of Y).

2021-4: Square Peg, Round Hole:

Write a function which returns a numeric array of the same shape as the right argument representing the difference between the areas of the circles and the areas of the largest squares that can be inscribed within each circle.

2021-5: Rect-ify:

Write a function that has a right argument which is a positive integer less than or equal to 1,000,000 and returns a 2-element integer vector representing the rows and columns of the most square rectangle such that the number product of the number of rows and columns equals the argument.

2021-6: Fischer Random Chess:

Write a function that as a character vector right argument that is a permutation of 'KQRRBBNN' and returns 1 if the K is between the two Rs and the Bs occupy one odd and one even position; and otherwise returns a 0.

2021-7: Can You Feel the Magic?:

Write a function to test whether an array is a magic square.

2021-8: Time to Make a Difference:

Write a function that returns the number of minutes between two timestamps.

2021-9: In the Long Run:

Write a function that returns an integer singleton that represents the highest number of consecutive days where the price increased, decreased, or remained the same, relative to the previous day.

2021-10: On the Right Side:

Write a function that returns a right-aligned character array with restricted width.