Move History

Rooted by: Is it odd?
Fork Selected
  • Fundamentals
    Numbers
    Data Types
    Integers
    Description

    I'm just playing around with kumite !!!!!

    Code
    def is_odd(input):
        return input & 1
    
    Test Cases
    import codewars_test as test
    from solution import is_odd
    
    @test.describe("Fixed Tests")
    def fixed_tests():
        @test.it('Basic Test Cases')
        def basic_test_cases():
            test.assert_equals(is_odd(1), True)
            test.assert_equals(is_odd(2), False)
            test.assert_equals(is_odd(13), True)
            test.assert_equals(is_odd(18284), False)
            test.assert_equals(is_odd(-1), True)
            
    @test.describe("Random Tests")
    def random_tests():
        
        from random import randint 
        
        for _ in range(100):
            n = randint(-(10**randint(1, 5)), 10 ** randint(1, 5))
            @test.it(f"testing for is_odd({n})")
            def test_case():
                test.assert_equals(is_odd(n), n & 1)
      
  • Code
    • public static class Kata
    • {
    • public static bool IsOdd(int input)
    • {
    • return (input & 1) == 1;
    • }
    • }
    • def is_odd(input):
    • return input & 1
    Preloaded Code
    • using System;
    Test Cases
    • namespace Solution {
    • using NUnit.Framework;
    • using System;
    • import codewars_test as test
    • from solution import is_odd
    • // TODO: Replace examples and use TDD by writing your own tests
    • [TestFixture]
    • public class SolutionTest
    • {
    • [Test]
    • public void MyTest()
    • {
    • Assert.AreEqual(true, Kata.IsOdd(1));
    • Assert.AreEqual(false, Kata.IsOdd(2));
    • Assert.AreEqual(true, Kata.IsOdd(13));
    • Assert.AreEqual(false, Kata.IsOdd(18284));
    • Assert.AreEqual(true, Kata.IsOdd(-1));
    • }
    • }
    • }
    • @test.describe("Fixed Tests")
    • def fixed_tests():
    • @test.it('Basic Test Cases')
    • def basic_test_cases():
    • test.assert_equals(is_odd(1), True)
    • test.assert_equals(is_odd(2), False)
    • test.assert_equals(is_odd(13), True)
    • test.assert_equals(is_odd(18284), False)
    • test.assert_equals(is_odd(-1), True)
    • @test.describe("Random Tests")
    • def random_tests():
    • from random import randint
    • for _ in range(100):
    • n = randint(-(10**randint(1, 5)), 10 ** randint(1, 5))
    • @test.it(f"testing for is_odd({n})")
    • def test_case():
    • test.assert_equals(is_odd(n), n & 1)