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 Solvers2535
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
5046 Solvers
-
1277 Solvers
-
Increment a number, given its digits
614 Solvers
-
Back to basics 22 - Rotate a matrix
866 Solvers
-
Find a subset that divides the vector into equal halves
372 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!