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

Create challenge_1.py #33

Open
wants to merge 2 commits into
base: master
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
24 changes: 24 additions & 0 deletions Challenge questions/Picklebunker/challenge_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import re

def condense(string):
result=""
for s in string.split():
result+=s.capitalize()
return result

def vaporize(string2):
components= re.sub( r"([A-Z])", r" \1", string).split()
result=components[0]
for c in components[1:]:
result+=" "+c
return result





string="My name is someone"
string2=condense(string)

print(condense(string))
print(vaporize(string))
30 changes: 30 additions & 0 deletions Challenge questions/Picklebunker/challenge_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
import random

def scramble(word):
if len(word)<=3:
return word
else:
i=[(l.start(0),l.end(0)) for l in re.finditer(r'[A-Za-z]',word)]
start_i=i[0][0]
end_i=i[-1][0]
body=list(word[start_i+1:end_i])
random.shuffle(body)
result=word[start_i]+''.join(body)+word[end_i:]
return result



text="""Write a Code that scrambles the words by following the rules below:
Words less than or equal to 3 characters need not be scrambled.
Don't scramble first and last char, so Scrambling can become Srbmnacilg or
Srbmnailcg or Snmbracilg , i.e. letters except first and last can be scrambled
in any order. Punctuation at the end of the word to be maintained as is i.e.
"Surprising," could become "Spsirnirug," but not "Spsirn,irug".
Following punctuation marks are to be supported - comma, question mark,
full stop, semicolon, exclamation. Do this for a file and
maintain sequences of lines."""

newtext=' '.join([scramble(w) for w in text.split()])

newtext
8 changes: 8 additions & 0 deletions Challenge questions/Picklebunker/challenge_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pandas as pd

path=""
def transpose_csv(path):
return pd.read_CSV(path).transpose()


transpose_csv(path)