Skip to content

Instantly share code, notes, and snippets.

@rjshekar90
Created March 7, 2017 23:43
Show Gist options
  • Save rjshekar90/632ca47596224960391484e866479781 to your computer and use it in GitHub Desktop.
Save rjshekar90/632ca47596224960391484e866479781 to your computer and use it in GitHub Desktop.
from itertools import combinations
b=int(input())
a=input().split()
c=int(input())
a=''.join(sorted(a))
a_count=0
for i in combinations(a,c):
if 'a' in i:a_count+=1
print ("%0.3f" %(a_count/len(list(combinations(a,c)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment