I don't understand why for test suite 4 :
a=[0 1 1 1 0 2 2 0 1 1 1 0];
y_correct = [1 1];
I expect y_correct = [1 1 1]
The idea seems to be to return the element that occurs in the longest run, or all such elements in case of a tie. In case 4 there are two longest runs, both with element 1.
Thanks Tim for the explanation . So as the vector [1 1 1] appears twice in test 4 with the unique value 1 , the result must be twice the unqiue value -> [ 1 1]. ok ok thanks again
I have this array as I counted the times it repeats. However, can someone give me a command to pull out the max values with the number to the left? Any advise? The first value in column on the right top doesn't matter as it should always be 1. I try the max command it only shows the max value of 3...:
Great problem. Thank you.
Is there a way to test output without submitting?
I really liked this one
This was fun.
The problem should specify that if the same number repeats the longest run of consecutive numbers more than once, it must be repeated in the output.
hy,is there a problem with the above mentioned question
a_len=length(a); % Calculate the length of a
c=ones(a_len,1); % Initialize the consecutive times of the corresponding position
if a(num_a)==a(next_a) % If this number is equal to the following number, then n_val+1, and the next cycle
c(num_a)=n_val; % If this number is not equal to the following number, assign the current n_val to the corresponding number of consecutive times, and jump out of the inner for loop
a_conti=max(c); %Find the largest number of consecutive times in the c array
max_location=find(c==a_conti); % Corresponds to the position of the maximum consecutive times
val=a(max_location); % Find out the corresponding position in a
Test 1 is error！
y_correct =[1 2];
This is the best solution I have seen. ????
Why is test 4 like that tho
Tricky one, but enjoyed solving it.
Is this a correct solution?
Why/How does the leading solution (with size 8) even work? -_-
I think Cody should test this "solution".
Tricky one.. but enjoyed it.
if a(num_a)==a(next_a) %如果这个数字和后面的数字相等，则n_val+1，并进行下一次循环
Test 1 and 4 are wrong
Could you please comment on this method? It is very unlikely for me as a beginner in Matlab to have such a concise code. You are more than welcome to elaborate here or via my e-mail address firstname.lastname@example.org
Really succinct code. One of the best I saw so far in the contest. @Piero Cimule
Could you check this for me, please?
How else could you solve in any other traditional programming language?
It was not so easy...
i cannot understand
Determine if input is odd
Find state names that end with the letter A
Back to basics 15 - Benchmark
Reference Index Number
Return area of square
Kurchan 5x5 - Optimal Score
Still more miles to go before I sleep
I've got the power! (Inspired by Project Euler problem 29)
With apologies to William Blake
Don't be mean. Be nice!
Find the treasures in MATLAB Central and discover how the community can help you!
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