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 »

Review Suggested Edit

You can't approve or reject suggested edits because you haven't yet earned the Edit Posts ability.

Approved.
This suggested edit was approved and applied to the post almost 2 years ago by Aftermost2167‭.

5 / 255
Decoding a non injective bit matrix encoding
  • Hello!
  • I have come across this very interesting programming challenge I thought I'd share.
  • ### The problem
  • You're tasked to decode an encoding of a square bit matrix of certain size, which contains the number of 0 cells per line, column, diagonal (main and anti-diagonal) and quadrant, as well as the number of transitions per line and column. This encoding isn't injective, that is, it doesn't perfectly map one encoding to one matrix. Thus, your decoder should output how many matrices can be decoded from the given input encoding, and in case there's only one, display it.
  • ### Example
  • #### Encoding
  • size: 4
  • line 0s (left to right): 1, 1, 1, 1
  • columns 0s (left to right): 1, 1, 1, 1
  • quadrant 0s: top-right=2 top-left=0, bottom-right=2, bottom-left=0
  • diagonal 0s: main=0, anti=4
  • line transitions (left to right): 1, 2, 2, 1
  • column transitions (left to right): 1, 2, 2, 1
  • #### Decoded matrix
  • 0001
  • 0010
  • 0100
  • 1000
  • ### Constraints
  • The matrices are always square and 2x2 or bigger. The goal is to make a decoder that processes on or more 25x25 encodings under a second (on fairly modern hardware, I suppose). Below that, fastest code wins.
  • ### Evaluation
  • All solutions will be evaluated by me on the same machine, and the time measurements posted as comment on the corresponding answer.
  • Hello!
  • I have come across this very interesting programming challenge I thought I'd share.
  • ### The problem
  • You're tasked to decode an encoding of a square bit matrix of a certain size, which contains the number of 0 cells per line, column, diagonal (main and anti-diagonal) and quadrant, as well as the number of transitions per line and column. This encoding isn't injective, that is, it doesn't perfectly map one encoding to one matrix. Thus, your decoder should output how many matrices can be decoded from the given input encoding, and in case there's only one, display it.
  • ### Example
  • #### Encoding
  • size: 4
  • line 0s (left to right): 1, 1, 1, 1
  • columns 0s (left to right): 1, 1, 1, 1
  • quadrant 0s: top-right=2 top-left=0, bottom-right=2, bottom-left=0
  • diagonal 0s: main=0, anti=4
  • line transitions (left to right): 1, 2, 2, 1
  • column transitions (left to right): 1, 2, 2, 1
  • #### Decoded matrix
  • 0001
  • 0010
  • 0100
  • 1000
  • ### Constraints
  • The matrices are always square and 2x2 or bigger. The goal is to make a decoder that processes one or more 25x25 encodings in under a second (on fairly modern hardware, I suppose). Below that, fastest code wins.
  • ### Evaluation
  • All solutions will be evaluated by me on the same machine, and the time measurements posted as a comment on the corresponding answer.

Suggested almost 2 years ago by trichoplax‭