# Questions tagged [ragged-list]

A ragged list, also called a jagged list, is a list where each element can either be some terminal type (e.g. an integer) or another ragged list.

43 questions
Filter by
Sorted by
Tagged with
7k views

### Unflatten an Array

This challenge was inspired by a question on Mathematica.SE. Say you've got a nested list/array of some arbitrary structure (the lists at each level don't necessarily have the same length). For ...
• 196k
6k views

### Is it true? Ask Jelly!

Background Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style all) atom. Ȧ takes an array as input and returns 1 ...
• 210k
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: ...
• 196k
3k views

### Re-name all identifiers to a single letter

Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which ...
• 12.4k
8k views

### Flatten the Array! [duplicate]

In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] ...
• 5,054
2k views

### B​u​i​l​d a n​e​s​t

The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array. The rules Your code must produce a unique valid nested array for every ...
• 49.9k
3k views

### Gödel encoding - Part I

Related but different. Part II Taken from the book: Marvin Minsky 1967 – Computation: Finite and Infinite Machines, chapter 14. Background As the Gödel proved, it is possible to encode with a unique ...
• 3,238
3k views

### Pad a jagged array to be square

Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that ...
• 23.5k
1k views

### Decode the Void

A void list is a list that at no level contains any non-list objects. Or if you prefer a recursive definition The empty list is void A list containing only other void lists is void All void lists ...
• 97.6k
2k views

### Reconstruct a recursively prime-encoded integer

Recursively prime-encoded integers Consider $11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843$. This isn't a nice prime factorisation, as $42239$ and $5530987843$ make it ...
• 49.8k
1k views

### Scan a ragged list

hgl has a "scan" function called sc. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it. If we ...
• 97.6k
2k views

### Deep Search a List

For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, ...
• 41.4k
1k views

### Find the maximum length in a ragged list

Given a ragged list of positive integers find the size of the largest list contained somewhere in it. For example: [1,[1,[8,2,[1,2],5,4,9]],2,[],3] Here the answer ...
• 97.6k
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 ...
• 105k
3k views

### Iteratively delete a list

Say I have a ragged list, like: [ [1, 2], [3, [4, 5] ] ] And I want to iterate over each item and delete it one-by-one. However, I don't know the ...
• 37.1k
1k views

### Inverted ragged list

Given a ragged list of positive integers, where the maximum depth is $d_\text{max}$, return the same list, except for every element $e$, its depth is $d_\text{max}+1-d_e$ (where $d_e$ is the ...
• 7,848
2k views

### Collect the elements of an array

Add++, the Language of the Month, has the "collect" builtin as BC. Your task is to implement this builtin. Consider a non-empty array, where each element ...
• 49.8k
2k views

### Sort numbers in a ragged list

Given a ragged list, e.g. [[4, 7], [5, 3, [], [6, [2]]]] Your challenge is to sort only the numbers in it. For example, with the above, the result would be ...
• 37.1k
1k views

### Build a list from a depth map

You will be given as input a non-empty list of positive integers. For example: [1,2,2,2,1] You want to produce a ragged list as output which has this as its "...
• 97.6k
3k views

### Make a list flat

Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it ...
2k views

### Multiply numbers by their depth

Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested. For example, with the list ...
• 37.1k
2k views

### Is it a valid list?

Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list. A list is either: ...
• 37.1k
2k views

### Is it a properly tiered list?

A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list. A ragged list is properly tiered if it contains either all positive integers or all properly ...
• 97.6k
3k views

Create a function (or closest equivalent, or full program) that takes an list of some datatype (your choice) that may be nested and a string (in either order), and generalizes the lisp c[ad]+r ...
• 1,458
759 views

### Minimum depth of a ragged list

As input you will be given a ragged list of positive integers containing at least one integer at some level. For example: [[],[[1,2,[3]]],[]] You should output ...
• 97.6k
870 views

### Make every fixed list

We are to define the idea of a fixed list as follows: A fixed list is a list of fixed lists. This definition is recursive so it's useful to look at some examples. The empty list ...
• 97.6k
1k views

### Count count count

Description You have a list of integers and start counting from the first term to the next and continue from that to the next and so on.. How many times have you counted? For example given [ 2, 5, 3, ...
• 10.7k
1k views

### Ragged list pattern matching

Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list. But in addition to ...
• 47.5k
2k views

### Reverse an N-Dimensional array

Details Write a function or program that, given an array (or list), containing only integers, returns or output an array with all sub-elements reversed. That is, reverse all elements of the deepest ...
• 709
1k views

### Recursively rotate a ragged list

Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state. ...
• 16.6k
773 views

### Ragged index of

Your input is a ragged list of positive integers and a positive integer. Your task is to find that positive integer and return it's index, or if the positive integer doesn't exist, indicate it's ...
• 7,848
954 views

### Array depth of a ragged list

This is not a duplicate of this challenge. Here by an array, I mean a nested list that is "not ragged", i.e., it is either a list of elements, or a list of arrays of the same shape. For ...
• 47.5k
982 views

### Compare shapeless lists

Let's have a ragged list containing no values, only more lists. For example: [[[],[[]],[],[]],[],[[],[],[]],[]] And the list will be finite, meaning that ...
• 97.6k
1k views

• 97.6k
801 views

### Ragged Matrix Indexing

A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ...
• 5,049
721 views

### Is it an ordinal?

Background (feel free to skip) Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared ...
• 7,848
489 views

• 5,945
196 views

### Ragged list pattern matching, Part 2

This is a sequel to Ragged list pattern matching. In this challenge, the wildcard may match a sequence of items of any length instead of just a single item. Given a pattern and a ragged list of ...
• 47.5k