# towAsOne challenge

Hi,

I am working on below challenge
http://codingbat.com/prob/p113261

I tried my code as below
``````public boolean twoAsOne(int a, int b, int c) {
if((a+b)==c)
{
return true;
}

else if((b+c)==a)
{
return true;
}

else if((a+c)==b)
{
return true;
}
else
return false;
}
``````

I am getting below result
Expected      Run
twoAsOne(1, 2, 3) → true      true      OK
twoAsOne(3, 1, 2) → true      true      OK
twoAsOne(3, 2, 2) → false      false      OK
twoAsOne(2, 3, 1) → true      true      OK
twoAsOne(5, 3, -2) → true      true      OK
twoAsOne(5, 3, -3) → false      false      OK
twoAsOne(2, 5, 3) → true      true      OK
twoAsOne(9, 5, 5) → false      false      OK
twoAsOne(9, 4, 5) → true      true      OK
twoAsOne(5, 4, 9) → true      true      OK
twoAsOne(3, 3, 0) → true      true      OK
twoAsOne(3, 3, 2) → false      false      OK
other tests
OK

how to  improve my approach and design of this challenge. How do i make a

graphical venn or some other relevant diagram to design it before writing single

line of code to decide best strategy?
LVL 7
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
It's a bit wordy, but fine. You could have just done

``````return a+b == c || a+c == b || c+b == a;
``````
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
:)
0
Commented:
// overkill in this case, but
List<Integer> list = new ArrayList<Integer>();
return list.contains(a+b+c);
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.