Problem 74. Balanced number
Solution Stats
Problem Comments
-
1 Comment
there is a problem with the test.
it does not accept the following code:
s1=[]
s2=[]
l=length(s)
if mod(l,2)~= 0
for i = 1:ceil(length(s)/2)-1
s1 = [s1,str2double(s(i))]
end
for i = ceil(length(s)/2)+1:l
s2=[s2,str2double(s(i))]
end
else
for i = 1:ceil(length(s)/2)
s1 = [s1,str2double(s(i))]
end
for i = ceil(length(s)/2)+1:l
s2=[s2,str2double(s(i))]
end
end
if sum(s1)==sum(s2)
tf = 1
else
tf = 0
end
Solution Comments
-
2 Comments
-
1 Comment
could be better
-
1 Comment
I just wanted to see if this would be accepted. I can't find a way to remove it...
-
1 Comment
can you please explain what is going on inside dot function and why the str input?
-
1 Comment
in this code,it seems that end/2 is not alwayss an integer,so we need modify it,l wonder your code works or the workspace report a warning
-
1 Comment
That is cheating :P
-
1 Comment
nicely done..
-
1 Comment
Excellent way to use the dot product. Wish I would have thought of it!
Problem Recent Solvers2327
Suggested Problems
-
2238 Solvers
-
Find common elements in matrix rows
1858 Solvers
-
280 Solvers
-
Project Euler: Problem 4, Palindromic numbers
645 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
674 Solvers
More from this Author95
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!