631 - Microzoft Calendar

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
somov
New poster
Posts: 2
Joined: Mon Jul 08, 2002 9:35 pm
Contact:

631 - Microzoft Calendar

Post by somov »

I can't solve this problem. As I see, it's not so hard, but all my attempts to get AC failed :( . Could anyone tell me, what's wrong with the problem?
Jalal
Learning poster
Posts: 65
Joined: Sun Jun 02, 2002 8:41 pm
Location: BANGLADESH
Contact:

Post by Jalal »

how we will tell it
if u not give the system of ur solve or code? :wink:
Caesum
Experienced poster
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK
Contact:

Post by Caesum »

Can anyone give the output for:
1600-01-01
5000-12-31
Ivan Golubev
Experienced poster
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

Post by Ivan Golubev »

Caesum wrote:Can anyone give the output for:
1600-01-01
5000-12-31
Bates-Sun-Second-4-399bd
Bates-Sun-Second-5-3003
sluga
New poster
Posts: 20
Joined: Sun Jan 22, 2006 10:48 pm
Location: Croatia

Post by sluga »

Which years before doors are considered leap? Those like 4bd or those like 5bd? I am asking because for example, 5bd is 8 years before 4, which is a leap year.
A sta da radim
sluga
New poster
Posts: 20
Joined: Sun Jan 22, 2006 10:48 pm
Location: Croatia

631 Microzoft calendar - need some inputs/outputs!

Post by sluga »

I am trying to solve this problem, but I can't get ACC.
I hate this kind of problems, but would really like to solve this one.
(personaly, this is one of the most ugly problems I have ever seen)
Please, post some inputs and clarifications ( if you can think of any ) because I am doing something wrong...
Thank You!
A sta da radim
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

Getting many WA...
Could someone verify my i/o test ?
INPUT

Code: Select all

1998-06-19
1997-06-26
1997-06-25
1997-06-24
1600-01-01
1754-12-31
2476-12-04
4444-04-12
END
OUTPUT

Code: Select all

Bates-Money-Sixth-6-1bd
Gill-Sun-First-2-1bd
Gill-Sun-First-1-1bd
Feast 5-2bd
Bates-Sun-Fourth-3-399bd
Bates-Sun-Second-4-244bd
Gill-Money-Fourth-2-479
Bates-Mountains-First-5-2446
Thanks in advance.
----
Rio
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Sorry, my solution is in Pascal and I currently have no compiler for it.

One, quite simple, way to test your program is to write two functions old_next(year,month,day) and new_next(year,period,month,week,day) that can be implemented as a series of nested if-else statements. You could internally represent the 'feast' days as period 3, or something like that.

Now have a program that writes old dates to a file called 'test.in' and new dates to a file called 'test.out'. Start the program off at old date (1600,1,1) and new date (-399,2,1,2,4), writing to the files and calling old_next() and new_next(), until you reach new date (5000,1,1).

Run your solution with 'test.in' as input and compare its output with 'test.out'.

EDIT: stubbscroll is right, 1600-01-01 is Bates-Sun-Second-4-399bd. I changed my posting accordingly.
Last edited by little joey on Wed May 30, 2007 2:29 pm, edited 2 times in total.
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.
stubbscroll
Experienced poster
Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway
Contact:

Post by stubbscroll »

Rio, I get a different output for line 5 with my AC program. Here's my output for your tests:

Code: Select all

Bates-Money-Sixth-6-1bd
Gill-Sun-First-2-1bd
Gill-Sun-First-1-1bd
Feast 5-2bd
Bates-Sun-Second-4-399bd
Bates-Sun-Second-4-244bd
Gill-Money-Fourth-2-479
Bates-Mountains-First-5-2446
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

Thanks, little joey and stubbscroll.

I found the bug and got AC.
I was re-using functions witch I made for "602 What Day Is It?", and forgot to modify it.
----
Rio
jurajz
Learning poster
Posts: 69
Joined: Sat Sep 02, 2006 7:30 pm
Location: Slovakia

Post by jurajz »

sluga wrote:Which years before doors are considered leap? Those like 4bd or those like 5bd? I am asking because for example, 5bd is 8 years before 4, which is a leap year.
I assumed, that leap years before doors are 4bd, 8bd, 12bd, ... and I got AC.
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 631 - Microzoft Calendar

Post by metaphysis »

Test data generator:

Code: Select all

#include <iostream>

using namespace std;

bool isLeapYear(int yyyy)
{
    return ((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0);
}

int main(int argc, char *argv[])
{
    for (int i = 1600; i <= 5000; i += 100)
    {
        for (int j = 1; j <= 12; j++)
        {
            if (j == 2)
            {
                for (int k = 1; k <= 28; k++)
                {
                    cout << i << "-02-";
                    if (k < 10) cout << '0';
                    cout << k << '\n';
                }
                if (isLeapYear(i)) cout << i << "-02-29\n";
            }
            else
            {
                for (int k = 1; k <= 30; k++)
                {
                    cout << i << '-';
                    if (j < 10) cout << '0';
                    cout << j << '-';
                    if (k < 10) cout << '0';
                    cout << k << '\n';
                }
                
                if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12)
                {
                    cout << i << '-';
                    if (j < 10) cout << '0';
                    cout << j << "-31\n";
                }
            }
        }
    }

    cout << "END\n";
    return 0;
}
Post Reply

Return to “Volume 6 (600-699)”