Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

81%
+7 −0
Challenges Truthify an array

Jelly has an atom called untruth, which when given indices, creates an array with 1s at those places: [2,4] → [0,1,0,1]. You are required to perform the inverse of this. Given a 2D boolean array, ...

10 answers  ·  posted 3y ago by Razetime‭  ·  last activity 2y ago by General Sebast1an‭

#3: Post edited by user avatar caird coinheringaahing‭ · 2021-06-17T03:18:09Z (almost 3 years ago)
Added array manipulation tag
Truthify an array
[Jelly](https://github.com/DennisMitchell/jellylanguage) has an atom called untruth, which when given indices, creates an array with 1s at those places: `[2,4] → [0,1,0,1]`.

You are required to perform the inverse of this. Given a 2D boolean array, find the indices of the true values in it.


# Challenge
You will be given a single 2D boolean array \$M\$. You may take its dimensions as a separate argument if needed.

The output must consist of all the indices of the true values in \$M\$.

Output may be 0-indexed or 1-indexed.

It is guaranteed that the input will only consist of two different values.

# Test Cases
All test cases are 0-indexed.
```
I: [[1,0,1,1,1,0]]
O: [[0,0],[0,2],[0,3],[0,4]]

I: [[1,0,1],[1,0,1],[0,1,0]]
O: [[0,0],[0,2],[1,0],[1,2],[2,1]]

```
#2: Post edited by user avatar Razetime‭ · 2021-01-08T16:26:32Z (over 3 years ago)
  • [Jelly](https://github.com/DennisMitchell/jellylanguage) has an atom called untruth, which when given indices, creates an array with 1s at those places: `[2,4] → [0,1,0,1]`.
  • You are required to perform the inverse of this. Given a boolean array with any number of dimensions, find the indices of the true values in it.
  • # Challenge
  • You will be given a single boolean array \$M\$. You may take its dimensions as a separate argument if needed.
  • The output must consist of all the indices of the true values in \$M\$.
  • Output may be 0-indexed or 1-indexed.
  • It is guaranteed that the input will only consist of two different values.
  • # Test Cases
  • All test cases are 0-indexed.
  • ```
  • I: [1,0,1,1,1,0]
  • O: [0,2,3,4]
  • I: [[1,0,1],[1,0,1],[0,1,0]]
  • O: [[0,0],[0,2],[1,0],[1,2],[2,1]]
  • I: [[[1,0,1,1],[1,1,1,1],[0,0,0,1],[1,0,0,1]],[[0,1,0,0],[0,0,0,0],[0,1,1,1],[0,1,0,0]],[[1,1,1,0],[0,0,1,0],[1,1,1,0],[1,0,0,1]],[[0,0,0,1],[1,0,1,0],[1,1,0,0],[0,1,1,1]]]
  • O: [[0,0,0],[0,0,2],[0,0,3],[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,2,3],[0,3,0],[0,3,3],[1,0,1],[1,2,1],[1,2,2],[1,2,3],[1,3,1],[2,0,0],[2,0,1],[2,0,2],[2,1,2],[2,2,0],[2,2,1],[2,2,2],[2,3,0],[2,3,3],[3,0,3],[3,1,0],[3,1,2],[3,2,0],[3,2,1],[3,3,1],[3,3,2],[3,3,3]]
  • ```
  • [Here are the inputs in a more usable format.](https://dzaima.github.io/paste#0VVBBDsMgDLvzlhyCvdN@sNMegPjCNGnt/9cQU1pVwiGO7dDX57tvv2dp1dzq@LyXltduJ/oggpmTg6yq3PwiiOooU3TIJu8yqssyTK21mZyTWa3e3fOatCbv7sem5b1vepsbjPaI7ecY0mCcUSNERfZaA0Ke71eAEMLkIaTmOO7rP@JECJPn6EO50DyUD5v7QTzEQ32qn3nUvtS@lJ7SU3oqNxBC9v4H#JS)
  • [Jelly](https://github.com/DennisMitchell/jellylanguage) has an atom called untruth, which when given indices, creates an array with 1s at those places: `[2,4] → [0,1,0,1]`.
  • You are required to perform the inverse of this. Given a 2D boolean array, find the indices of the true values in it.
  • # Challenge
  • You will be given a single 2D boolean array \$M\$. You may take its dimensions as a separate argument if needed.
  • The output must consist of all the indices of the true values in \$M\$.
  • Output may be 0-indexed or 1-indexed.
  • It is guaranteed that the input will only consist of two different values.
  • # Test Cases
  • All test cases are 0-indexed.
  • ```
  • I: [[1,0,1,1,1,0]]
  • O: [[0,0],[0,2],[0,3],[0,4]]
  • I: [[1,0,1],[1,0,1],[0,1,0]]
  • O: [[0,0],[0,2],[1,0],[1,2],[2,1]]
  • ```
#1: Initial revision by user avatar Razetime‭ · 2021-01-08T10:49:21Z (over 3 years ago)
Truthify an array
[Jelly](https://github.com/DennisMitchell/jellylanguage) has an atom called untruth, which when given indices, creates an array with 1s at those places: `[2,4] → [0,1,0,1]`.

You are required to perform the inverse of this. Given a boolean array with any number of dimensions, find the indices of the true values in it.


# Challenge
You will be given a single boolean array \$M\$. You may take its dimensions as a separate argument if needed.

The output must consist of all the indices of the true values in \$M\$.

Output may be 0-indexed or 1-indexed.

It is guaranteed that the input will only consist of two different values.

# Test Cases
All test cases are 0-indexed.
```
I: [1,0,1,1,1,0]
O: [0,2,3,4]

I: [[1,0,1],[1,0,1],[0,1,0]]
O: [[0,0],[0,2],[1,0],[1,2],[2,1]]

I: [[[1,0,1,1],[1,1,1,1],[0,0,0,1],[1,0,0,1]],[[0,1,0,0],[0,0,0,0],[0,1,1,1],[0,1,0,0]],[[1,1,1,0],[0,0,1,0],[1,1,1,0],[1,0,0,1]],[[0,0,0,1],[1,0,1,0],[1,1,0,0],[0,1,1,1]]]
O: [[0,0,0],[0,0,2],[0,0,3],[0,1,0],[0,1,1],[0,1,2],[0,1,3],[0,2,3],[0,3,0],[0,3,3],[1,0,1],[1,2,1],[1,2,2],[1,2,3],[1,3,1],[2,0,0],[2,0,1],[2,0,2],[2,1,2],[2,2,0],[2,2,1],[2,2,2],[2,3,0],[2,3,3],[3,0,3],[3,1,0],[3,1,2],[3,2,0],[3,2,1],[3,3,1],[3,3,2],[3,3,3]]
```

[Here are the inputs in a more usable format.](https://dzaima.github.io/paste#0VVBBDsMgDLvzlhyCvdN@sNMegPjCNGnt/9cQU1pVwiGO7dDX57tvv2dp1dzq@LyXltduJ/oggpmTg6yq3PwiiOooU3TIJu8yqssyTK21mZyTWa3e3fOatCbv7sem5b1vepsbjPaI7ecY0mCcUSNERfZaA0Ke71eAEMLkIaTmOO7rP@JECJPn6EO50DyUD5v7QTzEQ32qn3nUvtS@lJ7SU3oqNxBC9v4H#JS)