-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from rampantvoid/rampantvoid
Fixes #22
- Loading branch information
Showing
1 changed file
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
import datetime | ||
|
||
def github_text_contributions(text, start_date): | ||
# github contirbution grid size | ||
rows, cols = 7, 52 | ||
grid = [[0] * cols for _ in range(rows)] | ||
|
||
char_maps = { | ||
'A': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,1,1,1,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1] | ||
], | ||
'B': [ | ||
[1,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,1,1,1,0] | ||
], | ||
'C': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,0,0,0,0], | ||
[1,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'D': [ | ||
[1,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,1,1,1,0] | ||
], | ||
'E': [ | ||
[1,1,1,1,1], | ||
[1,0,0,0,0], | ||
[1,1,1,1,0], | ||
[1,0,0,0,0], | ||
[1,1,1,1,1] | ||
], | ||
'F': [ | ||
[1,1,1,1,1], | ||
[1,0,0,0,0], | ||
[1,1,1,1,0], | ||
[1,0,0,0,0], | ||
[1,0,0,0,0] | ||
], | ||
'G': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,0], | ||
[1,0,1,1,1], | ||
[1,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'H': [ | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,1,1,1,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1] | ||
], | ||
'I': [ | ||
[1,1,1,1,1], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0], | ||
[1,1,1,1,1] | ||
], | ||
'J': [ | ||
[0,0,0,0,1], | ||
[0,0,0,0,1], | ||
[0,0,0,0,1], | ||
[1,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'K': [ | ||
[1,0,0,0,1], | ||
[1,0,0,1,0], | ||
[1,1,1,0,0], | ||
[1,0,0,1,0], | ||
[1,0,0,0,1] | ||
], | ||
'L': [ | ||
[1,0,0,0,0], | ||
[1,0,0,0,0], | ||
[1,0,0,0,0], | ||
[1,0,0,0,0], | ||
[1,1,1,1,1] | ||
], | ||
'M': [ | ||
[1,0,0,0,1], | ||
[1,1,0,1,1], | ||
[1,0,1,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1] | ||
], | ||
'N': [ | ||
[1,0,0,0,1], | ||
[1,1,0,0,1], | ||
[1,0,1,0,1], | ||
[1,0,0,1,1], | ||
[1,0,0,0,1] | ||
], | ||
'O': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'P': [ | ||
[1,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,1,1,1,0], | ||
[1,0,0,0,0], | ||
[1,0,0,0,0] | ||
], | ||
'Q': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,0,1,0,1], | ||
[1,0,0,1,0], | ||
[0,1,1,0,1] | ||
], | ||
'R': [ | ||
[1,1,1,1,0], | ||
[1,0,0,0,1], | ||
[1,1,1,1,0], | ||
[1,0,0,1,0], | ||
[1,0,0,0,1] | ||
], | ||
'S': [ | ||
[0,1,1,1,0], | ||
[1,0,0,0,0], | ||
[0,1,1,1,0], | ||
[0,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'T': [ | ||
[1,1,1,1,1], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0] | ||
], | ||
'U': [ | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[0,1,1,1,0] | ||
], | ||
'V': [ | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[0,1,0,1,0], | ||
[0,0,1,0,0] | ||
], | ||
'W': [ | ||
[1,0,0,0,1], | ||
[1,0,0,0,1], | ||
[1,0,1,0,1], | ||
[1,0,1,0,1], | ||
[0,1,0,1,0] | ||
], | ||
'X': [ | ||
[1,0,0,0,1], | ||
[0,1,0,1,0], | ||
[0,0,1,0,0], | ||
[0,1,0,1,0], | ||
[1,0,0,0,1] | ||
], | ||
'Y': [ | ||
[1,0,0,0,1], | ||
[0,1,0,1,0], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0], | ||
[0,0,1,0,0] | ||
], | ||
'Z': [ | ||
[1,1,1,1,1], | ||
[0,0,0,1,0], | ||
[0,0,1,0,0], | ||
[0,1,0,0,0], | ||
[1,1,1,1,1] | ||
], | ||
' ': [ | ||
[0,0,0,0,0], | ||
[0,0,0,0,0], | ||
[0,0,0,0,0], | ||
[0,0,0,0,0], | ||
[0,0,0,0,0] | ||
] | ||
} | ||
|
||
x, y = 1, 1 # Start position | ||
for char in text.upper(): | ||
if char in char_maps: | ||
char_map = char_maps[char] | ||
for i in range(5): | ||
for j in range(5): | ||
if y + j < cols: | ||
grid[x + i][y + j] = char_map[i][j] | ||
y += 6 | ||
|
||
contribute_dates = [] | ||
for i in range(rows): | ||
for j in range(cols): | ||
if grid[i][j] == 1: | ||
days_to_add = i + j * 7 | ||
contribute_date = start_date + datetime.timedelta(days=days_to_add) | ||
contribute_dates.append(contribute_date.strftime("%Y-%m-%d")) | ||
|
||
return contribute_dates | ||
|
||
# Example usage | ||
start_date = datetime.date.today() # A Sunday | ||
|
||
text = input("Enter text to be displayed\n") | ||
text = text.upper() | ||
dates = github_text_contributions(text, start_date) | ||
print("Contribute on these dates:") | ||
for date in dates: | ||
print(date) |