Why does y = bitshift(x,1); give a larger solution size than the most common answer listed so far?
The first problem. Very easy but enough to start the Cody Game. Great game!
I guess it`s because calling bitshift makes the code size bigger. You call a function.
When there is only x*2 its 1 operation only.
Deceivingly easy start to the game!
Ha ha I got it
I did in fact start here.
Good problem for beginners.
I tried to use bitshift but I forgot it doesn't work with x<0
Easy starter problem. Except I was expecting Cody, to require a '.m' file upload.
very basic,very interesting indeed
good for newcomers
1st try :)
This is the best way to start using Cody
This is the best problem to start using Cody.
Instructions say to press the "Solve This Now!" button, but there is no such button...
I submitted the following, which works in my version of matlab, but it found errors and said it wasn't valid:
function y = times2(x)
% Modify the line below so that the output y is twice the incoming value x
y = bitsll(x,fi(1));
% After you fix the code, press the "Submit" button, and you're on your way.
The beginning of the dream!
this is nice..
What is the meaning of these axises
No one can solve this.
Hardest problem ever.
a new starting
Nice problem for beginners
Great for test, like Hello world.
Search for multiplication techniques on MATLAB if you can't get the answer.
Cody Players, How are you guys liking the new Scratchpad and Run Function features so far? Have you been using it during solution creation? Why or why not?
Good basic question
Very Simple !!!
Well crafted problem!
Bugfest lmao can this program even read basic matlab? fix your shit
Leading solution size is 0???
don't know how the leading solution is calculated;/
Ach! even bigger than mine, you cheater!
this is fun!
This is the best way to star using Cody
one step at atime
why the leading solution size is 0
This was my first!
good job yar
This user appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
Addition is used instead of multiplication as it will take a shorter amount of time to compute
Haha, well done!
It might help to put in the variable x.
Is there a way to make y autoupdate when you change the value of x?
This is a basic solution, everyone should be able to solve this.
i did it!!!
Step 1 complete
trying the best
Is it necessary to use the . after 2?
Couldn't you write y = 2*x; ?
Yeah, i do it
This was a great starter question.
what is the correct answer??
What this solution is wrong?
Is it wrong?
how do you improve this solution?
how leading solution size is 0?
Probably hacked something
So really, the name of the game is to pass only the assertion tests; as opposed to the description of the problem.
Definitely not seeing how to get a solution size 0...
What the heck is freepass?
Is this a solution ?
Nice place to test... ;-)
cute but ridiculous
why it's 'freepass.please',not other words else?
'freepass' is just a (cute but ridiculous) hack (see problem http://www.mathworks.com/matlabcentral/cody/problems/1774-free-passes-for-everyone ). The 'please' part is because we are really polite...
hello Alfonso !
I'd like to know how the solution size for your solution to the 'times two' question is '0'
can you please explain ?
how is this even possible, solution with 0 size?
does freepass; still work?
"Leading Solution is 0".. Just.. How?!
I rescored this solution and it failed
@Aditya: I do not appreciate this solution being rescored, this particular solution had historical value to me, but obviously not to you
The reason I rescored your solution is because a solution cannot have a size of 0. With respect to your comment on the historical value, I think the solution is still there and I haven't changed that. If you still believe its an error from my side, you can email email@example.com and we can discuss it further.
Another solution is that you could use your free pass trick and rescore this solution again. I just don't want the solution to have a size of 0.
Zero-score solutions have some history in Cody (see problem 42396). This solution was the only zero-score freepass solution (all other passing freepass solutions got a score of 100 for good reasons), so having this solution now fail the test removes its score and hence its significance. In any way, this is all fine and just a game, I just think it would be sad to see all of the other solutions in Cody that got zero, negative, maxint or other "impossible" scores being rescored for no good reason (#endofgetoffmylawnrant)
Good Point. I speak to Ned about this and discuss whether we should keep such solutions or not.
Thanks for the input and sorry for the trouble. #peace
@Alfonso: I have reverted back my change :)
that's fantastic, thanks!
Tried the freepass command on my computer, all I get is
Undefined variable "freepass" or class "freepass.please".
Also I have no idea how code size is calculated
this cheapo solutions need to be deleted, no one benefits from this or learns about matlab
Alfonso, please remove this nonsense score which prevents those of us trying to learn from actually discovering how to improve our prgramming
function y = times2(x)
y = x * 2;
@Admin, please remove Alfonsos score. This is meant to be about learning Matlab to solve problems, not hacking cody and allowing egotistical self-promotion.
can anyone tell me why this is incorrect
I see two problems. It needs to be a function (as modeled by the template), and the input command hangs and times out when called by a web service.
It works, but it's ugly :-)
Never realized that MATLAB sees a defined assignment (y = 2*x) different than no assignment (2*x => assignment to ans).
If anything, I would have guessed the second would be (slightly) more effort.
does this variable "ans" overrides MATLAB's default "ans"?
ok, i got there in the end. but it defeats the rules - there is no "y" variable when you change the template to ans = times2(x)...
how do you know what the rules are?!?
comment section gives a great info
Missing test cases:
... and a few others.
The test suite is weak. Please add:
To focus the power of Matlab, add these tests:
assert(isequal(times2(Inf), Inf)) assert(isequal(times2(NaN), NaN))
assert(isequal(times2(), )) assert(isequal(times2(magic(3)), 2*magic(3)))
Create a cell array out of a struct
Getting the indices from a vector
Spot the outlier
multiply by three
Find my daddy long leg (No 's')
Finding Perfect Squares
Determine whether a vector is monotonically increasing
Replace NaNs with the number that appears to its left in the row.
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