CORRECTION: While I was looking for references for the luck system in Nethack, I learned - after >20 years! - that I was wrong all the time and that a new moon does not affect your luck at all. The Nethack Wiki is pretty clear here:

The baseline level to which it may return is +1 if you most recently started or restored the game during a full moon, −1 if started or restored on Friday the 13th, and 0 if neither or both. A new moon does not affect your luck at all.

(Emphasis mine)


(Original posting starts here)

Nethack gives you a luck penalty when it’s new moon or Friday the 13th. But… when do these two events fasll together? I used the pycalcal package to calculate these occurences, and what came out is…

from pycalcal import *
from math import floor

for y in range(2025, 2200):
    for d in unlucky_fridays_in_range(gregorian_year_range(y)):
        m = d + 0.0
        if floor(new_moon_at_or_after(m)) == d:
            g = gregorian_from_fixed(d)
            print('Friday 13th %s %s AND THE MOON IS NEW!!!1!!' % (GREGORIAN_MONTHS_OF_YEAR_NAMES[g[1]], g[0]))

Output:

Friday 13th April 2029 AND THE MOON IS NEW!!!1!!
Friday 13th May 2067 AND THE MOON IS NEW!!!1!!
Friday 13th December 2069 AND THE MOON IS NEW!!!1!!
Friday 13th September 2080 AND THE MOON IS NEW!!!1!!
Friday 13th August 2083 AND THE MOON IS NEW!!!1!!
Friday 13th January 2108 AND THE MOON IS NEW!!!1!!
Friday 13th June 2132 AND THE MOON IS NEW!!!1!!
Friday 13th May 2135 AND THE MOON IS NEW!!!1!!
Friday 13th September 2148 AND THE MOON IS NEW!!!1!!
Friday 13th July 2170 AND THE MOON IS NEW!!!1!!
Friday 13th April 2181 AND THE MOON IS NEW!!!1!!

It is a pretty rare event, but when it happens, I will stay away from my keyboard as far as possible.