All Questions
489
questions
3
votes
1
answer
89
views
Build a dictionary from a string by the extraction of data from all the pairs <TAG|VAL> contained inside the string and clean string from TAGs
I have written code to manage a string and retrieve from it a dictionary which must contain pairs key-value dependent from the string.
To be more clear I'll show ...
0
votes
1
answer
46
views
Optimize for compute/timespace - substring matching STD pk / sk format
BUSINESS CASE
For users of my application I need to manage a granular list of grants. I'm using an aws dynamodb backend with lite Single Table Design (STD) strategies. A common syntax for STD keys ...
8
votes
3
answers
874
views
Split String Function Implementation in Python
For learning purposes, I am trying to implement Python's built-in function split. I am new to Python, and I know that str.split ...
3
votes
1
answer
88
views
Multiline string concatenation
Problem Description
Printing the result of adding two numpy arrays together is very ugly.
Here we will use these numpy arrays as an example:
...
6
votes
1
answer
137
views
One Time Pad encryption in Python
I made this code to encrypt a string with the One Time Pad method. Is this pythonic code, and are there obvious ways I can improve?
The program accepts a plaintext and can either accept an inputted ...
3
votes
2
answers
143
views
A simple search-and-replace algorithm
In recent times, I've been using the following algorithm repeatedly in different languages (Java, Python, ...) to search and replace strings. I don't like this implementation very much, it's very ...
1
vote
1
answer
207
views
Function that finds the exact number of times a string appears in a text
So I was tasked with providing a function that returns how many exact occurrences of attribute word appear in attribute text. The goal is for the function to be as fast as possible, and I managed to ...
4
votes
3
answers
840
views
Codewars: Multiplying Polynomials
I'm trying to solve the following Kata from Codewars in Python.
My code produces the desired result for all the tests, yet it is not optimal, so it takes too much time to accomplish the big tests.
<...
-2
votes
1
answer
185
views
Design an algorithm to predict words based on a skeleton from a given dictionary
The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and ...
2
votes
3
answers
136
views
Automate the boring stuff with python - Comma Code v2
This is the second version of code reviewed earlier.
Comma Code
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function ...
1
vote
3
answers
190
views
Automate the boring stuff with python - Comma Code
Comma Code
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns a
...
1
vote
1
answer
351
views
Replacing NOUNS, VERBS, ADJECTIVES in a text file with input words
I've written code for a program that reads a text file, checking if there's any capitalized parts of speech of specific types (noun, adj, verb, adv) in the text and replace them with the user's chosen ...
4
votes
4
answers
2k
views
Matching words from a text with a big list of keywords in Python
I implemented the following code to retrieve medication names from a given text (prescription_text in the code). It works by matching words in the text with a list ...
7
votes
4
answers
431
views
Separating a String of Text into Separate Words in Python
Occasionally, we want to do a rudimentary parsing on English text; we separate the text into separate words.
...
4
votes
4
answers
3k
views
A function that uses a regex to parse date and time and returns a datetime object
The code works, but I think can be simplified, I don't know which specific steps, but my version seems to me quite complicated
I build a function that takes a specific string format and returns a <...