All Questions
780
questions
8
votes
45
answers
1k
views
Calculate sum of self-exponentation
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=...
14
votes
5
answers
382
views
Generate a subgroup of a free group
In group theory, the free group with \$n\$ generators can be obtained by taking \$n\$ distinct symbols (let's call them \$a, b, c ...\$ etc), along with their inverses \$ a^{-1},b^{-1},c^{-1} ...\$ . ...
26
votes
15
answers
2k
views
Is it a cartesian product?
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,...
28
votes
23
answers
2k
views
Weave two lists, cycling if necessary
Consider two lists, A and B. To weave them together, we take the first element of A, then the first element of B, then the next element of A, the next element of B, and so on, ending with the last ...
23
votes
18
answers
2k
views
Emulate Jelly's tie-scan
The golfing language Jelly has a built-in ƭ called "tie", that cycles through a list of functions every time it's called. For example, ...
1
vote
7
answers
126
views
Interlaced array [duplicate]
You are given an array A of length N and an array B of length ...
17
votes
15
answers
1k
views
Reconstruct a list of strings from its prefixes
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 ...
18
votes
18
answers
1k
views
Reconstruct a list from its prefixes
A list \$[a_1,a_2,a_3 \cdots a_n]\$ can be uniquely represented as an unordered list of its prefixes - \$ [[a_1],[a_1, a_2], [a_1,a_2,a_3] \cdots [a_1,a_2,a_3 \cdots a_n]] \$. This can be in any order ...
12
votes
6
answers
1k
views
Contract a tensor
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 ...
19
votes
10
answers
2k
views
Search the deepest depths of an array
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0.
Here is an example:
...
26
votes
23
answers
2k
views
Remove falsy rows and columns
Your challenge is to, given a matrix of nonnegative integers, remove all rows and columns that contain a 0.
For example, with this matrix:
...
20
votes
27
answers
2k
views
What and where is the max?
This small challenge derives from my annoyance at discovering that numpy doesn't have a built in function for it.
Input
An n by m matrix of integers.
Output
The maximum value in the matrix and the 2d ...
7
votes
4
answers
404
views
Busy Letters & Evil CEOs
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 ...
24
votes
15
answers
3k
views
"Perfect" an array
Given an n non-negative integers, how many numbers must be changed so that each number x appears x times? You cannot add or remove elements, only replace them with other numbers.
For example:
...
10
votes
6
answers
956
views
Unnecessary Fluff
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.
...