-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadme_Generator.py
More file actions
72 lines (60 loc) · 3.35 KB
/
Readme_Generator.py
File metadata and controls
72 lines (60 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
def getFoldersNames(path):
folders = []
for item in os.listdir(path):
if not os.path.isfile(item) and item not in ('.git', '.idea'):
folders.append(item)
return folders
def getFilesNames(path):
files = os.listdir(path)
return files
def getProblemURLandScore(path):
inFile = open(path, 'r', encoding='utf-8')
url = inFile.readline().split()[-1]
score = inFile.readline().split()[-1]
inFile.close()
return url, score
def getTotalNumberOfProblems():
totalNumber = 0
folders = getFoldersNames(os.getcwd())
for folder in folders:
subfolders = getFoldersNames(os.path.join(os.getcwd(), folder))
for subfolder in subfolders:
totalNumber += len(getFilesNames(os.path.join(os.getcwd(), folder, subfolder)))
return totalNumber
readmeFile = open('Documentation.md', 'w', encoding='utf-8')
print('<p align="center"><a href="https://www.hackerrank.com/nithishsingh"><img src="asset/png/Solution.png" ></a></p>', file=readmeFile)
print(file=readmeFile)
print('# HackerRank', file=readmeFile)
print('HackerRank Solution to Practice Problem in Various Domain.', file=readmeFile)
print(file=readmeFile)
print('# Only For Educational Purpose use it as Reference not a point of solution',file=readmeFile)
print(file=readmeFile)
print('This repository contains ' + str(getTotalNumberOfProblems()) + ' solutions to Hackerrank practice problems with Python 3.', file=readmeFile)
print(file=readmeFile)
print('Updated daily :) If it was helpful please press a star.', file=readmeFile)
print(file=readmeFile)
print('[](https://github.com/nithishsingh/HackerRank-Solution) ', file=readmeFile)
print('[](https://github.com/nithishsingh/HackerRank-Solution)', file=readmeFile)
print('[](https://github.com/nithishsingh/HackerRank-Solution) ', file=readmeFile)
print('[](https://github.com/nithishsingh/HackerRank-Solution)', file=readmeFile)
print(file=readmeFile)
folders = getFoldersNames(os.getcwd())
for folder in sorted(folders):
print('- ' + folder, file=readmeFile)
subfolders = getFoldersNames(os.path.join(os.getcwd(), folder))
for subfolder in sorted(subfolders):
print(' ' + subfolder, file=readmeFile)
files = getFilesNames(os.path.join(os.getcwd(), folder, subfolder))
for file in sorted(files):
if file.endswith(('.py', '.sql')):
url, score = getProblemURLandScore(os.path.join(os.getcwd(), folder, subfolder, file))
print(' - ' + "".join(file.split(".")[1:-1])[1:]
+ ' | [Problem](' + url
+ ')'
+ ' | [Solution]'
+ '(https://github.com/nithishsingh/HackerRank-Solution/blob/master/'
+ folder.replace(' ', '%20') + '/' + subfolder.replace(' ', '%20') + '/'
+ file.replace(' ', '%20') + ')'
+ ' | Score: ' + str(score), file=readmeFile)
readmeFile.close()