Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [strings]

A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

1
vote
1answer
23 views

Python program to get the first word

Given a string the task it to find its first word with some rules: The string can have points and commas A word can start with a letter, a point or space One word can contain one apostrophe and it ...
1
vote
2answers
33 views

Python program to get the longest substring of the same character

Given a word the program outputs the length of the longest substring with the same letters. For example: long_repeat('sdsffffse') == 4 long_repeat('ddvvrwwwrggg') == 3 long_repeat('abababaab') == 2 ...
2
votes
2answers
34 views

Python program to translate sentences from “bird language”

Given a sentence in 'bird language', where there are two rules: After each consonant there is a random vowel added. For example if the consonant is "l" it will end as "la" or "le"... After each vowel ...
1
vote
2answers
27 views

Function to count words in Python

I am new to developing in Python and would like to see comments about my word count solution. Please indicate my mistakes or best solutions. ...
3
votes
1answer
29 views

Count the number of words & lines that has multiple vowels in python

I am working on this coding problem "Count the number of words & lines that have more than X vowels for every Y words in every Z line" Basically the input string has multiple lines and I need ...
4
votes
1answer
27 views

Python program to know who wins a tic-tac-toe game

Given an input where we have two players: "X" and "O", and empty cells marked with a "." like: check_winner([ "X.O", "XX.", "XOO"]) the program outputs if there are three "X" ...
2
votes
1answer
64 views

Removing first or last character of a string with unit-testing

I am trying to remove a duplicate letter of first or last letter, with an exception of containing 'a' as first letter and 'l' and 'e' as last letter. However, this code does not look efficient to me ...
-2
votes
0answers
8 views

Java-Code to implement Soft-TF-IDF Similarity using Jaro-Winkler Distance [on hold]

I want to compare the string similarity values from two nodes by using soft-tf-idf. The idea is to get two nodes by a nested for-loop and create a vector-space model by adding all existing token in ...
6
votes
1answer
80 views

Find words with this prefix

This function (find_prefix) is supposed to find words starting with a given prefix in a container. The container is sorted. This function is a fairly performance-...
11
votes
8answers
4k 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 - ...
3
votes
1answer
80 views

Random String Chooser

I was tasked with creating the class RandomStringChooser that prints the strings in the passed array in a random order, based on the ...
20
votes
4answers
3k views

Count all vowels in string

For a homework assignemnt, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...
-1
votes
0answers
26 views

How to count the number of occurrences of english word and chinese character in some files? [closed]

How to count the number of occurrences of english word and chinese character in some files? I want to implement a function through Node.js: count the number of occurrences of english word and ...
2
votes
0answers
25 views

Faster way to replace strings in pandas series using dictionary in Python

I'm working with a dictionary with 11830 keys/values, that have to loop over 13905 strings, that can have up to 50 words each. My series looks like this: ...
5
votes
1answer
85 views

Identify fraudulent bank transactions

Task: Return true if a transaction is allowed and return false if transaction is prohibited. Details: 1. String is represented as an "array" that can contain up to three elements. We need to ...
4
votes
1answer
52 views

Preperiodic, periodic or aperiodic binary string

This is extension of the rep-string task from Rosette code. I do not only want to check if the input string is the shortest periodic string (rep-string) or not, but also check if it is preperiodic. ...
1
vote
2answers
50 views

Optimize printing massive strings to System.out with respect to time

I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
5
votes
2answers
316 views

Search string in file, replace it, and write back to file

I have this simple function that just reads a file, replaces all occurances of a string, and write it back to the file: ...
5
votes
2answers
746 views

Find hamming distance between two Strings of equal length in Java

I have a private class that I want to be able to find the shortest Hamming Distance between two Strings of equal length in Java. The private class holds a char[] ...
5
votes
4answers
284 views

Determine if a string only contains repetitions of a substring

This is my first Python program in years, it's just a simple string manipulation program. Given a string, determine if it contains repetitions of any substring. For example, ...
3
votes
1answer
42 views

Extracting small word parts (quadgrams) from text using R

I would like to extracts small word parts (quadgrams) from text. Example: hello world results in: ...
11
votes
4answers
754 views

Cropping a message using array splits

I am trying to write a simple function to crop a given message to a specific length but at the same time not to cut the words in between and no trailing spaces in the end. Example: Input String: ...
7
votes
3answers
89 views

Static utility class for string manipulation in C++

My programming foundations were formed in Java, but I've decided to only use C++ from now on for my projects as a personal learning experience. Static utility classes are common in Java; but I don't ...
6
votes
2answers
307 views

Generating 10-character passwords, with 3-6 digits and 3-6 uppercase letters, in C++

In response to a question on Information Security on brute-forcing passwords, I wrote code that helped solve the problem: Generate a password list of 10 character passwords containing only a ...
2
votes
1answer
35 views

Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack

Algorithm: Determine if an array of arrays of characters can be concatenated in order, into a substring of haystack. Example: ...
9
votes
2answers
489 views

