Saturday, April 6, 2019

devco trial


Bubbles.py

from collections import OrderedDict

def nonrepeating(orig):

input = orig.lower()

dict=OrderedDict.fromkeys(input,0)

# traverse
for ch in input:
dict[ch]+=1

# nonrepeat
nonRepeatDict = [key for (key,value) in dict.iteritems() if value==1]
print nonRepeatDict

repeatStr = []
for tx in list(orig):
if tx not in nonRepeatDict:
repeatStr.append(tx)

makeitastring = ''.join(map(str, nonRepeatDict + repeatStr))
print makeitastring

if __name__ == "__main__":
orig = "Bubble"
nonrepeating(orig)



# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(N):
    # write your code in Python 3.6
    ret = '+'
    flag = '+'
    for i in range(1, N):
        if flag == '+':
            ret += '-'
            flag = '-'
        else:
            ret += '+'
            flag = '+'
    return ret

No comments:

Post a Comment

free online comma separating tool

https://delim.co/#