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 70ced89

Browse files
update
1 parent 2c8de55 commit 70ced89

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
read -p "Enter the expression: " exp
2+
printf "%.3f" $(echo $exp | bc -l)

‎algorithms/21_sock-merchant.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
#
10+
# Complete the 'sockMerchant' function below.
11+
#
12+
# The function is expected to return an INTEGER.
13+
# The function accepts following parameters:
14+
# 1. INTEGER n
15+
# 2. INTEGER_ARRAY ar
16+
#
17+
18+
def sockMerchant(n, ar):
19+
# Write your code here
20+
my_dict = {i:ar.count(i) for i in ar}
21+
rem = 0
22+
for i in my_dict.values():
23+
rem += i//2
24+
return rem
25+
26+
27+
if __name__ == '__main__':
28+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
29+
30+
n = int(input().strip())
31+
32+
ar = list(map(int, input().rstrip().split()))
33+
34+
result = sockMerchant(n, ar)
35+
36+
fptr.write(str(result) + '\n')
37+
38+
fptr.close()

0 commit comments

Comments
(0)

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