# Questions tagged [array-manipulation]

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

173 questions
Filter by
Sorted by
Tagged with
5k views

### Separate a list into even-indexed and odd-indexed parts

Inspired by this question: Make a function (or a full program) that receives a list of numbers and outputs the list rearranged, so that even-indexed numbers appear first, and odd-indexed numbers ...
3k views

### Numbers Increase While Letters Decrease

Inspired by this Stack Overflow question: Sorting a list: numbers in ascending, letters in descending. Your task is to solve the following problem and, as this is code-golf, you should do so in as few ...
966 views

### Sort a difference list

The difference list of a list of integers is the list differences of consecutive members. For example the difference list of 1, 3, 2 ,4 is ...
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 ...
2k views

### Function clipboard: paste

This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: copy. Introduction MATL's function ...
943 views

### Calculate the bounded cumulative sum of a vector

The cumulative sum of a vector is calculated by simply taking the sum of all previous elements. For instance: ...
1k views

### Reverse Maths Cycles

Inspired by this In the linked challenge, we are asked to apply addition to the elements of the original and the reverse of the input array. In this challenge, we are going to make it slightly more ...
1k views

### Minimally sort a list into a matrix

Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not ...
1k views

### Enumerate Derangements

Given some positive integer $n$ generate all derangements of $n$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number $i$ cannot be in ...
2k views

### Generate all square sub-matrices of a given size

You will be given a square matrix of integers M and another positive integer n, strictly smaller than the size of M. Your task is to generate all square sub-matrices of M of size n. For the purposes ...
984 views

### Turn this array into a matrix

Take a non-nested array as input. Turn it into a matrix by using the following method: Let's say my array is [1, 2, 3, 4, 5] First, I repeat that array 5 times: (...
542 views

### Topple the sandpile

(There are related questions about infinite sandpiles, and finding identity elements of sandpiles.) Given a matrix of non-negative integers, return a matrix of the same dimensions, but toppled: If ...
917 views

### Group Integers by Originality

Introduction: I collect twisty puzzles. Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and ...
158 views

### Advent Challenge 8: Storage Cart Transport Planning!

<< Prev Thanks to the PPCG community, Santa now has balanced his storage carts. Now, he needs to move them into the transport docks so that they can be sent to the loading bays. Unfortunately, ...
3k views

### The Nine Pattern

Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number ...
1k views

### Calculate a probability exactly

This task is about writing code to compute a probability exactly. The output should be a precise probability written as a fraction in its most reduced form. That is it should never output ...
286 views

### Almost Lexicographical List Comparison

Input Two lists A and B of nonnegative integers. Output Either 1, ...
709 views

### Find unique elements based on a given key

Input Take a list of values xi each paired with a key yi. [(x1, y1), (x2, y2), ...] Output Return a list L containing only values from the set {xi}. The ...
1k views

### Rearranging a set of numbers into order

The Question Given a set of 9 numbers, m[], which contains only numbers 1 through 9 in a random order, with no two numbers being the same, create a program in any ...
350 views

### Count, Replace, Add Up! [duplicate]

Definition Define the nth term of the CRAU sequence as follows. Begin with the singleton array A = [n]. Do the following n times: For each integer k in A, replace the entry k with k natural numbers,...
920 views

### Same length sub arrays

Background: Here's a little simple challenge. You want to be able to find out whether the arrays inside an array have the same length. Input: Your input should consist of exactly one array (this is ...