# Questions tagged [array-manipulation]

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

554 questions
Filter by
Sorted by
Tagged with
421 views

### Advent Challenge 6: Transport Dock Relabeling!

<< Prev Next >> Thanks to the PPCG community, Santa managed to sort his presents into the correct order for moving into the transportation dock. Unfortunately, the transportation dock signs are ...
2k views

### Advent Challenge 5: Move the presents to the transport docks!

<< Prev Next >> Thanks to the PPCG community, Santa has managed to remanufacture all of his presents and after the assembly line, the presents are now ready to be moved into the transport docks!...
476 views

### Make sets disjoint without emptying them

Suppose you have a set of sets of integers. It's possible that some of the sets will overlap (i.e. sharing elements). You could get rid of the overlaps by deleting elements from the sets, but then ...
1k views

### Mod-balanced lists

Introduction Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also ...
634 views

### Advent Challenge 1: Help Santa unlock his present vault!

Next >> Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find Challenge Santa has had a history of elves stealing presents from his vault in the past, so this ...
3k views

### Normalize a Vector

To normalize a vector is to scale it to a length of 1 (a unit vector), whilst keeping the direction consistent. For example, if we wanted to normalize a vector with 3 components, u, we would first ...
469 views

### The Shield Wall

Historical Background The shield wall is a tactical war formation that dates back to at least 2500 BC. It consisted of warriors overlapping their shields with those of their companions to form a '...
371 views

### Iterative Alliterative Additive Array Antics

I honestly don't know what the point of this sort of calculation would be, but it should make fun golfing. Shortest code wins. Input (in no particular order) An array of integers, ...
224 views

### The Median of Practically Recreational Languages

