Skip to content

Commit

Permalink
Merge pull request #33 from rampantvoid/rampantvoid
Browse files Browse the repository at this point in the history
Fixes #22
  • Loading branch information
anshikasrivastava17 authored Jul 24, 2024
2 parents 49c3e0c + ee22cfb commit ad44726
Showing 1 changed file with 228 additions and 0 deletions.
228 changes: 228 additions & 0 deletions Day 5/Issue 22/Priyanshu/main.py
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)

0 comments on commit ad44726

Please sign in to comment.