We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Debugging
- Prime Dates
- Discussions
Prime Dates
Prime Dates
Sort by
recency
|
55 Discussions
|
Please Login in order to post a comment
The output is equals to the expected result but HackerRank states that it is wrong. :(
Compiler Message Wrong Answer Input (stdin) 02-08-2025 04-09-2025 Your Output (stdout) 5 Expected Output 5
Here is my Java code:
How are we supposed to know the updateLeapYear function is wrong?
it works when you move from python 3 to pypy3
import re month = []
def updateLeapYear(year): if year % 400 == 0: month[2] = 29 elif year % 100 == 0: month[2] = 28 elif year % 4 == 0: month[2] = 29 else: month[2] = 28
def storeMonth(): month[1] = 31 month[2] = 28 month[3] = 31 month[4] = 30 month[5] = 31 month[6] = 30 month[7] = 31 month[8] = 31 month[9] = 30 month[10] = 31 month[11] = 30 month[12] = 31
def findPrimeDates(d1, m1, y1, d2, m2, y2): storeMonth() result = 0
for i in range(1, 15): month.append(31)
line = input() date = re.split('-| ', line) d1 = int(date[0]) m1 = int(date[1]) y1 = int(date[2]) d2 = int(date[3]) m2 = int(date[4]) y2 = int(date[5])
result = findPrimeDates(d1, m1, y1, d2, m2, y2) print(result)
This is my Java 8 solution, feel free to ask me any questions.
I don't recommend people using the implementation of the questions but, follow these steps to solve:
1. correct "or other line of code".
Checking if the current date is lucky, increase result by 1.
Updating the current date to the next date.
Found all errors but couldn't pass in Python 3, when changed to Pypy 3 it passed.