From b49b9caf67c04df8077e32913927ed438a62684d Mon Sep 17 00:00:00 2001 From: the-blind-pew Date: Mon, 20 Mar 2023 22:30:04 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=98=D0=B7=D0=B2=D0=B8=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D0=B5,=20=D1=87=D1=82=D0=BE=20=D1=82=D0=B0=D0=BA=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BB=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes lesson_1/.DS_Store | Bin 0 -> 6148 bytes lesson_1/task1.py | 5 +++++ lesson_1/task2.py | 5 +++++ lesson_1/task3.py | 3 +++ lesson_1/task4.py | 5 +++++ lesson_1/task5.py | 4 ++++ 7 files changed, 22 insertions(+) create mode 100644 .DS_Store create mode 100644 lesson_1/.DS_Store create mode 100644 lesson_1/task1.py create mode 100644 lesson_1/task2.py create mode 100644 lesson_1/task3.py create mode 100644 lesson_1/task4.py create mode 100644 lesson_1/task5.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..29a7291c6770d4ec37c4248c1c025527c47db060 GIT binary patch literal 6148 zcmeHK&5qMB5FWRMb&3!@AOQ!YT)0)Mq(X=bQnqvtdq6@2!2wV=A=PfAY`khxDkw#{ z^9Jw`yazA9vv7iMY_p=-MSDYn^;GsZo*zg4oZ1;865~Y{5)Ft*qA_+nbY}?rxt)@Z zwQK74uv4DjA{DW@Yk*ef>nZwH?3A6oQ6Bo#EH3O_|9O(|%_e>o>U z+>95u&x=o&)vrL{HLZ`D{5ITz{y_I?2n~Tqoz*3?VO{=VhjrW3?!=O3xD;hm@Z5rh{9nRT$hK z`r&A_9{SLOyF>rpC|IvOdE-v_U~m8E?Yq_c^@mTID-!rWXt`$b7kq}&W-@#e&&xuU z2k>!T+dpbC_YpC_?~F%JXqR?qLXUvk*vqVy@x7ISp%ce|W8gwFV9zLdF`H3 zzAZ%58>-@5|KgII|dvBn+$Z#aKQKf?w{-b%_KK+3^)eLihlD%6`EspP6A8j9vh2t87Cn-?$Rg74^if^K6f!${X7+Gu#!UAz00-6TbIR^eJ G13v-O(2))R literal 0 HcmV?d00001 diff --git a/lesson_1/.DS_Store b/lesson_1/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a05bf48df5bfea51e3f13a93233090e433992446 GIT binary patch literal 6148 zcmeHK%TB{E5S)cdMCzqSE=c}@Nd1FQwFl0808q*S5eQP@&|Ch9PlVYAh^D!M5ZaCG z+1RsoJW^~g09m|l=D-X<#iA(cjF>i$b{z%zm?$@kd_Lh z0;xbMkP7^S0z9+Ts;OhvsX!`_3VbP``$J(-Yyx{n+d5cT3P7B&*^ItkmNljXHi5k( zduZaJL=TlnF~q~!UV_&I_KqG7iR43K=Fj9sY<7-cj1FlWvrYw4fqexu_odDB{9o~x z8BOwyl2s~@3j9|EWU{HgKuMUm=-X(x9x{sV%r}r22$!h|8 VM;%4mEu5Ga0TU#vRNxmB_y7juGkO33 literal 0 HcmV?d00001 diff --git a/lesson_1/task1.py b/lesson_1/task1.py new file mode 100644 index 0000000..a84684f --- /dev/null +++ b/lesson_1/task1.py @@ -0,0 +1,5 @@ +num_arr = input().split(" ") +num_sum = 0 +for i in num_arr: + num_sum += float(i) +print(num_sum) diff --git a/lesson_1/task2.py b/lesson_1/task2.py new file mode 100644 index 0000000..1e9148c --- /dev/null +++ b/lesson_1/task2.py @@ -0,0 +1,5 @@ +current_str = input() +while(True): + replace_arr = input().split("->") + current_str = current_str.replace(replace_arr[0], replace_arr[1]) + print(current_str) diff --git a/lesson_1/task3.py b/lesson_1/task3.py new file mode 100644 index 0000000..11554c3 --- /dev/null +++ b/lesson_1/task3.py @@ -0,0 +1,3 @@ +num_arr = input().split(" ") +for i in num_arr: + print(int(round(abs(float(i)), 0)), end=" ") diff --git a/lesson_1/task4.py b/lesson_1/task4.py new file mode 100644 index 0000000..65d43aa --- /dev/null +++ b/lesson_1/task4.py @@ -0,0 +1,5 @@ +num_arr = input().split(" ") +num_sum = 0 +for i in num_arr: + num_sum += float(i) ** 2 +print(num_sum) diff --git a/lesson_1/task5.py b/lesson_1/task5.py new file mode 100644 index 0000000..0f0b7a5 --- /dev/null +++ b/lesson_1/task5.py @@ -0,0 +1,4 @@ +unencoded_str = input().replace(" ", "") +key = int(input()) +for i in unencoded_str: + print(chr(96 + (ord(i) + key - 96) % 26), end="") From 2ad65716f435383fdc4c1e47e53a5a87fc070a0f Mon Sep 17 00:00:00 2001 From: the-blind-pew Date: Tue, 21 Mar 2023 14:06:40 +0300 Subject: [PATCH 2/3] Finally --- .DS_Store | Bin 6148 -> 6148 bytes lesson_1/.DS_Store | Bin 6148 -> 6148 bytes lesson_2/dearchiver_lwz.py | 55 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 lesson_2/dearchiver_lwz.py diff --git a/.DS_Store b/.DS_Store index 29a7291c6770d4ec37c4248c1c025527c47db060..3d1adcf7dd688e431e96e2cae3b6da7a32538062 100644 GIT binary patch delta 92 zcmZoMXfc=|#>B!ku~2NHo+2aX#(>?7iv?Ji7&$ldFdb%`Y|13SXf$~l(@S2Xvf!e; vocz3W1_lPk&1aYm88@?Y@N)q5Zf0cp&ODi4#F2xMfq@Aq&9FH_WDPR_S+f=o delta 68 zcmZoMXfc=|#>B)qu~2NHo+2ar#(>?7jO?3vSPnC8zR9M?xUqqYc{4i)KL=3FWB)qu~2NHo+2a1#DLw4H!w0Xa!lr7oL znUkNKl#`#tz`!8Dz`)oIr1k!T0g%POz=@>34y%rzXgUx!7-Oo>16qMwg9)Yv1_q{d uoEDg3Reu$se)B@ca+b~P9Q+)>00DBoGf(ChvE*O`x&o+(VRL}U7G?lsT~jsy delta 67 zcmZoMXfc=|#>B`mu~2NHo+2aj#DLw5%#(STrf;6cT*$I{0rO|Z&Fmcf96%+TCo+F$ Wp3E;|$-w{wj0_A+n*&6)FarQ`#t`NJ diff --git a/lesson_2/dearchiver_lwz.py b/lesson_2/dearchiver_lwz.py new file mode 100644 index 0000000..8dda575 --- /dev/null +++ b/lesson_2/dearchiver_lwz.py @@ -0,0 +1,55 @@ +import math +import sys + +if not (2 <= len(sys.argv) <= 3): + print('Usage: python', sys.argv[0], '{encoded_file}.lwz (output_file)') + exit(-1) + +in_path = sys.argv[1] + +out_path = sys.argv[2] if len(sys.argv) == 3 else sys.argv[1][:-4][:sys.argv[1][:-4].find('.')] + '_dec' \ + + sys.argv[1][:-4][sys.argv[1][:-4].find('.'):] + +dictionary = {i: (i,) for i in range(256)} + +current_bytes = [] + +with open(in_path, 'rb') as file_in: + with open(out_path, 'wb') as file_out: + bites = math.ceil(math.log2(len(dictionary))) + bytes = bites // 8 + if bytes % 8 == 0: + bytes += 1 + sym = int.from_bytes(file_in.read(bytes), byteorder='little') + file_out.write(bytearray(dictionary[sym])) + current_bytes.append(dictionary[sym][0]) + current_bytes.append(sym) + current_bytes = list(dictionary[sym]) + while(True): + bites = math.ceil(math.log2(len(dictionary))) + bytes1 = bites // 8 + bytes1 += 1 + sym = file_in.read(bytes1) + if not sym: + break + sym = int.from_bytes(sym, byteorder='little') + #print('byte array:', current_bytes) + #print('int symbol:', sym) + if sym in dictionary: + file_out.write(bytearray(dictionary[sym])) + current_bytes.append(dictionary[sym][0]) + dictionary[len(dictionary)] = tuple(current_bytes) + current_bytes = list(dictionary[sym]) + else: + current_bytes.append(current_bytes[0]) + file_out.write(bytearray(current_bytes)) + dictionary[len(dictionary)] = tuple(current_bytes) + #print('=====================') + +print('new entries in the dictionary:') +printable_key = [] +for i in range(256, len(dictionary)): + for j in range(len(dictionary[i])): + printable_key.append(chr(dictionary[i][j])) + print(i, '->', ''.join(printable_key)) + printable_key.clear() \ No newline at end of file From 45c08b8b5ad92f0f12c63a674abe4ddbfdc538db Mon Sep 17 00:00:00 2001 From: the-blind-pew Date: Tue, 21 Mar 2023 20:21:12 +0300 Subject: [PATCH 3/3] fixed task3.py --- lesson_1/task3.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lesson_1/task3.py b/lesson_1/task3.py index 11554c3..b1d6d1b 100644 --- a/lesson_1/task3.py +++ b/lesson_1/task3.py @@ -1,3 +1,5 @@ +import math + num_arr = input().split(" ") for i in num_arr: - print(int(round(abs(float(i)), 0)), end=" ") + print(int(math.floor(abs(float(i)))), end=" ")