Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d158f53

Browse files
Create Gemstones.py
1 parent aad7abf commit d158f53

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

‎String/Gemstones.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the gemstones function below.
10+
def unique(arr):
11+
G=[]
12+
for i in arr:
13+
if i not in G:
14+
G.append(i)
15+
return G
16+
def gemstones(arr):
17+
l=[]
18+
for j in arr:
19+
for i in unique(j):
20+
l.append(i)
21+
count=0
22+
v=unique(l)
23+
for k in v:
24+
if l.count(k)==len(arr):
25+
count+=1
26+
return count
27+
28+
29+
if __name__ == '__main__':
30+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
31+
32+
n = int(input())
33+
34+
arr = []
35+
36+
for _ in range(n):
37+
arr_item = input()
38+
arr.append(arr_item)
39+
40+
result = gemstones(arr)
41+
42+
fptr.write(str(result) + '\n')
43+
44+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /