cleanup
+230 −142 · 36 files changed
-
.idea/.name+1 −0 -
.idea/coderbyte.iml+8 −0 -
.idea/encodings.xml+4 −0 -
.idea/misc.xml+37 −0 -
.idea/modules.xml+8 −0 -
.idea/vcs.xml+6 −0 -
easy/01-first-reverse.py+3 −3 -
easy/02-first-factorial.py+4 −4 -
easy/03-lognest-word.py+5 −6 -
easy/04-letter-changes.py+7 −6 -
easy/05-simple-adding.py+2 −0 -
easy/06-letter-capitalize.py+5 −5 -
easy/07-simple-symbols.py+5 −4 -
easy/08-check-nums.py+2 −3 -
easy/09-time-convert.py+4 −5 -
easy/10-alphabet-soup.py+4 −4 -
easy/11-ab-check.py+6 −6 -
easy/12-vowel-count.py+8 −8 -
easy/13-word-count.py+6 −5 -
easy/14-ex-oh.py+7 −8 -
easy/15-palindrome.py+8 −8 -
easy/16-arith-geo.py+3 −3 -
easy/17-array-addition-1.py+4 −4 -
easy/18-letter-count-1.py+2 −2 -
easy/19-second-great-low.py+7 −7 -
easy/20-division-stringified.py+8 −8 -
easy/21-counting-minutes-1.py+21 −20 -
easy/22-mean-mode.py+3 −3 -
easy/23-dash-insert.py+2 −2 -
easy/24-swap-case.py+2 −1 -
easy/25-number-addition.py+1 −3 -
easy/26-third-greatest.py+3 −3 -
easy/27-powers-of-two.py+7 −5 -
easy/28-additive-persistance.py+1 −1 -
easy/29-multiplicative-persistance.py+2 −2 -
medium/06-string-scramble.py+24 −3
@@ -0,0 +1 @@ +coderbyte \ No newline at end of file @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="PYTHON_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="jdk" jdkName="Python 2.7.9 (/usr/bin/python2.7)" jdkType="Python SDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> +</project> \ No newline at end of file @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="DaemonCodeAnalyzer"> + <disable_hints /> + </component> + <component name="DependencyValidationManager"> + <option name="SKIP_IMPORT_STATEMENTS" value="false" /> + </component> + <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> + <component name="ProjectLevelVcsManager" settingsEditedManually="false"> + <OptionsSetting value="true" id="Add" /> + <OptionsSetting value="true" id="Remove" /> + <OptionsSetting value="true" id="Checkout" /> + <OptionsSetting value="true" id="Update" /> + <OptionsSetting value="true" id="Status" /> + <OptionsSetting value="true" id="Edit" /> + <ConfirmationsSetting value="0" id="Add" /> + <ConfirmationsSetting value="0" id="Remove" /> + </component> + <component name="ProjectModuleManager"> + <modules /> + </component> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.9 (/usr/bin/python2.7)" project-jdk-type="Python SDK" /> + <component name="PropertiesComponent"> + <property name="options.lastSelected" value="preferences.editor" /> + <property name="options.splitter.main.proportions" value="0.3" /> + <property name="options.splitter.details.proportions" value="0.2" /> + </component> + <component name="PyConsoleOptionsProvider"> + <option name="myPythonConsoleState"> + <console-settings /> + </option> + </component> + <component name="RunManager"> + <list size="0" /> + </component> +</project> \ No newline at end of file @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/coderbyte.iml" filepath="$PROJECT_DIR$/.idea/coderbyte.iml" /> + </modules> + </component> +</project> \ No newline at end of file @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project> \ No newline at end of file @@ -1,8 +1,8 @@ -#Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order. +# Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order. #Use the Parameter Testing feature in the box below to test your code with different arguments. def FirstReverse(str): - return str[::-1] + return str[::-1] - print FirstReverse(raw_input()) + print FirstReverse(raw_input()) @@ -9,11 +9,11 @@ in the box below to test your code with different arguments. from math import factorial -def FirstFactorial(num): - return factorial(num) - - +def FirstFactorial(num): + return factorial(num) + + # keep this function call here # to see how to enter arguments in Python scroll down print FirstFactorial(raw_input()) @@ -1,12 +1,11 @@ -def LongestWord(sen): - si = sen.split() - return max(si, key=len) +def LongestWord(sen): + si = sen.split() + return max(si, key=len) + - # keep this function call here # to see how to enter arguments in Python scroll down -print LongestWord(raw_input()) - +print LongestWord(raw_input()) """ Have the function LongestWord(sen) take the sen parameter being passed and return the @@ -10,14 +10,15 @@ def LetterChanges(str): s = y.upper() ns.append(s) else: - ns.append(y) + ns.append(y) else: - ns.append(y) - + ns.append(y) + xs = ''.join(ns) - - return xs - + + return xs + + print LetterChanges(raw_input()) """ Have the function LetterChanges(str) take the str parameter being @@ -3,6 +3,8 @@ Have the function SimpleAdding(num) add up all the numbers from 1 to num. For the test cases, the parameter num will be any number from 1 to 1000. """ + + def SimpleAdding(num): sumall = sum(range(1, num + 1)) @@ -1,10 +1,10 @@ -def LetterCapitalize(str): - return str.title() - - +def LetterCapitalize(str): + return str.title() + + # keep this function call here # to see how to enter arguments in Python scroll down -print LetterCapitalize(raw_input()) +print LetterCapitalize(raw_input()) """ Have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated by only one space. @@ -2,20 +2,21 @@ def SimpleSymbols(str): li = list(str) idx = 0 - while idx+1 < len(li): + while idx + 1 < len(li): if li[idx] == '+': idx += 1 if li[idx].isalpha(): - idx +=1 + idx += 1 if li[idx] == '+': return "true" else: return "false" elif li[idx].isalpha(): return "false" - idx+=1 + idx += 1 -print SimpleSymbols(raw_input()) + +print SimpleSymbols(raw_input()) """ Have the function SimpleSymbols(str) take the str parameter being passed and determine if it is an acceptable sequence by either returning @@ -1,5 +1,4 @@ -def CheckNums(num1,num2): - +def CheckNums(num1, num2): if num2 > num1: return 'true' elif num1 == num2: @@ -9,7 +8,7 @@ def CheckNums(num1,num2): # keep this function call here # to see how to enter arguments in Python scroll down -print CheckNums(raw_input()) +print CheckNums(raw_input()) """ Have the function CheckNums(num1,num2) @@ -1,11 +1,10 @@ -def TimeConvert(num): +def TimeConvert(num): + return str(num / 60) + ':' + str(num % 60) + - return str(num/60) + ':'+str( num % 60) - - # keep this function call here # to see how to enter arguments in Python scroll down -print TimeConvert(raw_input()) +print TimeConvert(raw_input()) """ Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). @@ -1,11 +1,11 @@ def AlphabetSoup(str): - li = list(str) - li.sort() - return ''.join(li).strip(" ") + li = list(str) + li.sort() + return ''.join(li).strip(" ") # keep this function call here # to see how to enter arguments in Python scroll down -print AlphabetSoup(raw_input()) +print AlphabetSoup(raw_input()) """ Have the function AlphabetSoup(str) take the str string parameter being passed and return the string with the letters in alphabetical order (ie. hello becomes ehllo). Assume numbers and punctuation symbols will not be included in the string. @@ -1,18 +1,18 @@ def ABCheck(str): for i in range(0, len(str) - 4): - if (str[i] == 'a'): - if (str[i + 4] == 'b'): + if str[i] == 'a': + if str[i + 4] == 'b': return 'true' - if (str[i] == 'b'): - if (str[i + 4] == 'a'): + if str[i] == 'b': + if str[i + 4] == 'a': return 'true' return 'false' - + # keep this function call here # to see how to enter arguments in Python scroll down -print ABCheck(raw_input()) +print ABCheck(raw_input()) """ Have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (ie. "lane borrowed" would result in true because there is exactly three characters between a and b). Otherwise return the string false. @@ -1,13 +1,13 @@ -def VowelCount(str): - o = 0 - for i in "aeiou": - o += str.count(i) - - return o - +def VowelCount(str): + o = 0 + for i in "aeiou": + o += str.count(i) + + return o + # keep this function call here # to see how to enter arguments in Python scroll down -print VowelCount(raw_input()) +print VowelCount(raw_input()) """ Have the function VowelCount(str) take the str string parameter being passed and return the number of vowels the string contains (ie. "All cows eat grass" would return 5). Do not count y as a vowel for this challenge. """ @@ -1,9 +1,10 @@ def WordCount(str): - o = 1 - o += str.count(" ") - - return o -# keep this function call here + o = 1 + o += str.count(" ") + + return o + +# keep this function call here # to see how to enter arguments in Python scroll down print WordCount(raw_input()) """ @@ -1,17 +1,16 @@ -def ExOh(str): - +def ExOh(str): o = str.count('o') x = str.count('x') - + if x == o: - return 'true' + return 'true' else: - return 'false' - - + return 'false' + + # keep this function call here # to see how to enter arguments in Python scroll down -print ExOh(raw_input()) +print ExOh(raw_input()) """ Have the function ExOh(str) take the str parameter being passed and return the string true if there is an equal number of x's and o's, otherwise return the string false. Only these two letters will be entered in the string, no punctuation or numbers. For example: if str is "xooxxxxooxo" then the output should return false because there are 6 x's and 5 o's. """ @@ -1,14 +1,14 @@ def Palindrome(str): - o = str.replace(" ","") - - if o == o[::-1]: - return 'true' - else: - return 'false' - + o = str.replace(" ", "") + + if o == o[::-1]: + return 'true' + else: + return 'false' + # keep this function call here # to see how to enter arguments in Python scroll down -print Palindrome(raw_input()) +print Palindrome(raw_input()) """ Have the function Palindrome(str) take the str parameter being passed and return the string true if the parameter is a palindrome, (the string is the same forward as it is backward) otherwise return the string false. For example: "racecar" is also "racecar" backwards. Punctuation and numbers will not be part of the string. """ @@ -1,9 +1,9 @@ def ArithGeo(arr): diff = arr[1] - arr[0] div = float(arr[1]) / float(arr[0]) - for index in range(len(arr)-1): + for index in range(len(arr) - 1): if not (arr[index + 1] - arr[index] == diff): - for index2 in range(len(arr)-1): + for index2 in range(len(arr) - 1): if not float((arr[index2 + 1]) / float(arr[index2]) == div): return -1 return 'Geometric' @@ -11,7 +11,7 @@ def ArithGeo(arr): # keep this function call here # to see how to enter arguments in Python scroll down -print ArithGeo(raw_input()) +print ArithGeo(raw_input()) """ Have the function ArithGeo(arr) take the array of numbers stored in arr and return the string "Arithmetic" if the sequence follows an arithmetic @@ -1,15 +1,15 @@ -def ArrayAdditionI(arr): +def ArrayAdditionI(arr): targetValue = max(arr) arr.remove(targetValue) mall = sum(arr) if targetValue <= mall: - return 'true' + return 'true' else: - return 'false' + return 'false' # keep this function call here # to see how to enter arguments in Python scroll down -print ArrayAdditionI(raw_input()) +print ArrayAdditionI(raw_input()) """ Have the function ArrayAdditionI(arr) take the array of numbers stored in arr @@ -7,14 +7,14 @@ def LetterCountI(str): for letter in alp: if word.count(letter) > 1: le.append(index) - if le == []: + if not le: return -1 return al[le[0]] # keep this function call here # to see how to enter arguments in Python scroll down -print LetterCountI(raw_input()) +print LetterCountI(raw_input()) """ Have the function LetterCountI(str) take the str parameter being passed @@ -1,10 +1,10 @@ -def SecondGreatLow(arr): - alt = sorted(list(set(arr))) - if len(alt) == 1: - alt.append(alt[0]) - return ' '.join([str(alt[x]) for x in 1,-2]) - - +def SecondGreatLow(arr): + alt = sorted(list(set(arr))) + if len(alt) == 1: + alt.append(alt[0]) + return ' '.join([str(alt[x]) for x in 1, -2]) + + # keep this function call here # to see how to enter arguments in Python scroll down print SecondGreatLow(raw_input()) @@ -1,15 +1,15 @@ from math import ceil -def DivisionStringified(num1,num2): - resultFloat = num1/float(num2) - resultFloatInt = "{:,}".format(int(resultFloat // 1)) - if resultFloat <= 999: - return int(ceil(resultFloat)) - else: - return resultFloatInt +def DivisionStringified(num1, num2): + resultFloat = num1 / float(num2) + resultFloatInt = "{:,}".format(int(resultFloat // 1)) + if resultFloat <= 999: + return int(ceil(resultFloat)) + else: + return resultFloatInt # keep this function call here # to see how to enter arguments in Python scroll down -print DivisionStringified(raw_input()) +print DivisionStringified(raw_input()) # not working @@ -1,6 +1,5 @@ def CountingMinutesI(str): - - e = str.replace(':',' ').replace('-',' ').replace('pm',' p').replace('am',' a').split() + e = str.replace(':', ' ').replace('-', ' ').replace('pm', ' p').replace('am', ' a').split() g = [int(s) for s in e if s.isdigit()] if (e[2] == 'p' and e[5] == 'p') or (e[2] == 'a' and e[5] == 'a'): @@ -8,41 +7,43 @@ def CountingMinutesI(str): if g[0] == g[2]: if g[1] == g[3]: return 1440 - + elif g[1] < g[3]: - return abs((g[1])-g[3]) - + return abs((g[1]) - g[3]) + elif g[1] > g[3]: - return 1380+(60-abs((g[1])-g[3])) - + return 1380 + (60 - abs((g[1]) - g[3])) + elif g[0] < g[2]: if g[2] == 12: if g[3] < g[1]: - return 720+((g[2]-g[0])*60)-(abs(g[1]-g[3])) - return 720+((g[2]-g[0])*60)+(abs(g[1]-g[3])) - return abs((g[1])-g[3])+60*abs((g[2])-g[0]) + return 720 + ((g[2] - g[0]) * 60) - (abs(g[1] - g[3])) + return 720 + ((g[2] - g[0]) * 60) + (abs(g[1] - g[3])) + return abs((g[1]) - g[3]) + 60 * abs((g[2]) - g[0]) elif g[0] > g[2]: if g[0] == 12: if g[1] == g[3] or g[1] < g[3]: - return abs((g[1])-g[3])+60*g[2] - return (g[2]*60)+abs((g[1])-g[3]) + return abs((g[1]) - g[3]) + 60 * g[2] + return (g[2] * 60) + abs((g[1]) - g[3]) elif e[2] == 'a' and e[5] == 'p' or e[2] == 'p' and e[5] == 'a': if g[0] == 12 or g[2] == 12: if g[2] == 12: - return 720-(g[0]*60)+abs(g[1]-g[3]) - return 720+(g[2]*60)+abs(g[1]-g[3]) + return 720 - (g[0] * 60) + abs(g[1] - g[3]) + return 720 + (g[2] * 60) + abs(g[1] - g[3]) elif g[0] == g[2]: if g[3] == g[1]: return 720 elif g[3] > g[1]: - return 720+abs((g[1])-g[3]) + return 720 + abs((g[1]) - g[3]) elif g[3] < g[1]: - return 720-abs((g[1])-g[3]) + return 720 - abs((g[1]) - g[3]) elif g[0] < g[2]: - return 720+abs((g[2] - g[0])*60)+abs(g[1]-g[3]) - - return ((g[1])-g[3])+720 -print CountingMinutesI(raw_input()) + return 720 + abs((g[2] - g[0]) * 60) + abs(g[1] - g[3]) + + return ((g[1]) - g[3]) + 720 + + +print CountingMinutesI(raw_input()) # needs redoing @@ -1,9 +1,9 @@ -def MeanMode(arr): - mn = sum(arr)/len(arr) +def MeanMode(arr): + mn = sum(arr) / len(arr) if arr.count(mn) > 1: return 1 return 0 - + # keep this function call here # to see how to enter arguments in Python scroll down print MeanMode(raw_input()) @@ -22,8 +22,8 @@ def DashInsert(str): IndexError return "".join(d) - + # keep this function call here # to see how to enter arguments in Python scroll down -print DashInsert(raw_input()) +print DashInsert(raw_input()) # needs redoing @@ -7,7 +7,8 @@ def SwapCase(str): d.append(letter[1].upper()) return "".join(d) -# keep this function call here + +# keep this function call here # to see how to enter arguments in Python scroll down print SwapCase(raw_input()) @@ -9,7 +9,6 @@ def NumberAddition(str): except: return 0 - xs = "".join(xc) for ele in xs: @@ -18,10 +17,9 @@ def NumberAddition(str): else: d.append('+') - f = "".join(d) return eval(f) - + # keep this function call here # to see how to enter arguments in Python scroll down print NumberAddition(raw_input()) @@ -1,11 +1,11 @@ def ThirdGreatest(strArr): # code goes here d = [] - for i,v in enumerate(strArr): + for i, v in enumerate(strArr): d.append((len(v))) - return "".join(sorted(strArr,key=str.__len__, reverse=True)[2:3]) - + return "".join(sorted(strArr, key=str.__len__, reverse=True)[2:3]) + # keep this function call here # to see how to enter arguments in Python scroll down print ThirdGreatest(raw_input()) @@ -1,10 +1,12 @@ from math import sqrt + + def PowersofTwo(num): - if sqrt(num) % 2 == 0: - return 'true' - return 'false' - + if sqrt(num) % 2 == 0: + return 'true' + return 'false' + # keep this function call here # to see how to enter arguments in Python scroll down -print PowersofTwo(raw_input()) +print PowersofTwo(raw_input()) # needs work @@ -1,5 +1,4 @@ def AdditivePersistence(num): - counter = 0 ss = num @@ -14,6 +13,7 @@ def AdditivePersistence(num): return counter + def mpp(nm): nm = map(int, str(nm)) return sum(nm) @@ -1,5 +1,4 @@ def MultiplicativePersistence(num): - counter = 0 ss = num @@ -14,13 +13,14 @@ def MultiplicativePersistence(num): return counter + def mpp(nm): nm = map(int, str(nm)) p = 1 for n in nm: p *= n return p - + # keep this function call here # to see how to enter arguments in Python scroll down print MultiplicativePersistence(raw_input()) @@ -8,9 +8,30 @@ def StringScramble(str1,str2): if len(ll ^ set(str2)) and len(ll ^ set(str1)): return 'false' return 'true' - + +""" +Using the Python language, +have the function StringScramble(str1,str2) +take both parameters being passed and return +the string true if a portion of str1 characters +can be rearranged to match str2, +otherwise return the string false. +For example: if str1 is "rkqodlw" and str2 is "world" +the output should return true. +Punctuation and symbols will not be entered with the parameters. + +""" # keep this function call here # to see how to enter arguments in Python scroll down -print StringScramble(raw_input()) +print StringScramble("abcgggdfe","abcdef") +print StringScramble("h3llko","hello") +print StringScramble("coodrebtqqkye","coderbyte") +print StringScramble("heloooolwrdlla","helloworld") +print StringScramble("coamamaaqq","comma") +print StringScramble("letrrkakaeaaaqq","letter") +print StringScramble("aqwe","qa") +print StringScramble("yelowrqwedlk","yellowred") +print StringScramble("cdore","coder") -# not working +# Input = "cdore" & str2= "coder"Output = "true" +# Input = "h3llko" & str2 = "hello"Output = "false" \ No newline at end of file