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.
5
votes
3answers
79 views
Efficient data-driven finite state machine
In creating this answer to a recent question, I thought I might write a fully worked example that implements a finite state machine in C.
The purpose is to implement the following function:
...
2
votes
1answer
21 views
Extracting initials with R
Playing around in R with a Edx CS50 homework. The job is meant to be done in C, I am using (the more familiar) R just for warmup....
4
votes
2answers
408 views
5
votes
2answers
657 views
Classifying image by file extension within a PDF creator
To create a pdfDocument I am using following code which works as expected but do not want to use multiple if else.
Any patterns or any design strategies? It may ...
0
votes
0answers
45 views
Parsing string and extracting meaningful information [on hold]
Given a string containing user names(length 2) or Group names(length 2, 13) followed by the optional comment I have to parse the message and extract meaningful information from it.
Example:
Valid ...
1
vote
0answers
26 views
Optimizing string concatenations and checking for unique subsets
This code accurately completes my task. However, it does not scale very well. I have been doing my best to optimize the big O complexity; however, I'm not able to make any big improvements. I have the ...
0
votes
0answers
20 views
Minimal length of substring that forms cyclic string
there is a knows problem stated as "Cyclic string":
A string S has been recorded many times, and then from the resulting line took a substring, and give to you.Your task is to determine the minimum ...
10
votes
3answers
437 views
Using Python to tokenize a string in a stack-based programming language
As an avid user of esoteric programming languages, I'm currently designing one, interpreted in Python.
The language will be stack-based and scripts will be a mix of symbols, letters, and digits, like ...
3
votes
0answers
53 views
Search a string for barcodes but ignore certain characters
I had to write a string search function that would search for barcodes, and be forgiving of minor formatting differences. For example, the barcode may be entered as ...
0
votes
0answers
94 views
The strend function with pointers in C (K&R 5-4) [closed]
Function should check if t array appears at the end of the s array.
Example input: ...
2
votes
1answer
40 views
PHP function to convert a Portuguese word from plural to singular
I know, this sounds really difficult, but it is really easy.
I needed to convert a single Portuguese word in the plural into singular. I know there's a right name for that, but it is escaping me.
...
2
votes
1answer
38 views
replacing characters in string one by one to create target string
while doing a code clash on codingames, in which we had to replace a character in a string one by one to transform it into a target string, printing out every itteration of the new string, resulting ...
0
votes
2answers
649 views
Getting substrings from a string c#
I have a c# application which displays the names of assessments and the zone which they are performed upon, separated by a comma and a space. For instance:
assessment1, Firewall
mom's assessment, LAN
...
2
votes
2answers
70 views
Rule of five and move semantics for a string class
I have been learning about the rule of five and I tried to implement an example myself. It all works exactly as I'd expect, but I was wondering if I've missed any obvious issues or easier/faster ways ...
6
votes
4answers
632 views
2
votes
1answer
52 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.
...
2
votes
1answer
73 views
Find substring count without string functions
Find the substring count from a string without string functions in Java. Given String str = "abcdefghcde"; and ...
4
votes
0answers
60 views
Advent Of Code 2016 Day 9 Part 1 Solution
This code gives the solution to Part 1 of this question:
http://adventofcode.com/2016/day/9
Summary: You have to find the length of the input string after using the markers to duplicate parts of it. ...
3
votes
3answers
72 views
Simple random string generator in C
It is just a simple piece of C code that generates random lenght random HEX srings. Any ideas how this code can be improved?
...
13
votes
4answers
501 views
Nth Index of Char in String
I've written a function that searches for the nth occurrence of a character in the given string. A positive value for n will search from left-to-right, while a negative value will search from right-to-...
1
vote
3answers
106 views
Determine if two strings with no repeating characters are permutations of each other
I've made a short program to determine if a string is permutation of another string.
Example input/output :
a) 123, 112 <- False
b) 123, 321 <- True
c) 112, 121 <- these don't ...
5
votes
2answers
107 views
Transform a Japanese word to furigana
I developed a script to transform a Japanese word in Furigana thanks to the jisho website. But the code is very ugly, especially the extractHiraganaFromHTML and <...
0
votes
1answer
99 views
Get all possible palindromes in C#
As the title says, the goal is to get all the possible palindromes of a string in C#:
...
1
vote
0answers
47 views
Short string class
On one of the projects I'm working on, we have many objects that store (small) strings, loaded from database. I know std::string's have small string optimization (...
6
votes
2answers
91 views
Check if string is or can be made into a “valid string”
The Challenge:
A valid string is one in which all distinct characters occur the same
number of times. Given a string S, check if the string can be made
valid by removing less than or equal to ...
6
votes
2answers
462 views
PrimitiveParser
This class has the responsibility of parsing a string to one of the primitive types: int, double, ...
5
votes
1answer
78 views
Reading string from a text file and returning the number of occurrences of each substring of length k
This program takes a simple nucleotide sequence and finds the most common "k-mers" in the sequence, as determined by the supplied dataset (see below). The goal of the program is to find the origin of ...
1
vote
2answers
111 views
3
votes
2answers
184 views
Get character occurence count along with character in a string
I want to find character sequence count in a given string.
Sample Input: aaaabbbbaaacccbbb
Output: a4b4a3c3b3
My below function is working great and giving me the same result. but can this be ...
4
votes
4answers
101 views
Check for Palindrome string in Java
I was wondering if you can give me advice on this solution to assess if an user input string is a palindrome or not.
How can I optimize this solution?
...
2
votes
2answers
57 views
Rotate every letter in string by K places
The challenge:
Given a string S and a fixed number K, rotate every letter in S by K places (if reach the end of the alphabet, go back to the beginning). Letters should remain the same case. Symbols ...
3
votes
2answers
29 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:
...
6
votes
2answers
60 views
Find a famous writer in a random string
I'm doing a CodeEval challenge, where the object is to find a famous writers name and a year, inside of a random given string.
You have a set of rows with names of famous writers encoded inside. ...
3
votes
0answers
45 views
finding substrings within arrays - javascript
I need to find the substrings within my array. If I have an array: ["abc", "abcd", "abcde", "xyz"], my method should return the array members: ...
3
votes
1answer
78 views
ExceptionPrettifier for prettier exception strings
I've been refining my previous idea for pretty exception strings and made the following changes:
Exceptions can be ordered.
Prints all properties including Data.
...
2
votes
3answers
62 views
Returning distinct characters in combined Strings
I am trying to return distinct characters from the combination of 2 Strings. The following is my solution which seems to work based on my tests.
Is there a more ...
6
votes
2answers
285 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:
...
5
votes
1answer
72 views
Text search in Python
Whilst self-studying algorithms, I came across the Karp-Rabin rolling hash search algorithm here. I decided to have a go at implementing it in Python:
For ease of reading; the data-structure ...
5
votes
1answer
308 views
Find all strings in list which have keywords in it from another list
I a list of strings A and a list of keywords B. Now I want to return all strings from list A which have all keywords from B in it as a new list.
...
3
votes
3answers
110 views
Reverse vowels in a string
What do you think about this solution? I guess there are too many lists...
...
3
votes
4answers
68 views
Program to rotate an array
I wrote this code where I have to rotate an array of 'n' elements by 'd' elements in the anti-clockwise direction.Can it be done in a better and simpler way?
...
1
vote
3answers
62 views
C strlcat implementation
I have to reproduce some basic functions in C and one of them is strlcat.
After reading the man and testing the strlcat from <bsd/string.h> library, I wrote ...
3
votes
1answer
66 views
Win32/C: Notepad wrapper that automatically converts Unix line endings to Windows line endings
At my work we're dealing with a lot of PHP files written by a third-party company and sometimes we want to "quickly look at" these files in Notepad rather than having to open up a full IDE.
The ...
5
votes
1answer
60 views
Interleaving of two strings
I have written this recursive code to find all interleaves of two strings, where the order of strings are preserved. For example:
s1="abc" s2="1"
a1bc
ab1c
abc1
...
1
vote
1answer
60 views
Program for an atoi() function in Java
I have written this code to check all the edge cases in the implemention of an atoi() function.Please review.
...
3
votes
1answer
54 views
Concatenate variable number of strings
I am learning C on my own. This is not an assignment. I am trying to implement a function that takes a variable numbers of strings and concatenate them in a new string. It works, but I feel it is not ...
4
votes
1answer
42 views
String tokenizing with arbitrary token count in C
I am building a small program for input handling so I can conveniently parse lines and tokenize strings. The token handling works right now but I have to malloc a lot in the main() to make it work. ...
6
votes
2answers
319 views
Function to find all occurrences of substring
This function returns a list of all the beginning indices of a substring in a string. After finding the index of a substring, the search for the next one begins just after this index.
...
1
vote
2answers
43 views
Title capitalization exercise from The Odin Project
I just finished the book title class exercise for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates ...
3
votes
2answers
409 views
Python-style string multiplication
When people migrate from Python to C++, they're often bothered by the fact that C++ strings don't support multiplication like Python's strings do.
std::string does ...