# Questions tagged [array-manipulation]

A competition to solve a particular problem through the usage and manipulation of arrays.

533 questions
Filter by
Sorted by
Tagged with
5k views

### Covering a Skyline with brush strokes

Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it. [1,3,2,1,2,1,5,3,3,4,2]...
3k views

### Pointer jumping

Suppose we have an array $\texttt{ps}$ of length $n$ with pointers pointing to some location in the array: The process of "pointer jumping" will set every pointer to the location the pointer it ...
317 views

### Nested lists as printable 2D objects [closed]

I don't know if something like this exists already (and I'm not finding the right key words) but if not, it felt like it could be an interesting coding puzzle. The challenge is, to take an ...
266 views

### Execute Triangularity Move

TL;DR for those not interested: Look at the test cases at the bottom. Have a program/function that outputs the 2D list displayed for the given input. Introduction: On November 15th, 2018 puzzle ...
493 views

### Count the contiguous submatrices

Migrated from chat Given two non-empty non-negative integer matrices A and B, answer the number of times A occurs as a contiguous, possibly overlapping, submatrix in B. Examples/Rules 0. There may ...
2k views

### Coat of Many Colours

Challenge Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat. Example ...
2k views

### Non-overlapping Matrix Sum

Non-overlapping Matrix Sum Given k arrays of length n, output the maximum sum possible using one element from each array such that no two elements are from the same index. It is guaranteed that k<=...
2k views

### Rotation invariant fingerprinting

Imagine we have some polyomino and would like to uniquely identify them, however the polyominos can be rotated, so blindly hashing them won't give us the same fingerprint for a piece and a rotation ...
1k views

### Standardize the Samples (Compute the z-Score)

Given a list of floating point numbers, standardize it. Details A list $x_1,x_2,\ldots,x_n$ is standardized if the mean of all values is 0, and the standard deviation is 1. One way to compute this ...
425 views

### Hilbertize an image

For a computer vision app I want to do a mapping of an image, in such a way that every pixel fit hilbert curve, instead of conventional layout. So task could be as follows: Task description Given ...
6k views

### P Pr Pre Pref Prefi Prefix Prefixe Prefixes