According to TIO there are two types of programming languages: Practical (seen in many corporate environments as a development standard). Recreational (if seen in a corporate environment, you're ...
790 views

### Largest Deep Sum [closed]

Given an n-dimensional array filled with numbers, output which p-dimensional array has the largest sum. Input An n-dimensional array of numbers, or your language's equivalent. You can assume this is ...
4k views

### Determinant of an Integer Matrix

Given a square integer matrix as input, output the determinant of the matrix. Rules You may assume that all elements in the matrix, the determinant of the matrix, and the total number of elements in ...
935 views

### Pick-flatten a list

Consider the process of "picking" a nested list. Picking is defined as follows: If the argument is a list, take an element from the list at random (uniformly), and pick from that. If the argument is ...
2k views

### An Array of Challenges #3: Moving Averages

Note: This is #3 in a series of array-manipulation challenges. For the previous challenge, click here. Moving Average of a List The moving average of a list is a calculation resulting in a new, ...
3k views

### Basic sort, with annoying bug

Your input is a list/sequence/vector/array of 5-255 positive integers, not necessarily unique. You may assume whatever input format is most suitable, and that each integer (as well as the quantity of ...
3k views

### Find the unique twins

You will be given two Arrays / Lists / Vectors of non-negative integers A and B. Your task is to output the highest integer N that appears in both A and B, and is also unique in both A and B. You ...
3k views

### Count the changes in an array

Your task today is to write a program or function that takes an array of integers, and counts the number of times, reading it left to right, that the value changes. This is easier to show with an ...
3k views

### Does it oscillate periodically?

Challenge Given a list, determine if grouping the list into runs of increasing and decreasing elements will result in a list of equal-sized lists. In other words, "turning points" of the list are ...
654 views

### Oscillation equality

We have objects that oscillate between two integer points, [l, r], at the speed of one unit per time unit, starting at l on <...
809 views

### Alternested numbers

Consider the array of positive integers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ... Then, concatenate them: ...
497 views

### Expand an Array

Expand an array to all directions by duplicating the outer elements You will be given two inputs: an array and the expansion degree For example if I give you ...
484 views

### Fill the steps (randomly)!

This is Hole-9 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given a simple (rectangular, non-jagged) Boolean array (...
4k views

### Am I a golfy array?

Definition and Rules A golfy array is an array of integers, where each element is higher than or equal to the arithmetic mean of all the previous elements. Your task is to determine whether an array ...
1k views

### Find the greatest line

You will be given a 2-D array A of integers, and a length N. Your task is to find within the array the straight line (horizontal, vertical or diagonal) of N elements that yields the highest total sum, ...
2k views

### I am greater than you! [duplicate]

Write a function or program that given a list of non negative integers, arranges them such that they form the largest possible number. INPUT [50, 2, 1, 9] ...
7k views

### In Search of a Soulmate

Given a nonempty finite list of integers, output a truthy value if there are exactly two equal entries and all other entries are distinct, and a falsey value otherwise. Examples ...
993 views

### An expanding array

Given two positive integers p and q, your task is to return the array A created by applying the following algorithm: Start with A = [p, q] and d = 2 For each pair (x, y) of contiguous numbers in A ...
3k views

### Narcissistic array elements

Definition Narcissistic 1 integers of an array think they are better than their neighbours, because they are strictly higher than their arithmetic mean. Neighbours are defined as follows: If the ...
2k views

### Deep Search a List

For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, ...
3k views

### The Three 'R's: Reverse, Reorder, Repeat

While doodling around with numbers, I found an interesting permutation you can generate from a list of numbers. If you repeat this same permutation enough times, you will always end up back at the ...
7k views

### Am I an insignificant array?

An insignificant array is an array of positive integers, where the absolute differences between consecutive elements are all smaller than or equal to 1. For example, the following array is ...
2k views

### Score a Game of Boggle

Background In Boggle, a round is scored by adding up the points for each unique word a player has found (i.e. any word that more than one player has found is worth 0 points). The points are calculated ...
4k views

### Add an array with itself

Your challenge today is to take an array, split it into chunks, and add those chunks. Here's how this works: Your program or function will be given an array of integers ...
3k views

### Randomly select from an array

This challenge is rather simple: You are given an array of positive (not including 0) integers, and have to select a random element from this array. But here's the twist: The probability of selecting ...
2k views

### Nth Differences

In math, one way to figure out what the type of a given relation (linear, quadratic, etc) is to calculate the differences. To do so you take a list of y values for which the gap between the ...
2k 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 ...
918 views

### Kolakoski-like self-referencing sequences

This is how the Kolakoski sequence (OEIS A000002) is defined: The Kolakoski sequence is a sequence that contains 1 and 2, and ...
977 views

### Measuring a pile of logs

Introduction This is a log of length 5: ##### I want to pile a bunch of these logs on top of each other. How I do this is that I slide a new log onto the ...
3k views

### Is this a valid Takuzu board?

Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules: No ...
2k views

### Array Factorization

Given an array of positive integers, output a stable array of the distinct prime factors of these integers. In other words, for each integer in the input in order, get its prime factors, sort them, ...
1k views

### Matrix in Range

The Challenge Given an integer n>0 output a n+1 X n+1 matrix containing all integers from ...
3k views

You will be given two arrays of floating-point numbers. Your task is to pair the corresponding elements of the two arrays, and get the maximum of each pair. However, if the two corresponding elements ...
1k views

### Are the lists divisible?

Inspired (with the explanation stolen from) this Background Say you have two lists A = [a_1, a_2, ..., a_n] and ...
629 views

### Stretch an array

Earlier I defined the process of crushing an array In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the ...
2k views

### Circularly moving sum

Inspired by a question at Stack Overflow. Given a non-empty array of integers x and a positive integer n, compute the sum of ...
3k views

### How hard can I crush my array?

Lets define the process of crushing an array of numbers. In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double ...
2k views

### Skip like a frog!

Given an array of non-negative integers, your task is to only keep certain elements of it, as described below. Let's say the array is ...
70 views

### Turn an integer n into an N-DIMENSIONAL list [duplicate]

Inspired by this question. Given an integer n, create an n-dimensional list of "length" n in every dimension, where every element is n. Rules: If your language has a built-in that does this, you ...
6k views

### Turn an integer n into a list containing it n times

Given an integer n as input, return a list containing n, repeated n times. For example, the ...