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 Solvers2514
Suggested Problems
-
6883 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
339 Solvers
-
Get the length of a given vector
7615 Solvers
-
Try 1.5.4: Celsius to Fahrenheit
743 Solvers
-
Is this triangle right-angled?
4624 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!