Compare commits

..

2 Commits

Author SHA1 Message Date
ee7d0e9e08 G05 2024-01-18 15:17:03 +01:00
mxsgd
f4afb37947 G05 2024-01-18 15:09:46 +01:00
5 changed files with 50044 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Python 3.8" /> <option name="sdkName" value="Python 3.8" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project> </project>

25
TaskG04/run.py Normal file
View File

@ -0,0 +1,25 @@
import re
import sys
def binary_to_utf8(binary_string):
# padding = 8 - len(binary_string) % 8
# binary_string += '0' * padding
# binary_string = binary_string.rstrip('0')
bytes_list = [binary_string[i:i+8] for i in range(0, len(binary_string), 8)]
decimal_list = [int(byte, 2) for byte in bytes_list]
bytes = bytearray(decimal_list)
try:
utf8_text = bytes.decode('utf-8')
except UnicodeDecodeError:
utf8_text = bytes.decode('utf-8', errors='replace')
return utf8_text
return utf8_text
for line in sys.stdin:
result = binary_to_utf8(line.strip())
print(result.encode('utf-8'))

File diff suppressed because one or more lines are too long

17
TaskG05/run.py Normal file
View File

@ -0,0 +1,17 @@
import sys
import binascii
def hex_to_utf8(hex_string):
hex_string = hex_string.replace(' ', '').replace('0x', '')
bytes_data = binascii.unhexlify(hex_string)
try:
utf8_text = bytes_data.decode('utf-8')
except UnicodeDecodeError:
utf8_text = bytes_data.decode('utf-8', errors='replace')
return utf8_text
for line in sys.stdin:
result_text = hex_to_utf8(line.strip())
print(result_text.encode('utf-8'))