We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Merge the Tools!
- Discussions
Merge the Tools!
Merge the Tools!
Sort by
recency
|
2644 Discussions
|
Please Login in order to post a comment
Here is hackerrank merge the tools! solution in python - https://programmingoneonone.com/hackerrank-merge-the-tools-solution-in-python.html
Here is my proposed solution. It does not use set or dict as set is does not ensure ordering, and dict, before Python 3.7 does not preserve order as well:
This ensures "All characters in the individual subsequence preserve their order" while ensuring we don't traverse the strings in individual loops.
import textwrap def merge_the_tools(string, k): # your code goes here chunks = textwrap.wrap(string, k) for a in chunks: print(''.join(list(set(a))))