Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions Lib/antigravity.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@

"""
Antigravity module - A humorous reference to xkcd comic #353.

This module contains a geohash function inspired by xkcd comic #426,
which provides a humorous take on geolocation hashing.

Upon import, this module automatically opens xkcd comic #353 in your web browser.
"""

import webbrowser
import hashlib

# Open the xkcd comic that inspired this module
webbrowser.open("https://xkcd.com/353/")

def geohash(latitude, longitude, datedow):
'''Compute geohash() using the Munroe algorithm.

>>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
37.857713 -122.544543

'''
"""Compute geohash() using the Munroe algorithm.

This function implements a humorous geolocation hashing algorithm
inspired by xkcd comic #426. It takes geographic coordinates and a date,
then generates a "geohash" by combining the coordinates with values
derived from an MD5 hash of the date.

Args:
latitude (float): The latitude coordinate.
longitude (float): The longitude coordinate.
datedow (bytes): A date string in bytes format to use for hashing.

Returns:
None: This function prints the result instead of returning it.

Example:
>>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
37.857713 -122.544543

Note:
This is a humorous implementation and should not be used for
actual geolocation purposes. For real geohashing, consider using
a proper geohashing library.

References:
- xkcd comic #426: https://xkcd.com/426/
- xkcd comic #353: https://xkcd.com/353/
"""
# https://xkcd.com/426/
h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
Expand Down
17 changes: 15 additions & 2 deletions Lib/this.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
The Zen of Python, by Tim Peters

This module contains the famous "Zen of Python" poem by Tim Peters,
encoded using ROT13 (rotate by 13 places) substitution cipher.

The module automatically decodes and prints the Zen of Python when imported.
"""

# The Zen of Python encoded with ROT13
s = """Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Expand All @@ -20,9 +30,12 @@
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

# ROT13 translation dictionary
# Maps each letter to the letter 13 positions later in the alphabet
d = {}
for c in (65, 97):
for i in range(26):
for c in (65, 97): # ASCII values for 'A' and 'a'
for i in range(26): # 26 letters in the alphabet
d[chr(i+c)] = chr((i+13) % 26 + c)

# Decode and print the Zen of Python
print("".join([d.get(c, c) for c in s]))
Loading