Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Beginners programming challenge #29

  1. #1
    Join Date
    Nov 2012
    Beans
    39
    Distro
    Ubuntu 13.04 Raring Ringtail

    Beginners programming challenge #29

    It has been 6 months since #28 so I decided to put my rarely-used ubuntu forums account to good use and create #29!
    We welcome you to the 29th Beginners programming challenge!

    The task is simple, create a converter between the Gregorian Calendar and the disused French Revolutionary Calendar

    It only has to convert from Gregorian to French Revolutionary
    It should take input in the following formats:
    1) Through a command line interface through this format (<program name> -i)
    2) Through a file printing the output through the screen in this format (<program name> <file name>)
    3) Through a file exporting the output to another format through this format (<program name> <file name> -o <output file name>)

    A fixed arithmetic rule for determining leap years was proposed in the name of the Committee of Public Education by Gilbert Romme on 19 Floréal An III (8 May 1795). The proposed rule was to determine leap years by applying the rules of the Gregorian calendar to the years of the French Republic (years IV, VIII, XII, etc. were to be leap years) except that year 4000 (the last year of ten 400-year periods) should be a common year instead of a leap year.
    When entering the date into the program it should accept the following format Decade (I/II/III), (day) de (month) de l'Annee (year) de la Revolution or La Fete (<COMPLEMENTARY DAY: look here>) de l'Annee (year) de la Revolution
    Cookie Points
    1) Export the year in roman numerals
    2) Convert both ways

    Disqualified Entries

    Any overly obfuscated code will be immediately disqualified without account for programmers skill. Please remember that these challenges are for beginners and therefore the code should be easily readable and well commented.

    Any non-beginner entries will not be judged. Please use common sense when posting code examples. Please do not give beginners a copy paste solution before they have had a chance to try this for themselves.

    Assistance
    If you need help feel free to ask around on irc.freenode.net channel #ubuntu-beginners-dev
    Last edited by BluNova; May 17th, 2013 at 05:23 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Beginners programming challenge #29

    It's BACK!
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad] [Sub-forum]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  3. #3
    Join Date
    Jun 2011
    Location
    Paris
    Beans
    55

    Re: Beginners programming challenge #29

    This actually seems like a non-beginners challenge since the French Revolutionary calendar officially begins on the true autumnal equinox. Can the fixed rule described in the wikipedia article be used?

    A fixed arithmetic rule for determining leap years was proposed in the name of the Committee of Public Education by Gilbert Romme on 19 Floréal An III (8 May 1795). The proposed rule was to determine leap years by applying the rules of the Gregorian calendar to the years of the French Republic (years IV, VIII, XII, etc. were to be leap years) except that year 4000 (the last year of ten 400-year periods) should be a common year instead of a leap year.

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    1,877
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Beginners programming challenge #29

    If you look at the French Wikipedia, there are divergent opinions about the extension of the calendar outside its 14 years of actual use... Looks like there should be an option parameter

  5. #5
    Join Date
    Jun 2011
    Location
    Paris
    Beans
    55

    Re: Beginners programming challenge #29

    Also, how do you enter the sans-culottides with the format Decade (I/II/III), (jour) de (mois) de l'Annee (année) de la Revolution.?

  6. #6
    Join Date
    Nov 2012
    Beans
    39
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Beginners programming challenge #29

    I have changed it to this rule for leap years:

    A fixed arithmetic rule for determining leap years was proposed in the name of the Committee of Public Education by Gilbert Romme on 19 Floréal An III (8 May 1795). The proposed rule was to determine leap years by applying the rules of the Gregorian calendar to the years of the French Republic (years IV, VIII, XII, etc. were to be leap years) except that year 4000 (the last year of ten 400-year periods) should be a common year instead of a leap year.
    Last edited by BluNova; May 15th, 2013 at 07:12 PM.
    Do you know why snow is white? Because it forgot what colour it was.
    You really hate it when people die, yet you're in the army. Why is that?
    I'm in the army so they won't die.
    That contradiction might kill you someday.


  7. #7
    Join Date
    Apr 2013
    Location
    43.49°N 7.46°E
    Beans
    117
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Beginners programming challenge #29

    Quote Originally Posted by BluNova View Post
    I have changed it to this rule for leap years:

    A fixed arithmetic rule for determining leap years was proposed in the name of the Committee of Public Education by Gilbert Romme on 19 Floréal An III (8 May 1795). The proposed rule was to determine leap years by applying the rules of the Gregorian calendar to the years of the French Republic (years IV, VIII, XII, etc. were to be leap years) except that year 4000 (the last year of ten 400-year periods) should be a common year instead of a leap year.
    If I have rightly understood this rule, the leap_year function could be written as follows:
    Code:
    def leap_year(yr)
        return (((yr.remainder(4)==0) and (yr.remainder(100)!=0)) or ((yr.remainder(400)==0) and ((yr / 400)!=10)))
    end

  8. #8
    Join Date
    Nov 2012
    Beans
    39
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Beginners programming challenge #29

    I don't think so, as 100 would not be a leap year on your function
    You could easily do it by checking that its divisible by 4 and then checking that the year is not 4000
    Last edited by BluNova; May 17th, 2013 at 05:22 PM.
    Do you know why snow is white? Because it forgot what colour it was.
    You really hate it when people die, yet you're in the army. Why is that?
    I'm in the army so they won't die.
    That contradiction might kill you someday.


  9. #9

    Re: Beginners programming challenge #29

    Years divisible by 100 but not by 400 are not leap years in the Gregorian calendar; this confusion is the source of one somewhat notorious bug in Microsoft Excel. But I read it as meaning that every 4000th year is a common year. So I'd tweak alan9800's algorithm to be
    Code:
    def leap_year(y)
        (4 divides y) and (100 does not divide y) or (400 divides y) and (4000 does not divide y)
    You basically have to write out the whole truth table to verify it, though. Maybe there's a clearer way.

  10. #10
    Join Date
    Apr 2013
    Location
    43.49°N 7.46°E
    Beans
    117
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Beginners programming challenge #29

    Quote Originally Posted by BluNova View Post
    I don't think so, as 100 would not be a leap year on your function
    You could easily do it by checking that its divisible by 4 and then checking that the year is not 4000
    as trent.josephsen has explained in the above post, according to the rules of the Gregorian calendar not all the years which are divisible by 100 are leap years, but only those which are divisible by 400.
    This said, I'd have a question: should I consider as a normal year only the year 4000 or even its multiples, e.g. the years 8000, 12000 and so on? I ask this because, at least by reading what's written on wikipedia, it's not clear if the rule of Romme has to be applied only to the year 4000 or even to its multiples.
    Last edited by alan9800; May 18th, 2013 at 10:21 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •