Skip to content

Instantly share code, notes, and snippets.

@bikz05
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bikz05/06335f17f7ae356482a6 to your computer and use it in GitHub Desktop.
Save bikz05/06335f17f7ae356482a6 to your computer and use it in GitHub Desktop.
# 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]);
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