def days(month,day): return (d.date(d.datetime.now().year, month, day) - d.date(d.datetime.now().year, 1, 1)).days + 1
- def days(month,day):
return sum([31,28,31,30,31,30,31,31,30,31,30,31][:month-1])+day- return (d.date(d.datetime.now().year, month, day) - d.date(d.datetime.now().year, 1, 1)).days + 1
#TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example. #include <criterion/criterion.h> #replace with the actual method being tested #def days(month, day): import codewars_test as test from solution import days import datetime as d @test.describe("Fixed Tests") def basic_tests(): @test.it('Basic Test Cases') def basic_test_cases(): now = d.datetime.now() check = now.year % 4 == 0 test.assert_equals(days(3, 1), (60,61)[check]) test.assert_equals(days(12, 31), (365,366)[check]) test.assert_equals(days(1, 1), 1) # didn't get extra day cuz there was no february yet test.assert_equals(days(9, 17), (260,261)[check])
- #TODO: Replace examples and use TDD by writing your own tests. The code provided here is just a how-to example.
- #include <criterion/criterion.h>
- #replace with the actual method being tested
- #def days(month, day):
- import codewars_test as test
- from solution import days
- import datetime as d
- @test.describe("Fixed Tests")
- def basic_tests():
- @test.it('Basic Test Cases')
- def basic_test_cases():
test.assert_equals(days(3, 1), 60)test.assert_equals(days(12, 31), 365)test.assert_equals(days(1, 1), 1)test.assert_equals(days(9, 17), 260)- now = d.datetime.now()
- check = now.year % 4 == 0
- test.assert_equals(days(3, 1), (60,61)[check])
- test.assert_equals(days(12, 31), (365,366)[check])
- test.assert_equals(days(1, 1), 1) # didn't get extra day cuz there was no february yet
- test.assert_equals(days(9, 17), (260,261)[check])