Skip to main content

All Questions

1 vote
1 answer
236 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 ...
Jules Raschilas's user avatar
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 ...
cuzureau's user avatar
  • 181
1 vote
1 answer
870 views

Adding string to a text file without duplicates

I have a function below, store_in_matchid_file, and it adds certain strings to a .txt file as long as that string doesn't already exist in the file. However that ...
Jack's user avatar
  • 47
14 votes
8 answers
19k views

Python program to take in two strings and print the larger string

I have written a Python program to take in two strings and print the larger of the two strings. Here is my code - ...
Justin's user avatar
  • 2,575
5 votes
1 answer
86 views

Check if we can form a word across words in a sentence

I've come across a simple challenge: given a phrase, check if we can form the given word vertically by stacking words in rows. For example, we can form the word ...
Eugene Yarmash's user avatar
5 votes
2 answers
451 views

Small Chatbot challenge

The Challenge : You have a list conversations, in which each element is a conversation that is represented as an array of words. You need to create a chatbot that will complete a conversation ...
Aness's user avatar
  • 151
2 votes
1 answer
1k views

Find a substring count in an string

This code is written to find substring count in a string in Python 3. The original problem description is here. Please suggest better ways of solving this. ...
sarvajeetsuman's user avatar
3 votes
2 answers
262 views

Largest substring which starts and ends with some substring

This code is meant to find the length of the largest substring within a string that starts and ends with a given non-empty substring. Here are some examples: ...
cycloidistic's user avatar
6 votes
2 answers
930 views

Reduce as many adjacent chars as possible in string

This code is meant to reduce a given string as much as possible by deleting adjacent characters. Here are some examples: ...
cycloidistic's user avatar
5 votes
5 answers
3k views

Number of sub strings with same first and last character

Problem Statement: You are given a function \$f(x)\$, where \$f(x)\$ is \$1\$ if the first and last characters of string \$x\$ are equal; else it is \$0\$. You are given a string \$S\$ and you ...
gaurav's user avatar
  • 179
2 votes
3 answers
127 views

Large number to many characters

My goal is to take any size number, and convert it to a string of smaller characters that represent the concatenation of the binary expansion of the number. To illustrate what I am talking about, here ...
Nick Pandolfi's user avatar