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 »
Sandbox

Post History

60%
+1 −0
Sandbox Digit antitranspose [FINALIZED]

posted 2y ago by trichoplax‭  ·  edited 2y ago by trichoplax‭

#5: Post edited by user avatar trichoplax‭ · 2022-11-12T23:26:25Z (about 2 years ago)
Mark as finalized
  • Digit antitranspose
  • Digit antitranspose [FINALIZED]
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - All rows will have the same length (the input will always be rectangular)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "852,741,630" : "012,345,678"
  • "7531,6420" : "01,23,45,67"
  • "0" : "0"
  • "12" : "2,1"
  • "2,1" : "12"
  • "3,4" : "43"
  • "43" : "3,4"
  • "56,78" : "86,75"
  • "86,75" : "56,78"
  • "7777" : "7,7,7,7"
  • "7,7,7,7" : "7777"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • # Now posted: [Digit antitranspose](https://codegolf.codidact.com/posts/287386)
  • ---
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - All rows will have the same length (the input will always be rectangular)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • In these examples input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "852,741,630" : "012,345,678"
  • "7531,6420" : "01,23,45,67"
  • "0" : "0"
  • "12" : "2,1"
  • "2,1" : "12"
  • "3,4" : "43"
  • "43" : "3,4"
  • "56,78" : "86,75"
  • "86,75" : "56,78"
  • "7777" : "7,7,7,7"
  • "7,7,7,7" : "7777"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#4: Post edited by user avatar trichoplax‭ · 2022-11-12T16:16:59Z (about 2 years ago)
Specify input is rectangular
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "852,741,630" : "012,345,678"
  • "7531,6420" : "01,23,45,67"
  • "0" : "0"
  • "12" : "2,1"
  • "2,1" : "12"
  • "3,4" : "43"
  • "43" : "3,4"
  • "56,78" : "86,75"
  • "86,75" : "56,78"
  • "7777" : "7,7,7,7"
  • "7,7,7,7" : "7777"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - All rows will have the same length (the input will always be rectangular)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "852,741,630" : "012,345,678"
  • "7531,6420" : "01,23,45,67"
  • "0" : "0"
  • "12" : "2,1"
  • "2,1" : "12"
  • "3,4" : "43"
  • "43" : "3,4"
  • "56,78" : "86,75"
  • "86,75" : "56,78"
  • "7777" : "7,7,7,7"
  • "7,7,7,7" : "7777"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#3: Post edited by user avatar trichoplax‭ · 2022-11-12T12:32:07Z (about 2 years ago)
Add more test cases
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "0" : "0"
  • "12" : "2,1"
  • "3,4" : "43"
  • "56,78" : "86,75"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "852,741,630" : "012,345,678"
  • "7531,6420" : "01,23,45,67"
  • "0" : "0"
  • "12" : "2,1"
  • "2,1" : "12"
  • "3,4" : "43"
  • "43" : "3,4"
  • "56,78" : "86,75"
  • "86,75" : "56,78"
  • "7777" : "7,7,7,7"
  • "7,7,7,7" : "7777"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#2: Post edited by user avatar trichoplax‭ · 2022-11-12T03:01:29Z (about 2 years ago)
Move example out of bullet point list
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • - For example, the input may be a string of numeric characters with delimiters between rows
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "0" : "0"
  • "12" : "2,1"
  • "3,4" : "43"
  • "56,78" : "86,75"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").
  • Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.
  • ## Input
  • - A (not necessarily square) matrix or grid of single digit non-negative numbers
  • - This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
  • - The width and height will always be at least 1 (the grid will never be empty)
  • - The single digit numbers contained in this data structure may be of number types or characters or single character strings
  • For example, the input may be a string of numeric characters with delimiters between rows.
  • ## Output
  • - The same data structure type as the input
  • - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
  • - Each digit in the input is moved:
  • - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  • - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)
  • ## Examples
  • Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.
  • ### Square input
  • ```text
  • 012
  • 345
  • 678
  • ```
  • ### Square output
  • ```text
  • 852
  • 741
  • 630
  • ```
  • ### Rectangular input
  • ```text
  • 01
  • 23
  • 45
  • 67
  • ```
  • ### Rectangular output
  • ```text
  • 7531
  • 6420
  • ```
  • ## Test cases
  • Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.
  • ```text
  • "012,345,678" : "852,741,630"
  • "01,23,45,67" : "7531,6420"
  • "0" : "0"
  • "12" : "2,1"
  • "3,4" : "43"
  • "56,78" : "86,75"
  • ```
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
#1: Initial revision by user avatar trichoplax‭ · 2022-11-11T17:13:54Z (about 2 years ago)
Digit antitranspose
Convert a matrix or grid of digits to its antitranspose. For a square matrix , this is its reflection in its [antidiagonal](https://en.wikipedia.org/wiki/Main_diagonal#Antidiagonal "Antidiagonal on Wikipedia"). More generally, for a rectangular matrix, this is its reflection in its [skew diagonal](https://mathworld.wolfram.com/SkewDiagonal.html "Skew diagonal on Wolfram").

Less formally, the line to reflect in is from South West to North East, at 45 degrees regardless of the proportions of the rectangle.

## Input
- A (not necessarily square) matrix or grid of single digit non-negative numbers
- This may be a matrix or any 2 dimensional data structure or a 1 dimensional data structure along with width and/or height, or a sequence of 1 dimensional data structures representing rows
- The width and height will always be at least 1 (the grid will never be empty)
- The single digit numbers contained in this data structure may be of number types or characters or single character strings
- For example, the input may be a string of numeric characters with delimiters between rows

## Output
- The same data structure type as the input
  - This applies to every nested level: if the input is a list of strings of characters, the output must be a list of strings of characters
- Each digit in the input is moved:
  - from (x, y) to (height - y - 1, width - x - 1) (if zero indexed from top left)
  - from (x, y) to (height - y + 1, width - x + 1) (if one indexed from top left)

## Examples
Here input and output are represented as newline separated strings of characters. You can check that the input and output match by holding a reflective surface such as a mirror or phone screen at 45 degrees next to the input. The reflected numbers won't be upright but they will be in the same locations as the output.

### Square input
```text
012
345
678
```

### Square output
```text
852
741
630
```

### Rectangular input
```text
01
23
45
67
```

### Rectangular output
```text
7531
6420
```

## Test cases
Test cases are in the format `"input" : "output"` where the input and output are strings containing comma separated rows. For comparison, the first 2 test cases are the same as the examples shown above.

```text
"012,345,678" : "852,741,630"
"01,23,45,67" : "7531,6420"
"0" : "0"
"12" : "2,1"
"3,4" : "43"
"56,78" : "86,75"
```

> Explanations are optional, but I'm more likely to upvote answers that have one.