🐍 Python Weekly Coding Challenge - The space explorer’s journey #154166
Replies: 5 comments
-
Hey @mecodeatlas , this was a fun challenge!
It runs efficiently since we only go through the input once. |
Beta Was this translation helpful? Give feedback.
-
My solution for this problem: code: # this function returns a dictionary which contains the characters and the number following them
def generate_decode_dictionary(string):
decode_dictionary: dict = {}
for n in range(0, len(string), 2):
# adjacent pairs: n, n+1
character, position = string[n], string[n + 1]
# add the numbers as keys and characters as values
decode_dictionary[position] = character
return decode_dictionary
# this function helps in sorting the dictionary based on keys
def sort_dictionary(dictionary):
return dict(sorted(dictionary.items()))
decoded_dictionary = generate_decode_dictionary("x2e1m4a3")
sorted_decoded_dictionary = sort_dictionary(decoded_dictionary)
print("".join(sorted_decoded_dictionary.values())) my approach:
|
Beta Was this translation helpful? Give feedback.
-
my code:
approach:
|
Beta Was this translation helpful? Give feedback.
-
Hi @mecodeatlas,
ApproachExtract letters and their positions from the string |
Beta Was this translation helpful? Give feedback.
-
c = input() Approach |
Beta Was this translation helpful? Give feedback.
-
This is the first of four challenges designed to test and improve your Python skills. Each week, you'll tackle a new problem focusing on logic, data manipulation, and efficiency. Engage with others, share your ideas, and collaborate to find creative solutions—this is a space to learn and grow together! 🚀
General rules
Evaluation criteria (Total: 100 points)
Now, let’s dive into the first challenge! 🔥
The space explorer’s journey
You are a space explorer who has discovered an encrypted alien message. To decipher it and understand what the aliens are communicating, you must develop an efficient decoder.
Objective
Write a program that decodes a message following a specific encoding pattern.
Input & Output
Input: A string where each letter is followed by a number indicating its position in the decoded message.
Example:
Expected output:
Rules
:
(colon).Good luck!
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions