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
package main | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"strings" |
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 random | |
import operator | |
random.seed() | |
A, B, N = map(int, input().split()) | |
# заполняем список случайными числами: | |
l = [random.randint(A, B) for i in range(N)] | |
# сортируем по неубыванию, возвращая список пар чисел (индекс, число) | |
m = sorted(enumerate(l), key=operator.itemgetter(1)) | |
# создаём список дистанций между отсортированными числами |
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 random | |
import collections | |
import operator | |
import itertools | |
random.seed() | |
l = [random.randint(1, 18) for i in range(8)] | |
#l = [4, 8, 18, 18, 10, 3, 11, 18] | |
print(*l) |
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
from pony import orm | |
db = orm.Database() | |
orm.set_sql_debug(True) | |
class Author(db.Entity): | |
name = orm.PrimaryKey(str) | |
books = orm.Set('Book') |
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
from random import randint | |
mylist = [randint(10,20) for x in range(randint(10,15))] | |
print(*mylist) | |
even = [x for x in enumerate(mylist) if x[1] % 2 == 0] | |
for i in zip((x[0] for x in even), sorted(x[1] for x in even)): | |
mylist[i[0]] = i[1] | |
print(*mylist) |
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
from functools import lru_cache | |
def timestr_to_tuple(s): | |
return tuple(int(x) for x in s.split(':')) | |
@lru_cache(maxsize=None) | |
def count(time, newtime): | |
x = min(abs(newtime[0] - time[0]), abs(newtime[0] + time[0] - 24)) + min( |
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 socket | |
import threading | |
addr = socket.gethostbyname(socket.gethostname()) | |
port = 22000 | |
srv_addr = (addr, port) | |
broadcast_addr = ".".join(addr.split('.')[:-1]) + '.255' | |
nport = 22001 | |
n_srv_addr = (broadcast_addr, port) |
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
''' | |
Программа для нахождения перебором решения задачи о 7-ми кенигсбергских мостах. | |
см. https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B0_%D0%BE_%D1%81%D0%B5%D0%BC%D0%B8_%D0%BA%D1%91%D0%BD%D0%B8%D0%B3%D1%81%D0%B1%D0%B5%D1%80%D0%B3%D1%81%D0%BA%D0%B8%D1%85_%D0%BC%D0%BE%D1%81%D1%82%D0%B0%D1%85 | |
Решения этой задачи не существует, что доказал Леонард Эйлер. | |
''' | |
bridges = ( | |
(1, 2), | |
(1, 2), |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
;; Set package repositories | |
(require 'package) | |
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")) | |
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | |
(package-initialize) | |
(eval-when-compile | |
(require 'use-package) | |
(require 'use-package-ensure)) |