Skip to content

Instantly share code, notes, and snippets.

@briandailey
Created September 27, 2012 19:58
Show Gist options
  • Select an option

  • Save briandailey/3796133 to your computer and use it in GitHub Desktop.

Select an option

Save briandailey/3796133 to your computer and use it in GitHub Desktop.

Revisions

  1. briandailey revised this gist Sep 27, 2012. 2 changed files with 1 addition and 6 deletions.
    6 changes: 0 additions & 6 deletions leap_year (for cal project)
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    def is_leap_year?(year)
    return true if year % 400 == 0
    return false if year % 100 == 0
    return true if year % 4 == 0
    false
    end
    1 change: 1 addition & 0 deletions leap_year.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    is_leap_year = lambda x: x % 400 == 0 or (x % 100 != 0 and x % 4 == 0)
  2. briandailey revised this gist Sep 27, 2012. 1 changed file with 4 additions and 19 deletions.
    23 changes: 4 additions & 19 deletions leap_year (for cal project)
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,6 @@
    def leap(year)
    def is_leap_year?(year)
    return true if year % 400 == 0
    return false if year % 100 == 0
    return true if year % 4 == 0
    false
    true if year % 4 == 0
    false if year % 100 == 0
    true if year % 400 == 0
    end

    This will return true if the year is a multiple of 400. Otherwise it returns nil.

    --Working version --

    def leap_year?(year)
    if year % 400 == 0
    true
    elsif year % 100 == 0
    false
    elsif year % 4 == 0
    true
    else
    false
    end
  3. @hassanshamim hassanshamim revised this gist Sep 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion leap_year (for cal project)
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ This will return true if the year is a multiple of 400. Otherwise it returns ni

    --Working version --

    def leap_year?(year)
    def leap_year?(year)
    if year % 400 == 0
    true
    elsif year % 100 == 0
  4. @hassanshamim hassanshamim revised this gist Sep 27, 2012. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion leap_year (for cal project)
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,17 @@ def leap(year)
    true if year % 400 == 0
    end

    This will return true if the year is a multiple of 400. Otherwise it returns nil.
    This will return true if the year is a multiple of 400. Otherwise it returns nil.

    --Working version --

    def leap_year?(year)
    if year % 400 == 0
    true
    elsif year % 100 == 0
    false
    elsif year % 4 == 0
    true
    else
    false
    end
  5. @hassanshamim hassanshamim created this gist Sep 27, 2012.
    8 changes: 8 additions & 0 deletions leap_year (for cal project)
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    def leap(year)
    false
    true if year % 4 == 0
    false if year % 100 == 0
    true if year % 400 == 0
    end

    This will return true if the year is a multiple of 400. Otherwise it returns nil.