File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ # Note that this solution assumes a unique string
3
+ # implies a lowercase letter and the uppercase of
4
+ # that letter is not considered duplicates
5
+ # example: the string "Hather" has an uppercase "H"
6
+ # and lowercase "h" yet the string has no duplicate
7
+ # "h" or "H"
8
+
9
+
10
+ def uniqueChar (passedStr ):
11
+
12
+ # Will use the built-in function set() which
13
+ # eliminates dupplicates
14
+ deleteDuplicateIfAny = set (passedStr )
15
+
16
+ # If the string had unique characters the string
17
+ # length remains the same
18
+ # If the string has duplicates then size
19
+ if len (deleteDuplicateIfAny ) == len (passedStr ):
20
+ return "Unique"
21
+ else :
22
+ return "Not Unique"
23
+
24
+
25
+ example = "Helloh"
26
+
27
+ print (uniqueChar (example ))
Original file line number Diff line number Diff line change
1
+ example = "hello"
2
+ example2 = "ehloe"
3
+
4
+ for letter in example :
5
+ if letter in example2 :
6
+ index = example2 .index (letter )
7
+ example2 = example2 [:index ] + example2 [index + 1 :]
8
+ print (example2 )
9
+
10
+ if example2 == '' :
11
+ print ("done with permutation" )
12
+ break
13
+ else :
14
+ continue
15
+ else :
16
+ print ("Not permutatable" )
17
+ break
18
+
Original file line number Diff line number Diff line change
1
+
2
+
3
+ def replaceSpace (stringPas , totalLen ):
4
+ # Use replace() to search for blank sapces in the string
5
+ # and replace with "%20"
6
+ newString = stringPas .replace (' ' ,"%20" )
7
+
8
+ # Can use the length of string passed (second arg)
9
+ # to check the length of new string is not greater
10
+ # than original length
11
+ if len (newString ) > totalLen :
12
+ return "Fail"
13
+ else :
14
+ return newString
15
+
16
+ print (replaceSpace ("Hi, how is your " ,18 ))
You can’t perform that action at this time.
0 commit comments