Skip to content

Commit 22591bc

Browse files
Python --> set(completed)
1 parent e06a64a commit 22591bc

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

HackerRank/Python/set/Untitled.ipynb

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,143 @@
4343
"source": [
4444
"# [No Idea!](https://www.hackerrank.com/challenges/no-idea/problem)"
4545
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": 12,
50+
"metadata": {},
51+
"outputs": [
52+
{
53+
"name": "stdin",
54+
"output_type": "stream",
55+
"text": [
56+
" 3 2\n",
57+
" 1 5 3\n",
58+
" 3 1\n",
59+
" 5 7\n"
60+
]
61+
},
62+
{
63+
"name": "stdout",
64+
"output_type": "stream",
65+
"text": [
66+
"0\n"
67+
]
68+
}
69+
],
70+
"source": [
71+
"a1,a2=input().split()\n",
72+
"a=input().split()\n",
73+
"set_1=set(input().split())\n",
74+
"set_2=set(input().split())\n",
75+
"# print(abs(len(a&set_1)-len(a&set_2)))\n",
76+
"print(sum([(i in set_1)-(i in set_2) for i in a]))"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 19,
82+
"metadata": {},
83+
"outputs": [
84+
{
85+
"data": {
86+
"text/plain": [
87+
"['1', '5', '3']"
88+
]
89+
},
90+
"execution_count": 19,
91+
"metadata": {},
92+
"output_type": "execute_result"
93+
}
94+
],
95+
"source": [
96+
"a"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": 14,
102+
"metadata": {},
103+
"outputs": [
104+
{
105+
"data": {
106+
"text/plain": [
107+
"{'1', '3'}"
108+
]
109+
},
110+
"execution_count": 14,
111+
"metadata": {},
112+
"output_type": "execute_result"
113+
}
114+
],
115+
"source": [
116+
"set_1"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 15,
122+
"metadata": {},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"{'5', '7'}"
128+
]
129+
},
130+
"execution_count": 15,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"set_2"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": 24,
142+
"metadata": {},
143+
"outputs": [
144+
{
145+
"data": {
146+
"text/plain": [
147+
"1"
148+
]
149+
},
150+
"execution_count": 24,
151+
"metadata": {},
152+
"output_type": "execute_result"
153+
}
154+
],
155+
"source": []
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": 22,
160+
"metadata": {},
161+
"outputs": [
162+
{
163+
"data": {
164+
"text/plain": [
165+
"[False, True, False]"
166+
]
167+
},
168+
"execution_count": 22,
169+
"metadata": {},
170+
"output_type": "execute_result"
171+
}
172+
],
173+
"source": [
174+
"[(i in set_2) for i in a]"
175+
]
176+
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": null,
180+
"metadata": {},
181+
"outputs": [],
182+
"source": []
46183
}
47184
],
48185
"metadata": {

0 commit comments

Comments
 (0)