Comment detail

除算・余剰を使わずに閏年 (Nested Flatten)

This comment is reply for 5337 にしお: とても素朴な書き方。剰余の計算を禁止して...(除算・余剰を使わずに閏年). Go to thread root.

ついにゅっとなってやってしまった。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def leap(x, d=400):
    return (
        not d and [d]
        or
        x == 0 and [[1, 0, 1][d >> 6 & 3]]
        or
        x < d and [leap(x, [0, 4, 100][d >> 6 & 3])]
        or
        [leap(x - d, d)]
    )[0]

Index

Feed

Other

Link

Pathtraq

loading...