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.

Filter by
Sorted by
Tagged with
2
votes
1answer
117 views

Generate Unique ID in C#

Objective To create a unique id with few characters as possible. Language: C# Engine Unity3D Target : iOS && iPadOS Scenario I found quite a few solutions from Stack Exchange but would ...
4
votes
2answers
83 views

String replacement with dictionaries — follow up

I was reminded by an achievement notification yesterday of this question of mine, posted nearly four and a half years ago. After reading through my own code and the review posted, I decided to re-...
4
votes
1answer
87 views

fasm convert hex byte to binary string

This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner? ...
3
votes
1answer
29 views

x64 fasm strlen

This is a simple strlen function with registers documented: ...
1
vote
2answers
140 views

Create secret messages

The problem is stated in Encrypt this!: Your message is a string containing space separated words. You need to encrypt each word in the message using the following rules: The first letter ...
1
vote
1answer
66 views

Expand compressed string range

Say you have two strings: exp->aaccbb comp-> aa2bb This example will return true as there are 2 chars between aa and bb. I have written this code snippet and am wondering if there is a better way do ...
2
votes
1answer
46 views

Number of unique substrings of particular length of a binary string

Question: A binary string is given with only 0's and 1's. A number n is also given as the length of a sub string to be considered. It is to find the number of unique substrings. Here, n=3. My ...
10
votes
4answers
2k views

Python's .split() implemented in C

I'm new to the C programming language and I just made a basic version of Python's split() function using C. Note: A major functionality I chose not to implement is ...
4
votes
1answer
80 views

Printing a string in NASM Win16 Assembly

A small script that simply prints a given string. It's an improved snippet that combines some recommendations given in my post on string helper functions. ...
-1
votes
1answer
29 views

Provide one file where all error messages are defined in c++ [closed]

I would like to store all error messages in one file and call them for example with ...
4
votes
1answer
148 views

Two input file string comparison with C++. Large dataset 800+k. Harsh criticism welcomed

So I had a similar problem to this: https://stackoverflow.com/questions/39749430/import-huge-dataset-into-access-from-excel-via-vba/57995602#57995602 Although it was already answered, I provided a ...
8
votes
3answers
1k views

Generating a random string of 6 characters long in Python 3.6.2

I am learning Python, so pardon me if this is the very crude approach. I am trying to generate a random string using alphanumeric characters. Following is my code: ...
2
votes
1answer
52 views

Simple Email Subject Filtering (python)

This challenge took me forever. I spent a lot of time messing with regular expressions, but couldn't get it to work. I ended up coming up with this abomination. If anybody wants to take the time I'...
8
votes
1answer
49 views

strsepf() - Parsing string using strsep with a scanf-like interface

vstrsepf is string parsing utility function born from the idea of using strsep and strtol ...
7
votes
2answers
157 views

Simple IP address parser in C

I have written a C function to parse an IP address that should match the regular expression ^\d+.\d+.\d+.\d+ and nothing else. Additionally all bytes are limited to ...
3
votes
1answer
43 views

Small String hashing and compare

The idea is to convert first 8 character from the C string to uint64_t or uint32_t, then to convert to Big Endian. The value ...
2
votes
1answer
64 views

Guessing The Word

Made after seeing A Simple Word Guessing Game. Any code critique is welcome! ...
8
votes
3answers
175 views

“Fast strlen” in C using scalar bithacks

I've translated an implementation of strlen in x86 assembly to C and added alignment checking: ...
2
votes
2answers
51 views

Standardizes Rows of a Pandas.DataFrame Object

Please take a look at this little snippet of code and explicate on whether there are an efficiency enhancements that you'd make for it. It standards a row of a pandas.DataFrame by adding zeros to it ...
1
vote
0answers
42 views

How do I optimize memoization in order to find longest palindromic substring?

I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string. I have seen other questions on this problem that successfully solve ...
9
votes
2answers
185 views

python search replace and join with delimiter

I'm brand new and been going through some beginner code problems on checkIO. I finished this one today and am posting because I'm sure there is a much more elegant way to accomplish this, and I think ...
1
vote
1answer
160 views

InternedString as alternative to regular String

I need to use large strings as a dictionary keys, and I want to optimize the repetitive GetHashCode() and Equals() calls in it. ...
3
votes
2answers
187 views

Function to prompt and check user input

I'm trying to make a function that asks for a string input and then validates it. If the answer is not correct, the function asks them again for valid input with a while loop. In order to validate ...
2
votes
1answer
150 views

Strong Password Checker (Python)

Problem Write a program to return True, if a string is a strong password. A password is considered strong if below conditions are all met: It should have at ...
7
votes
1answer
87 views

Boyer Moore Horspool Search Algorithm in Go

I am practicing Go and try to implement Boyer Moore Horspool Algorithm in Go, It returns all ocurrance of a "phrase" in a given text. This code is working, but I would be pleased to have any feedback ...
1
vote
1answer
93 views

Capitalize the First Letter of Words in a String (JavaScript, Python)

Problem Write a function that accepts a string, capitalizes the first letter of each word in the string, and returns the capitalized string. Examples ...
1
vote
0answers
48 views

Algorithm for building a string by appending and cloning substrings [closed]

I have a problem where I need to construct a given string from scratch for a minimum cost by either: Appending a new character for a cost A Appending a substring of my existing string for a cost B ...
1
vote
1answer
74 views

Anagram (Python, JavaScript)

Problem Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is a string that contains same characters ([A-Za-z0-9]) and the order of ...
2
votes
1answer
58 views

LeetCode 65: Valid Number (C++)

Problem Validate if a given string can be interpreted as a decimal or scientific number. Examples: ...
4
votes
3answers
625 views

LeetCode 65: Valid Number (Python)

Problem Validate if a given string can be interpreted as a decimal or scientific number. Some examples: ...
4
votes
3answers
86 views

A custom String class implementation

This is my first implementation of a "container" using the Rule of Five, any feedback I'll gladly accept. I've tried to make it as Exception-Safe as possible. I've made it for an assignment. Header <...
2
votes
1answer
88 views

LeetCode: Greatest Common Divisor of Strings C#

https://leetcode.com/problems/greatest-common-divisor-of-strings/ For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or more times) ...
4
votes
2answers
709 views

Palindrome and Reverse a String Problems (JavaScript, Python)

Problem 1 Given a string, the task is to reverse the string and return a reversed string. Problem 2 Given a string, return true if the string is a palindrome or false if it is not. Code Just for ...
4
votes
1answer
102 views

Random password generator that ensures diversity of character types and absence of confusing characters

I wrote the following password generator, to generate a password in which each character group appears at least at once. ...
1
vote
0answers
59 views

C# KMP algorithm

I tried to implement KMP algorithm on my own and found it kind of hard to follow. Can you please comment how would you make this code easier to read / understand. ...
11
votes
3answers
736 views

Generating sequential alphanumeric values that match a certain pattern

I'm working on generating large volumes of test data for some performance testing. Part of this is going to involve generating a lot of values that represent an "MBI", which is a certain kind of alpha-...
7
votes
1answer
77 views

Rust echo implementation that supports command line options

I rewrote echo from the manpage to learn Rust, and got the following: ...
3
votes
1answer
97 views

Knuth-Morris-Pratt algorithm in Java Finding substrings in a matrix

Problem Given two matrices: a pattern p and a text t. Write a program that counts the number of occurrences of ...
5
votes
1answer
85 views

99 beers song in Rust

I'm learning Rust. I find it sometimes confusing when compared to other programming languages, especially when dealing with strings and slices. Her's an implementation of the 99 beer song that I've ...
2
votes
0answers
108 views

Split a string into valid words

I am trying to solve this LeetCode question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word ...
5
votes
2answers
122 views

Splitting each word using longest substring that matches in a vocab/dictionary

This function takes in a string and a fixed list of vocab: splits a string into words by spaces for each word, check in the dictionary/vocab and find the longest matching substrings, if none matching ...
8
votes
5answers
1k views

String Operation to Split on Punctuation

I've a function to split text on punctuation and leave the rest of the string (including whitespace in other items of the list): ...
2
votes
0answers
55 views

Function to match the case of a text as per another text

I am translating a text into another language using Google APIs. Sometimes the translated text returned from the API does not match the case of the text provided - e.g. when translating the text "...
2
votes
1answer
68 views

Rustacious way of checking if string ends with any suffix from a selection

What's the best way to check if a String ends with any of multiple suffixes in Rust? I have a working, naive solution: ...
-5
votes
1answer
33 views

Finding frequency of unique array elements by using single pointer [closed]

I am supposed to find the frequency of the unique array elements of a character array via a user defined function like int *unique(char *s), which takes a pointer to a character and returns a pointer ...
8
votes
1answer
156 views

Normalize whitespace and describe string

The most valuable of all talents is that of never using two words when one will do. Thomas Jefferson. NuGet and GitHub I found it useful to automatically normalize string content a little bit and ...
5
votes
1answer
75 views

Wu-Manber algorithm for multiple pattern matching in C++

I'm trying to implement the Wu-Manber algorithm (http://webglimpse.net/pubs/TR94-17.pdf). From my understanding, the algorithm basically does string matching using a hash table-based approach with ...
2
votes
3answers
1k views

String whitespaces

Here is a shortest possible syntax for replacing whitespaces with null and throwing an exception where it is not allowed: ...
3
votes
1answer
95 views

Removing duplicate Unicode characters

Motivation I came across an interesting question on SO: determine-if-string-has-all-unique-characters and thought about providing an extension method to enable duplicate removal given some kind of ...
12
votes
5answers
1k views

Comma Code - Automate the Boring Stuff with Python

Below is my code for the Comma Code problem from Chapter 4 of Automate the Boring Stuff with Python. Is there anything I can do to make it cleaner? Comma Code Say you have a list value like ...