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 Solvers2311
Suggested Problems
-
3495 Solvers
-
Find the peak 3n+1 sequence value
1537 Solvers
-
Determine if a Given Number is a Triangle Number
341 Solvers
-
Back to basics 12 - Input Arguments
546 Solvers
-
Output any real number that is neither positive nor negative
339 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!