Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
p% times ..question is not clear can U provide the algo or code for this
def appears(a, p): m = len(a) count = {} for i in a: if count.has_key(i): count[i] += 1 else: count[i] = 1 for i, c in count.iteritems(): if float(c)*100/m == p: return i return Nonea = [1,2,4,4,4,1,8,-1,23,23]print appears(a, 10)
p% times ..question is not clear can U provide the algo or code for this
ReplyDeletedef appears(a, p):
ReplyDeletem = len(a)
count = {}
for i in a:
if count.has_key(i):
count[i] += 1
else:
count[i] = 1
for i, c in count.iteritems():
if float(c)*100/m == p:
return i
return None
a = [1,2,4,4,4,1,8,-1,23,23]
print appears(a, 10)