-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
218 changed files
with
24,254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Certificates | ||
|
||
To get a certificate, two problems have to be solved within 90 minutes. | ||
|
||
The following is an incomplete list of possible problems per certificate as of 2021.09.15: | ||
|
||
- [Problem Solving (Basic)](problem-solving-basic) | ||
- [Active Traders](problem-solving-basic/active-traders) | ||
- [Balanced System Files Partition](problem-solving-basic/balanced-system-files-partition) | ||
- [Longest Subarray](problem-solving-basic/longest-subarray) | ||
- [Maximum Cost of Laptop Count](problem-solving-basic/maximum-cost-of-laptop-count) | ||
- [Nearly Similar Rectangles](problem-solving-basic/nearly-similar-rectangles) | ||
- [Parallel Processing](problem-solving-basic/parallel-processing) | ||
- [Password Decryption](problem-solving-basic/password-decryption) | ||
- [Road Repair](problem-solving-basic/road-repair) | ||
- [String Anagram](problem-solving-basic/string-anagram) | ||
- [Subarray Sums](problem-solving-basic/subarray-sums) | ||
- [Unexpected Demand](problem-solving-basic/unexpected-demand) | ||
- [Usernames Changes](problem-solving-basic/usernames-changes) | ||
- [Vowel Substring](problem-solving-basic/vowel-substring) | ||
- [Problem Solving (Intermediate)](problem-solving-intermediate) | ||
- [Bitwise AND](problem-solving-intermediate/bitwise-and) | ||
- [Equalizing Array Elements](problem-solving-intermediate/equalizing-array-elements) | ||
- [File Renaming](problem-solving-intermediate/file-renaming) | ||
- [Hotel Construction](problem-solving-intermediate/hotel-construction) | ||
- [Largest Area](problem-solving-intermediate/largest-area) | ||
- [Maximum Subarray Value](problem-solving-intermediate/maximum-subarray-value) | ||
- [Nice Teams](problem-solving-intermediate/nice-teams) | ||
- [Sorted Sums](problem-solving-intermediate/sorted-sums) | ||
- [Task of Pairing](problem-solving-intermediate/task-of-pairing) | ||
- [User-Friendly Password System](problem-solving-intermediate/user-friendly-password-system) | ||
|
||
Besides the solutions, there are Python 3 and C++ code stubs and some test cases so you can first try to solve the problems without time pressure if you want to. Keep in mind that most of this is uncommented code that just gets the job done. Nothing more. | ||
|
||
# TODO | ||
- Find more efficient solution for [Maximum Subarray Value](problem-solving-intermediate/maximum-subarray-value). It's getting timeouts for a few test cases. | ||
- Verify correctness of [Nice Teams](problem-solving-intermediate/nice-teams). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
certificates/problem-solving-basic/active-traders/solution.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/python3 | ||
|
||
import math | ||
import os | ||
import random | ||
import re | ||
import sys | ||
|
||
from collections import defaultdict | ||
|
||
# | ||
# Complete the 'mostActive' function below. | ||
# | ||
# The function is expected to return a STRING_ARRAY. | ||
# The function accepts STRING_ARRAY customers as parameter. | ||
# | ||
|
||
def mostActive(customers): | ||
d = defaultdict(int) | ||
for c in customers: | ||
d[c] += 1 | ||
return sorted([c for c, cnt in d.items() if cnt / len(customers) >= 0.05]) | ||
|
||
if __name__ == '__main__': | ||
fptr = open(os.environ['OUTPUT_PATH'], 'w') | ||
|
||
customers_count = int(input().strip()) | ||
|
||
customers = [] | ||
|
||
for _ in range(customers_count): | ||
customers_item = input() | ||
customers.append(customers_item) | ||
|
||
result = mostActive(customers) | ||
|
||
fptr.write('\n'.join(result)) | ||
fptr.write('\n') | ||
|
||
fptr.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
string ltrim(const string &); | ||
string rtrim(const string &); | ||
|
||
|
||
|
||
/* | ||
* Complete the 'mostActive' function below. | ||
* | ||
* The function is expected to return a STRING_ARRAY. | ||
* The function accepts STRING_ARRAY customers as parameter. | ||
*/ | ||
|
||
vector<string> mostActive(vector<string> customers) { | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
ofstream fout(getenv("OUTPUT_PATH")); | ||
|
||
string customers_count_temp; | ||
getline(cin, customers_count_temp); | ||
|
||
int customers_count = stoi(ltrim(rtrim(customers_count_temp))); | ||
|
||
vector<string> customers(customers_count); | ||
|
||
for (int i = 0; i < customers_count; i++) { | ||
string customers_item; | ||
getline(cin, customers_item); | ||
|
||
customers[i] = customers_item; | ||
} | ||
|
||
vector<string> result = mostActive(customers); | ||
|
||
for (int i = 0; i < result.size(); i++) { | ||
fout << result[i]; | ||
|
||
if (i != result.size() - 1) { | ||
fout << "\n"; | ||
} | ||
} | ||
|
||
fout << "\n"; | ||
|
||
fout.close(); | ||
|
||
return 0; | ||
} | ||
|
||
string ltrim(const string &str) { | ||
string s(str); | ||
|
||
s.erase( | ||
s.begin(), | ||
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))) | ||
); | ||
|
||
return s; | ||
} | ||
|
||
string rtrim(const string &str) { | ||
string s(str); | ||
|
||
s.erase( | ||
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), | ||
s.end() | ||
); | ||
|
||
return s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/python3 | ||
|
||
import math | ||
import os | ||
import random | ||
import re | ||
import sys | ||
|
||
|
||
|
||
# | ||
# Complete the 'mostActive' function below. | ||
# | ||
# The function is expected to return a STRING_ARRAY. | ||
# The function accepts STRING_ARRAY customers as parameter. | ||
# | ||
|
||
def mostActive(customers): | ||
# Write your code here | ||
pass | ||
|
||
if __name__ == '__main__': | ||
fptr = open(os.environ['OUTPUT_PATH'], 'w') | ||
|
||
customers_count = int(input().strip()) | ||
|
||
customers = [] | ||
|
||
for _ in range(customers_count): | ||
customers_item = input() | ||
customers.append(customers_item) | ||
|
||
result = mostActive(customers) | ||
|
||
fptr.write('\n'.join(result)) | ||
fptr.write('\n') | ||
|
||
fptr.close() |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input000.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Alpha | ||
Omega | ||
Beta |
22 changes: 22 additions & 0 deletions
22
certificates/problem-solving-basic/active-traders/test-cases/input001.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
21 | ||
Alpha | ||
Beta | ||
Zeta | ||
Beta | ||
Zeta | ||
Zeta | ||
Epsilon | ||
Beta | ||
Zeta | ||
Beta | ||
Zeta | ||
Beta | ||
Delta | ||
Zeta | ||
Beta | ||
Zeta | ||
Beta | ||
Zeta | ||
Beta | ||
Zeta | ||
Beta |
25 changes: 25 additions & 0 deletions
25
certificates/problem-solving-basic/active-traders/test-cases/input002.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
24 | ||
Dog | ||
Goes | ||
Woof | ||
Cat | ||
Goes | ||
Meow | ||
Bird | ||
Goes | ||
Tweet | ||
And | ||
Mouse | ||
Goes | ||
Squeek | ||
Cow | ||
Goes | ||
Moo | ||
Frog | ||
Goes | ||
Croak | ||
And | ||
The | ||
Elephant | ||
Goes | ||
Toot |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input003.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Bey | ||
Ddtlcouegmdbyfwu | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ddtlcouegmdbyfwu | ||
Ddtlcouegmdbyfwu | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ddtlcouegmdbyfwu | ||
Ppuvhifnuap | ||
Ddtlcouegmdbyfwu | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap | ||
Ppuvhifnuap |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input004.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Bfeo | ||
Xjgwxtrxi | ||
Pnnpmud | ||
Pnnpmud | ||
Xjgwxtrxi | ||
Wdswxxrx | ||
Wdswxxrx | ||
Xjgwxtrxi | ||
Wdswxxrx | ||
Xjgwxtrxi | ||
Pnnpmud | ||
Wdswxxrx | ||
Xjgwxtrxi | ||
Wdswxxrx | ||
Xjgwxtrxi | ||
Xjgwxtrxi | ||
Wdswxxrx | ||
Wdswxxrx | ||
Xjgwxtrxi | ||
Xjgwxtrxi |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input005.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Ampprswkdkobdagw | ||
Wcfa | ||
Zooot | ||
Zn | ||
Zooot | ||
Wufeesrvn | ||
Zn | ||
Xillkfdvpfpxabqlngd | ||
Zn | ||
Zn | ||
Qvwdrm | ||
Zn | ||
Zooot | ||
Qvwdrm | ||
Zooot | ||
Zn | ||
Zn | ||
Zooot | ||
Xillkfdvpfpxabqlngd | ||
Rskcw |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input006.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Exouyfjhnwp | ||
Van | ||
Tanwwyoosxtnex | ||
Omkfnkswrawkjxw | ||
Zskzazjqtlkiqydpt | ||
Omkfnkswrawkjxw | ||
Van | ||
Sndpvannrywfrnrghlj | ||
Tanwwyoosxtnex | ||
Van | ||
Qpxnlkcwdpdksw | ||
Qpxnlkcwdpdksw | ||
Tanwwyoosxtnex | ||
Zskzazjqtlkiqydpt | ||
Sndpvannrywfrnrghlj | ||
Zskzazjqtlkiqydpt | ||
Tanwwyoosxtnex | ||
Sndpvannrywfrnrghlj | ||
Van | ||
Zskzazjqtlkiqydpt |
21 changes: 21 additions & 0 deletions
21
certificates/problem-solving-basic/active-traders/test-cases/input007.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
20 | ||
Ami | ||
Wuxavlwftgyxxhpygs | ||
Wk | ||
Vwfnbngh | ||
Wmzheqx | ||
Wuxavlwftgyxxhpygs | ||
Oxhaiafmvkb | ||
Wk | ||
Wuxavlwftgyxxhpygs | ||
Wmzheqx | ||
Vwfnbngh | ||
Vwfnbngh | ||
Wmzheqx | ||
Ocni | ||
Xjmornquma | ||
Wmzheqx | ||
Xjmornquma | ||
Ltpwmhqw | ||
Wk | ||
Ocni |
Oops, something went wrong.