Skip to main content

Questions tagged [array]

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

Filter by
Sorted by
Tagged with
17 votes
18 answers
1k views

Task Given an unsorted list of integers, order it in such a way that the absolute difference of every two adjacent elements will always be equal to 1: \$|dx| = 1\$ There will be guaranteed one or more ...
Glory2Ukraine's user avatar
11 votes
11 answers
788 views

Challenge: Find integers \$a\$ and \$b\$ defining linear function \$f(x) = ax + b\$ with \$a > 0, b \ge 0\$ such that the sum of the elements of the input list \$l\$ located at the values of the ...
Fmbalbuena's user avatar
  • 5,085
16 votes
16 answers
1k views

In a secret lab corridor, there are emitters and gates: A number represents a laser emitter with a certain frequency, a 0 represents an inactive gate. If two ...
turalson's user avatar
  • 581
18 votes
5 answers
1k views

You need to hide in a maze from a robot which methodically follows the left hand wall rule. That is, it enters, immediately turns left, and will always move keeping its left hand on the wall. It only ...
Steve Bennett's user avatar
5 votes
5 answers
364 views

Write a program/function to calculate the squadrat "yard" from a collection of squadrats. Squadrats is a platform that gamifies outdoor activities by recording which large (~1.6 km square) ...
Steve Bennett's user avatar
9 votes
4 answers
664 views

A text that can be arranged triangularly in some fashion can be read back in some other fashion effectively enciphering it. Narrowing down a set of plausible triangular numberings allows to ...
Domenico's user avatar
  • 2,463
13 votes
7 answers
980 views

Update 2025-06-04: Thanks for the submissions everyone! It seems like a lot of the solutions are quite slow / timeout for the 100 length test case, so I don't think any will be able to do the 10k. ...
Ted's user avatar
  • 2,417
10 votes
6 answers
840 views

In some forms of assembly, there are separate "short jump" and "long jump" instructions. However, these jumps can themselves have different lengths, which can affect the distance ...
mousetail's user avatar
  • 14.4k
4 votes
1 answer
287 views

I like writing answers using Brainfuck, since this language basically simulates a Turing machine, and it is pretty challenging to find the shortest answer for any problem, since there are a lot of ...
Weird Glyphs's user avatar
13 votes
9 answers
865 views

The symmetric inverse semigroup is a very important object in the study of semigroups, for a number of reasons, but most obviously due to the Wagner-Preston theorem. In brief, for any set \$X\$, the ...
caird coinheringaahing's user avatar
15 votes
14 answers
2k views

You are given a two-dimensional array consisting of 0s and 1s. The number of rows and columns can vary. For example, 10 by 20. 0 represents water. 1 represents land. Your task is to find the area of ...
Pavel's user avatar
  • 475
11 votes
13 answers
1k views

Solve this problem in the fewest number of bytes of code possible. We have a data variable that contains user input data. Data is a list of integers. Write the code that finds the longest bitonic ...
Pavel's user avatar
  • 475
37 votes
17 answers
2k views

Background Recently, I was installing updates on my pc with Pacman (I use arch btw) and noticed the order it downloaded files was like this Start with the largest 4 downloads When a download ...
mousetail's user avatar
  • 14.4k
9 votes
48 answers
2k views

Given an array of positive integers, calculate the sum of each number raised to its own power. For example, given 4,6,7, the code needs to return \$4^4+6^6+7^7=...
Andy Liu's user avatar
  • 251
28 votes
16 answers
2k views

The cartesian product of two multisets \$A\$ and \$B\$ is the multiset of all ordered pairs consisting of an element of \$A\$ and an element of \$B\$. For example, the cartesian product of \$\{1, 2, 7,...
emanresu A's user avatar
  • 46.2k
24 votes
19 answers
2k views

The golfing language Jelly has a built-in ƭ called "tie", that cycles through a list of functions every time it's called. For example, ...
emanresu A's user avatar
  • 46.2k
16 votes
15 answers
1k views

emanresu A posted a challenge to reconstruct an ordered list of integers from its unordered set of unordered prefixes. Many users (beginning with xnor's answer) noticed that summing each unordered ...
Greg Martin's user avatar
  • 16.7k
12 votes
7 answers
2k views

Introduction Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and ...
Tbw's user avatar
  • 3,023
26 votes
23 answers
2k views

Your challenge is to, given a matrix of nonnegative integers, remove all rows and columns that contain a 0. For example, with this matrix: ...
emanresu A's user avatar
  • 46.2k
7 votes
4 answers
449 views

Imagine you are given an array/string containing \$5\$ letters of the English alphabet, with each letter having any value from A to Z (inclusive). Every day, each letter will perform a job, which can ...
Trivaxy's user avatar
  • 697
10 votes
6 answers
1k views

Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task: Take a list of positive integers and a positive integer \$m\$ as input. ...
Command Master's user avatar
11 votes
8 answers
1k views

We want to go on a night hike with the youth group, but of course not everyone has their torch, even though we told them we planned to split up. What options are there for group formation if n teens ...
Philippos's user avatar
  • 2,688
19 votes
24 answers
3k views

One lane is closed, the vehicles have to thread their way in according to the zip-lock system: One car from one lane, the next car from the other lane, always taking turns. Input: Two vehicle queues, ...
Philippos's user avatar
  • 2,688
7 votes
2 answers
365 views

Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble. For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/...
math scat's user avatar
  • 9,528
30 votes
20 answers
4k views

You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few ...
Wheat Wizard's user avatar
  • 103k

1
2 3 4 5
17