The strings tag has no wiki summary.
0
votes
0answers
6 views
How to get string in a function in Python? [migrated]
I am current writing a game with tkinter GUI Python.
import sys
from tkinter import*
#Functions to handle button click
def startgame():
player21abel=Label(text=" Guess a Letter ...
4
votes
1answer
113 views
Understanding Boyer-Moore Algorithm
Edit: I've found the original publication. It seems to me that the original does not have a l′(i). But I could be wrong because the definition of rpr(i) is so obscure to me. I'm not sure how it makes ...
5
votes
2answers
199 views
Is there any language-agnostic specification for “String Natural Sorting Order”
As I painfully try to find a good natural sorting algorithm written in JavaScript I then stumble upon a bunch of different implementations, & interesting blog posts & answers on Stack ...
-1
votes
0answers
50 views
Finding all the combinations of a word [duplicate]
Is there any algorithm that can find every combination of the letters in a word?
For example, say I have the word air. I know from math that there are 3! different combinations. I want the algorithm ...
3
votes
1answer
125 views
How to fix legacy code that uses <string.h> unsafely?
We've got a bunch of legacy code, written in straight C (some of which is K&R!), which for many, many years has been compiled using Visual C 6.0 (circa 1998) on an XP machine. We realize this is ...
-5
votes
2answers
252 views
How does std::string in c++ allocate memory? [closed]
I've noticed that the string library doesn't require one to allocate space before writing the input/output. How does the string library allocate that memory dynamically, i know of the 'new' keyword in ...
1
vote
2answers
74 views
Is there a stricter strtoull() in any ubiquitous C library?
I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number.
strtoull() does set ...
0
votes
1answer
381 views
VB.NET - Serial Key Generating (Encryption, Hashing, Encoding?) Algorithm
I am trying to create a basic licensing system where I take a unique ID from the client computer, and I get this Hexadecimal string (hyphens removed e.g. "84-18-CE-...."):
...
-1
votes
2answers
157 views
Assigning strings to pointer in C Language
I am a new learner of C language, my question is about pointers. As far i learned and searched pointers can only store addresses of other variables, but cannot store the actual values(like integers or ...
-1
votes
1answer
74 views
Choosing a file format to storage a simple text data [closed]
My .NET application makes its work and then creating a report (an Excel worksheet).
The report holds thousands of short text strings [KEY - VALUE], so excel worksheets suites very well, one column ...
1
vote
4answers
760 views
Regex to String generation
Let's say that we have a regex and an index i. If we suppose that the set of strings that match our regex are sorted in a lexicographical order, how could we get the i element of this list?
Edit : I ...
0
votes
1answer
66 views
exception for string literal conventions
If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability?
example:
$foo = "bar'baz"; // ...
0
votes
2answers
706 views
Why doesn't Ruby have implicit conversion of Fixnum into String?
Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string:
2.0.0p247 :010 > "a"+1
TypeError: no implicit conversion of Fixnum into String
Why is this ...
0
votes
0answers
50 views
Search substring using suffix array (and LCP)
I'm searching for a best way to improve suffix array run time using LCP.
My text (about 2 500 000 chars) seems like: 0ricco0eric0america0polo0....
My thoughs:
SA=suffixArray
char=firstChar(input)
s ...
1
vote
1answer
130 views
Algorithm to create permutations for a given alphabet based on a sequence number
I would like to have a function that will create a word (always the same word) for a given sequence number based on a given alphabet.
word(0, [a,b,c]) = a
word(1, [a,b,c]) = b
word(2, [a,b,c]) = c
...
-1
votes
2answers
332 views
Word recognition in a string without spaces or punctuation marks
I have a small C# project that reads a file and gives me an output: a string that does not contain spaces nor any types of punctuation marks. It may also contain a few misspellings.
Ex.
Output: ...
1
vote
2answers
195 views
What's the difference of an object being final and an object being immutable in java?
final String str = "do not change me";
str = "why not?"; //it will result in compile time error saying that final fields can not be re-assigned once created i.e. the reference cannot be changed
...
0
votes
3answers
156 views
How can I handle this string concatenation in C in a reusable way
I've been writing a small C application that operates on files, and I've found that I have been copy+pasting this code around my functions:
char fullpath[PATH_MAX];
fullpath[0] = '\0';
...
0
votes
0answers
41 views
Algorithm for HIghest Local Alignment Score with a specific character match between two subsequences
I'm writing a code that identifies the highest-scoring local alignment between a substring X' of X and a substring Y' of Y that has at least one column in which a C from X' is aligned to a W from Y'.
...
0
votes
0answers
143 views
What is the purpose of chunking strings in natural language processing?
I see many examples of libraries that use a 'chunker' and also people asking how to write chunkers, but what is this for and why do we need it? Isn't it enough to split a text by whitespace or other ...
5
votes
4answers
631 views
Why doesn't Haskell have a 'format' function for string interpolation?
I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
1
vote
4answers
226 views
How can I take a list of tokens (of variable number) and know what each token means?
I have to read a text document with data formatted as follows: (a couple of examples)
07 M W F 1400 1450 C 2004
M W F 0900 1030 EN 2036
06 M T R 1300 1350 EN 1003
17 T R 0900 1015 EN 1052
The ...
1
vote
1answer
121 views
Search Substring in String collection
I have a big collection of strings a[1], …, a[N] where N is about several millions. I am provided a string m and I need to iterate over all the strings a[i] that contain m. In other words, I need to ...
11
votes
3answers
1k views
How many strings are created in memory when concatenating strings in Java?
I was asked about immutable strings in Java. I was tasked with writing a function that concatenated a number of "a"s to a string.
What I wrote:
public String foo(int n) {
String s = "";
for ...
2
votes
1answer
118 views
Comparing strings against a pool of words
I am creating an app where the user enters 8 characters. After he enters the string I have to see if it is an eight letter word. If not, check if contains a seven letter word etc.
I am checking ...
2
votes
6answers
378 views
Settle an Argument: String vs. Array?
True or False: A string is the same thing as an array.
I had an interview the other day and the above question was asked. I said false, but the interviewer said it was actually true. I explained to ...
-1
votes
5answers
544 views
How common is string manipulation, really? [closed]
I've noticed a lot of programming introductions (almost any language) usually include a heavy barrage of string manipulation quite early, such as:
Count the number of "xx" in the given string. We'll ...
0
votes
1answer
84 views
Code execution within delimiters
Is there any way I can execute a block of code in a loop, like so:
[ some code goes here ]
Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.:
[the user can create ...
8
votes
1answer
249 views
Match two strings but allow for a degree of error
How can I match two strings, but at the same time allow for X number of characters to be incorrect in the match. The number of errors should be a controllable variable.
While X number of characters ...
1
vote
1answer
290 views
PHP Simplest XML tokenizer for string processing?
I need to do some text processing tasks with short XML fragments.
The section "details" shows an example... My solution is to use a tokenizer based on regular expresions, but it is not elegant and not ...
-1
votes
6answers
2k views
Converting an empty string to a number [closed]
If you are designing a function which should conver a string to an integer, how would you convert an empty string? The question is only about this one particular input value (empty string).
Between ...
0
votes
4answers
567 views
What does it mean to perform an operation “In Place” for Interpreted Languages?
Programming question:
Reverse words in a string (words are separated by one or more spaces).
Now do it in-place.
What does "in-place" mean in the above context for an interpreted language ...
8
votes
1answer
662 views
Possible Damerau-Levenshtein improvement?
I recently implemented the Damerau-Levenshtein distance algorithm from the pseudocode on Wikipedia. I couldn't find any explanation of exactly how it works and the pseudocode uses completely ...
0
votes
3answers
93 views
How to manage intermediate outputs efficiently?
I am implementing a C preprocessor in C...
I have the three functions:
trigraph replacing function
Line splicing function
comment removing function
However these functions work separately on ...
3
votes
5answers
2k views
A string is immutable, so why are they not all constants?
The string type is immutable.
We can use the const keyword with strings in high level language like .NET. My understanding of 'const' means constant (it remains the same, we can't change the value).
...
7
votes
3answers
445 views
Longest subsequence without string
Does there exist a dynamic programming algorithm to find the longest subsequence in a string X that does not contain Y as substring? Just that this problem seems so similar to other DP string ...
6
votes
2answers
219 views
Index independent character comparison within text blocks
I have the following task: developing a program where there is a block of sample text which should be typed by user. Any typos the user does during the test are registered. Basically, I can compare ...
0
votes
1answer
216 views
Algorithm Identification [ String & Dictionary ]
I recently heard of an interview question:
Given a string and a dictionary. Break the string into meaningful words
and I remember solving this before with dynamic programming fairly quickly (maybe ...
3
votes
5answers
3k views
How do you compress ASCII strings into smaller bytes?
I'm working with an embedded device with a unique protocol that sends messages to other devices and I'm making an application that parses the sent packets. Each packet carries 8 bytes. The protocol is ...
5
votes
4answers
45k views
Initializing char array with string
I don't remember how I got to the thread, but I was reading its replies and one of them states that you should never initialize a char[] with a string literal.
My question: Is initializing a ...
6
votes
2answers
4k views
Which string search algorithm is actually the fastest?
I have been stuck for some time on which is the fastest string search algorithm, heard many opinions, but in the end I'm not sure.
I have heard some people saying that the fastest algorithm is ...
6
votes
1answer
385 views
Finding occurrences of a useful words and phrases in strings
I am building an app that analyzes posts by people by pulling their Tweets and Facebook posts. I need to process all the posts and find useful phrases. What I mean by useful is that, any word or ...
3
votes
3answers
212 views
Storing lots of large strings with frequent “appends” and few reads
In my current project, I need to store a very long ASCII string to each instance of a given object. This string will receive an 2 appends per minute and will not be retrieved so frequently.
The ...
1
vote
2answers
380 views
Looking for a non-cryptographic hash function that returns a single character
Suppose I have a dictionary of ASCII words stored in uppercase. I also want to save those words into separate files so that the total word count of each file is approximately the same. By simply ...
-2
votes
1answer
243 views
C Minishell Command Expansion Printing Gibberish
I'm writing a unix minishell in C, and am at the point where I'm adding command expansion. What I mean by this is that I can nest commands in other commands, for example:
$> echo hello $(echo ...
18
votes
2answers
5k views
Why does Java use UTF-16 for internal string representation?
I would imagine the reason was fast, array like access to the character at index, but some characters won't fit into 16 bits, so it wouldn't work...
So if you have to handle special cases anyways, ...
1
vote
1answer
138 views
How to implement string matching based on a pattern
I was asked to build a tool that can identify if a string match a pattern.
Example:
{1:20} stuff t(x) {a,b,c}
would match:
1 stuff tx a
20 stuff t c
It is a sort of regex but with a ...
6
votes
2answers
734 views
Complex string matching with fuzzywuzzy
I'm attempting to write a process that matches obscure strings to a single 'master string' for further processing. I have a lot of data that looks something like this:
Basketball
Basket Ball
Football
...
6
votes
1answer
3k views
Shortest Common Superstring: find shortest string that contains all given string fragments
Given some string fragments, I would like to find the shortest possible single string ("output string") that contains all the fragments. Fragments can overlap each other in the output string.
...
7
votes
2answers
11k views
When should I use StringBuilder or StringBuffer?
In a production web application, my fellow programmers used StringBuffer everywhere. Now I am taking care of application development and corrections. After reading StringBuilder and StringBuffer I ...