forked from keshavsingh4522/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
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
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,42 @@ | ||
#palindrome_partition | ||
|
||
#Method to check whether the string is palindrome or not | ||
def isPalindrome(string:str, start:int, end:int): | ||
while start < end: | ||
if string[end] != string[start]: | ||
return False | ||
start += 1 | ||
end -= 1 | ||
return True | ||
|
||
#Recursive method to search for all the possible partitions. | ||
def findAllPartitions(allPartitions, subPartitions, initial, n, string): | ||
if initial >= n: | ||
x = subPartitions.copy() | ||
allPartitions.append(x) | ||
return | ||
|
||
for i in range(initial, n): | ||
if isPalindrome(string, initial, i): | ||
|
||
subPartitions.append(string[initial:i + 1]) | ||
|
||
findAllPartitions(allPartitions, subPartitions, i + 1, n, string) | ||
|
||
subPartitions.pop() | ||
|
||
#Method to print all the possible palindrome partitions. | ||
def palindromePartitions(string): | ||
allPartitions = [] | ||
subPartitions = [] | ||
|
||
findAllPartitions(allPartitions, subPartitions, 0, len(string), string) | ||
|
||
for i in enumerate(allPartitions): | ||
for j in enumerate(allPartitions[i[0]]): | ||
print(allPartitions[i[0]][j[0]], end = " ") | ||
print() | ||
|
||
#Take a string input | ||
string = str(input()) | ||
palindromePartitions(string) |
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,28 @@ | ||
# Check pc health status | ||
# For a stable system, | ||
# free space should be > 20% and, | ||
# disk usage should be < 75% | ||
|
||
# pip install psutil | ||
|
||
import shutil | ||
import psutil | ||
|
||
|
||
def check_disk_usage(disk): | ||
du = shutil.disk_usage(disk) | ||
free = du.free / du.total * 100 | ||
return free | ||
|
||
|
||
def check_cpu_usage(): | ||
usage = psutil.cpu_percent(1) | ||
return usage | ||
|
||
|
||
a = check_disk_usage("/") | ||
b = check_cpu_usage() | ||
if a > 20 or b < 75: | ||
print("Pc is stable \nfree space: {:.2f}% \nCPU usage: {:.2f}%".format(a,b)) | ||
else: | ||
print("Error!!!\nAction required \nfree space: {:.2f}% \nCPU usage: {:.2f}%".format(a, b)) |