Given a string such as
s = '011110010000000100010111'
find the length of the longest string of consecutive 1's. In this example, the answer would be 4.
Input x = '110100111'
Output y is 3
Nice and useful !
Nice one, didn't think it was possible to do in one line initially...
What does this mean?
a = [1, diff(x), 1]
Solved on iPhone
Any suggestions on how to improve more ?
How can i improve the code?
With this code, every test passes except 4th one. Why is it so?
any way of improving this algorithm?
when y is empty vector, max(y) is not returning zero which is making my code complicated
It runs well in my Matlab program.
How much time it takes in your MATLAB? There is a limit of 50 seconds for Cody
probably the most inefficient code ever written :)
I'm loving it
I know it's not very efficient, but I sort of liked an idea behind this loop. Hence shared.
Great solution that's easy to understand adn translatable to future use.
extremely unfamiliar with "regexp" function results in a extremely stupid code...
hmmmmm.... ;-) nice
dynamic expression! this is super cool, i didnt know matlab had this and that you could write a matlab code that's so hard to read. Why the 49?
Honestly, right now I find it hard to read as well. 49 is the decimal representation of the ASCII character '1' (type +'1' in the Matlab Command Window).
finally a proper use of regexp in Cody
can you explain your code?
Clean the List of Names
Project Euler: Problem 6, Natural numbers, squares and sums.
Equal to their cube
What number has this problem?
Find nth maximum
Knight's Tour Checker
Renaming a field in a structure array
Remove the small words from a list of words.
Implement a ROT13 cipher
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office