Skip to content

hw-1.2#169

Open
mikhail771 wants to merge 3 commits into
mate-academy:masterfrom
mikhail771:hw-1.2
Open

hw-1.2#169
mikhail771 wants to merge 3 commits into
mate-academy:masterfrom
mikhail771:hw-1.2

Conversation

@mikhail771

Copy link
Copy Markdown

No description provided.

|| ((a && d) && (!c && !b))
|| ((b && c) && (!a && !d))
|| ((b && d) && (!c && !a))
|| ((c && d) && (!a && !b))) ? true : false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternary operator is redundant here, try to remove it and check result

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
public boolean booleanExpression(boolean a, boolean b, boolean c, boolean d) {
return false;
return (((a && b) && (!c && !d))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to make this shorter with ^ (XOR) operator

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +17 to +22
return (((a ^ b) && (c ^ d))
|| ((a ^ c) && (b ^ d))
|| ((a ^ d) && (c ^ b))
|| ((b ^ c) && (a ^ d))
|| ((b ^ d) && (c ^ a))
|| ((c ^ d) && (a ^ b)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've got some redundant check here:

Suggested change
return (((a ^ b) && (c ^ d))
|| ((a ^ c) && (b ^ d))
|| ((a ^ d) && (c ^ b))
|| ((b ^ c) && (a ^ d))
|| ((b ^ d) && (c ^ a))
|| ((c ^ d) && (a ^ b)));
return (a ^ b) && (c ^ d) || (a ^ c) && (b ^ d);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants