diff options
Diffstat (limited to 'codechef')
-rwxr-xr-x | codechef/chdiger.py | 14 | ||||
-rwxr-xr-x | codechef/chnum.py | 7 | ||||
-rw-r--r-- | codechef/jain.c | 33 | ||||
-rwxr-xr-x | codechef/jain.py | 6 |
4 files changed, 60 insertions, 0 deletions
diff --git a/codechef/chdiger.py b/codechef/chdiger.py new file mode 100755 index 0000000..a3c83fb --- /dev/null +++ b/codechef/chdiger.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +for _ in range(int(input())): + n, d = input().split() + n, d = [int(x) for x in n], int(d) + for i in range(-1, -1-len(n), -1): + if n[i] > d: + n[i] = d + else: + break + for i in range(i, -len(n), -1): + if n[i] < n[i-1]: + n.pop(i - 1) + n.append(d) + print(''.join(map(str, n))) diff --git a/codechef/chnum.py b/codechef/chnum.py new file mode 100755 index 0000000..95bad50 --- /dev/null +++ b/codechef/chnum.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +from collections import Counter + +for _ in range(int(input())): + input() + sizes = Counter(z // abs(z) for z in map(int, input().split())).values() + print(max(sizes), min(sizes)) diff --git a/codechef/jain.c b/codechef/jain.c new file mode 100644 index 0000000..6471e93 --- /dev/null +++ b/codechef/jain.c @@ -0,0 +1,33 @@ +#include <stdio.h> + +const char VOWELS[] = {97, 101, 105, 111, 117}; + +int main() +{ + char *c, s[1001]; + long t, n, i, j, tmp; + + scanf("%ld", &t); + while (t--) { + long vowels[32] = {}; + + scanf("%ld", &n); + for (i = 0; i < n; ++i) { + tmp = 0; + scanf("%s", &s); + for (c = s; *c; ++c) { + for (j = 0; VOWELS[j] ^ *c; ++j); + tmp |= 1 << j; + } + ++vowels[tmp]; + } + + tmp = vowels[31] * (vowels[31] - 1) / 2; + for (i = 0; i < 31; ++i) + for (j = i + 1; j < 32; ++j) + tmp += ((i | j) == 31) * vowels[i] * vowels[j]; + printf("%ld\n", tmp); + } + + return 0; +} diff --git a/codechef/jain.py b/codechef/jain.py new file mode 100755 index 0000000..8601072 --- /dev/null +++ b/codechef/jain.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +from itertools import combinations + +for _ in range(int(input())): + print(sum(len(a | b) == 5 for a, b in combinations( + (set(input()) for d in range(int(input()))), 2))) |