Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22 #33

Merged
merged 2 commits into from
Jul 24, 2024
Merged
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
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)