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.
288 questions
44
votes
4
answers
16k
views
A lightning-fast StringBuilder
In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed.
To ...
84
votes
4
answers
22k
views
Function to print command-line usage for a program [closed]
The following function works well to print out a help message for the program I have written. It prints a multi-line string message that describes the command line usage with some examples:
...
20
votes
3
answers
3k
views
A CSharpish String.Format formatting helper
A while ago I implemented .net's string.Format() method in VB6; it works amazingly well, but I'm sure there has to be a way to make it more efficient.
I'll start ...
23
votes
5
answers
29k
views
Split a string into chunks of the same length
Inspired by this question in chat
Is there an easy way in .NET to split a string into an array by pulling chunks of the text in. I.e. I have an 18 character string I would like in 3 6-character ...
44
votes
2
answers
40k
views
Balanced parentheses
Given an expression string exp, write a program to examine whether the
pairs and the orders of
"{","}","(",")","[","]"
are correct in exp.
For example,...
11
votes
1
answer
4k
views
Z-Algorithm for pattern matching in strings
I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings.
...
15
votes
4
answers
3k
views
Int extension for translating integer to plain English
This code was inspired by this question: Number to Words
...
14
votes
1
answer
4k
views
fgets() Alternative
size_t readline_tostring(char * restrict dest, size_t size, FILE * restrict stream)
fgets() is OK yet it has some short-...
13
votes
4
answers
4k
views
Algorithm for Run Length Encoding - String Compression
I attempted a problem from the Cracking the Coding Interview book. The following input: aabcccaaa should give the following output: ...
9
votes
3
answers
24k
views
Simple string joiner in modern C++
(See the next iteration.)
I have this small template function for conveniently dumping a sequence into a string such that there is a delimiter between two consecutive elements, and no such after the ...
6
votes
3
answers
1k
views
The Genetic Code
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Wascally wabbits. The repository with all my up-to-date solutions so far can be found ...
6
votes
3
answers
89k
views
Calculate all possible combinations of given characters
I was asked in my textbook Lectures on Discrete Mathematics for Computer Science to construct a program that would take an alphabet ({a,b,c} or any combination of ...
5
votes
2
answers
447
views
int128 handling in c-code, gcc / glibc / linux - follow up
I had a draft for int128 handling reviewed there:
int128 handling in c-code, gcc / glibc / linux
I changed a lot according to the hints there, while leaving in, e.g.,
a trailing space on each line, ...
4
votes
1
answer
2k
views
Simplifying and optimizing factors and prime factorization generator
My first algorithm for finding the factors of a number was pretty slow and horrible (it started at \$O(n^2)\$, where n was not even the inputted number), but I eventually came up with this new code. ...
2
votes
1
answer
154
views
Fast search for the longest repeating substrings in large text (Rev.2)
This is the second iteration of the Fast search for the longest repeating substrings in large text code review. Special thanks goes to G. Sliepen who conducted the first review.
Functional ...