At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more than you think.
With MATLAB, times tables should be easy! Write a function that outputs times tables up to the size requested.
Example:
Input n = 5 Output m is [ 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 ]
Cześć
it would seem that the recently added test#2 is incorrectly defined
Agree with Mr.Alfonso ; Test#2 is incorrectly defined
Agree with Mr.Alfonso ; Test#2 is incorrectly defined
Agree with Mr.Alfonso ; Test#2 is incorrectly defined
Agree with Mr.Alfonso ; Test#2 is incorrectly defined
Apparently the Cody Team can't make a times table. :-p
Agree with the above
For those who wish to solve anyway: Make a correct solution that works with tests 1 and 3, and then hardcode an if with n==3 at the end to make solution 2 work
Sorry for the typo, I just fixed the test#2.
Good question!
How can people solve problem like this with a size 10 ?
Easy one
Easy one!
Please help me out,cant find out the error
I think the error is pretty clear. line3: column=1:1:n; line4:row=1:1:n.
besides, 1:n just fine, the "1" in the middle is quite not necessary.
what if i use 1:n and 1:1:n?both are same right? The step size is 1 for both the case. Tried what you said but Test suit fails again
two equal sign in line 3&4 are missed: this is fatal error, fix that, in my computer seems work fine. and 1:n is another problem, it can pass even you don't change it. nontheless, 1 in the middle is redundant. it CAN be removed, not like you have to.
How could you solve this by size 10?
hahahaha,hello~~
very easy
nice
On my matlab this code works for all the test, but here it fails, why?
m = reshape(1:n^2,[n,n])';
Moreover How can I see better solutions of the problem that I solved, so I can improve my Matlab skills?
Thank you very much for your attention
Sorry, I missed a ;-)
(^^)v
Yeah,I did it.
Test solution 2 is incorrect, should be:
y_correct = [1 2 3; 2 4 6; 3 6 9]
current solution isn't even square...
The test suite is broken for this problem.
The second test should say y_correct = [1 2 3; 2 4 6;3 6 9];
can someone please tell me what I've done wrong here pls. Thanks
You've done nothing wrong; the solution to Test Suite #2 is incorrect.
No need to apply loop here, m=[1:n]'*[1:n] works fine.
function m = timestables(n)
m=(1:n)'*(1:n);
end
test # 2 is wrong, as it should be a 3x3 matrix,
y_correct for x=3 is:
[1 2 3; 2 4 6; 3 6 9]
Test nr. 2 seems not right: the soluton for x= 3 should be:
y_correct = [1 2 3; 2 4 6; 3 6 9]
lol
I tried on my matlab, it works.
this solution is correct... the answer for test #2 is incorrect.
Nice question. Good reminder how vector multiplication works.
Good
Pretty Cool
Duh! Thanks for reminding me how matrix multiplication works
good to learn with matrix scalar multiplication
it's correct for any value !!!!!
What, this is so weird!!!! Nice job
Missing semicolons...
l just wonder is it a real boring thing (times table),that we need to program it,for exam.12*12=144,almost everybody who atteded high school can answer,2^10=1024;25*25=625,13*13=169;14*14=196;15*15=225;it is such an easy thing that we needn't to make a table,we can calculate it out once we see such an multiplication
like your solution its very concise but there is one problem for me you have used '* for multiplication, can you please tell why?
function m = timestables(n)
for i=1:n
for j=1:n
m(i,j)=i*j;
end
end
%apparently this doesn't work even though MatLab says it works for any size
Brilliant!
After the solution I come up with ends up in the middle of the graph I feel disappointed. But then I learn there's a command that does something I didn't know about and I feel better about myself because I learned a new command!
amazing!
very elegant :)
nice :)
1392 Solvers
Determine if a Given Number is a Triangle Number
276 Solvers
Back to basics 20 - singleton dimensions
216 Solvers
Getting the row and column location from a matrix
182 Solvers
206 Solvers