Last active
August 29, 2015 14:10
-
-
Save bikz05/06335f17f7ae356482a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 1 | |
# http://progexercise.dev.indeed.net/progcontest/problems/1 | |
input = "RUNNINGWITHSCISSORS" | |
list = list(input) | |
dic = {} | |
count = len(list); | |
for x in list: | |
if x not in dic: | |
dic[x] = count; | |
else: | |
dic[x] = dic[x] + count; | |
count = count - 1; | |
new = sorted(dic.items(), key=lambda x: (-x[1], x[0])); | |
print ''.join([x[0] for x in new]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
link1 = (4, 3); | |
myList1 = [2, 3, 4, 1]; | |
link2 = (1, 1); | |
myList2 = [1, 2, 3]; | |
link3 = (1, 3); | |
myList3 = [2, 1, 4, 3]; | |
dic = {}; | |
def getNo(i, j, count = 0): | |
if(j == i): | |
return count; | |
if count == len(dic): | |
return "IMPOSSIBLE"; | |
count = count + 1; | |
count = getNo(dic[i], j, count); | |
return count; | |
# Solution for list 3 | |
for x in range(len(myList3)): | |
dic[x + 1] = myList3[x]; | |
print getNo(link3[0], link3[1]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment