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.

7
votes
0answers
41 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 ...
6
votes
0answers
704 views

Parsing Lua 5.2 strings with patterns

I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It works perfectly as far as I tested. ...
5
votes
0answers
101 views

Tokenizing and sorting the strings of a text file with the results of a public competition

I made this script to carry out a specific real-life task, which was to sort a list of candidates in a public competition by grade. The file with the informations consists of a text file copied from ...
4
votes
0answers
50 views

Palindrome insertion challenge

Here is my solution to the following Daily Coding Problem challenge Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible anywhere in the ...
4
votes
0answers
64 views

Rabin-Karp algorithm implementation

This code uses the Rabin-Karp algorithm to compare two text files. It takes a few minutes when both files contain around 1000 words. How can I improve? ...
4
votes
0answers
50 views

Improved Knuth-Morris-Pratt over a source of indeterminate length

Following the successful review of my previous implementation. Please review my new, generic implementation of the Knuth-Morris-Pratt algorithm. Its modified to search a source of indeterminate ...
4
votes
0answers
269 views

Slices of Strings

In an attempt to summarize the question and all the good answers to this question, I decided to try to write a pair of string extensions that could split a string in respect to number of slices ...
4
votes
0answers
303 views

Error handling with C-string input using get() and getline()

I've just learned the basics of c-strings and how to read line oriented input. I noticed that fail bits are set for each function. However, not every problem sends a fail bit, so I thought this would ...
4
votes
0answers
269 views

Finding the length of arbitrary ASCII character strings

I have implemented this MIPS code to determine the length of given ASCII character strings. Is there a simpler way to implement this code? Is there is a built-in function in MIPS? Given String: ...
4
votes
0answers
252 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. ...
4
votes
0answers
97 views

Perform a contains-ignore-case with multiple search-tokens

I had a look on Stack Overflow etc. on how to perform a contains ignore case with n given strings. Most answers suggested using regex for this task. Although it's a valid option, I prefer doing upper-...
3
votes
0answers
32 views

SHA256 implemented in Rust

I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback. As far as I can tell it ...
3
votes
0answers
88 views

Finding differences in strings with Levenshtein distance and soundex

I am trying to find a way to optimize the code runtime. Improvements I have implemented include using dictionaries, removing redundancies and using str.translate. <...
3
votes
0answers
72 views

Count number of substrings which contains particular strings

I need to count the number of substrings of s which contains both the strings a and b. This ...
3
votes
0answers
282 views

Reverse string in Kotlin

In the question of how to reverse a string in Java, a comment mentioned that combining Unicode code points need to be taken into account. The below code works as intended for all test cases I tried. ...
3
votes
0answers
234 views

String conversion and stream insertion of std::ratio and std::chrono::duration

I've developed a set of functions to convert a std::ratio or std::chrono::duration to a ...
3
votes
0answers
585 views

File path normalizer

I recently wrote a file path normalizing function, with normalizing a pure lexical process. This means the function is unaware of the filesystem, and would not for instance consider symbolic links or ...
3
votes
0answers
49 views

Multiple parsers for keywords in strings

I'm writing some code that parses strings, often using simple keywords. On parsing, the code performs various actions, such a printing a response, running functions etc. and it keeps track of whether ...
3
votes
0answers
190 views

Fastest way to build string feature vectors Python

I have a list of strings to search along with a list of words and want to produce boolean feature vectors indicating presence of each word within the strings. What is the fastest way to build these ...
3
votes
0answers
311 views

Hackerrank: Sherlock and anagram (optimal time complexity)

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
3
votes
0answers
855 views

Hackerrank: Sherlock and anagram

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
3
votes
0answers
110 views

Converting a sentence string to a number in Scheme

