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 Solvers2539
Suggested Problems
-
942 Solvers
-
Create a cell array out of a struct
1239 Solvers
-
Create a vector whose elements depend on the previous element
545 Solvers
-
Rounding off numbers to n decimals
3088 Solvers
-
5370 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!