Given some finite list, return a list of all its prefixes, including an empty list, in ascending order of their length. (Basically implementing the Haskell function ...
540 views

### Map the cheaters!

After all assignments are submitted, a dictionary is created that maps student number to the hash of their file. This dictionary, or hashmap, or mapping (whatever your language calls it) will look as ...
2k views

### Split Mark's marks

Challenge Mark is a student who receives his N marks in a concatenated way in a one single line. The challenge is to separate his marks, knowing that each mark ...
224 views

### Let's play Peg Solitaire

Peg solitaire is a popular game usually played alone. The game consists of some number of pegs and a board which is divided into a grid - usually the board is not rectangular but for this challenge we ...
396 views

### Sort a list, poorly

Don't you hate it when you're trying to roughly sort a list based on user data, but you have to poll the user for thousands of comparisons? Hate no more, because the answers to this challenge are (...
288 views

### Finding the period of a recurring element in an array [closed]

Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all ...
289 views

As with most APL symbols, has different meanings when called with one argument (transpose) versus two arguments (dyadic transpose / reorder dimensions). This ...
2k views

### All the single eights

Given a non-empty rectangular array of integers from 0 to 9, output the amount of cells that are ...
652 views

### Determine the Widest Valley

Imagine we get a slice of some mountainous region, this would result in a shape similar to this: ...
381 views

### Count cyclically self-describing lists

Cyclically self-describing lists A list $L$ of positive integers is cyclically self-describing, if the following conditions hold. $L$ is nonempty. The first and last elements of $L$ are ...
2k views

### Repeat this GCD operation

Problem A3 from the 2008 Putnam competition says: Start with a finite sequence $a_1, a_2, \dots, a_n$ of positive integers. If possible, choose two indices $j < k$ such that $a_j$ does not ...
4k views

### My array should equal this, but it doesn't!

Given an array of integers a which contains n integers, and a single integer x; remove the fewest amount of elements from ...
2k views

### Trim that distracting background off!

Isn't it annoying when you're taking a picture, but the background detracts from the actual substance of the image? I'd say it is. I need to know how much I should crop so that I get rid of this ...
479 views

### Smoothing a pair of arrays

Input Two lists with binary values (list_a, list_b) of equal length=>3. Output Two lists with binary values ...
410 views

### Array indexes to number and number reversed

Given an input array having minimum length 2 and maximum length 9 having any initial values output an array having length ...
859 views

### Find an array that fits a set of sums

Consider an array A of length n. The array contains only positive integers. For example ...
957 views

### Multiplicative undelta

Let us define the "multiplicative deltas" of values $[\; a_0, \cdots a_N, \;]$ as: $$[\; a_1 / a_0, \cdots, a_{i+1} / a_i, \cdots, a_N / a_{N-1} \;]$$ The reverse operation - namely "...
623 views

2k views

### Check my tunneling arrays

Imagine you have an array of integers, whose non-negative values are pointers to other positions in the same array, only that those values represent tunnels, so if the value in position A is positive ...
2k views

### Multi-dimensional reversal

Given an N-dimensional orthogonal (non-ragged) array of non-negative integers, and an indication of which dimensions to reverse, return the array but reversed along those dimensions. The indication ...
1k views

### Find Array Runs

Find the runs inside an array A run is defined as three or more numbers that increment from the previous with a constant step. For example [1,2,3] would be a run with step 1, [1,3,5,7] would be a run ...
478 views

### Codegolf Rainbow : Sorting Colors with Reflection

Introduction: After I posted two rainbow-related challenges: Codegolf Rainbow : Fun with Integer-Arrays 1 and Codegolf Rainbow : Draw in Black-and-White 2, the following comment was made by @ChrisM ...
1k views

### Fill up to duplicate ranges

Let $L$ be a list of positive integers with no particular ordering, and which can contain duplicates. Write a program or function which outputs a list of positive integers $M$ (whose ordering is ...
2k views

### A knight's graph on an N-by-N board

In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞: A Knight's Graph is a graph that represents all legal moves of the knight chess piece ...
831 views

### Scoring 6,5,4 (AKA Ship, Captain, and Crew)

Inspired and looted from this dice challenge by Arnauld Input You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices. Goal Given a valid dice matrix, you are ...
3k views

### Most Common Multiple

Not to be confused with Least Common Multiple. Given a list of positive integers with more than one element, return the most common product of two elements in the array. For example, the MCM of the ...
330 views

### Minimal Centrosymmetrization

Topically related. Objective: Given a matrix of positive integers $M$, output the smallest centrosymmetric matrix which contains $M$ (this matrix may contain non-positive integers as well). A ...
104 views

### Make the super number hyper-pyramid [duplicate]

Challenge Given a positive integer $n$, output the $n$-dimensional pyramidal list. Example $n = 1$: Objects arranged in a 1D pyramid (line) with side length 1 is just by itself. So, the ...
312 views

### Optimal Caching

You will be given a sequence of memory requests and a cache size. You must return the least possible number of cache misses under any cache replacement strategy. An optimal strategy is Belady's ...
2k views

### How much is my dice matrix worth?

Input A non-empty binary matrix consisting of 3x3 sub-matrices put side by side. Task Your task is to identify valid dice patterns (as described below) among the 3x3 sub-matrices. Each valid ...
3k views

### Remove surrounding zeroes of a 2d array

This is a 2-dimensional version of this question. Given a non-empty 2-dimensional array/matrix containing only non-negative integers:  \begin{bmatrix} {\color{Red}0} & {\color{Red}0} & {\...
8k views

### Implementing a stack

I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf: Challenge Your task is to ...
469 views

### Einstein's Sorter

Challenge Given a list of integers and a velocity, $v$, implement a sorting algorithm which simulates a program sorting the list from smallest to biggest at the given velocity. Einstein's Theory ...
Defintion A centrosymmetric matrix is a square matrix that is symmetric about its center. More rigorously, a matrix $A$ of size $n \times n$ is centrosymmetric if, for any \\$i,\: j \in ([1, n] \...