Extracting the parent, leaf, and extension from a valid path

Powershell has the Split-Path cmdlet which allows you to extract the Parent and Leaf of a file. In PS version 6, you can extract the extension, with the ...
2
votes
3answers
151 views

Armstrong number generator

This is my code to generate all possible Armstrong numbers between the two given numbers. The logic uses string instead of integer to separate the digits to optimize the code. ...
-2
votes
2answers
144 views

ArmstrongNumber checker

This is my code written to check whether a given number is armstrong or not . but the logic differs from the conventional logic of using integer and separating its digits and calculating , instead i ...
1
vote
2answers
40 views

Trimming strings in non-contiguous spreadsheet ranges

This code is tested and works, but I am needing some guidance on simplifying these loops with non-contiguous ranges. I was thinking an array might be better, but I ...
3
votes
1answer
144 views

Splitting a long string based on its graphical presentation

I got a long string, let's call it Story. I fetch this story from a database so I don't know how long it is. I want to display this story in a view, but what if ...
1
vote
1answer
74 views
3
votes
1answer
127 views

Python snippet for finding word in string

I wrote a simple function that finds a word in a string without use of the re module. My function looks like this: ...
6
votes
3answers
679 views

Reverse the word in a string with the same order in javascript

I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except ...
6
votes
0answers
38 views

Checking whether a string fragment could be part of a longer UTF-8 string

Although UTF-8 validation is a common task, I'm trying to solve a slightly different task; given a string of bytes, work out whether it could potentially be a fragment of a valid UTF-8 string. That's ...
5
votes
1answer
65 views

Rendering tree of nodes as string

I'm creating a debug-view for my expression-trees. They record each operation automatically in a tree that I am transforming into string so that I can see the exact ...
1
vote
0answers
22 views

Average histogram combining multiple files and vector of vectors (in c++)

I run a program of simulation N times (I use each time a different random numbers to initialize it). The results of the program are stored in 2N directories: every run produces two approximations. The ...
1
vote
1answer
41 views

Bubble sort in C (for strings)

What do you think of this bubble sorting function in C, for a string array? I would like to improve the readability, performance, and any good practices. ...
0
votes
1answer
35 views

Building complex sentences based on a data structure

I really do not like how bad this looks. It is not readable and I am not sure if I need the stacked map's. There are a lot of iterations going on here (map, join, replace) and performance is really ...
2
votes
1answer
31 views

Converting words/numbers to Discord “letter/number emojis”

I am a beginner to Python (and programming overall) and I decided that it would be funny if I wrote a program that could convert Letters/Numbers to these "Letter Emojis" in Discord. It works but I am ...
2
votes
1answer
104 views

Game to shuffle and guess a word

I'm new to C++ and while learning, I wrote a simple program that asks for a word, shuffle sthe characters and then asks another person to find the original word, given the shuffled letters. I would ...
1
vote
1answer
44 views

Efficient way to add a colon before and after every word in strings inside a Series

I was working with twitter data, and extracted every emoji from the data. But, when I passed that data through CountVectorizer, colons where substracted from the ...
0
votes
1answer
67 views

Combinational string search using Java

I wrote a program that receives 2 strings (Input and Search) in the Search string. The sign '+' indicates that if the substring before the '+' exists in the Input string. (The search string cannot ...
4
votes
1answer
34 views

Count words in a list of titles, with some cleanup

I have a list of article titles, where I wish to count the number of occurrences for each word (and remove some words and characters). The input is in a .csv file where the titles are in column '...
4
votes
2answers
51 views

String joining function in C

I wrote a function that joins a collection of Strings with a delimiter. It's based on Java's version of the function. I'm assuming C has some similar built-in. Example: ...
3
votes
4answers
99 views

Linux wc command in C

I'm working on my implementaion of the linux wc command. I finally have something that is working properly (with no options yet) but i think it needs a lot of "cleaning". I mean, i highly disrespect ...
2
votes
2answers
56 views

Keep ABC size down for conditional string concatenation in Ruby

This method takes a comment object and displays it correctly depending on what columns are available. EVENT_TEXT and REASON_TEXT ...
2
votes
1answer
30 views

Check for pangrams in elisp

I'm trying to find pangrams ie sentences that contain all the letters of the alphabet, for instance "The quick brown fox jumps over the lazy dog". I'm an absolute beginner in elisp, and it ended up ...
9
votes
2answers
428 views

A function which translates a sentence to title-case

The task is to write a JavaScript-function which translates a given blank-separated sentence to title-case. Means that all words shall start with a capital and then the rest of the word in lower-case....
8
votes
4answers
366 views

strToHex ( string to its hex representation as string)

I want to convert strings to their hex representations as strings too (like hex dump programs), for example "abz" to "61627A". ...
4
votes
2answers
124 views

strTok function (thread safe, supports empty tokens, doesn't change string)

I'm new to C language and want to explode a string like we do in PHP explode() function, I searched for a built-in function with the C standard library, and I found ...