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!
@Sam Nazari
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
Great!
I did in fact start here.
Good problem for beginners.
Nice!!!
Yeah
cool
alright
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
test
Very interesting!
good for newcomers
interesting
interesting!
good questionsss
1st try :)
like
ez
GG
nice
nice
good job
good job
nice
good
ok
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...
good
grade
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.
end
The beginning of the dream!
this is nice..
Smooth
What is the meaning of these axises
nice...
No one can solve this.
Hardest problem ever.
nice problem
a new starting
Nice problem
Nice
Nice problem for beginners
nice
Great for test, like Hello world.
Nice
good
nice
well done)
good
good
good
good
good
good
good
Good
Ans:-y=x.^2;
">
test
Search for multiplication techniques on MATLAB if you can't get the answer.
multiply
nice
easy
so easy
Nice
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?
Easy one
Good basic question
Very Simple !!!
good
Well crafted problem!
I like
firstly, good
rtest">
test
novice lalala...
nice
good
testttt
testttt
testttt
nice
easy
Start
Bugfest lmao can this program even read basic matlab? fix your shit
awesome <3
good!
nice one
nice!!
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
Nice starter
very easy
Go ahead
why the leading solution size is 0
very easy
easy
nice
nice
nice
nice
hi
easy
nice
:)
good job
This was my first!
good job
easy!!
good job yar
This user appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
bitshift(-3,1)
ans =
-6
good job yar
Nice
good job yar
Addition is used instead of multiplication as it will take a shorter amount of time to compute
good job yar
Haha, well done!
It might help to put in the variable x.
good job yar
Is there a way to make y autoupdate when you change the value of x?
good job yar
This is a basic solution, everyone should be able to solve this.
good job yar
i did it!!!
gz
good job yar
Step 1 complete
good job yar
trying the best
good job yar
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 ?
thanks !
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 ned.gulley@mathworks.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;
end
@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 :-)
Nice! :)
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:
assert(isequal(times2(0),0));
assert(isequal(times2(0.1),0.2));
assert(isequal(times2(0.000001),0.000002));
assert(isequal(times2(0.1000000000001),0.2000000000002));
assert(isequal(times2(1.0000000000000000000000000000001),2));
assert(isequal(times2(-0),0));
... and a few others.
The test suite is weak. Please add:
assert(isequal(times2(Inf), Inf))
assert(isequal(times2(NaN), NaN))
assert(isequal(times2([]), []))
assert(isequal(times2(magic(3)), 2*magic(3)))
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)))
nice
856 Solvers
289 Solvers
388 Solvers
The sum of the numbers in the vector
434 Solvers
480 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!