This file contains hidden or 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
| public class Graph { | |
| private int V; | |
| private int E; | |
| private Bag<Integer>[] adj; // adjacency list | |
| //create a V-vertex graph with no edges | |
| public void Graph(int V) { | |
| this.V = V; | |
| this.E = 0; | |
| adj = (Bag<Integer>[])new Bag[V]; |
This file contains hidden or 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
| <?php | |
| date_default_timezone_set('UTC'); | |
| echo '<html>'; | |
| $request=explode('/',$_SERVER['SCRIPT_NAME'],3); | |
| $log_url=$request[2]; | |
| if (empty($log_url)) { | |
| $upper="[email protected]/".date('o/m')."/"; | |
| $log_url="[email protected]/".date('o/m/d').".html"; | |
| }; | |
| $log = @file_get_contents("http://chatlogs.jabber.ru/${log_url}"); |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| check_results = { | |
| 5: """ | |
| 1 2 3 4 5 | |
| 16 17 18 19 6 | |
| 15 24 25 20 7 | |
| 14 23 22 21 8 | |
| 13 12 11 10 9""", | |
| 7: """ |
This file contains hidden or 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
| def flattener(l): | |
| """ | |
| flattener convert a list of lists to a flat list of values | |
| it is a recursive function: | |
| - outcase: a non-iterable value of l | |
| - body: iterate through sublists in l and extend the result of flattener(sublist) | |
| :param list l: a list of lists with any values | |
| :return: a flat list of values | |
| """ |
This file contains hidden or 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
| import sys | |
| import heapq | |
| from collections import Counter | |
| class Entry(object): | |
| def __init__(self, freq=0, char=None): | |
| self.freq = freq | |
| self.char = char | |
| if char is None: |
This file contains hidden or 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
| #include <cstddef> // size_t | |
| #include <cstring> | |
| struct String { | |
| String(const char *str = ""); | |
| String(size_t n, char c); | |
| ~String(); | |
| String(const String &other); |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import sys | |
| import math | |
| import itertools | |
| def degree2radian(deg): | |
| return deg * (math.pi / 180) | |
| def get_distance(x_a, y_a, x_b, y_b): | |
| return math.hypot(x_b - x_a, y_b - y_a) |
This file contains hidden or 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
| # 1. | |
| def left_anti(a: list, b: list) -> list: | |
| sa = set(a) # O(N_alogN_a) | |
| sb = set(b) # O(N_blogN_b) | |
| result = list(sa - sb) # O(N_a) | |
| return result # O((N_a+N_b)log(N_a+N_b)) -> O(NlogN) | |
| assert left_anti([1, 2, 3, None], [None]) == [1, 2, 3] | |
| assert left_anti([], [1, 2, 3]) == [] |
This file contains hidden or 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
| class ExampleMiddleware: | |
| # get_response это call-back | |
| def _init_(self, get_response): | |
| self.get_response = get_response | |
| def _call_(self, request): | |
| # Код, который будет вызываться для каждого request-а до вызова view-хи | |
| response = self.get_response(request) |
This file contains hidden or 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
| #!/usr/bin/env python | |
| """Django's command-line utility for administrative tasks.""" | |
| import os | |
| import sys | |
| def main(): | |
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'me.settings') | |
| try: | |
| from django.core.management import execute_from_command_line |