-
Code def is_even(x): return 1 ^ x % 2
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 - def is_even(x):
return abs((x % 2)-1)- return 1 ^ x % 2
- 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 }}