# Questions tagged [array-manipulation]

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

632 questions
Filter by
Sorted by
Tagged with
2k views

### Game of Life, but on a 4-8-8 tiling

Background The 4-8-8 tiling looks like this: For the purpose of this challenge, we take the orientation of the tiling as exactly shown above. In plain English words, we take the tiling so that it can ...
199 views

### So is that maximum?

Given a map from arrays of integers of same size to single integers, determine if there is a set of indices such that the output is equal to the maximum of the elements at those indices for every ...
113 views

### How many fill buckets to blank? [duplicate]

The fill bucket is a tool available in many drawing tools which replaces a contiguous chunk of one color with a another color. We are going to define a fill bucket which operates on lists of non-...
228 views

### Draw constraint system #18762389

Background Page 219 of A New Kind of Science (a book by Stephen Wolfram, the creator of Mathematica) shows an interesting 2D pattern generated by constraints. The relevant section in the book starts ...
3k views

### "-rot" transform

Background -rot transform (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first ...
2k views

### Hunt for discount

Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items ...
2k views

### Show me the trajectory

Given a list of integers find the "trajectory" that results from indefinitely moving the instructed steps to the right (left if negative), wrapping if necessary, starting at the first ...
707 views

The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For ...
1k views

### Split into sublists of specified sizes

05AB1E has the £ builtin which, given a list of integers b and a string s, splits ...
5k views

### What's my PIN number?

My PIN number is 1077, but that's too difficult to remember. I know from muscle memory that it's a digit, followed by a different digit, then followed by two of the same digit, which is different to ...
4k views

### Build me a room

Related A room, in the context of this challenge, is a multidimensional array where the elements on the "outside" are 1, to represent the walls, and all ...
485 views

2k views

### Split a list at the second occurrence of the first element

Why should you golf in Haskell? Find out here. In that answer, Zgarb defines a task: Let's define a function f that splits a list at the second occurrence of the ...
984 views

### Smallest slice of array containing a number of items

Take this array: [1, 2, 6, 4, 4, 1, 0, 0, 2, 0, 4, 1, 4, 2, 4, 8, 1, 2, 4] There are quite a few places where ...
3k views

### I'm Lazy*: Top-left align my text

* and don't have a word processor with top-left align support :D Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be ...
515 views

### Split a list into maximal equal-sum sections

Task Given a non-empty list of positive digits, group them into sublists of equal sum. You may output any subset of solutions with maximal number of sublists (equivalently, minimal sum). The input may ...
1k views

Background Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules: Connect two cells with number N with a line spanning N cells, so ...
373 views

Introduction Dr. Leslie Lamport, of the eponymous Lamport one-time signature scheme, is getting rather old. But he can't die until his most famous algorithm gets all the kinks ironed out! In ...
2k views

### Generate a mantis's head (symmetrical triangle)

Given guaranteed strictly positive integers $w$ and $n$, output An equilateral triangle array with side length $w$, filled with two distinct, consistent values. I'll call these ...
1k views

### List array elements which can be summed from other elements

Consider an array of unique integers, with an arbitrary length greater than 2. It is sometimes possible to express elements of the array as the sum of at least two other elements. For example, if our ...
2k views

### The Computer Thief

You wake up and find out that your computer has been stolen! You have a few sensors and scanners, but unfortunately, the footage is incomplete, so you want to find and rank your suspects for further ...
1k views

### Sum on a Fenwick Tree

Background Information: What is a Fenwick Tree? With a normal array, it costs $O(1)$ to access and modify an element, but $O(n)$ to sum $n$ elements. Working with a prefix sum array (an array ...
958 views

### Longest Sublist with Equal Occurrences

Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not ...
2k views

### Guide my eyes in the right direction

Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source). A valid answer: Takes a number $w$ and (assumed non-negative) integer $x$. Starts with an integer list with a length of $2^w$...
2k views

### Apply at indices

Given: a blackbox function $f : \mathbb N \to \mathbb N$, a list of positive integers $L$, and a list of indices $I$, apply $f(x)$ to the elements of $L$ at the indices specified in $I$. ...
1k views

### How many Faro shuffles for a cycle?

Background Inspired by this video by Matt Parker A Faro shuffle is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one: the deck of 52 cards ...
322 views

### Generate the ticks of a graph

A challenge many developers face when drawing a graph from scratch to plot some data is generating its ticks. In below graph, there are 6 horizontal ticks (1750, 1800, 1830, 1860, 1880 and 1900) and ...
2k views

### Solve the Alien Probe puzzle

Introduction In this TED-Ed video (which I'd recommend watching first), a puzzle is presented. 27 unit cubes must be painted with one of red, green, or purple on each face, so that they can be ...
887 views

### Best Rolling Ao5

In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" ...
225 views

### Implement ΔList [duplicate]

Given a list of integers, such as {1, 4, 2, 8, 10}, TI-Basic's ΔList will determine the difference between every overlapping ...
1k views

### Replace all items with their counts

Task: Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, <...
2k views

### Are All the Items the Same?

Given a list of non-negative integers, return whether or not that list is all the same number. Rules Input and output can be taken/given in any reasonable and convenient format Truthy/Falsey values ...
2k views

### Close neighbours stick together

Given a list of positive digits, return that list with consecutive elements grouped together. For example: ...
4k views

### Is it better to walk or run in the rain?

The age-old question - is it better to walk or run? There are two trains of thought. If you run, you cause the rain to effectively hit you from the front, which increases your surface area and ...
An $n\times n$ Latin Square is a grid containing exactly $n$ distinct values where the values in each row and column are distinct. For example, \begin{matrix} A & B & C \\ C & A &...