content
stringlengths
7
1.05M
class Rocket: def calc_fuel_weight(self, weight): weight = int(weight) return int(weight / 3) - 2 def calc_fuel_weight_recursive(self, weight): weight = int(weight) # This time with recursion for fuel weight total = self.calc_fuel_weight(weight) fuelweight = self.calc_fuel_weight(total) while fuelweight > 0: total = total + fuelweight fuelweight = self.calc_fuel_weight(fuelweight) return total
def captial(string): strs = string.title() return strs n = input() n = captial(n) print(n)
''' Copyright (c) 2012-2021 Roel Derickx, Paul Norman <penorman@mac.com>, Sebastiaan Couwenberg <sebastic@xs4all.nl>, The University of Vermont <andrew.guertin@uvm.edu>, github contributors Released under the MIT license, as given in the file LICENSE, which must accompany any distribution of this code. ''' __author__ = "Roel Derickx" __program__ = "ogr2osm" __version__ = "1.1.1" __license__ = "MIT License"
streams_dict = {} def session_established(session): # When a WebTransport session is established, a bidirectional stream is # created by the server, which is used to echo back stream data from the # client. session.create_bidirectional_stream() def stream_data_received(session, stream_id: int, data: bytes, stream_ended: bool): # If a stream is unidirectional, create a new unidirectional stream and echo # back the data on that stream. if session.stream_is_unidirectional(stream_id): if (session.session_id, stream_id) not in streams_dict.keys(): new_stream_id = session.create_unidirectional_stream() streams_dict[(session.session_id, stream_id)] = new_stream_id session.send_stream_data(streams_dict[(session.session_id, stream_id)], data, end_stream=stream_ended) if (stream_ended): del streams_dict[(session.session_id, stream_id)] return # Otherwise (e.g. if the stream is bidirectional), echo back the data on the # same stream. session.send_stream_data(stream_id, data, end_stream=stream_ended) def datagram_received(session, data: bytes): session.send_datagram(data)
""" Политическая жизнь одной страны очень оживленная. В стране действует K политических партий, каждая из которых регулярно объявляет национальную забастовку. Дни, когда хотя бы одна из партий объявляет забастовку, при условии, что это не суббота или воскресенье (когда и так никто не работает), наносят большой ущерб экономике страны. i-я партия объявляет забастовки строго каждые bᵢ дней, начиная с дня с номером aᵢ. То есть i-я партия объявляет забастовки в дни aᵢ, aᵢ+bᵢ, aᵢ+2bᵢ и т.д. Если в какой-то день несколько партий объявляет забастовку, то это считается одной общенациональной забастовкой. В календаре страны N дней, пронумерованных от 1 до N. Первый день года является понедельником, шестой и седьмой дни года — выходные, неделя состоит из семи дней. Формат ввода Программа получает на вход число дней в году N (1≤N≤10⁶) и число политических партий K (1≤K≤100). Далее идет K строк, описывающие графики проведения забастовок.i-я строка содержит числа aᵢ и bᵢ (1≤aᵢ,bᵢ≤N). Формат вывода Выведите единственное число: количество забастовок, произошедших в течение года. Примечания Первая партия объявляет забастовки в дни 2, 5, 8, 11, 14, 17. Вторая партия объявляет забастовки в дни 3, 8, 13, 18. Третья партия — в дни 9 и 17. Дни номер 6, 7, 13, 14 являются выходными. Таким образом, забастовки пройдут в дни 2, 3, 5, 8, 9, 11, 17, 18. """ n, k = map(int, input().split()) a, b = map(int, input().split()) mySet = set(range(a, n + 1, b)) for i in range(1, k): a, b = map(int, input().split()) firstSet = set(range(a, n + 1, b)) mySet |= firstSet satSet = set(range(6, n + 1, 7)) sunSet = set(range(7, n + 1, 7)) print(len(mySet - (satSet | sunSet)))
"""gcam_cerf_expansion Generate an electricity capacity expansion plan from GCAM-USA in the format utilized by CERF. License: BSD 2-Clause, see LICENSE and DISCLAIMER files """ def gcam_cerf_expansion(a, b): """Generate an electricity capacity expansion plan from GCAM-USA in the format utilized by CERF.""" return a + b
n = int(input()) c = int(input()) numbers = [] for i in range(n): numbers.append(int(input())) if sum(numbers) < c: print("IMPOSSIBLE") else: while sum(numbers) > c: numbers[numbers.index(max(numbers))] -= 1 for number in sorted(numbers): print(number)
def change(age,*som): print(age) for i in som: print(i) return change(12,'name','year','mon','address') change('a1','b1') change('a2','b2',11)
FreeMono18pt7bBitmaps = [ 0x27, 0x77, 0x77, 0x77, 0x77, 0x22, 0x22, 0x20, 0x00, 0x6F, 0xF6, 0xF1, 0xFE, 0x3F, 0xC7, 0xF8, 0xFF, 0x1E, 0xC3, 0x98, 0x33, 0x06, 0x60, 0xCC, 0x18, 0x04, 0x20, 0x10, 0x80, 0x42, 0x01, 0x08, 0x04, 0x20, 0x10, 0x80, 0x42, 0x01, 0x10, 0x04, 0x41, 0xFF, 0xF0, 0x44, 0x02, 0x10, 0x08, 0x40, 0x21, 0x0F, 0xFF, 0xC2, 0x10, 0x08, 0x40, 0x21, 0x00, 0x84, 0x02, 0x10, 0x08, 0x40, 0x23, 0x00, 0x88, 0x02, 0x20, 0x02, 0x00, 0x10, 0x00, 0x80, 0x1F, 0xA3, 0x07, 0x10, 0x09, 0x00, 0x48, 0x00, 0x40, 0x03, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x1E, 0x00, 0x18, 0x00, 0x20, 0x01, 0x80, 0x0C, 0x00, 0x70, 0x05, 0xE0, 0xC9, 0xF8, 0x01, 0x00, 0x08, 0x00, 0x40, 0x02, 0x00, 0x10, 0x00, 0x1E, 0x00, 0x42, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x08, 0x40, 0x0F, 0x00, 0x00, 0x1E, 0x01, 0xF0, 0x1F, 0x01, 0xE0, 0x0E, 0x00, 0x00, 0x3C, 0x00, 0x86, 0x02, 0x06, 0x04, 0x04, 0x08, 0x08, 0x10, 0x30, 0x10, 0xC0, 0x1E, 0x00, 0x0F, 0xC1, 0x00, 0x20, 0x02, 0x00, 0x20, 0x02, 0x00, 0x10, 0x01, 0x00, 0x08, 0x03, 0xC0, 0x6C, 0x3C, 0x62, 0x82, 0x68, 0x34, 0x81, 0xCC, 0x08, 0x61, 0xC3, 0xE7, 0xFF, 0xFF, 0xF6, 0x66, 0x66, 0x08, 0xC4, 0x62, 0x31, 0x8C, 0xC6, 0x31, 0x8C, 0x63, 0x18, 0xC3, 0x18, 0xC2, 0x18, 0xC3, 0x18, 0x86, 0x10, 0xC2, 0x18, 0xC6, 0x10, 0xC6, 0x31, 0x8C, 0x63, 0x18, 0x8C, 0x62, 0x31, 0x98, 0x80, 0x02, 0x00, 0x10, 0x00, 0x80, 0x04, 0x0C, 0x21, 0x9D, 0x70, 0x1C, 0x00, 0xA0, 0x0D, 0x80, 0xC6, 0x04, 0x10, 0x40, 0x80, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0xFF, 0xFE, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x3E, 0x78, 0xF3, 0xC7, 0x8E, 0x18, 0x70, 0xC1, 0x80, 0xFF, 0xFE, 0x77, 0xFF, 0xF7, 0x00, 0x00, 0x08, 0x00, 0xC0, 0x04, 0x00, 0x60, 0x02, 0x00, 0x30, 0x01, 0x00, 0x18, 0x00, 0x80, 0x0C, 0x00, 0x40, 0x02, 0x00, 0x20, 0x01, 0x00, 0x10, 0x00, 0x80, 0x08, 0x00, 0x40, 0x04, 0x00, 0x20, 0x02, 0x00, 0x10, 0x01, 0x00, 0x08, 0x00, 0x80, 0x04, 0x00, 0x00, 0x0F, 0x81, 0x82, 0x08, 0x08, 0x80, 0x24, 0x01, 0x60, 0x0E, 0x00, 0x30, 0x01, 0x80, 0x0C, 0x00, 0x60, 0x03, 0x00, 0x18, 0x00, 0xC0, 0x06, 0x00, 0x30, 0x03, 0x40, 0x12, 0x00, 0x88, 0x08, 0x60, 0xC0, 0xF8, 0x00, 0x06, 0x00, 0x70, 0x06, 0x80, 0x64, 0x06, 0x20, 0x31, 0x00, 0x08, 0x00, 0x40, 0x02, 0x00, 0x10, 0x00, 0x80, 0x04, 0x00, 0x20, 0x01, 0x00, 0x08, 0x00, 0x40, 0x02, 0x00, 0x10, 0x00, 0x80, 0x04, 0x0F, 0xFF, 0x80, 0x0F, 0x80, 0xC3, 0x08, 0x04, 0x80, 0x24, 0x00, 0x80, 0x04, 0x00, 0x20, 0x02, 0x00, 0x10, 0x01, 0x00, 0x10, 0x01, 0x80, 0x18, 0x01, 0x80, 0x18, 0x01, 0x80, 0x18, 0x01, 0x80, 0x58, 0x03, 0x80, 0x1F, 0xFF, 0x80, 0x0F, 0xC0, 0xC0, 0x86, 0x01, 0x00, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x04, 0x00, 0x20, 0x0F, 0x00, 0x06, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x40, 0x01, 0x00, 0x04, 0x00, 0x2C, 0x01, 0x9C, 0x0C, 0x0F, 0xC0, 0x01, 0xC0, 0x14, 0x02, 0x40, 0x64, 0x04, 0x40, 0xC4, 0x08, 0x41, 0x84, 0x10, 0x42, 0x04, 0x20, 0x44, 0x04, 0x40, 0x48, 0x04, 0xFF, 0xF0, 0x04, 0x00, 0x40, 0x04, 0x00, 0x40, 0x04, 0x07, 0xF0, 0x3F, 0xF0, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x0B, 0xF0, 0x30, 0x30, 0x00, 0x60, 0x00, 0x80, 0x01, 0x00, 0x04, 0x00, 0x10, 0x00, 0x40, 0x01, 0x00, 0x0E, 0x00, 0x2C, 0x01, 0x0C, 0x18, 0x0F, 0xC0, 0x01, 0xF0, 0x60, 0x18, 0x03, 0x00, 0x20, 0x04, 0x00, 0x40, 0x0C, 0x00, 0x80, 0x08, 0xF8, 0x98, 0x4A, 0x02, 0xE0, 0x3C, 0x01, 0x80, 0x14, 0x01, 0x40, 0x14, 0x03, 0x20, 0x21, 0x0C, 0x0F, 0x80, 0xFF, 0xF8, 0x01, 0x80, 0x18, 0x03, 0x00, 0x20, 0x02, 0x00, 0x20, 0x04, 0x00, 0x40, 0x04, 0x00, 0xC0, 0x08, 0x00, 0x80, 0x18, 0x01, 0x00, 0x10, 0x01, 0x00, 0x30, 0x02, 0x00, 0x20, 0x02, 0x00, 0x0F, 0x81, 0x83, 0x10, 0x05, 0x80, 0x38, 0x00, 0xC0, 0x06, 0x00, 0x30, 0x03, 0x40, 0x11, 0x83, 0x07, 0xF0, 0x60, 0xC4, 0x01, 0x60, 0x0E, 0x00, 0x30, 0x01, 0x80, 0x0E, 0x00, 0xD0, 0x04, 0x60, 0xC1, 0xFC, 0x00, 0x1F, 0x03, 0x08, 0x40, 0x4C, 0x02, 0x80, 0x28, 0x02, 0x80, 0x18, 0x03, 0xC0, 0x74, 0x05, 0x21, 0x91, 0xF1, 0x00, 0x10, 0x03, 0x00, 0x20, 0x02, 0x00, 0x40, 0x0C, 0x01, 0x80, 0x60, 0xF8, 0x00, 0x77, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x1D, 0xFF, 0xFD, 0xC0, 0x1C, 0x7C, 0xF9, 0xF1, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xE3, 0x8F, 0x1C, 0x38, 0xE1, 0xC3, 0x06, 0x00, 0x00, 0x06, 0x00, 0x18, 0x00, 0xE0, 0x07, 0x00, 0x38, 0x01, 0xC0, 0x06, 0x00, 0x38, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFC, 0xC0, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x70, 0x03, 0x80, 0x0C, 0x00, 0x70, 0x03, 0x80, 0x1C, 0x00, 0x60, 0x00, 0x3F, 0x8E, 0x0C, 0x80, 0x28, 0x01, 0x80, 0x10, 0x01, 0x00, 0x10, 0x02, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x01, 0xF0, 0x1F, 0x00, 0xE0, 0x0F, 0x01, 0x86, 0x08, 0x08, 0x80, 0x24, 0x01, 0x40, 0x0A, 0x00, 0x50, 0x1E, 0x83, 0x14, 0x20, 0xA2, 0x05, 0x10, 0x28, 0x81, 0x46, 0x0A, 0x18, 0x50, 0x3F, 0x80, 0x04, 0x00, 0x10, 0x00, 0x80, 0x02, 0x00, 0x18, 0x18, 0x3F, 0x00, 0x1F, 0xF0, 0x00, 0x06, 0x80, 0x00, 0x34, 0x00, 0x01, 0x30, 0x00, 0x18, 0x80, 0x00, 0x86, 0x00, 0x04, 0x30, 0x00, 0x60, 0x80, 0x02, 0x06, 0x00, 0x10, 0x10, 0x01, 0x80, 0x80, 0x08, 0x06, 0x00, 0x7F, 0xF0, 0x06, 0x00, 0x80, 0x20, 0x06, 0x01, 0x00, 0x10, 0x18, 0x00, 0xC0, 0x80, 0x06, 0x04, 0x00, 0x11, 0xFC, 0x0F, 0xF0, 0xFF, 0xF8, 0x04, 0x01, 0x01, 0x00, 0x20, 0x40, 0x04, 0x10, 0x01, 0x04, 0x00, 0x41, 0x00, 0x10, 0x40, 0x08, 0x10, 0x0C, 0x07, 0xFF, 0x01, 0x00, 0x70, 0x40, 0x06, 0x10, 0x00, 0x84, 0x00, 0x11, 0x00, 0x04, 0x40, 0x01, 0x10, 0x00, 0x44, 0x00, 0x21, 0x00, 0x33, 0xFF, 0xF8, 0x03, 0xF1, 0x06, 0x0E, 0x8C, 0x01, 0xC4, 0x00, 0x64, 0x00, 0x12, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x20, 0x01, 0x88, 0x01, 0x83, 0x03, 0x80, 0x7E, 0x00, 0xFF, 0xE0, 0x20, 0x18, 0x20, 0x0C, 0x20, 0x04, 0x20, 0x02, 0x20, 0x02, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x02, 0x20, 0x02, 0x20, 0x04, 0x20, 0x0C, 0x20, 0x18, 0xFF, 0xE0, 0xFF, 0xFF, 0x08, 0x00, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00, 0x10, 0x80, 0x00, 0x40, 0x00, 0x20, 0x40, 0x10, 0x20, 0x0F, 0xF0, 0x04, 0x08, 0x02, 0x04, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x02, 0x20, 0x01, 0x10, 0x00, 0x88, 0x00, 0x44, 0x00, 0x3F, 0xFF, 0xF0, 0xFF, 0xFF, 0x88, 0x00, 0x44, 0x00, 0x22, 0x00, 0x11, 0x00, 0x08, 0x80, 0x00, 0x40, 0x00, 0x20, 0x40, 0x10, 0x20, 0x0F, 0xF0, 0x04, 0x08, 0x02, 0x04, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x1F, 0xF8, 0x00, 0x03, 0xF9, 0x06, 0x07, 0x84, 0x00, 0xC4, 0x00, 0x24, 0x00, 0x12, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x0F, 0xF8, 0x00, 0x14, 0x00, 0x09, 0x00, 0x04, 0x80, 0x02, 0x20, 0x01, 0x18, 0x00, 0x83, 0x01, 0xC0, 0x7F, 0x00, 0xFC, 0x3F, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x3F, 0xFC, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0xFC, 0x3F, 0xFF, 0xF8, 0x10, 0x00, 0x80, 0x04, 0x00, 0x20, 0x01, 0x00, 0x08, 0x00, 0x40, 0x02, 0x00, 0x10, 0x00, 0x80, 0x04, 0x00, 0x20, 0x01, 0x00, 0x08, 0x00, 0x40, 0x02, 0x00, 0x10, 0x00, 0x81, 0xFF, 0xF0, 0x03, 0xFF, 0x80, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x10, 0x01, 0x08, 0x00, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00, 0x10, 0x80, 0x10, 0x20, 0x18, 0x0C, 0x18, 0x01, 0xF0, 0x00, 0xFF, 0x1F, 0x84, 0x01, 0x81, 0x00, 0xC0, 0x40, 0x60, 0x10, 0x30, 0x04, 0x18, 0x01, 0x0C, 0x00, 0x46, 0x00, 0x13, 0x00, 0x05, 0xF0, 0x01, 0xC6, 0x00, 0x60, 0xC0, 0x10, 0x18, 0x04, 0x06, 0x01, 0x00, 0xC0, 0x40, 0x30, 0x10, 0x04, 0x04, 0x01, 0x81, 0x00, 0x23, 0xFC, 0x0F, 0xFF, 0x80, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x42, 0x00, 0x84, 0x01, 0x08, 0x02, 0x10, 0x04, 0x20, 0x0F, 0xFF, 0xF0, 0xF0, 0x01, 0xE7, 0x00, 0x70, 0xA0, 0x0A, 0x16, 0x03, 0x42, 0x40, 0x48, 0x4C, 0x19, 0x08, 0x82, 0x21, 0x10, 0x44, 0x23, 0x18, 0x84, 0x22, 0x10, 0x86, 0xC2, 0x10, 0x50, 0x42, 0x0E, 0x08, 0x41, 0xC1, 0x08, 0x00, 0x21, 0x00, 0x04, 0x20, 0x00, 0x84, 0x00, 0x10, 0x80, 0x02, 0x7F, 0x03, 0xF0, 0xF8, 0x1F, 0xC6, 0x00, 0x41, 0xC0, 0x10, 0x50, 0x04, 0x12, 0x01, 0x04, 0xC0, 0x41, 0x10, 0x10, 0x46, 0x04, 0x10, 0x81, 0x04, 0x10, 0x41, 0x04, 0x10, 0x40, 0x84, 0x10, 0x31, 0x04, 0x04, 0x41, 0x01, 0x90, 0x40, 0x24, 0x10, 0x05, 0x04, 0x01, 0xC1, 0x00, 0x31, 0xFC, 0x0C, 0x03, 0xE0, 0x06, 0x0C, 0x04, 0x01, 0x04, 0x00, 0x46, 0x00, 0x32, 0x00, 0x0B, 0x00, 0x05, 0x00, 0x01, 0x80, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00, 0x0E, 0x00, 0x0D, 0x00, 0x04, 0xC0, 0x06, 0x20, 0x02, 0x08, 0x02, 0x03, 0x06, 0x00, 0x7C, 0x00, 0xFF, 0xF0, 0x10, 0x0C, 0x10, 0x02, 0x10, 0x03, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x03, 0x10, 0x06, 0x10, 0x0C, 0x1F, 0xF0, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xFF, 0xC0, 0x03, 0xE0, 0x06, 0x0C, 0x04, 0x01, 0x04, 0x00, 0x46, 0x00, 0x32, 0x00, 0x0B, 0x00, 0x07, 0x00, 0x01, 0x80, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00, 0x0E, 0x00, 0x0D, 0x00, 0x04, 0xC0, 0x06, 0x20, 0x02, 0x08, 0x02, 0x03, 0x06, 0x00, 0xFC, 0x00, 0x30, 0x00, 0x30, 0x00, 0x7F, 0xC6, 0x38, 0x1E, 0xFF, 0xF0, 0x02, 0x01, 0x80, 0x40, 0x08, 0x08, 0x01, 0x81, 0x00, 0x10, 0x20, 0x02, 0x04, 0x00, 0x40, 0x80, 0x18, 0x10, 0x06, 0x02, 0x03, 0x80, 0x7F, 0xC0, 0x08, 0x18, 0x01, 0x01, 0x80, 0x20, 0x18, 0x04, 0x01, 0x80, 0x80, 0x10, 0x10, 0x03, 0x02, 0x00, 0x20, 0x40, 0x06, 0x7F, 0x80, 0x70, 0x0F, 0xC8, 0x61, 0xE2, 0x01, 0x90, 0x02, 0x40, 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x38, 0x00, 0x3E, 0x00, 0x0F, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x60, 0x01, 0x80, 0x0F, 0x00, 0x2B, 0x03, 0x23, 0xF0, 0xFF, 0xFF, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x18, 0x10, 0x20, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x02, 0x00, 0x04, 0x01, 0xFF, 0xC0, 0xFC, 0x1F, 0x90, 0x01, 0x08, 0x00, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00, 0x10, 0x80, 0x08, 0x40, 0x04, 0x20, 0x02, 0x10, 0x01, 0x08, 0x00, 0x84, 0x00, 0x42, 0x00, 0x21, 0x00, 0x10, 0x80, 0x08, 0x40, 0x04, 0x10, 0x04, 0x0C, 0x06, 0x03, 0x06, 0x00, 0x7C, 0x00, 0xFE, 0x03, 0xF8, 0x80, 0x02, 0x04, 0x00, 0x10, 0x30, 0x01, 0x80, 0x80, 0x08, 0x06, 0x00, 0xC0, 0x30, 0x06, 0x00, 0x80, 0x20, 0x06, 0x03, 0x00, 0x30, 0x10, 0x00, 0x80, 0x80, 0x06, 0x0C, 0x00, 0x10, 0x40, 0x00, 0x86, 0x00, 0x06, 0x20, 0x00, 0x11, 0x00, 0x00, 0xD8, 0x00, 0x06, 0x80, 0x00, 0x1C, 0x00, 0x00, 0xE0, 0x00, 0xFC, 0x0F, 0xE8, 0x00, 0x19, 0x00, 0x03, 0x10, 0x00, 0x62, 0x00, 0x08, 0x41, 0x81, 0x08, 0x28, 0x21, 0x05, 0x04, 0x21, 0xA0, 0x84, 0x36, 0x30, 0x84, 0x46, 0x08, 0x88, 0xC1, 0x31, 0x18, 0x24, 0x12, 0x04, 0x82, 0x40, 0xB0, 0x48, 0x14, 0x09, 0x02, 0x80, 0xA0, 0x30, 0x1C, 0x06, 0x03, 0x80, 0x7E, 0x0F, 0xC2, 0x00, 0x60, 0x60, 0x0C, 0x06, 0x03, 0x00, 0x60, 0xC0, 0x0C, 0x10, 0x00, 0xC6, 0x00, 0x0D, 0x80, 0x00, 0xA0, 0x00, 0x1C, 0x00, 0x03, 0x80, 0x00, 0xD8, 0x00, 0x11, 0x00, 0x06, 0x30, 0x01, 0x83, 0x00, 0x60, 0x30, 0x08, 0x06, 0x03, 0x00, 0x60, 0xC0, 0x06, 0x7F, 0x07, 0xF0, 0xFC, 0x1F, 0x98, 0x03, 0x04, 0x01, 0x03, 0x01, 0x80, 0xC1, 0x80, 0x20, 0x80, 0x18, 0xC0, 0x04, 0x40, 0x03, 0x60, 0x00, 0xE0, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x03, 0xFF, 0x80, 0xFF, 0xF4, 0x00, 0xA0, 0x09, 0x00, 0x48, 0x04, 0x40, 0x40, 0x02, 0x00, 0x20, 0x02, 0x00, 0x10, 0x01, 0x00, 0x10, 0x00, 0x80, 0x08, 0x04, 0x80, 0x24, 0x01, 0x40, 0x0C, 0x00, 0x60, 0x03, 0xFF, 0xF0, 0xFC, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0xF8, 0x80, 0x02, 0x00, 0x10, 0x00, 0xC0, 0x02, 0x00, 0x18, 0x00, 0x40, 0x03, 0x00, 0x08, 0x00, 0x40, 0x01, 0x00, 0x08, 0x00, 0x20, 0x01, 0x00, 0x04, 0x00, 0x20, 0x00, 0x80, 0x04, 0x00, 0x10, 0x00, 0x80, 0x02, 0x00, 0x10, 0x00, 0x40, 0x02, 0x00, 0x08, 0x00, 0x40, 0xF8, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0xF8, 0x02, 0x00, 0x38, 0x03, 0x60, 0x11, 0x01, 0x8C, 0x18, 0x31, 0x80, 0xD8, 0x03, 0x80, 0x08, 0xFF, 0xFF, 0xF8, 0xC1, 0x83, 0x06, 0x0C, 0x0F, 0xC0, 0x70, 0x30, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x0F, 0xF8, 0x30, 0x08, 0x40, 0x08, 0x80, 0x08, 0x80, 0x08, 0x80, 0x08, 0x80, 0x38, 0x60, 0xE8, 0x3F, 0x8F, 0xF0, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x04, 0x00, 0x01, 0x0F, 0x80, 0x4C, 0x18, 0x14, 0x01, 0x06, 0x00, 0x21, 0x80, 0x08, 0x40, 0x01, 0x10, 0x00, 0x44, 0x00, 0x11, 0x00, 0x04, 0x40, 0x01, 0x18, 0x00, 0x86, 0x00, 0x21, 0xC0, 0x10, 0x5C, 0x18, 0xF1, 0xF8, 0x00, 0x07, 0xE4, 0x30, 0x78, 0x80, 0x32, 0x00, 0x24, 0x00, 0x50, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x03, 0x00, 0x02, 0x00, 0x12, 0x00, 0xC3, 0x07, 0x01, 0xF8, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x80, 0x7C, 0x20, 0x60, 0xC8, 0x20, 0x0A, 0x10, 0x01, 0x84, 0x00, 0x62, 0x00, 0x08, 0x80, 0x02, 0x20, 0x00, 0x88, 0x00, 0x22, 0x00, 0x08, 0xC0, 0x06, 0x10, 0x01, 0x82, 0x00, 0xE0, 0x60, 0xE8, 0x0F, 0xE3, 0xC0, 0x07, 0xE0, 0x1C, 0x18, 0x30, 0x0C, 0x60, 0x06, 0x40, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0xFF, 0xFF, 0xC0, 0x00, 0xC0, 0x00, 0x40, 0x00, 0x60, 0x00, 0x30, 0x03, 0x0C, 0x0E, 0x03, 0xF0, 0x03, 0xFC, 0x18, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x0F, 0xFF, 0x82, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0xFF, 0xF0, 0x0F, 0xC7, 0x9C, 0x3A, 0x18, 0x07, 0x08, 0x01, 0x8C, 0x00, 0xC4, 0x00, 0x22, 0x00, 0x11, 0x00, 0x08, 0x80, 0x04, 0x40, 0x02, 0x10, 0x03, 0x08, 0x01, 0x82, 0x01, 0x40, 0xC3, 0x20, 0x3F, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x7F, 0x00, 0xF0, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x47, 0xC0, 0x2C, 0x18, 0x1C, 0x04, 0x0C, 0x01, 0x04, 0x00, 0x82, 0x00, 0x41, 0x00, 0x20, 0x80, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02, 0x08, 0x01, 0x04, 0x00, 0x82, 0x00, 0x47, 0xC0, 0xF8, 0x06, 0x00, 0x18, 0x00, 0x60, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x03, 0xFF, 0xF0, 0x03, 0x00, 0xC0, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x40, 0x10, 0x04, 0x01, 0x00, 0x40, 0x10, 0x04, 0x01, 0x00, 0x40, 0x10, 0x04, 0x01, 0x00, 0x40, 0x10, 0x04, 0x01, 0x00, 0x40, 0x10, 0x08, 0x06, 0xFE, 0x00, 0xF0, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0xFE, 0x10, 0x30, 0x10, 0xE0, 0x11, 0xC0, 0x13, 0x00, 0x16, 0x00, 0x1E, 0x00, 0x1B, 0x00, 0x11, 0x80, 0x10, 0xC0, 0x10, 0x60, 0x10, 0x30, 0x10, 0x18, 0x10, 0x1C, 0xF0, 0x3F, 0x7E, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0x02, 0x00, 0x08, 0x00, 0x20, 0x00, 0x80, 0xFF, 0xFC, 0xEF, 0x9E, 0x07, 0x1E, 0x20, 0xC1, 0x82, 0x10, 0x20, 0x42, 0x04, 0x08, 0x40, 0x81, 0x08, 0x10, 0x21, 0x02, 0x04, 0x20, 0x40, 0x84, 0x08, 0x10, 0x81, 0x02, 0x10, 0x20, 0x42, 0x04, 0x08, 0x40, 0x81, 0x3E, 0x1C, 0x38, 0x71, 0xF0, 0x0B, 0x06, 0x07, 0x01, 0x03, 0x00, 0x41, 0x00, 0x20, 0x80, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02, 0x08, 0x01, 0x04, 0x00, 0x82, 0x00, 0x41, 0x00, 0x20, 0x80, 0x13, 0xF0, 0x3E, 0x07, 0xC0, 0x30, 0x60, 0x80, 0x22, 0x00, 0x24, 0x00, 0x50, 0x00, 0x60, 0x00, 0xC0, 0x01, 0x80, 0x03, 0x00, 0x05, 0x00, 0x12, 0x00, 0x22, 0x00, 0x83, 0x06, 0x01, 0xF0, 0x00, 0xF1, 0xFC, 0x05, 0xC1, 0x81, 0xC0, 0x10, 0x60, 0x02, 0x18, 0x00, 0xC4, 0x00, 0x11, 0x00, 0x04, 0x40, 0x01, 0x10, 0x00, 0x44, 0x00, 0x11, 0x80, 0x08, 0x60, 0x02, 0x14, 0x01, 0x04, 0xC1, 0x81, 0x0F, 0x80, 0x40, 0x00, 0x10, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x3F, 0xC0, 0x00, 0x0F, 0xE3, 0xC6, 0x0E, 0x86, 0x00, 0xE1, 0x00, 0x18, 0xC0, 0x06, 0x20, 0x00, 0x88, 0x00, 0x22, 0x00, 0x08, 0x80, 0x02, 0x20, 0x00, 0x84, 0x00, 0x61, 0x00, 0x18, 0x20, 0x0A, 0x06, 0x0C, 0x80, 0x7C, 0x20, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x08, 0x00, 0x02, 0x00, 0x0F, 0xF0, 0xF8, 0x7C, 0x11, 0x8C, 0x2C, 0x00, 0x70, 0x00, 0xC0, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x3F, 0xFC, 0x00, 0x0F, 0xD1, 0x83, 0x98, 0x04, 0x80, 0x24, 0x00, 0x30, 0x00, 0xF0, 0x00, 0xFC, 0x00, 0x30, 0x00, 0xE0, 0x03, 0x00, 0x1C, 0x01, 0xF0, 0x1A, 0x7F, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0xFF, 0xFC, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x01, 0x06, 0x0F, 0x03, 0xF8, 0xF0, 0x3E, 0x08, 0x01, 0x04, 0x00, 0x82, 0x00, 0x41, 0x00, 0x20, 0x80, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02, 0x08, 0x01, 0x04, 0x00, 0x82, 0x00, 0x41, 0x00, 0xE0, 0x41, 0xD0, 0x1F, 0x8E, 0xFE, 0x0F, 0xE2, 0x00, 0x20, 0x60, 0x0C, 0x0C, 0x01, 0x80, 0x80, 0x20, 0x18, 0x0C, 0x01, 0x01, 0x00, 0x30, 0x60, 0x02, 0x08, 0x00, 0x41, 0x00, 0x0C, 0x60, 0x00, 0x88, 0x00, 0x19, 0x00, 0x01, 0x40, 0x00, 0x38, 0x00, 0xFC, 0x07, 0xE4, 0x00, 0x10, 0x80, 0x02, 0x18, 0x20, 0xC3, 0x0E, 0x18, 0x21, 0x42, 0x04, 0x28, 0x40, 0x8D, 0x88, 0x19, 0x93, 0x03, 0x22, 0x60, 0x2C, 0x68, 0x05, 0x85, 0x00, 0xA0, 0xA0, 0x1C, 0x1C, 0x01, 0x81, 0x80, 0x7C, 0x1F, 0x18, 0x03, 0x06, 0x03, 0x01, 0x83, 0x00, 0x63, 0x00, 0x1B, 0x00, 0x07, 0x00, 0x03, 0x80, 0x03, 0x60, 0x03, 0x18, 0x03, 0x06, 0x03, 0x01, 0x83, 0x00, 0x61, 0x00, 0x33, 0xF0, 0x7E, 0xFC, 0x1F, 0x90, 0x01, 0x8C, 0x00, 0x86, 0x00, 0xC1, 0x80, 0x40, 0xC0, 0x60, 0x20, 0x20, 0x18, 0x30, 0x04, 0x10, 0x03, 0x08, 0x00, 0x8C, 0x00, 0x64, 0x00, 0x16, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x01, 0x00, 0x01, 0x80, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x60, 0x00, 0x20, 0x07, 0xFE, 0x00, 0xFF, 0xF4, 0x01, 0x20, 0x09, 0x00, 0x80, 0x08, 0x00, 0x80, 0x08, 0x00, 0xC0, 0x04, 0x00, 0x40, 0x04, 0x00, 0x40, 0x14, 0x00, 0xA0, 0x07, 0xFF, 0xE0, 0x07, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x30, 0xC0, 0x30, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0C, 0x07, 0xFF, 0xFF, 0xFF, 0x80, 0xE0, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x07, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30, 0xE0, 0x1C, 0x00, 0x44, 0x0D, 0x84, 0x36, 0x04, 0x40, 0x07, 0x00 ] FreeMono18pt7bGlyphs = [ [ 0, 0, 0, 21, 0, 1 ], # 0x20 ' ' [ 0, 4, 22, 21, 8, -21 ], # 0x21 '!' [ 11, 11, 10, 21, 5, -20 ], # 0x22 '"' [ 25, 14, 24, 21, 3, -21 ], # 0x23 '#' [ 67, 13, 26, 21, 4, -22 ], # 0x24 '$' [ 110, 15, 21, 21, 3, -20 ], # 0x25 '%' [ 150, 12, 18, 21, 4, -17 ], # 0x26 '&' [ 177, 4, 10, 21, 8, -20 ], # 0x27 ''' [ 182, 5, 25, 21, 10, -20 ], # 0x28 '(' [ 198, 5, 25, 21, 6, -20 ], # 0x29 ')' [ 214, 13, 12, 21, 4, -20 ], # 0x2A '#' [ 234, 15, 17, 21, 3, -17 ], # 0x2B '+' [ 266, 7, 10, 21, 5, -4 ], # 0x2C ',' [ 275, 15, 1, 21, 3, -9 ], # 0x2D '-' [ 277, 5, 5, 21, 8, -4 ], # 0x2E '.' [ 281, 13, 26, 21, 4, -22 ], # 0x2F '/' [ 324, 13, 21, 21, 4, -20 ], # 0x30 '0' [ 359, 13, 21, 21, 4, -20 ], # 0x31 '1' [ 394, 13, 21, 21, 3, -20 ], # 0x32 '2' [ 429, 14, 21, 21, 3, -20 ], # 0x33 '3' [ 466, 12, 21, 21, 4, -20 ], # 0x34 '4' [ 498, 14, 21, 21, 3, -20 ], # 0x35 '5' [ 535, 12, 21, 21, 5, -20 ], # 0x36 '6' [ 567, 12, 21, 21, 4, -20 ], # 0x37 '7' [ 599, 13, 21, 21, 4, -20 ], # 0x38 '8' [ 634, 12, 21, 21, 5, -20 ], # 0x39 '9' [ 666, 5, 15, 21, 8, -14 ], # 0x3A ':' [ 676, 7, 20, 21, 5, -14 ], # 0x3B '' [ 694, 15, 16, 21, 3, -17 ], # 0x3C '<' [ 724, 17, 6, 21, 2, -12 ], # 0x3D '=' [ 737, 15, 16, 21, 3, -17 ], # 0x3E '>' [ 767, 12, 20, 21, 5, -19 ], # 0x3F '?' [ 797, 13, 23, 21, 4, -20 ], # 0x40 '@' [ 835, 21, 20, 21, 0, -19 ], # 0x41 'A' [ 888, 18, 20, 21, 1, -19 ], # 0x42 'B' [ 933, 17, 20, 21, 2, -19 ], # 0x43 'C' [ 976, 16, 20, 21, 2, -19 ], # 0x44 'D' [ 1016, 17, 20, 21, 1, -19 ], # 0x45 'E' [ 1059, 17, 20, 21, 1, -19 ], # 0x46 'F' [ 1102, 17, 20, 21, 2, -19 ], # 0x47 'G' [ 1145, 16, 20, 21, 2, -19 ], # 0x48 'H' [ 1185, 13, 20, 21, 4, -19 ], # 0x49 'I' [ 1218, 17, 20, 21, 3, -19 ], # 0x4A 'J' [ 1261, 18, 20, 21, 1, -19 ], # 0x4B 'K' [ 1306, 15, 20, 21, 3, -19 ], # 0x4C 'L' [ 1344, 19, 20, 21, 1, -19 ], # 0x4D 'M' [ 1392, 18, 20, 21, 1, -19 ], # 0x4E 'N' [ 1437, 17, 20, 21, 2, -19 ], # 0x4F 'O' [ 1480, 16, 20, 21, 1, -19 ], # 0x50 'P' [ 1520, 17, 24, 21, 2, -19 ], # 0x51 'Q' [ 1571, 19, 20, 21, 1, -19 ], # 0x52 'R' [ 1619, 14, 20, 21, 3, -19 ], # 0x53 'S' [ 1654, 15, 20, 21, 3, -19 ], # 0x54 'T' [ 1692, 17, 20, 21, 2, -19 ], # 0x55 'U' [ 1735, 21, 20, 21, 0, -19 ], # 0x56 'V' [ 1788, 19, 20, 21, 1, -19 ], # 0x57 'W' [ 1836, 19, 20, 21, 1, -19 ], # 0x58 'X' [ 1884, 17, 20, 21, 2, -19 ], # 0x59 'Y' [ 1927, 13, 20, 21, 4, -19 ], # 0x5A 'Z' [ 1960, 5, 25, 21, 10, -20 ], # 0x5B '[' [ 1976, 13, 26, 21, 4, -22 ], # 0x5C '\' [ 2019, 5, 25, 21, 6, -20 ], # 0x5D ']' [ 2035, 13, 9, 21, 4, -20 ], # 0x5E '^' [ 2050, 21, 1, 21, 0, 4 ], # 0x5F '_' [ 2053, 6, 5, 21, 5, -21 ], # 0x60 '`' [ 2057, 16, 15, 21, 3, -14 ], # 0x61 'a' [ 2087, 18, 21, 21, 1, -20 ], # 0x62 'b' [ 2135, 15, 15, 21, 3, -14 ], # 0x63 'c' [ 2164, 18, 21, 21, 2, -20 ], # 0x64 'd' [ 2212, 16, 15, 21, 2, -14 ], # 0x65 'e' [ 2242, 14, 21, 21, 4, -20 ], # 0x66 'f' [ 2279, 17, 22, 21, 2, -14 ], # 0x67 'g' [ 2326, 17, 21, 21, 1, -20 ], # 0x68 'h' [ 2371, 14, 22, 21, 4, -21 ], # 0x69 'i' [ 2410, 10, 29, 21, 5, -21 ], # 0x6A 'j' [ 2447, 16, 21, 21, 2, -20 ], # 0x6B 'k' [ 2489, 14, 21, 21, 4, -20 ], # 0x6C 'l' [ 2526, 19, 15, 21, 1, -14 ], # 0x6D 'm' [ 2562, 17, 15, 21, 1, -14 ], # 0x6E 'n' [ 2594, 15, 15, 21, 3, -14 ], # 0x6F 'o' [ 2623, 18, 22, 21, 1, -14 ], # 0x70 'p' [ 2673, 18, 22, 21, 2, -14 ], # 0x71 'q' [ 2723, 15, 15, 21, 3, -14 ], # 0x72 'r' [ 2752, 13, 15, 21, 4, -14 ], # 0x73 's' [ 2777, 16, 20, 21, 1, -19 ], # 0x74 't' [ 2817, 17, 15, 21, 1, -14 ], # 0x75 'u' [ 2849, 19, 15, 21, 1, -14 ], # 0x76 'v' [ 2885, 19, 15, 21, 1, -14 ], # 0x77 'w' [ 2921, 17, 15, 21, 2, -14 ], # 0x78 'x' [ 2953, 17, 22, 21, 2, -14 ], # 0x79 'y' [ 3000, 13, 15, 21, 4, -14 ], # 0x7A 'z' [ 3025, 8, 25, 21, 6, -20 ], # 0x7B '[' [ 3050, 1, 25, 21, 10, -20 ], # 0x7C '|' [ 3054, 8, 25, 21, 7, -20 ], # 0x7D ']' [ 3079, 15, 5, 21, 3, -11 ] ] # 0x7E '~' FreeMono18pt7b = [ FreeMono18pt7bBitmaps, FreeMono18pt7bGlyphs, 0x20, 0x7E, 35 ] # Approx. 3761 bytes
def intervalIntersection(A, B): aIndex = 0 bIndex = 0 toReturn = [] arg1 = A[aIndex] arg2 = B[bIndex] flag = True def compareArrs(aArr, bArr): signifyInd = "" zipComp = zip(aArr, bArr) compList = list(zipComp) lowIntSec = max(compList[0]) highIntSec = min(compList[1]) if aArr[0] > bArr[1]: signifyInd = "B" intersection = "NO INTERSECTION" elif bArr[0] > aArr[1]: signifyInd = "A" intersection = "NO INTERSECTION" else: if aArr[1] == highIntSec: signifyInd = "A" elif bArr[1] == highIntSec: signifyInd = "B" intersection = [lowIntSec, highIntSec] return [intersection, signifyInd] while flag: arg1 = A[aIndex] arg2 = B[bIndex] flag = False result = compareArrs(arg1, arg2) print(result) if result[0] == "NO INTERSECTION": pass else: toReturn.append(result[0]) if result[1] == "A": if aIndex == len(A)-1: print(toReturn) return toReturn else: aIndex += 1 print("aIndex", aIndex) flag = True elif result[1] == "B": if bIndex == len(B)-1: print(toReturn) return toReturn else: bIndex += 1 print("bIndex", bIndex) flag = True return toReturn A = [[0, 2], [5, 10], [13, 23], [24, 25]] B = [[1, 5], [8, 12], [15, 24], [25, 26]] intervalIntersection(A, B)
"""Hackerrank Problem: https://www.hackerrank.com/challenges/is-binary-search-tree/problem For the purposes of this challenge, we define a binary tree to be a binary search tree with the following ordering requirements: * The data value of every node in a node's left subtree is less than the data value of that node. * The data value of every node in a node's right subtree is greater than the data value of that node. Given the root node of a binary tree, can you determine if it's also a binary search tree? Complete the function in your editor below, which has 1 parameter: a pointer to the root of a binary tree. It must return a boolean denoting whether or not the binary tree is a binary search tree. You may have to write one or more helper functions to complete this challenge. """ """ Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ def inorder_traversal(root): """Function to traverse a binary tree inorder Args: root (Node): The root of a binary tree Returns: (list): List containing all the values of the tree from an inorder search """ res = [] if root: res = inorder_traversal(root.left) res.append(root.data) res = res + inorder_traversal(root.right) return res def check_binary_search_tree_(root): """Function to determine if the tree satisfies the condition to be a binary search tree Args: root (Node): The root of the binary tree to check Returns: (bool): Whether the tree is a binary search tree or not """ res = inorder_traversal(root) return res == sorted(res) and len(res) == len(set(res))
def test_no_metrics(run): tracking = run.tracking metrics = run.dict.pop("metrics") tracking.on_epoch_end(run) run.set(metrics=metrics)
"""Top-level package for copyany.""" __author__ = """Natan Bro""" __email__ = 'code@natanbro.com' __version__ = '0.1.0'
# -*- coding: utf-8 -*- VERSION_MAJOR = 0 VERSION_MINOR = 0 VERSION_MICRO = 4 VERSION = (VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO) VERSION_STR = '.'.join(map(str, VERSION))
#!/usr/bin/env python3 def fibs(): fib1, fib2 = 1, 1 while True: yield fib1 fib1, fib2 = fib2, fib1 + fib2 print(next(i for (i, f) in enumerate(fibs(), 1) if len(str(f)) == 1000))
""" Given a list of integers and a number K, return which contiguous elements of the list sum to K. """ inp = [1,2,3,4,5] K = 9 def contiguous_sum(arr: list, k: int): start_index = 0 end_index = -1 current_sum = 0 for i in range(len(arr)): if current_sum < k: current_sum += arr[i] if current_sum > k: current_sum -= arr[start_index] start_index += 1 elif current_sum == k: end_index = i break if end_index != -1: return arr[start_index:end_index] else: return [] print(contiguous_sum(inp, K))
# Copyright 2018 Tensorforce Team. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== def is_iterable(x): if isinstance(x, str): return False try: iter(x) return True except TypeError: return False class TensorforceError(Exception): """ Tensorforce error """ def __init__(self, message): if message[0].islower(): message = message[0].upper() + message[1:] if message[-1] != '.': message = message + '.' super().__init__(message) @staticmethod def unexpected(): return TensorforceError(message="Unexpected error!") @staticmethod def collision(name, value, group1, group2): return TensorforceError( message="{name} collision between {group1} and {group2}: {value}.".format( name=name, group1=group1, group2=group2, value=value ) ) @staticmethod def mismatch(name, value1, value2, argument=None): if argument is None: return TensorforceError( message="{name} mismatch: {value1} <-> {value2}.".format( name=name, value1=value1, value2=value2 ) ) else: return TensorforceError( message="{name} mismatch for argument {argument}: {value1} <-> {value2}.".format( name=name, argument=argument, value1=value1, value2=value2 ) ) @staticmethod def exists(name, value): return TensorforceError( message="{name} already exists: {value}.".format(name=name, value=value) ) @staticmethod def required(name, value): if is_iterable(x=value): value = ', '.join(str(x) for x in value) return TensorforceError( message="Missing {name} value: {value}.".format(name=name, value=value) ) @staticmethod def type(name, value, argument=None): if argument is None: return TensorforceError( message="Invalid {name} type: {type}.".format(name=name, type=type(value)) ) else: return TensorforceError( message="Invalid type for {name} argument {argument}: {type}.".format( name=name, argument=argument, type=type(value) ) ) @staticmethod def value(name, value, argument=None): if isinstance(value, dict): value = str(value) elif is_iterable(x=value): value = ', '.join(str(x) for x in value) if argument is None: return TensorforceError( message="Invalid {name} value: {value}.".format(name=name, value=value) ) else: return TensorforceError( message="Invalid value for {name} argument {argument}: {value}.".format( name=name, argument=argument, value=value ) )
#-*-coding: utf-8 -*- ''' Base cache Adapter object. ''' class BaseAdapter(object): db = None def __init__(self, timeout = -1): self.timeout = timeout def get(self, key): raise NotImplementedError() def set(self, key, value): raise NotImplementedError() def remove(self, key): raise NotImplementedError() def flush(self): raise NotImplementedError()
# coding : utf-8 print("\n \n \n \n \n \n Belo Horizonte, 05/06/2020, 17:34.\n Você está andando na sua casa normalmente indo tomar banho, acabado o banho quando você sai do box você tropeça e cai e bate a cabeça na pia. \n Você acorda no hospital e você é uma enfermeira nossa frente.") x = input("\n Você pode fazer uma pergunta para ela: \n 1 - Onde estou? \n 2 - Em que ano estamos? \n 3 - Olá estranho? \n 4 - Onde está meus parentes? \n Escolha: ") if x == '1': print("\n Enfermeira: Você está no hospital, teve uma batida forte, teve um coma, e agora está de volta. Parabéns \n \n ") if x == '2': print("\n Enfermeira: 09/08/2030, 03:50, pós pandemia, e outras coisas que não precisa se preocupar. \n \n ") if x == '3': print("\n Enfermeira: Olá, bem vindo ao mundo novamente, espero que se recupere bem. \n \n ") if x == '4': print("\n Enfermeira: Bem, seus vizinhos que lhe socorreram, tentamos contato mas... , nossa tenho que pegar sua bolsa de soro! \n \n ") print("Você: Quando reberei alta? Posso ter meu celular de volta? \n Enfermeira: Acalma-se, vou pegar para você") print("\n \n Ela te entrega o seu smartphone. \n Quando você vê as notícias se assusta: \n Covid-19 se modifica e está com nova taxa de mortalidade de 20%. \n Países estão a beira do colapso. \n 'unica saida sera a reforma agraria' diz especialista. \n Todos os Presidentes da America morrem. \n No Brasil kkk(ku klus kla) é perseguida pelo PCC(primeiro comando da capital). \n 1° presidente preto no Brasil é eleito via blockchain sendo o novo sistema eleitoral brasileiro. \n Cura é encontrada mas a um preço muito elevado. \n Ditadores foram executados pela IA que desenvolveram em parceria. \n Os mais ricos do mundo estão entrendo em crise por conta das criptomoedas. \n Cidades estão adotando sistemas de anarquia para se manter.") print("\n isso tudo em menos de 4 anos... Você desmaia. FIM DO CAP 1.")
def repeated_word(string): # separate the string string = string.split(' ') separated_string = [] for word in string: if word not in separated_string: separated_string.append(word) for word in range(0, len(separated_string)): print(separated_string[word], 'appears', string.count(separated_string[word])) def main(): string = "mercedes mercedes mexico orange spoon orange gary gary" repeated_word(string) if __name__ == "__main__": main()
#Algorythm: Quicksort (sometimes called partition-exchange sort) #Description: In this file we are using the Hoare partition scheme, #you can seen other implementation in the other quicksort files #Source link: I saw the algorithm explanation on https://en.wikipedia.org/wiki/Quicksort #Use: It is used to sort, it is a comparison sort #Developer: Tony Hoare #Mathematical analysis: It takes O(n log n) comparisons to sort n items, in worst cases it takes O(n^2) #Name: swapValues #Description: This function is used to swap the values of two indexs in an array #Arguments: 3; array is the array where the values are, # x is an index to swap value # y is the other index to swap values #Return: Nothing #Example: swapValues(sampleArray,0,1) def swapValues(array,x,y): #I created this temporal var to avoid call len(array) several times len_arr=len(array) #Tese conditions are done to avoid out of array exceptions if len_arr>0 and x<len_arr and x>=0 and y>=0 and y<len_arr and x!=y: #Just used this for debugging purposes #print("Swap "+str(array[x])+" and "+str(array[y])) temp_var=array[y] array[y]=array[x] array[x]=temp_var #Name: partition #Description: Used to create a partition and order it, swapping values #Arguments: 3; array is the array where the values are, # min_index is the minimum index of the partition # max_index is the maximum index of the partition #Return: 1, an integer which is an index #Example: ret_value = partition(sampleArray,0,20) def partition(array,min_index,max_index): pivot_value = array[min_index] i = min_index - 1 j = max_index + 1 while True: #Since Python doesn't have a 'do'...'while' loop, #we emulate it with something like this i = i + 1 while array[i] < pivot_value: i = i +1 j = j - 1 while array[j] > pivot_value: j = j -1 if i >= j: return j swapValues(array,i,j) #Name: quicksort #Description: The algorithm itself, basically it is the Python implementation #of the Hoare partition scheme of Quicksort algorithm #Arguments: 3; array is the array where the values are, # min_index is the minimum index of the array (or the min # index we want to sort) # max_index is the maximum index of the array (or the max # index we want to sort) #Return: Nothing #Example: quicksort(sampleArray,0,len(sampleArray)-1) (it will sort the entire #sampleArray def quicksort(array,min_index,max_index): if min_index < max_index: p=partition(array,min_index,max_index) quicksort(array,min_index,p) quicksort(array,p+1,max_index) #This is just for testing if everything works arr=[2,7,3,1] print("Unsorted array:") print(arr) quicksort(arr,0,len(arr)-1) print("Sorted array:") print(arr)
GET_ALL_GENRES = """ SELECT name FROM genres """ INSERT_GENRE = """ INSERT INTO genres (name) VALUES (:name) """
def admin_helper(admin) -> dict: return { "id": str(admin['_id']), "fullname": admin['fullname'], "email": admin['email'], } def state_count_helper(state_count) -> dict: return { "id": str(state_count['_id']), "date": state_count['date'], "state": state_count["state"], "ad_count": state_count["ad_count"], "avg_age": state_count["avg_age"], "email_count": state_count["email_count"], "phone_count": state_count["phone_count"] } def city_count_helper(city_count) -> dict: return { "id": str(city_count['_id']), "date": city_count['date'], "city": city_count["city"], "ad_count": city_count["ad_count"], "avg_age": city_count["avg_age"], "email_count": city_count["email_count"], "phone_count": city_count["phone_count"] }
def get_strings(city): city = city.lower().replace(" ", "") ans = [""] * 26 order = "" for i in city: if i not in order: order += i for i in city: ans[ord(i) - 97] += "*" return ",".join([i + ":" + ans[ord(i) - 97] for i in order]) print(get_strings("Chicago"))
n,a,b = map(int,input().split()) x = list(map(int,input().split())) answer = 0 for i in range(1, n): if a*(x[i]-x[i-1]) < b: answer += a*(x[i]-x[i-1]) else: answer += b print(answer)
# address of mongoDB MONGO_SERVER = 'mongodb://192.168.1.234:27017/' # MONGO_SERVER = 'mongodb://mongodb.test:27017/' SCHEDULER_DB = "scheduler" JOB_COLLECTION = "jobs" REGISTRY_URL = "registry.zilliz.com/milvus/milvus" IDC_NAS_URL = "//172.16.70.249/test" DEFAULT_IMAGE = "milvusdb/milvus:latest" SERVER_HOST_DEFAULT = "127.0.0.1" SERVER_PORT_DEFAULT = 19530 # milvus version, should be changed by manual SERVER_VERSION = "2.0.0-RC7" DEFUALT_DEPLOY_MODE = "single" HELM_NAMESPACE = "milvus" BRANCH = "master" DEFAULT_CPUS = 48 # path of NAS mount RAW_DATA_DIR = "/test/milvus/raw_data/" # nars log LOG_PATH = "/test/milvus/benchmark/logs/{}/".format(BRANCH) # Three deployment methods currently supported DEFAULT_DEPLOY_MODE = "single" SINGLE_DEPLOY_MODE = "single" CLUSTER_DEPLOY_MODE = "cluster" CLUSTER_3RD_DEPLOY_MODE = "cluster_3rd" NAMESPACE = "milvus" CHAOS_NAMESPACE = "chaos-testing" DEFAULT_API_VERSION = 'chaos-mesh.org/v1alpha1' DEFAULT_GROUP = 'chaos-mesh.org' DEFAULT_VERSION = 'v1alpha1' # minio config MINIO_HOST = "milvus-test-minio.qa-milvus.svc.cluster.local" MINIO_PORT = 9000 MINIO_ACCESS_KEY = "minioadmin" MINIO_SECRET_KEY = "minioadmin" MINIO_BUCKET_NAME = "test"
def selection_sort(arr, simulation=False): """ Selection Sort Complexity: O(n^2) ##------------------------------------------------------------------- """ iteration = 0 if simulation: print("iteration", iteration, ":", *arr) for i in range(len(arr)): minimum = i for j in range(i + 1, len(arr)): # "Select" the correct value if arr[j] < arr[minimum]: minimum = j arr[minimum], arr[i] = arr[i], arr[minimum] if simulation: iteration = iteration + 1 print("iteration", iteration, ":", *arr) return arr
src = Split(''' tls_test.c ''') component = aos_component('tls_test', src) component.add_comp_deps('security/mbedtls')
#Задача 3. Вариант 24 #Напишите программу, которая выводит имя "Максимилиан Гольдман", и запрашивает его псевдоним. Программа должна сцеплять две эти строки и выводить полученную строку, разделяя имя и псевдоним с помощью тире. #Semyenov A.N.Ы #08.03.2016 print("Сегодня речь пойдёт про Максимилиана Гольдмана") print("Под каким именем мы знаем этого человека?"); print("Ваш ответ: Макс Рейнхардт") print("Всё верно: Максимилиан Гольдман - Макс Рейнхардт") input('\nНажмите Enter для выхода')
NC_READ_REQUEST = 0 NC_READ_REPLY = 1 NC_HOT_READ_REQUEST = 2 NC_WRITE_REQUEST = 4 NC_WRITE_REPLY = 5 NC_UPDATE_REQUEST = 8 NC_UPDATE_REPLY = 9
""" string_util.py Miscellaneous string processing functions """ def title_case(sentence): """ Capitalize the first letter of every word in a sentence. Parameters ---------- sentence: string Sentence to be converted to title case Returns ------- result: string Input string converted to title case Example ------- >>> title_case('This iS a sampLe.') This Is A Sample. """ # error checking if not isinstance(sentence, str): raise TypeError('Input to title_case must be string') # convert entire sentence to lower case then split it into words words = (sentence.lower()).split() # capitalize each word for i in range(len(words)): words[i] = words[i].capitalize() # put the words back together into a sentence, separating them with spaces result = ' '.join(words) return result
""" Hello we are attempting to simulate the cochlea. The cochlea uses a concept called tonotopy i.e. low frequencies are processed at the apex and high frequencies are processed at the base. Furthermore sound travels to its point of transduction as a traveling wave """ def __self_description(): print("Simulation of a traveling wave...enjoy") if __name__ == "__main__": __self_description() else: "Using first.py as an import"
__author__ = 'olga' def scatterhist(ax, x, y): """ Create a scatterplot with histogram of the marginals, as in scatterhist() in Matlab but nicer. @param ax: @type ax: @param x: @type x: @param y: @type y: @return: hist_patches, scatter_points @rtype: matplotlib. """ raise NotImplementedError('Check out the "seaborn" plotting library for ' 'this.')
with open('input.txt') as f: input = f.readline() input = input.strip().split('-') input_min = int(input[0]) input_max = int(input[1]) def pwd_to_digits(pwd): digits = [] pwd_str = str(pwd) while len(pwd_str) > 0: digits.append(int(pwd_str[0])) pwd_str = pwd_str[1:] return digits def pwd_is_valid(pwd): digits = pwd_to_digits(pwd) prev_digit = -1 has_double = False has_decrease = False for next_digit in digits: if next_digit == prev_digit: has_double = True if next_digit < prev_digit: has_decrease = True prev_digit = next_digit return has_double and not has_decrease def new_pwd_is_valid(pwd): digits = pwd_to_digits(pwd) digits.append(-1) prev_digit = -1 group_len = 1 saw_double = False print("%d" % pwd) for next_digit in digits: if next_digit == prev_digit: group_len += 1 else: if group_len == 2: saw_double = True group_len = 1 prev_digit = next_digit print(" %d: %d" % (next_digit, group_len)) return saw_double pwds = [] for i in range(input_min, input_max+1): if pwd_is_valid(i): pwds.append(i) print("count == %d" % len(pwds)) new_pwds = [] for pwd in pwds: if new_pwd_is_valid(pwd): new_pwds.append(pwd) print("new_count == %d" % len(new_pwds))
class DrawflowNodeBase: def __init__(self): self.nodename = "basenode" self.nodetitle = "Basenode" self.nodeinputs = list() self.nodeoutputs = list() self.nodeicon = "" self.nodehtml = "<b>DO NOT USE THE BASE NODE!!!</b>" def name(self, name): self.nodename = name def title(self, title): self.nodetitle = title def input(self, varname, type): self.nodeinputs.append((varname, type)) def output(self, varname, type): self.nodeoutputs.append((varname, type)) def icon(self, html): self.nodeicon = html def html(self, html): self.nodehtml = html def getAsTuple(self): return (self.nodetitle, len(self.nodeinputs), len(self.nodeoutputs), self.nodeicon, self.nodename, self.nodehtml)
f = open("Files/Test.txt", mode="rt",encoding="utf-8") g = open("Files/fil1.txt", mode="rt",encoding="utf-8") h = open("Files/wasteland.txt", mode="rt",encoding="utf-8") # return type of read() method is str # To read specific number of character we have to pass the characters as arguments # print(f.read(25)) # To read the whole file we have to keep the argument of read() method empty print("Content in Test1.txt:\n",f.read()) print() print("Content in fil1.txt:\n",g.read()) print() print("Content in wasteland.txt:\n",h.read())
# -*- coding: utf-8 -*- """Unit test package for django-model-cleanup.""" # Having tests in a separate folder is a safe choice # You can have them mixed in the src but at some point you will get # problems with test discovery activating lazy objects and other import time # headaches. And if you fail to filter test during packaging you will get # similar problems in production.
class Solution: def decompressRLElist(self, nums: List[int]) -> List[int]: ret = [] i = 0 while i < len(nums): j = 0 while j < nums[i]: ret.append(nums[i+1]) j += 1 i += 2 return ret
# Given an array of numbers, find all the # pairs of numbers which sum upto `k` def find_pairs(num_array, k): pairs_array = [] for num in num_array: if (k - num) in num_array: pairs_array.append((num, (k - num))) return pairs_array result = find_pairs([0, 14, 0, 4, 7, 8, 3, 5, 7], 11) print(result)
class Solution: def champagneTower(self, poured: int, query_row: int, query_glass: int) -> float: filled = [[0.0] * (query_row + 2) for _ in range (query_row+2)] filled[0][0] = poured for row in range(query_row + 1): for col in range(query_row + 1): if (filled[row][col] > 1.0): overfill = filled[row][col] - 1.0 filled[row + 1][col] += overfill / 2.0 filled[row + 1][col +1] += overfill /2.0 # if needs to be here because we are not removing overfill from glasses that are overflowing, the maximum they can hold is 1 return filled[query_row][query_glass] if filled[query_row][query_glass] <= 1 else 1
""" link: https://leetcode.com/problems/linked-list-random-node problem: 对链表随机返回节点,要求 O(1) 级别的空间复杂度 solution: 统计长度,随机位置 solution-fix: 仅遍历一次,对当前第i个元素,有 1/i 的机率保留作为返回结果。需要多次随机,但只需要一次遍历。 """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def __init__(self, head: ListNode): """ @param head The linked list's head. Note that the head is guaranteed to be not null, so it contains at least one node. """ self.l = 0 self.head, t = head, head while t: self.l += 1 t = t.next def getRandom(self) -> int: """ Returns a random node's value. """ t = random.randint(0, self.l - 1) k = self.head while t: k = k.next t -= 1 return k.val # Your Solution object will be instantiated and called as such: # obj = Solution(head) # param_1 = obj.getRandom() # --- class Solution: def __init__(self, head: ListNode): self.head = head def getRandom(self) -> int: k = self.head res, n = k.val, 0 while k: n += 1 if random.randint(1, n) == n: res = k.val k = k.next return res
class Headers: X_VOL_TENANT = "x-vol-tenant"; X_VOL_SITE = "x-vol-site"; X_VOL_CATALOG = "x-vol-catalog"; X_VOL_MASTER_CATALOG = "x-vol-master-catalog"; X_VOL_SITE_DOMAIN = "x-vol-site-domain"; X_VOL_TENANT_DOMAIN = "x-vol-tenant-domain"; X_VOL_CORRELATION = "x-vol-correlation"; X_VOL_HMAC_SHA256 = "x-vol-hmac-sha256"; X_VOL_APP_CLAIMS = "x-vol-app-claims"; X_VOL_USER_CLAIMS = "x-vol-user-claims"; X_VOL_LOCALE = "x-vol-locale"; X_VOL_CURRENCY = "x-vol-currency"; X_VOL_VERSION = "x-vol-version"; X_VOL_DATAVIEW_MODE = "x-vol-dataview-mode"; DATE = "Date"; CONTENT_TYPE = "Content-type"; ETAG = "ETag";
# -*- coding: utf-8 -*- """ Yet another static site generator. """
''' Exercise 2: Write a function save_list2file(sentences, filename) that takes two parameters, where sentences is a list of string, and filename is a string representing the name of the file where the content of sentences must be saved. Each element of the list sentences should be written on its own line in the file filename. ''' def save_list2file(sentences, filename): with open(filename,'w') as x: for y in sentences: print(y, file=x) save_list2file(['yikes','lolxd'],'ayy')
class Solution: def uniquePathsWithObstacles(self, grid: List[List[int]]) -> int: if grid[0][0] == 1: return 0 m = len(grid) n = len(grid[0]) grid[0][0] = 1 for i in range(1, m): if grid[i][0] == 0: grid[i][0] = grid[i - 1][0] else: grid[i][0] = 0 for i in range(1, n): if grid[0][i] == 0: grid[0][i] = grid[0][i - 1] else: grid[0][i] = 0 for i in range(1, m): for j in range(1, n): if grid[i][j] == 0: grid[i][j] = grid[i - 1][j] + grid[i][j - 1] else: grid[i][j] = 0 return grid[m - 1][n - 1]
def categorical_cross_entropy(y_pred, y): x = np.multiply(y, np.log(y_pred)) loss = x.sum() return loss
largest = None smallest = None while True: num = input("Enter a number: ") if num == "done": break try: inp=float(num) except: print("Invalid input") if smallest is None: smallest=inp elif inp < smallest: smallest=inp elif inp>largest: largest=inp continue print("Maximum", largest) print("Minimum", smallest)
""" Copyright (c) 2018-present, Facebook, Inc. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory. """ class BadConfigError(Exception): """ Indicates that test config for launching ryu apps is invalid """ pass class ServiceRunningError(Exception): """ Indicates that magma@pipelined service was running when trying to instantiate ryu apps """ pass
class Solution: def numTilePossibilities(self, tiles: str) -> int: def dfs(counterMap): currentSum = 0 for char in counterMap: if counterMap[char] > 0: currentSum += 1 counterMap[char] -= 1 currentSum += dfs(counterMap) counterMap[char] += 1 return currentSum return dfs(Counter(tiles))
user1 = { "user": { "username": "akram", "email": "akram.mukasa@andela.com", "password": "Akram@100555" } } login1 = {"user": {"email": "akram.mukasa@andela.com", "password": "Akram@100555"}}
# Copyright (c) Jeremías Casteglione <jrmsdev@gmail.com> # See LICENSE file. __all__ = ['configure'] def configure(env, cfg): env.settings.merge(cfg, 'service.munin_node', ( 'config.dir', 'target.dir', 'prune.plugins', ))
class Image: def __init__(self, name): self.name = name def register(self): raise NotImplementedError def getImg(self): raise NotImplementedError
expected_output = { "five_sec_cpu_total": 13, "five_min_cpu": 15, "one_min_cpu": 23, "five_sec_cpu_interrupts": 0, }
alg.aggregation ( [ "c_custkey", "c_name", "c_acctbal", "c_phone", "n_name", "c_address", "c_comment" ], [ ( Reduction.SUM, "rev", "revenue" ) ], alg.map ( "rev", scal.MulExpr ( scal.AttrExpr ( "l_extendedprice" ), scal.SubExpr ( scal.ConstExpr ( "1.0f", Type.FLOAT ), scal.AttrExpr ( "l_discount" ) ) ), alg.join ( ( "l_orderkey", "o_orderkey" ), alg.join ( ( "c_nationkey", "n_nationkey" ), alg.scan ( "nation" ), alg.join ( ( "o_custkey", "c_custkey" ), alg.selection ( scal.AndExpr ( scal.LargerEqualExpr ( scal.AttrExpr ( "o_orderdate" ), scal.ConstExpr ( "19931001", Type.DATE ) ), scal.SmallerExpr ( scal.AttrExpr ( "o_orderdate" ), scal.ConstExpr ( "19940101", Type.DATE ) ) ), alg.scan ( "orders" ) ), alg.scan ( "customer" ) ) ), alg.selection ( scal.EqualsExpr ( scal.AttrExpr ( "l_returnflag" ), scal.ConstExpr ( "R", Type.CHAR ) ), alg.scan ( "lineitem" ) ) ) ) )
# -*- coding: utf-8 -*- """ """ def get_ratios(L1, L2): """ Assumes: L1 and L2 are lists of equal length of numbers Returns: a list containing L1[i]/L2[i] """ ratios = [] for index in range(len(L1)): try: ratios.append(L1[index]/float(L2[index])) except ZeroDivisionError: ratios.append(float('NaN')) #NaN = Not a Number except: raise ValueError('get_ratios called with bad arg') return ratios
""" Exceptions to be called by service check plugins when the appropriate situations arrive. None of these have special behaviour. """ class ParamError(Exception): """To be thrown when user input causes the issue""" pass class ResultError(Exception): """To be thrown when the API/Metric Check returns either no result (when this isn't expected) or returns a result that is essentially unusable. """ pass class AssumedOK(Exception): """To be thrown when the status of the check cannot be identified. This is usually used when the check requires the result of a previous run and this is the first run.""" pass class InvalidMetricThreshold(Exception): """To be thrown when you pass a metric threshold with wrong syntax""" pass class InvalidMetricName(Exception): """To be thrown when you pass an invalid metric name.""" pass
class TracardiException(Exception): pass class StorageException(TracardiException): pass class ExpiredException(TracardiException): pass class UnauthorizedException(TracardiException): pass
def precedence(op): if op == '^': return 3 if op == '+' or op == '-': return 1 if op == '*' or op == '/': return 2 return 0 def applyOp(a, b, op): if op == '^': return a ** b if op == '+': return a + b if op == '-': return a - b if op == '*': return a * b if op == '/': return a // b def evaluate(tokens, x_set): values = [[] for _ in range(len(x_set))] ops = [] i = 0 while i < len(tokens): if tokens[i] == ' ': i += 1 continue elif tokens[i] == '(': ops.append(tokens[i]) elif tokens[i] in 'xX' : for index, x in enumerate(x_set): values[index].append(x) elif tokens[i].isdigit(): val = 0 while (i < len(tokens) and tokens[i].isdigit()): val = (val * 10) + int(tokens[i]) i += 1 i -= 1 for index, x in enumerate(x_set): values[index].append(val) elif tokens[i] == ')': while len(ops) != 0 and ops[-1] != '(': op = ops.pop() for index, x in enumerate(values): val2 = x.pop() val1 = x.pop() x.append(applyOp(val1, val2, op)) ops.pop() else: while (len(ops) != 0 and precedence(ops[-1]) >= precedence(tokens[i])): op = ops.pop() for index, x in enumerate(values): val2 = x.pop() val1 = x.pop() x.append(applyOp(val1, val2, op)) ops.append(tokens[i]) i += 1 while len(ops) != 0: op = ops.pop() for index, x in enumerate(values): val2 = x.pop() val1 = x.pop() x.append(applyOp(val1, val2, op)) values = [value.pop() for value in values] global one_one if len(list(set(values))) != len(values): one_one = False return values set1 =[int(x) for x in input('Enter comma separated domain: ').split(',')] set2 =[int(x) for x in input('Enter comma separated codomain: ').split(',')] expression = input('(+,-,*,/,^) Enter expression in terms of x: ') one_one = True try: results = evaluate(expression, set1) if set(results) == set(set2): print('ONTO') else: print('NOT ONTO') if one_one: print('ONE-ONE') else: print('NOT ONE-ONE') except: print('Invalid expression')
""" Question 15 : Write a program that computes the values of a+aa+aaa+aaaa with a given digit as the value of a. Suppose the following input is supplied to the program : 9 Then, the output should be : 11106 Hints : In case of input data begin supplied to the question, it should be assumed to be a console input. """ # Solution : num = int(input("Enter a number : ")) n1 = int("%s" % num) n2 = int("%s%s" % (num, num)) n3 = int("%s%s%s" % (num,num,num)) n4 = int("%s%s%s%s" % (num,num,num,num)) print(n1+n2+n3+n4) """ Output : Enter a number : 9 11106 """
class LRG(object): def __init__(self, N, V, P, S, H, end='.'): self.nonterm = set(N) self.term = set(V) self.term.add('ε') self.prod = {} for lhs, rhs in P.items(): self.prod[lhs] = set() for part in rhs.split('|'): if len(part) > 0: self.prod[lhs].add(part) self.S = S self.H = H self.end = end self.term.add(self.end) self.reduction_table = {} self.update_reduction_table() def update_reduction_table(self): # ресет таблицы self.reduction_table = {} # перебираем все комбинации нетерминал+терминал # для каждого нетерминала в мн-ве нетерминалов без S, но с H for n in self.nonterm.difference(self.S).union(self.H): # для каждого терминала в мн-ве терминалов без пустой цепочки for t in self.term.difference('ε'): state = str(n + t) # задаем значение по умолчанию self.reduction_table[state] = '-' # для каждого A=lhs и alpha=rhs в мн-ве правил for lhs, rhs in self.prod.items(): # для каждой части правила rhs for part in rhs: if state == part: self.reduction_table[state] = lhs continue if n == self.H: if t == part: self.reduction_table[state] = lhs def produces(self, sentence): n = self.H for t in sentence: value = self.reduction_table[str(n + t)] if value == '-': return False n = value return True lrg = LRG(['S', 'A', 'B'], ['a', 'b'], { 'S': 'A.', 'A': 'Ab|Bb|b', 'B': 'Aa' }, 'S', 'H', end='.') print('Параметры регулярной левосторонней грамматики lrg:') print('N: ', lrg.nonterm) print('V: ', lrg.term) print('P: ', lrg.prod) print('S: ', lrg.S) print('Начальное состояние: ', lrg.H) print('Символ конца цепочки: ', lrg.end) print('Таблица сверток: ', lrg.reduction_table) print() while True: print('Введите цепочку или введите exit для выхода...') response = input() if response == 'exit': break if lrg.produces(response): print('цепочка ' + response + ' принадлежит грамматике') else: print('цепочка ' + response + ' не принадлежит грамматике')
class ControlSys(): def __init__(self, fig, imdis, vol_tran, vol_fron, vol_sagi, ax_tran, ax_fron, ax_sagi): self.fig =fig self.imdis = imdis self.vol_tran = vol_tran self.vol_fron = vol_fron self.vol_sagi = vol_sagi self.ax_tran = ax_tran self.ax_fron = ax_fron self.ax_sagi = ax_sagi self.scroll_tran = None self.scroll_fron = None self.scroll_sagi = None self.lx_tran = ax_tran.axhline(color='b', linewidth=0.8) self.ly_tran = ax_tran.axvline(color='b', linewidth=0.8) self.lx_fron = ax_fron.axhline(color='b', linewidth=0.8) self.ly_fron = ax_fron.axvline(color='b', linewidth=0.8) self.lx_sagi = ax_sagi.axhline(color='b', linewidth=0.8) self.ly_sagi = ax_sagi.axvline(color='b', linewidth=0.8) self.txt_tran = ax_tran.text(0, -10, '', color='b') self.txt_fron = ax_fron.text(0, -10, '', color='b') self.txt_sagi = ax_sagi.text(0, -10, '', color='b') self.fig.canvas.mpl_connect('button_press_event', self.button_press_events) def button_press_events(self, event): if self.ax_tran.in_axes(event): self.fig.canvas.mpl_connect('button_press_event', self.add_cursor(event, self.ax_tran)) self.fig.canvas.mpl_connect('button_press_event', self.frontal_view(int(event.ydata))) self.fig.canvas.mpl_connect('button_press_event', self.sagittal_view(int(event.xdata))) # self.scroll_tran = self.fig.canvas.mpl_connect('scroll_event', self.transverse_scroll) # self.fig.canvas.mpl_disconnect(self.scroll_fron) # self.fig.canvas.mpl_disconnect(self.scroll_sagi) elif self.ax_fron.in_axes(event): self.fig.canvas.mpl_connect('button_press_event', self.add_cursor(event, self.ax_fron)) self.fig.canvas.mpl_connect('button_press_event', self.transverse_view(int(event.ydata))) self.fig.canvas.mpl_connect('button_press_event', self.sagittal_view(int(event.xdata))) # self.scroll_fron = self.fig.canvas.mpl_connect('scroll_event', self.frontal_scroll) # self.fig.canvas.mpl_disconnect(self.scroll_tran) # self.fig.canvas.mpl_disconnect(self.scroll_sagi) elif self.ax_sagi.in_axes(event): self.fig.canvas.mpl_connect('button_press_event', self.add_cursor(event, self.ax_sagi)) self.fig.canvas.mpl_connect('button_press_event', self.transverse_view(int(event.ydata))) self.fig.canvas.mpl_connect('button_press_event', self.frontal_view(int(event.xdata))) # self.scroll_sagi = self.fig.canvas.mpl_connect('scroll_event', self.sagittal_scroll) # self.fig.canvas.mpl_disconnect(self.scroll_tran) # self.fig.canvas.mpl_disconnect(self.scroll_fron) def transverse_view(self, index): self.ax_tran.index = index self.imdis.update_transverse_display(self.ax_tran.index) self.fig.canvas.draw_idle() def frontal_view(self, index): self.ax_fron.index = index self.imdis.update_frontal_display(self.ax_fron.index) self.fig.canvas.draw_idle() def sagittal_view(self, index): self.ax_sagi.index = index self.imdis.update_sagittal_display(self.ax_sagi.index) self.fig.canvas.draw_idle() def add_cursor(self, event, ax): if ax is self.ax_tran: x, y, z = event.xdata, event.ydata, self.ax_tran.index coord_tran = [x, y, z] coord_fron = [x, z, y] coord_sagi = [y, z, x] self.plot_cursor(coord_tran, self.lx_tran, self.ly_tran, self.txt_tran) self.plot_cursor(coord_fron, self.lx_fron, self.ly_fron, self.txt_fron) self.plot_cursor(coord_sagi, self.lx_sagi, self.ly_sagi, self.txt_sagi) if ax is self.ax_fron: x, y, z = event.xdata, event.ydata, self.ax_fron.index coord_fron = [x, y, z] coord_tran = [x, z, y] coord_sagi = [z, y, x] self.plot_cursor(coord_tran, self.lx_tran, self.ly_tran, self.txt_tran) self.plot_cursor(coord_fron, self.lx_fron, self.ly_fron, self.txt_fron) self.plot_cursor(coord_sagi, self.lx_sagi, self.ly_sagi, self.txt_sagi) if ax is self.ax_sagi: x, y, z = event.xdata, event.ydata, self.ax_sagi.index coord_sagi = [x, y, z] coord_tran = [z, x, y] coord_fron = [z, y, x] self.plot_cursor(coord_tran, self.lx_tran, self.ly_tran, self.txt_tran) self.plot_cursor(coord_fron, self.lx_fron, self.ly_fron, self.txt_fron) self.plot_cursor(coord_sagi, self.lx_sagi, self.ly_sagi, self.txt_sagi) def plot_cursor(self, coord, lx, ly, txt): x, y, z = coord[0], coord[1], coord[2] lx.set_ydata(y) ly.set_xdata(x) txt.set_text('x=%1d y=%1d z=%1d' % (x, y, z)) self.fig.canvas.draw_idle() def transverse_scroll(self, event): if event.button == 'down': self.ax_tran.index -= 1 if event.button == 'up': self.ax_tran.index += 1 self.imdis.update_transverse_display(self.ax_tran.index) self.fig.canvas.draw_idle() def frontal_scroll(self, event): if event.button == 'down': self.ax_fron.index -= 1 if event.button == 'up': self.ax_fron.index += 1 self.imdis.update_frontal_display(self.ax_fron.index) self.fig.canvas.draw_idle() def sagittal_scroll(self, event): if event.button == 'down': self.ax_sagi.index -= 1 if event.button == 'up': self.ax_sagi.index += 1 self.imdis.update_sagittal_display(self.ax_sagi.index) self.fig.canvas.draw_idle()
s = input() words = ["dream", "dreamer", "erase", "eraser"] words = sorted(words, reverse=True) print() for word in words: if word in s: s = s.replace(word, "") if not s: ans = "YES" else: ans = "NO" print(ans)
def read_safeguard_sql(cluster_descr, host_type): for schemas_descr in cluster_descr.schemas_list: if schemas_descr.schemas_type != host_type: continue safeguard_descr = schemas_descr.safeguard if safeguard_descr is None: continue yield from safeguard_descr.read_sql() # vi:ts=4:sw=4:et
def name_printer(user_name): print("Your name is", user_name) name = input("Please enter your name: ") name_printer(name)
error_code = { "private_account": [179, "Kalau mau ngemock pikir-pikir juga dong, masa private akun, mana keliatan tweetnya "], "blocked_account": [136, "Botnya dah diblock sama {}, ah ga seru"], "duplicate_tweet": [187, "Duplicated tweet"], "tweet_target_deleted": [144, "Tweetnya udah dihapus, kasian deh lo"], "tweet_target_to_long": [186, "Tweet hasil formatnya kepanjangan, coba yang lain aja "], "tweet_deleted_or_not_visible": [385, "Tweet deleted or not visible"], "twitter_over_capacity": [130, "Twitternya lagi overcapacity, next time yah"], "page_does_not_exist": [34, "Pages does not exist"], "suspended_account": [63, "Yang mau dimock dah disuspend, twitter, mampus."] } tweet_text = { "dont_mock": ["Enak aja developernya mau di mock, jangan ngelawak deh {}", "Kak {}, mending cari kegiatan produktif deh."], "follow_dulu": "Follow dulu, kalau gak mau ya mock manual aja yah ", "untag_dong": "Kalau jelasin cara kerja botnya tolong di untag yah, " } file_meme = {"output": ["img/meme_spongebob_output.png", "img/meme_khaleesi_output.png"], "input": ["img/meme_new.png", "img/meme_khaleesi.png"]} important_ids = { "developer_id": 1012117785512558592, "bot_id": 1157825461277167616, "bot_test_id": 1182299095370629123, "jokowi": 366987179, } trigger_words = ["please", "pliisi", "please😂", "please👏", "please🤮", "please🤢", "pleasek", "pleaseb", "pleasej", "please💩", "pleasealay", "pleaseud"] emoji_tweet_text = { "pleasek": ["kamu mending tutup akun twitter aja {}.", "kalau mau ngetweet, dipikir pikir aja dulu kak {}.", "kenapasih ngetweet ginian {}?", "kira kira aja kalau mau ngetweet {}."], "pleaseb": ["bisa diem gak {}.", "bagusan kalo tweet ini di simpen di draft aja kak {}.", "bacooot {}.", "berisik bat sih {}"], "pleasej": ["jujur, lu ngetweet ginian biar apasih {}.", "jangan bikin emosi deh {} jam segini.", "juara, tweet {} juara dalam kegoblokan."] }
# <auto-generated> # This code was generated by the UnitCodeGenerator tool # # Changes to this file will be lost if the code is regenerated # </auto-generated> def to_millilitres(value): return value * 4546.091879 def to_litres(value): return value * 4.546091879 def to_kilolitres(value): return value * 0.0045460918799 def to_teaspoons(value): return value * 768.0 def to_tablespoons(value): return value * 256.0 def to_quarts(value): return value * 4.0 def to_pints(value): return value * 8.0 def to_fluid_ounces(value): return value * 160.0 def to_u_s_teaspoons(value): return value / 0.00108421072977394606 def to_u_s_tablespoons(value): return value / 0.003252632189321838592 def to_u_s_quarts(value): return value / 0.20816846011659767808 def to_u_s_pints(value): return value / 0.10408423005829883904 def to_u_s_gallons(value): return value / 0.83267384046639071232 def to_u_s_fluid_ounces(value): return value / 0.006505264378643677184 def to_u_s_cups(value): return value / 0.052042115029149417472
# -*- coding: utf-8 -*- ''' Service support for Solaris 10 and 11, should work with other systems that use SMF also. (e.g. SmartOS) ''' __func_alias__ = { 'reload_': 'reload' } def __virtual__(): ''' Only work on systems which default to SMF ''' # Don't let this work on Solaris 9 since SMF doesn't exist on it. enable = set(( 'Solaris', 'SmartOS', )) if __grains__['os'] in enable: if __grains__['os'] == 'Solaris' and __grains__['kernelrelease'] == "5.9": return False return 'service' return False def get_enabled(): ''' Return the enabled services CLI Example: .. code-block:: bash salt '*' service.get_enabled ''' ret = set() cmd = 'svcs -H -o SVC,STATE -s SVC' lines = __salt__['cmd.run'](cmd).splitlines() for line in lines: comps = line.split() if not comps: continue if 'online' in line: ret.add(comps[0]) return sorted(ret) def get_disabled(): ''' Return the disabled services CLI Example: .. code-block:: bash salt '*' service.get_disabled ''' ret = set() cmd = 'svcs -aH -o SVC,STATE -s SVC' lines = __salt__['cmd.run'](cmd).splitlines() for line in lines: comps = line.split() if not comps: continue if not 'online' in line and not 'legacy_run' in line: ret.add(comps[0]) return sorted(ret) def available(name): ''' Return if the specified service is available CLI Example: .. code-block:: bash salt '*' service.available ''' return name in get_all() def get_all(): ''' Return all installed services CLI Example: .. code-block:: bash salt '*' service.get_all ''' ret = set() cmd = 'svcs -aH -o SVC,STATE -s SVC' lines = __salt__['cmd.run'](cmd).splitlines() for line in lines: comps = line.split() if not comps: continue ret.add(comps[0]) return sorted(ret) def start(name): ''' Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> ''' cmd = '/usr/sbin/svcadm enable -t {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def stop(name): ''' Stop the specified service CLI Example: .. code-block:: bash salt '*' service.stop <service name> ''' cmd = '/usr/sbin/svcadm disable -t {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def restart(name): ''' Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> ''' cmd = '/usr/sbin/svcadm restart {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def reload_(name): ''' Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> ''' cmd = '/usr/sbin/svcadm refresh {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def status(name, sig=None): ''' Return the status for a service, returns a bool whether the service is running. CLI Example: .. code-block:: bash salt '*' service.status <service name> ''' cmd = '/usr/bin/svcs -H -o STATE {0}'.format(name) line = __salt__['cmd.run'](cmd) if line == 'online': return True else: return False def enable(name, **kwargs): ''' Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name> ''' cmd = '/usr/sbin/svcadm enable {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def disable(name, **kwargs): ''' Disable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.disable <service name> ''' cmd = '/usr/sbin/svcadm disable {0}'.format(name) return not __salt__['cmd.retcode'](cmd) def enabled(name): ''' Check to see if the named service is enabled to start on boot CLI Example: .. code-block:: bash salt '*' service.enabled <service name> ''' return name in get_enabled() def disabled(name): ''' Check to see if the named service is disabled to start on boot CLI Example: .. code-block:: bash salt '*' service.disabled <service name> ''' return name in get_disabled()
n = int(input()) a = set(map(int, input().split())) m = int(input()) b = set(map(int, input().split())) inx = a.intersection(b) unx = a.union(b) x = unx.difference(inx) for i in sorted(x): print(i)
class Simulation: def __init__(self, x, v, box, potentials, integrator): self.x = x self.v = v self.box = box self.potentials = potentials self.integrator = integrator
class MyClass: """ Multiline class docstring """ def method(self): """Multiline method docstring """ pass def foo(): """This is a docstring with some lines of text here """ return def bar(): '''This is another docstring with more lines of text ''' return def baz(): '''"This" is a string with some embedded "quotes"''' return def troz(): '''Indentation with tabs is just as OK ''' return def zort(): """Another multiline docstring """ pass def poit(): """ Lorem ipsum dolor sit amet. Consectetur adipiscing elit: - sed do eiusmod tempor incididunt ut labore - dolore magna aliqua - enim ad minim veniam - quis nostrud exercitation ullamco laboris nisi - aliquip ex ea commodo consequat """ pass def under_indent(): """ These lines are indented in a way that does not make sense. """ pass def over_indent(): """ This has a shallow indent - But some lines are deeper - And the closing quote is too deep """ pass def single_line(): """But with a newline after it! """ pass def this(): r""" 'hey ho' """ def that(): """ "hey yah" """ def and_that(): """ "hey yah" """ def and_this(): ''' "hey yah"''' def multiline_whitespace(): ''' ''' def oneline_whitespace(): ''' ''' def empty(): """""" def single_quotes(): 'testing' def believe_it_or_not_this_is_in_the_py_stdlib(): ''' "hey yah"''' def ignored_docstring(): """a => \ b""" def single_line_docstring_with_whitespace(): """ This should be stripped """ def docstring_with_inline_tabs_and_space_indentation(): """hey tab separated value tab at start of line and then a tab separated value multiple tabs at the beginning and inline mixed tabs and spaces at beginning. next line has mixed tabs and spaces only. line ends with some tabs """ def docstring_with_inline_tabs_and_tab_indentation(): """hey tab separated value tab at start of line and then a tab separated value multiple tabs at the beginning and inline mixed tabs and spaces at beginning. next line has mixed tabs and spaces only. line ends with some tabs """ pass def backslash_space(): """\ """ def multiline_backslash_1(): ''' hey\there\ \ ''' def multiline_backslash_2(): ''' hey there \ ''' def multiline_backslash_3(): ''' already escaped \\ ''' def my_god_its_full_of_stars_1(): "I'm sorry Dave\u2001" # the space below is actually a \u2001, removed in output def my_god_its_full_of_stars_2(): "I'm sorry Dave " def docstring_almost_at_line_limit(): """long docstring.................................................................""" def docstring_almost_at_line_limit2(): """long docstring................................................................. .................................................................................. """ def docstring_at_line_limit(): """long docstring................................................................""" def multiline_docstring_at_line_limit(): """first line----------------------------------------------------------------------- second line----------------------------------------------------------------------""" # output class MyClass: """Multiline class docstring """ def method(self): """Multiline method docstring """ pass def foo(): """This is a docstring with some lines of text here """ return def bar(): """This is another docstring with more lines of text """ return def baz(): '''"This" is a string with some embedded "quotes"''' return def troz(): """Indentation with tabs is just as OK """ return def zort(): """Another multiline docstring """ pass def poit(): """ Lorem ipsum dolor sit amet. Consectetur adipiscing elit: - sed do eiusmod tempor incididunt ut labore - dolore magna aliqua - enim ad minim veniam - quis nostrud exercitation ullamco laboris nisi - aliquip ex ea commodo consequat """ pass def under_indent(): """ These lines are indented in a way that does not make sense. """ pass def over_indent(): """ This has a shallow indent - But some lines are deeper - And the closing quote is too deep """ pass def single_line(): """But with a newline after it!""" pass def this(): r""" 'hey ho' """ def that(): """ "hey yah" """ def and_that(): """ "hey yah" """ def and_this(): ''' "hey yah"''' def multiline_whitespace(): """ """ def oneline_whitespace(): """ """ def empty(): """""" def single_quotes(): "testing" def believe_it_or_not_this_is_in_the_py_stdlib(): ''' "hey yah"''' def ignored_docstring(): """a => \ b""" def single_line_docstring_with_whitespace(): """This should be stripped""" def docstring_with_inline_tabs_and_space_indentation(): """hey tab separated value tab at start of line and then a tab separated value multiple tabs at the beginning and inline mixed tabs and spaces at beginning. next line has mixed tabs and spaces only. line ends with some tabs """ def docstring_with_inline_tabs_and_tab_indentation(): """hey tab separated value tab at start of line and then a tab separated value multiple tabs at the beginning and inline mixed tabs and spaces at beginning. next line has mixed tabs and spaces only. line ends with some tabs """ pass def backslash_space(): """\ """ def multiline_backslash_1(): """ hey\there\ \ """ def multiline_backslash_2(): """ hey there \ """ def multiline_backslash_3(): """ already escaped \\""" def my_god_its_full_of_stars_1(): "I'm sorry Dave\u2001" # the space below is actually a \u2001, removed in output def my_god_its_full_of_stars_2(): "I'm sorry Dave" def docstring_almost_at_line_limit(): """long docstring.................................................................""" def docstring_almost_at_line_limit2(): """long docstring................................................................. .................................................................................. """ def docstring_at_line_limit(): """long docstring................................................................""" def multiline_docstring_at_line_limit(): """first line----------------------------------------------------------------------- second line----------------------------------------------------------------------"""
# Hola 3 -> HolaHolaHola def repeticiones(n):#Funcion envolvente def repetidor(string):#funcion anidada assert type(string) == str, "Solo se pueden utilizar strings" #afirmamos que el valor ingresado es un entero, de lo contrario envia el mensaje de error return(string*n)# llama a scope superior return repetidor #regresa la funcion anidada def run(): repetir5 = repeticiones(5) print(repetir5("Hola")) repetir10 = repeticiones(10) print(repetir5("Chris")) if __name__ == '__main__': run()
DATASET = "forest-2" CLASSES = 2 FEATURES = 54 NN_SIZE = 256 DIFFICULTY = 10000
#!/usr/bin/env python3 class Case: def __init__(self, number_of_switches): self.number_of_switches = number_of_switches self.number_of_toggles = 0 def run(self): self.number_of_toggles = self.min_toggles_for(self.number_of_switches) def min_toggles_for(self, switches): """ If there are no switches, the toggles needed are 0. If there is only one switch, an unique toggle is needed. For two or more switches, the minimum number of toggles is two times the minimum number of toggles needed for one switch less, and for odd number of switches an additional toggle is necessary. """ if switches < 1: return 0 elif switches == 1: return 1 else: toggles = self.min_toggles_for(switches - 1) * 2 if switches % 2 == 1: # odd number of switches toggles += 1 return toggles class Input: def run(self): number_of_cases = int(input()) for c in range(number_of_cases): self.parse_case() def parse_case(self): number_of_switches = int(input()) switch_system = Case(number_of_switches) switch_system.run() print(switch_system.number_of_toggles) Input().run()
nome = input('Digite seu nome: ') cpf = input('Digite seu CPF: ') rg = input('Digite seu RG: ') msg = '{0}, seu CPF é {1} e seu RG é {2}' print(msg.format(nome,cpf,rg))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Schooner - Course Management System # University of Turku / Faculty of Technilogy / Department of Computing # (c) 2021, Jani Tammi <jasata@utu.fi> # # Submission.py - Data dictionary class for core.submission # 2021-08-27 Initial version. # 2021-09-03 Updated to more flexible version with .db_update(). # class Submission(dict): def __init__(self, cursor, submission_id: int = None): self.cursor = cursor # Primary key is whatever are the call parameters, minus the first two self.pkkeys = [k for k in locals().keys() if k not in ('self', 'cursor')] self.pkvals = locals() # to avoid KeyError while being used inside comprehensions self.pkvals = [self.pkvals[k] for k in self.pkkeys] SQL = f"SELECT * FROM core.{self.__class__.__name__} WHERE " if all(self.pkvals): SQL += " AND ".join([f"{pk}=%({pk})s" for pk in self.pkkeys]) else: SQL += "false" if cursor.execute(SQL, locals()).rowcount: self.update( dict( zip( [key[0] for key in cursor.description], cursor.fetchone() ) ) ) elif all([v is None for v in self.pkvals]): # (all) PKs are None -> Create empty dict self.update( dict( zip( [key[0] for key in cursor.description], [None] * len(cursor.description) ) ) ) else: raise ValueError( f"{self.__class__.__name__} (" + ", ".join(f"'{v}'" for v in self.pkvals) + ") not found!" ) def db_update(self, commit: bool = True) -> None: """Update database table to match. (Will not INSERT).""" issues = [] for k in self.pkkeys: if not self[k]: issues.append(k) if issues: raise ValueError( f"Primary key value(s) ({', '.join(issues)}) have NULL values!" ) SQL = f"UPDATE core.{self.__class__.__name__} SET " SQL += ", ".join([f"{k}=%({k})s" for k in self.keys() if k not in self.pkkeys]) SQL += " WHERE " SQL += " AND ".join([f"{pk}=%({pk})s" for pk in self.pkkeys]) if not self.cursor.execute(SQL, self).rowcount: raise Exception( f"Unable to UPDATE {self.__class__.__name__} (" + ", ".join(f"'{self[k]}'" for k in self.pkkeys) + ")!" ) if commit: self.cursor.connection.commit() # EOF
# -*- coding: utf-8 -*- def get_node_indice(self, coordinates=None): """Return a matrix of nodes coordinates. Parameters ---------- self : Mesh an Mesh object indices : list Indices of the targeted nodes. If None, return all. is_indice: bool Option to return the nodes indices (useful for unsorted Returns ------- coordinates: ndarray nodes coordinates indices : ndarray nodes indices """ if coordinates is None: return self.node.get_indice() else: pass # TODO Search for indice of a node from coordiantes
class ContainerHypervisor(): def __init__(self): self.data = {} def parse(self, verbose=True): assert False, "Please use a subclass the implements this method." def retrieve_inputs(self, inputs, *args): assert False, "Please use a subclass the implements this method." def upload_outputs(self, outputs): assert False, "Please use a subclass the implements this method." def run_task(self, task, data, parameters): """ Returns the dictionary of outputs from the task. """ assert False, "Please use a subclass the implements this method."
class ImportError(Exception): pass class CatalogueImportError(Exception): pass
class Solution: def numberToWords(self, num: int) -> str: LESS_THAN_20 = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"] TENS = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"] THOUSANDS = ["", "Thousand", "Million", "Billion"] def helper(num): if num == 0: return '' elif num < 20: return LESS_THAN_20[num] + ' ' elif num < 100: return TENS[num // 10] + ' ' + helper(num % 10) return LESS_THAN_20[num // 100] + ' Hundred ' + helper(num % 100) if num == 0: return 'Zero' res = '' i = 0 while num: if num % 1000: res = helper(num % 1000) + THOUSANDS[i] + ' ' + res i += 1 num //= 1000 return res.strip()
a = int(input()) b = int(input()) if(a > b): print(True) else: print(False)
class X: pass class Y: pass class Z: pass class A(X, Y): pass class B(Y, Z): pass class M(B, A, Z): pass # Output: # [<class '__main__.M'>, <class '__main__.B'>, # <class '__main__.A'>, <class '__main__.X'>, # <class '__main__.Y'>, <class '__main__.Z'>, # <class 'object'>] print(M.mro())
#Its a simple Rock paper scissor game print('...Rock...') print('...Paper...') print('...Scissor...') x = input('Enter Player 1 Choice ') print('No Cheating\n\n' * 20) y = input('Enter Play 2 Choice ') if x == 'paper' and y == 'rock': print('Player 1 won') elif x == 'rock' and y == 'paper': print('Player 2 wins') elif x == 'scissor' and y == 'paper': print('Player 1 wins') elif x == 'paper' and y == 'scissor': print('Player 2 wins ') elif x == 'rock' and y == 'scissor': print('Player 1 wins') elif x == 'scissor' and y == 'rock': print('Player 2 wins ') else: print('Something else went wrong')
# Python - 3.6.0 def solution(a, b): units = { 'g': 1e-3, 'mg': 1e-6, 'μg': 1e-9, 'lb': 0.453592, 'cm': 1e-2, 'mm': 1e-3, 'μm': 1e-6, 'ft': 0.3048 } m1, m2, r = [*map(lambda e: e[0] * units.get(e[1], 1), zip(a, b))] return 6.67e-11 * m1 * m2 / (r ** 2)
POINT = 30 ochki = 30 person = {"Сила":"0","Здоровье":"0","Мудрость":"0","Ловкость":"0"} points = 0 choice = None while choice != 0: print(""" 0 - Выход 1 - Добавить пункты к характеристике 2 - Уменьшить пункты характеристики 3 - Просмотр характеристик """) choice = int(input("Выбор пункта меню: ")) if choice == 1: print("Пожалуйста, введите характеристику. ", len(person), "характеристики:") for item in person: print(item) char = str(input("\n:")) char = char.title() while char not in person: print("Нет такой характеристики, вы не в WoW: ") char = str(input("\n:")) char = char.title() else: print("\nВведите количество пунктов. У вас", ochki, "свободных пунктов") points = int(input("\n:")) while points > ochki or points < 0: print("Вы не можете назначить такое количество пунктов", "Доступно", ochki, "свободных пунктов") points = int(input("\n:")) person[char] = points print(points, "пунктов было добавлено к", char) ochki -= points elif choice == 2: print("Пожалуйста, введите имя характеристики.", "Доступно изменение для: ") for item in person: if int(person[item]) > 0: print(item) char = str(input("\n:")) char = char.title() while char not in person: print("Нет такой характеристики, вы не в WoW: ") char = str(input("\n:")) char = char.title() else: print("\nВведите количество пунктов. Доступно", person[char], "пунктов:") points = int(input("\n:")) while points > int(person[char]) or points < 0: print("Невозможно удалить такое количество пунктов. Доступно", person[char], "пунктов") points = int(input("\n:")) person[char] = points print(points, "пунктов было удалено") ochki += points elif choice == 3: print("\nХарактеристики Вашего героя") for item in person: print(item, "\t\t", person[item]) elif choice == 0: print("BB") elif choice == 100500: ochki += 99999999 print ("Вы ввели чит код на 99999999 поинтов") else: print("В меню нет такого пункта")
def add(x,y): """Add two numer together""" return x + y def substract(x,y): """Substract x from y and return value """ return y - x
# Program 70 : Function to print binary number using recursion def convertToBinary(n): if n > 1: convertToBinary(n//2) print(n % 2,end = '') # decimal number dec = int(input("Enter Decimal Number : ")) convertToBinary(dec) print()
def to_celsius(kelvin:float, round_digit=2) -> float: """Convert Kelvin to Celsius Args: kelvin (float): round_digit (int, optional): Defaults to 2. Returns: float: celcius """ return round(kelvin-273.15, round_digit) def fahr_to_celsius(fahr): cel=(fahr-32)*(5/9) return round(cel) def celsius_to_fahr(celsius): fahr=(9*celsius)/5+32 return round(fahr)
buffet = ('beef', 'chicken', 'fish', 'pork', 'lamb') for item in buffet: print(item, end=" ") print() buffet = ('wagyu', 'chicken', 'fish', 'squid', 'lamb') for item in buffet: print(item, end=" ")
''' Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Example 3: Input: nums = [3,3], target = 6 Output: [0,1] Constraints: 2 <= nums.length <= 104 -109 <= nums[i] <= 109 -109 <= target <= 109 Only one valid answer exists. ''' class Solution: def two_sum(self, nums: List[int], target: int) -> List[int]: for num in nums: if (target - num) in nums: return [nums.index(num), nums.index(target - num)] else: continue
SQLALCHEMY_DATABASE_URI = \ 'postgres+psycopg2://postgres:postgres@172.16.100.140/tdt2018' # 'postgres+psycopg2://postgres:postgres@localhost/tdt2018' SECRET_KEY = '\x88D\xf09\x91\x07\x98\x89\x87\x96\xa0A\xc68\xf9\xecJ:U\x17\xc5V\xbe\x8b\xef\xd7\xd8\xd3\xe6\x98*4'
#!/usr/bin/env python3 # # author : Michael Brockus.   # contact: <mailto:michaelbrockus@gmail.com> # license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0 # # copyright 2020 The Meson-UI development team # info = '''\ Meson-UI is an open source build GUI meant to be both extremely fast, and, even more importantly, as user friendly as possible. The main design point of Meson-UI is to provide a standalone portable build GUI and allow the user to access all or most of Meson build systems features. ''' class ProjectInfo: def get_description(self) -> str: return info def get_version(self) -> str: return '0.20.1' def get_license(self) -> str: return 'Apache-2.0' def get_project_name(self) -> str: return 'meson-ui' def get_packages(self) -> list: return ['mesonui', 'mesonui.containers', 'mesonui.dashboard', 'mesonui.mesonuilib', 'mesonui.repository', 'mesonui.models', 'mesonui.view', 'mesonui.ui', 'mesonui.mesonuilib.appconfig', 'mesonui.mesonuilib.backends', 'mesonui.mesonuilib.ninjabuild', 'mesonui.mesonuilib.mesonbuild', 'mesonui.mesonuilib.mesonapi']
class Node(): def __init__(self, key, cor): self._p = None self._right = None self._key = key self._left = None self._cor = cor def get_cor(self): return self._cor def set_cor(self, valor): self._cor = valor def get_key(self): return self._key def set_key(self, value): self._key = value def get_right(self): return self._right def set_right(self, value): self._right = value def get_left(self): return self._left def set_left(self, value): self._left = value def get_p(self): return self._p def set_p(self, value): self._p = value class ARB(): def __init__(self): self.__nil = Node(None, "BLACK") self.__nil.set_left(self.get_nil()) self.__nil.set_right(self.get_nil()) self.__root = self.get_nil() def get_root(self): return self.__root def set_root(self, valor): self.__root = valor def get_nil(self): return self.__nil def set_nil(self, valor): self.__nil = valor def Altura(self, x): if x == self.get_nil(): return -1 h1 = self.Altura(x.get_left()) h2 = self.Altura(x.get_right()) return (1 + max(h1, h2)) def Inorder(self, x): if x != self.get_nil(): self.Inorder(x.get_left()) print(x.get_key().get_id(),x.get_key().get_name()) #id(nome) self.Inorder(x.get_right()) def SearchId(self, x, k): while x != self.get_nil() and k != x.get_key().get_id(): if k < x.get_key().get_id(): x = x.get_left() else: x = x.get_right() return x def SearchNome(self, x, k): while x != self.get_nil() and k != x.get_key().get_name(): if k < x.get_key().get_name(): x = x.get_left() else: x = x.get_right() return x def Minimo(self, x): while x.get_left() != self.get_nil(): x = x.get_left() return x def Maximo(self, x): while x.get_right() != self.get_nil(): x = x.get_right() return x def Sucessor(self, x): if x.get_right() != self.get_nil(): return self.Minimo(x.get_right()) else: y = x.get_p() while y != self.get_nil() and x == y.get_right(): x = y y = y.get_p() return y def Predecessor(self, x): if x.get_left() != self.get_nil(): return self.Maximo(x.get_left()) else: y = x.get_p() while y != self.get_nil() and x == y.get_left(): x = y y = y.get_p() return y def Insert_Fixup(self, z): while z.get_p().get_cor() == "RED": if z.get_p() == z.get_p().get_p().get_left(): y = z.get_p().get_p().get_right() if y.get_cor() == "RED": z.get_p().set_cor("BLACK") y.set_cor("BLACK") z.get_p().get_p().set_cor("RED") z = z.get_p().get_p() else: if z == z.get_p().get_right(): z = z.get_p() self.Left_Rotate(z) z.get_p().set_cor("BLACK") z.get_p().get_p().set_cor("RED") self.Right_Rotate(z.get_p().get_p()) else: y = z.get_p().get_p().get_left() if y.get_cor() == "RED": z.get_p().set_cor("BLACK") y.set_cor("BLACK") z.get_p().get_p().set_cor("RED") z = z.get_p().get_p() else: if z == z.get_p().get_left(): z = z.get_p() self.Right_Rotate(z) z.get_p().set_cor("BLACK") z.get_p().get_p().set_cor("RED") self.Left_Rotate(z.get_p().get_p()) self.get_root().set_cor("BLACK") def Insert(self, dado): new = Node(dado, "RED") y = self.get_nil() x = self.get_root() while x != self.get_nil(): y = x if new.get_key().get_id() < x.get_key().get_id(): #Comparação pelo ID x = x.get_left() else: x = x.get_right() new.set_p(y) if y == self.get_nil(): self.set_root(new) elif new.get_key().get_id() < y.get_key().get_id(): y.set_left(new) else: y.set_right(new) new.set_right(self.get_nil()) new.set_left(self.get_nil()) new.set_cor("RED") self.Insert_Fixup(new) def Delete_Fixup(self, x): while x != self.get_root() and x.get_cor() == "BLACK": if x == x.get_p().get_left(): w = x.get_p().get_right() if w.get_cor() == "RED": w.set_cor("BLACK") x.get_p().set_cor("RED") self.Left_Rotate(x.get_p()) w = x.get_p().get_right() if w.get_left().get_cor() == "BLACK" and w.get_right().get_cor() == "BLACK": w.set_cor("RED") x = x.get_p() else: if w.get_right() == "BLACK": w.get_left().set_cor("BLACK") w.set_cor("RED") self.Right_Rotate(w) w = x.get_p().get_right() w.set_cor(x.get_p().get_cor()) x.get_p.set_cor("BLACK") w.get_right().set_cor("BLACK") self.Left_Rotate(x.get_p()) x = self.get_root() else: w = x.get_p().get_left() if w.get_cor() == "RED": w.set_cor("BLACK") x.get_p().set_cor("RED") self.Right_Rotate(x.get_p()) w = x.get_p().get_left() if w.get_right().get_cor() == "BLACK" and w.get_left().get_cor() == "BLACK": w.set_cor("RED") x = x.get_p() else: if w.get_left() == "BLACK": w.get_right().set_cor("BLACK") w.set_cor("RED") self.Left_Rotate(w) w = x.get_p().get_left() w.set_cor(x.get_p().get_cor()) x.get_p.set_cor("BLACK") w.get_left().set_cor("BLACK") self.Right_Rotate(x.get_p()) x = self.get_root() x.set_cor("BLACK") def Delete(self,ID): z = self.SearchId(self.get_root(), ID) if z == self.get_nil(): return 0 if z.get_left() == self.get_nil() or z.get_right() == self.get_nil(): y = z else: y = self.Sucessor(z) if y.get_left() != self.get_nil(): x = y.get_left() else: x = y.get_right() if x != self.get_nil(): x.set_p(y.get_p()) if y.get_p() == self.get_nil(): self.set_root(x) elif y == y.get_p().get_left(): y.get_p().set_left(x) else: y.get_p().set_right(x) if y != z: z.set_key(y.get_key()) if y.get_cor() == "BLACK": self.Delete_Fixup(x) return y def Left_Rotate(self, x): y = x.get_right() # define y x.set_right(y.get_left()) # transforma a subárvore à esquerda y na subárvore à direita de x y.get_left().set_p(x) y.set_p(x.get_p()) if x.get_p() == self.get_nil(): # In the RBT "None" is T.get_None() y.get_left().set_p(x) y.set_p(x.get_p()) # liga o pai de x a y if x.get_p() == self.get_nil(): self.set_root(y) elif x == x.get_p().get_left(): x.get_p().set_left(y) else: x.get_p().set_right(y) y.set_left(x) # Coloca x à esquerda de y x.set_p(y) def Right_Rotate(self, x): y = x.get_left() x.set_left(y.get_right()) y.get_right().set_p(x) y.set_p(x.get_p()) if x.get_p() == self.get_nil(): y.get_right().set_p(x) y.set_p(x.get_p()) if x.get_p() == self.get_nil(): self.set_root(y) elif x == x.get_p().get_right(): x.get_p().set_right(y) else: x.get_p().set_left(y) y.set_right(x) x.set_p(y) class Livro(): num = 0 def __init__(self,name): Livro.num += 1 self.__id = Livro.num self.__name = name self.__status = True def get_id(self): return self.__id def set_id(self,valor): self.__id = valor def get_name(self): return self.__name def get_status(self): return self.__status def set_status(self,new): self.__status = new class User(): num = 0 def __init__(self,name): User.num +=1 self.__idUser = User.num self.__userName = name self.__listaID = [] self.__listaLivros = [] self.__qntEmprestimo = 0 def get_livrosID(self): return self.__listaID def set_livrosID(self, ID): self.__listaID.append(ID) def removeID(self, ID): self.__listaID.remove(ID) def get_id(self): return self.__idUser def set_id(self,novoID): self.__idUser = novoID def get_name(self): return self.__userName def set_name(self, novoNome): self.__userName = novoNome def get_livros(self): return self.__listaLivros def addLivro(self, livro): self.__listaLivros.append(livro) def removeLivro(self, livro): self.__listaLivros.remove(livro) def getQnt(self): return self.__qntEmprestimo def setQnt(self): self.__qntEmprestimo +=1 def subtraiQnt(self): self.__qntEmprestimo -=1 arcevoLivros = ARB() listaUsuarios = ARB() while True: print("-----------------------------------------------") print("Bem-vindo a Biblioteca BSI"), print("Escolha uma das opções abaixo:") print("1 - Cadastrar livro") print("2 - Descadastrar Livro") print("3 - Cadastrar Usuário") print("4 - Descadastrar Usuário") print("5 - Socilitar livro por empréstimo") print("6 - Devolver livro") print("7 - Apresentar relatórios") print("8 - Buscar livro") print("9 - Ver todos os livros do acervo") print("-----------------------------------------------") try: comando = int(input("Operação a realizar: ")) if comando > 9 or comando <= 0: print("Digite uma opção válida") except: print("Digite uma opção válida") if comando == 1: cadastrarLivro = input("Digite o nome do livro: ") if cadastrarLivro == "": print("O nome não pode ser vazio") else: livro = Livro(cadastrarLivro) arcevoLivros.Insert(livro) print("Livro cadastrado com sucesso") elif comando == 2: print("------------------------------------------") print("Livros disponíveis no momento: ") arcevoLivros.Inorder(arcevoLivros.get_root()) removerLivro = int(input("Digite o número de ID: ")) x = arcevoLivros.SearchId(arcevoLivros.get_root(), removerLivro) x = x.get_key() if x == None: print("-------------------------------------------") print("Você tentou remover um livro que não existe") else: if x.get_status(): arcevoLivros.Delete(removerLivro) print("Livro removido com sucesso") else: print("O livro está emprestado e não poderá ser removido") elif comando == 3: cadastrarUsuario = input("Digite o nome do usuário: ") if cadastrarUsuario == "": print("O nome não pode ser vazio") else: usuario = User(cadastrarUsuario) listaUsuarios.Insert(usuario) print("Usuário cadastrado com sucesso") print("Seu ID de usuário é: %d" % usuario.get_id()) elif comando == 4: print("Usuários cadastrados no sistema:") listaUsuarios.Inorder(listaUsuarios.get_root()) removerUsuario = int(input("Digite a ID do usuário:")) y = listaUsuarios.SearchId(listaUsuarios.get_root(),removerUsuario) y = y.get_key() if y == None: print("---------------------------------------------") print("Você tentou remover um usuário que não existe") else: if len(y.get_livros()) > 0: print("O usuário possui livros e não poderá ser deletado") else: listaUsuarios.Delete(removerUsuario) print("Usuário removido com sucesso") elif comando == 5: while True: userID = int(input("Digite seu ID de usuário: ")) livroID = int(input("Digite o ID do Livro: ")) idusuario = listaUsuarios.SearchId(listaUsuarios.get_root(),userID).get_key() idlivro = arcevoLivros.SearchId(arcevoLivros.get_root(), livroID).get_key() if idusuario == None or idlivro == None: print("-----------------------------------------------") print("Você digitou um ID de usuário ou livro inválido") break else: break while True: if idusuario != None and idlivro != None: if idlivro.get_status() == False: print("----------------------------------------------") print("Livro indisponível") break else: if idusuario.getQnt() <3: idusuario.setQnt() idlivro.set_status(False) idusuario.addLivro(idlivro.get_name()) idusuario.set_livrosID(idlivro.get_id()) print("O livro %s foi entregue ao usuário %s"% (idlivro.get_name(),idusuario.get_name())) break else: print("-------------------------------------------") print("O usuário excedeu o limite de empréstimos") break else: break elif comando == 6: verificador = 0 verificadorUser = 0 while True: userID = int(input("Digite seu número de usuário: ")) idusuario = listaUsuarios.SearchId(listaUsuarios.get_root(),userID).get_key() if idusuario == None: print("----------------------------------------------") print("Você inseriu um ID de usuário inválido") verificadorUser +=1 break if len(idusuario.get_livros()) == 0: print("----------------------------------------------") print("Você não pegou nenhum livro por empréstimo") verificador +=1 break else: print("----------------------------------------------") print("Esses são os livros que você pegou: ") for i in range(len(idusuario.get_livros())): print("%d-%s"%(idusuario.get_livrosID()[i],idusuario.get_livros()[i])) devolverLivro = int(input("Digite o ID do livro que deseja devolver: ")) livro = arcevoLivros.SearchId(arcevoLivros.get_root(), devolverLivro).get_key() if idusuario != None and livro != None: print("Livro {} devolvido com sucesso.".format(livro.get_name())) break else: print("----------------------------------------------") print("Número de usuário ou livro inválido") verificador +=1 break if verificadorUser == 0 and verificador == 0: if livro.get_name() in idusuario.get_livros(): livro.set_status(True) idusuario.subtraiQnt() idusuario.removeLivro(livro.get_name()) idusuario.removeID(devolverLivro) else: print("------------------------------------------------") break elif comando == 7: entrada = input("Deseja ver o relatório por livro ou por usuário?: ") if entrada == "livro": idlivro = int(input("Insira a ID do livro: ")) livro = arcevoLivros.SearchId(arcevoLivros.get_root(), idlivro).get_key() if livro != None: if livro.get_status() is True: print("O livro está disponível para empréstimo") else: print("O livro está emprestado") else: print("Este livro não existe") elif entrada == "usuário": iduser = int(input("Insira o ID do usuário:")) user = listaUsuarios.SearchId(listaUsuarios.get_root(), iduser).get_key() if user != None: if len(user.get_livros()) > 0: print("O usuário pegou os seguintes livros: ") for x in user.get_livros(): print(x) else: print("O usuário não pegou nenhum livro por empréstimo") else: print("Você selecionou uma opção inválida") elif comando == 8: buscarLivro = input("Digite o nome do livro: ") z= arcevoLivros.SearchNome(arcevoLivros.get_root(), buscarLivro) z = z.get_key() if z == None: print("O livro não consta em nosso acervo") else: print("O livro consta no nosso acervo") elif comando == 9: print("Livros que possuímos atualmente:") arcevoLivros.Inorder(arcevoLivros.get_root())
class Source(object): """Source is a data source capable of fetching and rendering data. To create your own custom data source, you should subclass this class and override it with your own fetch() and render() functions. aiohttp is provided to all Source classes to fetch data over HTTP. See httpcodesource.py for an example on how to build your own simple data Source class. """ def __init__(self, aio_session): self.session = aio_session async def fetch(self, *args, **kwargs): pass async def render(self, *args, **kwargs): pass
""" Implementation of EDA-specific components """ def mk_clock(ctx, name): """ Creates a clock signal """ bool_t = ctx.mk_boolean_type() i = ctx.mk_input(name + '_input', bool_t) first = ctx.mk_latch(name + '_first', bool_t) ctx.set_latch_init_next(first, ctx.mk_true(), ctx.mk_false()) inv = ctx.mk_latch(name + '_inv', bool_t) clk = ctx.mk_ite(first, i, inv, name=name) ctx.set_latch_init_next(inv, ctx.mk_true(), ctx.mk_not(clk)) return clk, i def mk_counter(context, name, typ, limit, init=None, increment=None, enable=None, reset=None): """ Counts from init to limit by increment. Returns the value of the counter and whether the limit has been reached or not. An enable signal and a reset signal may also be specified. Args: context: the context to use name: the unique name of this counter type: the type of the data stored in the counter limit: the limit after which the counter saturates init (=0): the initial value of the counter increment (=1): the increment value enable (=true): the counter is incremented only if enable is true reset (=false): resets the counter to the initial value Returns: counter: the current value of the counter Q: true iff the counter has reached saturation """ if init is None: init = context.mk_number("0", typ) if increment is None: increment = context.mk_number("1", typ) if enable is None: enable = context.mk_true() if reset is None: reset = context.mk_false() counter = context.mk_latch(name, typ) not_q = context.mk_lt(counter, limit) nex = context.mk_ite(reset,\ init,\ context.mk_ite(context.mk_and(enable, not_q),\ context.mk_add(counter, increment),\ counter)) context.set_latch_init_next(counter, init, nex) q = context.mk_not(not_q, name + '.Q') return counter, q class LatchD: r""" LatchD (LD) A latch with enable Symbol: ____ | | D ---| LD |--- Q | | E ---| | |____| Diagram: A latch wrapped around a mux +--------------------+ | __ | | | \ ____ | +--| 0 | | | | | |----| L |---+--- Q D ---| 1 | | | |__/ |____| | | E -----+ """ def __init__(self, ctx, name, t): """ Args: ctx: the context to use name: the unique name t: the type of the data stored """ self._ctx = ctx self._name = name self.q = ctx.mk_latch(name, t) def set_init_next(self, init, d, e): """ Sets the initial value of the latch Args: init: the initial value D: the input signal E: the enable signal """ ite = self._ctx.mk_ite(e, d, self.q) self._ctx.set_latch_init_next(self.q, init, ite) class Delay: r""" Delay (D) Delays a signal by one full clock cycle Symbol: ____ | | D ---| D |--- Q | | |> | |____| Diagram: Two latches in series ____ ____ | | | | D ---| L |---| L |--- Q | | | | |____| |____| """ def __init__(self, ctx, name, t): """ Args: ctx: the context to use name: the unique name t: the type of the data stored """ self._ctx = ctx self._name = name self._l = ctx.mk_latch(name + '_back', t) self.q = ctx.mk_latch(name, t) def set_init_next(self, init, d): """ Sets the initial value of the latch Args: init: the "fill" value for the first cycle D: the input signal """ self._ctx.set_latch_init_next(self._l, init, d) self._ctx.set_latch_init_next(self.q, init, self._l) class FlipFlopD: r""" Flip Flop D (FFD) Args: ctx: the context to use name: the unique name t: the type of the data stored C: the clock signal Returns: Q: the value stored in the flip flop Symbol: _____ | | D ---| FFD |--- Q | | C ---|> | |_____| Diagram: It consists of a master DL and a slave LD. The diagram shows the raising-edge version (notice the negated clock in the master latchD) +---------------------+ | ____ | _____ | | | | | | +--| L |---+ __ | D ----| LD |---+ | | | | \ | | | | |____| +--| 0 | | C -+-o| | | | |--+-- Q | |_____| +------------------| 1 | | |__/ | | +---------------------------------+ """ def __init__(self, ctx, name, t, c): """ Args: ctx: the context to use name: the unique name t: the type of the data stored C: the clock signal """ self._ctx = ctx self._name = name self._master = LatchD(ctx, name + '_master', t) self._slave = ctx.mk_latch(name + '_slave', t) self.q = self._ctx.mk_ite(c, self._master.q, self._slave, name + '.Q') self._c = c def set_init_next(self, init, d): """ Sets the initial and next value Args: init: the initial value D: the flip flop input signal """ self._master.set_init_next(init, d, self._ctx.mk_not(self._c)) self._ctx.set_latch_init_next(self._slave, init, self.q) class FlipFlopDE: r""" Flip Flop D with Enable (FFDE) Symbol: _____ | | D ---| FFD |--- Q E ---| | C ---|> | |_____| Diagram: It consists of a FFD wrapped by a mux +--------------------+ | __ | | | \ _____ | +--| 0 | | | | | |---| FFD |---+--- Q D ---| 1 | | | |__/ +-|> | | | |_____| E -----+ | | C ---------+ """ def __init__(self, ctx, name, t, c): """ Args: ctx: the context to use name: the unique name t: the type of the data stored C: the clock signal """ self._ctx = ctx self._name = name self._master = LatchD(ctx, name + '_master', t) self._slave = ctx.mk_latch(name + '_slave', t) self.q = self._ctx.mk_ite(c, self._master.q, self._slave, name + '.Q') self._c = c def set_init_next(self, init, d, e): """ Sets the initial and next value Args: init: the initial value D: the flip flop input signal E: the flip flop enable signal """ mux = self._ctx.mk_ite(e, d, self.q) self._master.set_init_next(init, mux, self._ctx.mk_not(self._c)) self._ctx.set_latch_init_next(self._slave, init, self.q)
word_to_find = "box" def get_puzzle(): o = [] with open("puzzle.txt","r") as file: x = file.readlines() for i in x: o.append(i.split(",")[:-1]) return o def chunks(lst, n): f = [] for i in range(0, len(lst), n): f.append(lst[i:i + n]) return f def find_letters_in_list(lst,word): c_in = 0 Out_ = [] for e,i in enumerate(lst): try: if i == word[c_in]: c_in += 1 Out_.append(e) else: pass except IndexError: pass return(Out_) def transpose(l1, l2): for i in range(len(l1[0])): row =[] for item in l1: row.append(item[i]) l2.append(row) return l2 def solve(): Rows = [] C = [] Column = [] alr_found = 0 puzzle = get_puzzle() for rows in puzzle: for letters in rows: Rows.append(letters) for X in range(len(puzzle)-1): C.append(str([i[X] for i in puzzle])) for i in C: b_c = i.replace("[","").replace("]","").replace("'","").replace(" ","") for i in b_c: if i == ",": pass else: Column.append(i) rev_rows = Rows[::-1] rev_columns = Column[::-1] #solving it col = 0 Chunk_column = chunks(Column,len(word_to_find)+len(word_to_find)) Out = Chunk_column Chunk_column_rev = chunks(Column,len(word_to_find)+len(word_to_find))[::-1] Out2 = Chunk_column_rev if word_to_find in "".join(Column).lower(): for i in Chunk_column: if word_to_find in "".join(i).lower(): l_index = find_letters_in_list(Chunk_column[col],word_to_find.upper()) for o in l_index: Out[col][o] = "("+str(Out[col][o])+")" else: col += 1 elif word_to_find in "".join(rev_columns).lower(): for i in Chunk_column_rev: if word_to_find[::-1] in "".join(i).lower(): l_index = find_letters_in_list(Chunk_column[col][::-1],word_to_find.upper()) for o in l_index: Out[col][o+1] = "("+str(Out[col][o+1])+")" else: col += 1 #give output x = [] transpose(Out,x) return x def user_friendly_data(): print("output from algorithm:") for i in solve(): print(" ".join(i)) user_friendly_data()
dataset_paths = { # Face Datasets (In the paper: FFHQ - train, CelebAHQ - test) 'ffhq': '', 'celeba_test': '', # Cars Dataset (In the paper: Stanford cars) 'cars_train': '', 'cars_test': '', # Horse Dataset (In the paper: LSUN Horse) 'horse_train': '', 'horse_test': '', # Church Dataset (In the paper: LSUN Church) 'church_train': '', 'church_test': '', # Cats Dataset (In the paper: LSUN Cat) 'cats_train': '', 'cats_test': '' } model_paths = { 'stylegan_ffhq': 'pretrained_models/stylegan2-ffhq-config-f.pt', 'ir_se50': 'pretrained_models/model_ir_se50.pth', 'shape_predictor': 'pretrained_models/shape_predictor_68_face_landmarks.dat', 'moco': 'pretrained_models/moco_v2_800ep_pretrain.pth' }
class Stop(): def __init__(self, name): self.name = name self.schedule = {} self.previous_stop = dict() self.next_stop = dict() self.neighbords = [self.previous_stop, self.next_stop] self.left_stop = None self.right_stop = None def set_schedule(self, line, schedule): self.schedule[line] = schedule def set_next_stop(self, line, next_stop): self.next_stop[line] = next_stop def set_previous_stop(self, line, previous_stop): self.previous_stop[line] = previous_stop def set_left_stop(self, left_stop): self.left_stop = left_stop def set_right_stop(self, right_stop): self.right_stop = right_stop
def sum_of_two_numbers(number_1, number_2): return number_1 + number_2 #print(sum(5,6)) if __name__ == '____': a, b= map(int, input().split()) print(sum(a, b))
#from DebugLogger00110 import DebugLogger00100 #import fbxsdk as fbx #from fbxsdk import * #import fbx as fbxsdk #from fbx import * # -*- coding: utf-8 -*- #from fbx import * #import DebugLogger00100 #import DebugLogger00100 #import WriteReadTrans_Z_00310 #import GetKeyCurve00110 #===================class Node========================= #import FbxCommon #===================class Node========================= print("fbx_____.py")
''' Exercício Python 015: Escreva um programa que pergunte a quantidade de Km percorridos por um carro alugado e a quantidade de dias pelos quais ele foi alugado. Calcule o preço a pagar, sabendo que o carro custa R$60 por dia e R$0,15 por Km rodado. ''' dias = int(input('Quantos dias alugados? ')) km = float(input('Quantos km rodados? ')) pago = (dias * 60) + (km * 0.15) print(f'O total a pagar é de R${pago:.2f}.')