I wrote a scheme procedure that converts strings such as "Two hundred and fifty" into a number like "250" that I can use in math calculations (It's for some Natural Language Processing project). Is ...
3
votes
0answers
139 views

Reduce encoded length of UTF-8 encoded Ruby string in C extension

I'm writing a Ruby extension in C. It's a string processing module working on UTF-8 encoded strings only. One method, full_width_to_ascii!, converts full width ...
3
votes
0answers
459 views

Largest common subsequence algorithm in C++

I'm relatively new to C++ and am trying to learn good programming practices and habits from the beginning. The code I wrote finds the largest common subsequence between to strings (and output the ...
3
votes
0answers
46 views

Reformatting a structured string like “a-b-c|A-B-C” into “a-A|b-B|c-C”

The code below was inspired by this post in Code Review. Here is how it was first intended by its author: I have the following code that converts a string that looks like : aaa-bbb|ccc-ddd|eee-...
2
votes
0answers
28 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: ...
2
votes
0answers
30 views

Finding the numerically listed string to the center algorthim

The algorithm takes input for a string's length for L, and the number of strings altogether for X. The hamming distance is for input D. Input Z calculates the exact amount of all possible characters ...
2
votes
0answers
38 views

Not a very interesting implementation of a simple substitution cipher in Python

I know this has been done before, but I needed to brush up my Python skills. Also, I intend to publicly share this code on a blog post sometime in the near future. This is also an attempt to improve ...
2
votes
0answers
36 views

vb.net Create textfile from template

What is the best approach for creating textfiles from/with a template ? Currently I just read the template from a textfile and Replace all values needed, but I don't think that this is the most solid ...
2
votes
0answers
61 views

Composing commands to control virtual machines

I created a function which takes some inputs and builds a specific set of strings. The function is working as intended, however I can't help thinking how ridiculous it looks every time I see it. I ...
2
votes
0answers
36 views

Multilang sentence to N-gram

Task: Transform sentence to n-gram and remove all punctuation Tests: Input: ngram('Name, + other ~ name!', 1) Result: ['Name', 'other', 'name'] Input: ngram('Name, + other ~ name!', 2) ...
2
votes
0answers
820 views

minimum window subsequence leetcode dynamic programming solution

Given strings S and T, find the minimum (contiguous) substring W of ...
2
votes
0answers
94 views

Simple, semi-function string implementation in C++

I have three files: the header, implementation and a test driver. This is a general purpose code review, so I would appreciate any feedback on anything from style to design to inaccuracies in my logic ...
2
votes
0answers
90 views

anagramDetection.js

A function that accepts two parameters, a parent and a child string. Determines how many times the child string - or an anagram of the of the child string - appears in the parent string. ...
2
votes
0answers
92 views

With 2 sets of strings, find a string that can be constructed from either set

Given the following sets of strings: are yo you u how nhoware alan arala dear de I need to find a sequence that can be constructed by concatenating the strings ...
2
votes
0answers
756 views

KMP string-matching algorithm implementation

This is Knuth-Morris-Prat algorithm implementation to check if a pattern is present in a larger text, and if it does the algorithm returns the start index of that pattern, else -1. It starts off by ...
2
votes
0answers
70 views

Subtraction in a spreadsheet column numbering scheme

The idea of the algorithm is to decrease a number from a word. Is there a better way to write this algorithm? limitiation: it is important to decrease with a limit, if BB is the word we decrease ...
2
votes
0answers
427 views

Number-to-words translator

I've created a class that translates an integer into words in an English (not British) format. My first human language is not English, and I don't have a good idea of a truly right way to read numbers,...
2
votes
0answers
144 views

Converting Chess FEN Notation to a Tuple and Back

This module is going to be part of a larger ElixirChess library for validating chess positions and moves, but I started with the core of it which is parsing a ...
2
votes
0answers
82 views

Storage policies

I often come across situations where a library component needs to buffer a large amount of data for later processing. The problem is that at the design stage a choice needs to be made as to whether to ...
2
votes
0answers
436 views

Function to split a given string according to predefined patterns

Here's a function that splits given string according to predefined patterns. It's part of a trigger function used to populate one table from another. I want to be sure that I'm not making any mistakes....
2
votes
0answers
215 views

Longest increasing subsequence and common substring

I wrote a program that computes longest increasing subsequences and common substrings. Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a ...
2
votes
0answers
2k views

Capitalize words in XSLT 1.0

Since XSLT 1.0 doesn't have a lot of convenience functions, I have had to cobble them myself. The below capitalizes "words" in a string as defined by a string of delimiters. Is there any way to ...
2
votes
0answers
96 views

How to increase concision and performance in a function to retrieve sentences where keywords match?

I'm building a text search system for a web application in PHP. I wrote this function that gets the sentences of the text which contains the keywords used by the user and also highlight them (well, ...
1
vote
0answers
24 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
0answers
26 views

Sort an array of strings using bubble sort

I have this following code to sort an array of strings order by ASCII value (alphabetically) using bubble sort. ...
1
vote
0answers
44 views

KMP algorithm in scala

I implemented KMP pattern matching algorithm in Scala. My code works but it looks more imperative and a scala translation of C/C++ implementation. I am not able to figure out how to manage multiple ...
1
vote
0answers
25 views

change a string and apply changes to other similar strings

I'm trying to get the changes that were made in a string and apply them to similar strings. string are similar if they are equal from 0 to index of change. let's say I have this strings: ...
1
vote
0answers
15 views

Swapping variable length strings asynchronously with connected microcontroller (Byte-banging)

I have an AT89S52 and an AT89C4051 microcontroller (both in the 8052 family) in which the bit lines of the data bus, one control pin and one status pin are connected together. In code, the data bus is ...
1
vote
0answers
35 views

Mixed Duo String Generator Part 2

Mixed Duo String Generator Hello again; Previously my code was critique and I applied this feedback to form my new revised code for the Mixed Duo String Generator. In the code below I revised it to ...