The script 'Hackerrank_Solution_Blank_File_Creator' is designed to automate the process of creating blank Python files for solving problems on Hackerrank. It reads problem titles and subdomain names from a text file, then creates a new directory for each subdomain and generates a blank Python file for each problem within the appropriate subdomain directory.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The script works by first reading lines from a text file. Each line either contains a problem title or a subdomain name. The script then checks if a directory for the subdomain exists, and if not, it creates one. It then generates a valid filename for each problem, creates a new Python file with that name in the appropriate subdomain directory, and writes a header to the file containing the problem title, subdomain, domain, author, and creation date. The script uses regular expressions to validate and clean up the problem titles and subdomain names.
import datetime
import os
import re
import sys
extension = ".py"
domain = "Python"
author = "Ahmedur Rahman Shovon"
created_date = datetime.datetime.today().strftime("%d %B %Y")
info_file_name = "python_info.txt"
def valid_name(given_name):
return re.sub(r"[^\w]", "", given_name)
def write_file_header(title, subdomain):
header_str = "''\n"
header_str += "Title : " + title + "\n"
header_str += "Subdomain : " + subdomain + "\n"
header_str += "Domain : " + domain + "\n"
header_str += "Author : " + author + "\n"
header_str += "Created : " + created_date + "\n"
header_str += "''\n"
return header_str
problem_list = ""
subdomain_name = ""
info_file = open(info_file_name, "r")
info_file_lines = info_file.readlines()
info_file.close()
for line in info_file_lines:
line = line.strip()
if line == "":
continue
elif line[0] == "[":
problem_list = line
else:
subdomain_name = line
if subdomain_name != "" and problem_list != "":
folder_name = valid_name(subdomain_name)
if not os.path.exists(folder_name):
os.makedirs(folder_name)
title_ar = re.findall(r'("[^"]*")', problem_list)
title_ar_len = len(title_ar)
for title in title_ar:
file_header_str = write_file_header(title[1:-1], subdomain_name)
title_valid = valid_name(title)
f = open(folder_name + "\\" + title_valid + extension, "w")
f.write(file_header_str)
f.close()
print("Folder: " + str(folder_name) + ". Total files: " + str(title_ar_len))
subdomain_name = ""
problem_list = ""
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.