Only once: cleaning up your columns - MATLAB Cody - MATLAB Central

Problem 2045. Only once: cleaning up your columns

Difficulty:Rate

We have a logical array (with ones and zeroes). It is simple: after processing every column may only contain a single true value, or none at all. Not on any row, but only the uppermost occurrence in the input array, if any.

For example:

 [ 0 0 1 1
   0 1 0 1
   0 0 1 1 ] 
becomes 
 [ 0 0 1 1
   0 1 0 0
   0 0 0 0 ] 

And of course, your solution should be the most innovative, shortest and most elegant one.

Solution Stats

60.66% Correct | 39.34% Incorrect
Last Solution submitted on Jun 27, 2024

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers32

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!