Hep, Cody Team, could you remove my solution please?
nice one but consumes size dunno how to reduce it
a bit tricky but nice
I like this problem, because I learnt about the Collatz sequence story. Very interessting.
What's wrong in this code?
the assignment c = [c,a]; must be out of the else clause, but still inside of the while block.
how can i simplify??
Thats right> construct c thru concat operator [..] instead of indexing it.
Index "i" doesn't care because it don't care the size of the sequence.
why this will go wrong?
How to reduce it's size?
This solution does not work for n = 3. Test Suite should include n = 3.
Hi all. I have no idea why there are many outputs of ans (the last of which is the right one), can anyone help to explain?
How can I reduce the size? Too many loops, yet I have to define the single commands :/
I don't think you should hard code the lists you should be constructing. Regex is fine, but you're limiting yourself by making such a narrow solution.
I personally don't like the regex solution because I'm trying to find interesting things about the language and I don't want to run through and find the shortest non regexp.
Now give me 500$
Would some kind soul enlighten me please?
it works fine on matlab when i assign 'c' a value
disp(c) contains the correct answer,unlike c. c is always equal to 1(last value of the iteration process)
This is a poor solution
fantastic..I never thought of that...
different approach but it used different functions frquenctly
this function collatz(N) produces specific values for N=10000, try this :
% more interesting figure, derivate N
dN looks like a sample of voice signal.
I really think the test set should go to much higher arguments. This sort of thing should not be allowed!
This is way more efficient than the recursive algorithms.
I am surprised that it is more efficient to solve this with a recursive function than a while loop.
This solution has size 43:
while n(end) > 1
n = [n mod(n(end),2)*(n(end)*2.5+1) + n(end)/2];
Is the loop overhead greater than the recursion overhead? Or is the weak point having to go to n(end) at each iteration?
Strange I can not delete my first comment. I wanted to format it a bit nicer :)
Good solution, David!:)
Back to basics 19 - character types
Compare two input matrices
Produce a sine wave
Find common elements in matrix rows
Return a list sorted by number of occurrences
Find relatively common elements in matrix rows
Find the alphabetic word product
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