Skip to content

APL Quest 2022 Problems

2022-1: Counting DNA Nucleotides?:

Write a function that takes a right argument that is a character vector or scalar representing a DNA string (whose alphabet contains the symbols 'A', 'C', 'G', and 'T') and returns a 4-element numeric vector containing the counts of each symbol 'A', 'C', 'G', and 'T' respectively.

2022-2: Attack of the Mutations!:

Write a function that takes right and left arguments that are character vectors or scalars of equal length – these represent DNA strings – and returns an integer representing the Hamming distance (the number of differences in corresponding positions) between the arguments.

2022-3: Uniquely Qualified:

Write a function that takes right and left arguments that are arrays of arbitrary rank, depth, and value, and returns a vector of all elements that appear in either of the two argument arrays but not in both.

2022-4: In the Long One...:

Write a function that takes a right argument that is a Boolean scalar or vector and returns the length of the longest sequence of consecutive 1s.

2022-5: Stairway to Heaven:

Write a function that takes a scalar integer argument and returns a character matrix comprised of spaces and that resembles a left-to-right ascending stairway.

2022-6: Pyramid Scheme:

Write a monadic function that takes an argument n that is an integer scalar in the range 0-100 and returns a square matrix "pyramid" with 0⌈¯1+2×n rows and columns of n increasing concentric levels.

2022-7: Just Golfing Around:

Write a function that takes a right argument that is a non-decreasing vector or scalar of strictly positive integers, representing a set of scores and returns a numeric vector of the place for each score; for duplicate scores, it returns the average of the places they hold.

2022-8: Let's Split!:

Write a function that takes non-empty character vector or scalar arguments and returns a 2-element vector of character vectors in which the right argument is split immediately before the first occurence of any element in the left argument.

2022-9: An Average Window (or a Windowed Average):

Write a function that takes a right argument that is a numeric scalar or non-empty vector and takes a left argument X that represents the number of neighboring elements on either side of each element in Y and returns a numeric vector or scalar where each element is the average (mean) of the corresponding element in Y and its X neighbors on either side.

2022-10: Separation Anxiety:

Write a function that takes a right argument that is a character vector or scalar representing a valid non-negative integer and a left argument that is a character scalar "separator" character and returns a character vector that is a representation of the right argument formatted such that the separator character is found between trailing groups of 3 digits.