Problem 865. Add more zeros
Solution Stats
Problem Comments
-
1 Comment
Didn't really understand the problem right from reading the task itself, but from reading the test cases. Really fun problem though. First time I used regexprep function, so I learned a lot!
Solution Comments
-
1 Comment
no regexp.
-
2 Comments
The problem asks to "add" a zero, no mention of append or prepend! Nice general solution though, and a new trick learned ($&0)
I feel I've overcomplicated my solution
regexprep(x, '(?(?=0[^0]|0$)0|)', '00')
-
5 Comments
I didn't know about $0! Nifty.
Neither did I! Matlab has great help.
The solution is not correct for the generalized case. 0$0 does a pre-pend of 0 not an append. The correct general solutions is either $00, or better to avoid operator ($0) confusion with the test set using 0s is operator ($%) $&0.
The solution is not correct for the generalized case. 0$0 does a pre-pend of 0 not an append. The correct general solutions is either $00, or better to avoid operator ($0) confusion with the test set using 0s is operator ($&) $&0. (Typo in prior comment)
The problem asks to "add" a zero, no mention of append or prepend! Nice general solution though, and a new trick learned ($&0)
Problem Recent Solvers199
Suggested Problems
-
Sum all integers from 1 to 2^n
11078 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
317 Solvers
-
Matrix with different incremental runs
312 Solvers
-
720 Solvers
-
2511 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!