-
Code is_even=lambda x: ~ x & 1
Test Cases import codewars_test as test import solution .describe('Test') def test_group(): .it('Even case') def is_even(): for i in range(-30, 30, 2): test.assert_equals(solution.is_even(i), True) .it('Odd case') def is_even(): for i in range(-29, 30, 2): test.assert_equals(solution.is_even(i), False)
Output:
-
Code is_even=lambda x: x & 1 ^ 1- is_even=lambda x: ~ x & 1
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}