Skip to main content

All Questions

Tagged with
7 votes
39 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=...
Andy Liu's user avatar
  • 121
14 votes
5 answers
366 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} ...\$ . ...
emanresu A's user avatar
  • 39.2k
26 votes
14 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,...
emanresu A's user avatar
  • 39.2k
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 ...
DLosc's user avatar
  • 39.9k
18 votes
13 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, ...
emanresu A's user avatar
  • 39.2k
1 vote
7 answers
118 views

Interlaced array [duplicate]

You are given an array A of length N and an array B of length ...
Daniil Tutubalin's user avatar
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 ...
Greg Martin's user avatar
  • 15.8k
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 ...
emanresu A's user avatar
  • 39.2k
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 ...
Tbw's user avatar
  • 2,093
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: ...
Larry Bagel's user avatar
  • 4,193
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: ...
emanresu A's user avatar
  • 39.2k
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 ...
Simd's user avatar
  • 3,106
7 votes
4 answers
400 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 ...
Trivaxy's user avatar
  • 487
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: ...
Larry Bagel's user avatar
  • 4,193
10 votes
6 answers
945 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. ...
Command Master's user avatar

15 30 50 per page
1
2 3 4 5
52