All Questions
11 questions
33
votes
55
answers
2k
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, <...
3
votes
2
answers
589
views
Remove duplicates from list and order it by count? (python 3)
How do I remove all duplicates from list and order it based on count?
...
51
votes
34
answers
9k
views
Covering a Skyline with brush strokes
Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it.
[1,3,2,1,2,1,5,3,3,4,2]...
21
votes
5
answers
459
views
Count cyclically self-describing lists
Cyclically self-describing lists
A list \$L\$ of positive integers is cyclically self-describing, if the following conditions hold.
\$L\$ is nonempty.
The first and last elements of \$L\$ are ...
22
votes
20
answers
2k
views
Find the "Recursive Size" of a List
Inspired by Find the “unwrapped size” of a list.
Define the Recursive Size, RS, of a list containing no lists as its length (number of items contained) and the ...
13
votes
33
answers
2k
views
Find the "unwrapped size" of a list
Let's define the "unwrapped size" function u of a nested list l (containing only lists) by the following rules:
If ...
69
votes
62
answers
4k
views
Count trailing truths
Inspired by, and in memory of, my dear friend and colleague,
Dan Baronet, 1956 – 2016. R.I.P.
He found the shortest possible APL solution to this task:
Task
Given a Boolean list, count the number of ...
39
votes
54
answers
11k
views
Determine the depth of an array
A simple challenge for your Monday evening (well, or Tuesday morning in the other half of the world...)
You're given as input a nested, potentially ragged array of positive integers:
...
26
votes
60
answers
4k
views
Non-Unique/Duplicate Elements
Write a program which finds the non-unique elements of an array of signed integers. The resulting array can be in any order.
Your answer may be a snippet which assumes the input to be stored in a ...
48
votes
20
answers
6k
views
Into how many pieces can you cut this string?
Consider a piece of string (as in "rope", not as in "a bunch of characters"), which is folded back and forth on the real line. We can describe the shape of the string with a list of points it passes ...
-3
votes
7
answers
411
views
Remove Duplicates From One List [duplicate]
Task:
Remove all duplicates from one list of integers. A list is simply a sequence of connected values that allows the same values to be stored at different positions in this sequence.
If an item ...