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

testing #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true
Expand Down
39 changes: 39 additions & 0 deletions src/01 Find Prime Factors/prime_challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from math import sqrt as sqrt

# challenge return all prime factors (including duplicates) as a list
# a*b*c*d*e = number
def get_prime_factors(bigNum):
if not isinstance(bigNum, int): return "Error"
if bigNum < 2: return "Error"
myList = list()
sqrtNum = int(sqrt(bigNum))+1
keepLooping = True
while keepLooping:
factor = get_factor(bigNum, sqrtNum)
if factor is not None:
myList.append(factor)
bigNum = int (bigNum / factor)
if sqrtNum > 3:
keepLooping = True
else:
keepLooping = False
else:
keepLooping = False

if bigNum > 1: myList.append(int(bigNum))
return myList

def get_factor(Num, sqrtNum):
factor = None
#print(Num, sqrtNum)
for i in range(2, sqrtNum, 1):
#print(i)
if ((int(Num) % i ) == 0) :
factor = i
break
else:
continue
return factor


print(get_prime_factors(630))
24 changes: 24 additions & 0 deletions src/02 Identify a Palindrome/pal_challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Python Code Challenge #2: Identify a Palindrome
# Your goal is to implement a function,
# `is_palindrome()`, that takes a text string
# as the input argument and returns a boolean
# indicating whether or not it's a palindrome.

def is_palindrome(myString):
myString = cleanString(myString)
print(myString)
revString = myString[::-1]
result = False
if revString == myString: result = True
return result

def cleanString(myString):
myString = myString.upper()
newString=''
for i in myString:
if ord(i) > 64 and ord(i) < 91:
newString = newString + i
return newString


print(is_palindrome("Go hang a salami - I'm a lasagna hog."))
24 changes: 24 additions & 0 deletions src/03 Sort a String/sortString_Challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

# function to sort the words in a string and return the sorted string.
# ignore case when sorting

def sort_words(myString):
myList = myString.split(' ')
# print(myList)
myList = sorted(myList, key=str.casefold)
# print(myList)
return (' '.join(myList))


#def make_List(myString):
# myList = myString.split(' ')
# return myList

#def list(myList):
# def __lt__(myList):
# ulist = list.lower()
# umyList = list.upper()
# return ulist < umyList

print(sort_words('string of words'))
print(sort_words('banana ORANGE apple'))