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.

learn more… | top users | synonyms (1)

0
votes
0answers
9 views

Getting Runtime error NZEC in Java [on hold]

I am trying to solve this problem at Codechef. But I am getting a runtime error NZEC. Please help me in finding my mistakes. Here is my Java code. ...
0
votes
0answers
11 views

Counting words in a string using methods [on hold]

I have a project to make a program that takes a string as input and then prints the number of words in the string as output. We are supposed to use 3 methods in this, one to read input, one to print ...
-1
votes
0answers
20 views

Checking regex pattern efficiency [on hold]

I have some strings like: @HELLO) AND @X @Y1) AND @TEST I am using this Regex: @[?\w?]\) AND @[?\w?] that detects ...
2
votes
2answers
81 views

Non-Contiguous Substrings

Problem: A non-contiguous substring of string \$s\$ is a sequence of \$k \geq 0\$ characters in \$s\$, in the order in which they occur in \$s\$. For instance, the set of all non-contiguous ...
5
votes
1answer
37 views

Test whether target string is substring of source string

The code is self-explanatory. It has \$O(n)\$ complexity, and it tells whether a given string is the substring of the source string. Are there any cases where this algorithm fails? Is there anything ...
3
votes
2answers
102 views

Getting a list of all fields in an object

I've got the following code that I use to output a list of all (public) fields in an object in an easy(ish) to read way. The issue with it is that the code is not easy to look at, and I'm not sure ...
2
votes
3answers
168 views

Remove repetitive strings from a given sentence efficiently

I recently gave a test on HackerRank: Given a string, return the most concise string that can be formed from it. For example: ...
3
votes
3answers
87 views

Hacking a SecureString based on std::basic_string for C++

Inspired by reading "How-to write a password-safe class?", I tried some clever (or dumb-fool) hack to create a widely-useable secure string using the ...
5
votes
2answers
77 views

Knuth–Morris–Pratt string match algorithm

The Knuth–Morris–Pratt string search algorithm is described in the paper Fast Pattern Matching in Strings (SIAM J. Computing vol. 6 no. 2, June 1977). The initial step of the algorithm is to compute ...
3
votes
2answers
51 views

Low level string manipulation functions in C

I'm working with a legacy program that does a bunch of markup manipulation, some of it higher-level and specific to the proprietary markup, some of it lower level string stuff. I rewrote and ...
7
votes
5answers
480 views

Normalizing `DateTime` values to strings

I have this as part of a project to normalize DateTime values to more readable strings, localized to the relative time in the past that they happened. It allows ...
2
votes
2answers
82 views

Gluing pieces of scrambled text (challenge on CodeEval)

I'm trying to solve this challenge on CodeEval. Quoting: For example, you can put pieces together and get the original text: evil pl vil pla il plan The answer is ‘evil plan’. Your ...
3
votes
2answers
51 views

Find the integer representing the last sub-string of a string

I came across a question at Udacity Intro to Computer Science course: Define a procedure, find_last, that takes as input two strings, a search string and a ...
9
votes
5answers
160 views

ASCII generator

Today I stumbled upon CodinGame, a site with programming challenges. I'll describe one of them. ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms ...
4
votes
2answers
61 views

Find if the prefix of the string exists in the values of the hash table

I have a hash map which maps to some strings which serve as prefixes and are of small length (max length is 6): ...
3
votes
2answers
41 views

Rosalind string algorithm problems

I've been starting to learn Rust by going through some of the Rosalind String Algorithm problems. If anyone would like to point out possible improvements, or anything else, that would be great. There ...
5
votes
1answer
25 views

SQL with SUBSTRING / CHARINDEX

I've got a VARCHAR variable of this kind: @string = "BLABLA10;GOGOGO30;RES777;ANOTHER;" (several keyword + number separated ...
4
votes
2answers
180 views

Happy Birthday Program

I'm trying to teach myself C. I've managed to make this program I call HappyToYou.c (inspired by this video): ...
5
votes
2answers
185 views

Basic random password generator

I'm trying to pick up some Haskell skills so thought I'd write a random password generator to get to grips with using IO. It was far trickier than I expected and I ...
6
votes
3answers
373 views

Checking balanced parenthesis string

I recently wrote a code in online recruitment test. It was very good. With each question, there were associated space and time limits check. If our code executed correctly within both limits, only ...
1
vote
1answer
77 views

Comparing random number of bits

I have a function that compares bits from a binary representation string and a chunk of memory and returns true if they are equal. This is the function (which works as expected): I'll explain with ...
3
votes
2answers
52 views

Haskell's intersperse in D

I am learning D. I'm trying to implement Haskell's intersperse in D. I want to use ranges. I feel that the intermediate "interspersed" value is wrong. Additionally, I suspect the concatenation ...
4
votes
1answer
70 views

Hex to Double converter

I stumbled on this SO question which was asking about a way to convert larger hex values to a positive numeric value: ...
7
votes
1answer
51 views

Printing three ASCII 'banners'

This code that I wrote for a lab works perfectly and gives the desired output. That said, it's over 200 lines of code to reach the result. This seems ridiculous, even when you consider that there is a ...
4
votes
1answer
88 views

Checking digits in a number

I'm working on an exercise that counts the number of even digits, odd digits, or zeros in a user-input integer (I made it a long so the user could put in more ...
2
votes
1answer
78 views

Finding the largest word in the given String

If there are two or more words that are the same length, return the first word from the string with that length. I am a beginner. Could anyone highlight good and bad parts of the following ...
4
votes
2answers
790 views

Funny String Java Solution

I'm a little rusty in Java, but I'm using it to get ready for interviews. Here's the problem description from HackerRank: Problem Statement Suppose you have a string \$S\$ which has length ...
1
vote
2answers
63 views

Increment number in jQuery

I have this number returned from an Ajax request: 015-0011-00001. I want to increment the last part of the number (00001) on ...
5
votes
1answer
97 views

Palindrome using stack

I recently started learning Java, algorithms, and data structures. I am trying to check if a string is palindrome. I would like a review to see where and how I could improve. ...
4
votes
2answers
130 views

Find palindrome in a string

The purpose of this code is to find the largest palindrome in a string. It works fine when the string is short, but every time I test this code with 1000+ characters in a string, it takes forever to ...
10
votes
5answers
177 views

Return the longest word (or words) in a string

I'm coding for a function that checks the longest word (or words) in a string: If multiple words are of the same size, those words have to be displayed. If a single word is inputted, that word has ...
3
votes
2answers
41 views

Aligning text in Haskell

This Haskell program just aligns the text lines on the given substrings. I took inspiration from here, but my code is not golfed. ...
7
votes
5answers
673 views

Creating a numeric phone keypad

I'm writing a Telephone class and it has a method called getDigits which takes in a String parameter and returns the number that would appear on your phone if you ...
3
votes
1answer
52 views

Greasemonkey script to refresh page until target string is found

I've been working on this user script to hunt for a specific string in an HTML webpage with the goal of finding the time at which it appeared. This feels needlessly complicated and I would like ...
8
votes
1answer
78 views

Replacement string Base64 (and a Base32) conversion

This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ...
1
vote
2answers
46 views

Clean regex matches with named matches

I have a regex pattern that will match some elements from a string and give them a particular name. For example, #^(?<foo>.*)^# will match the whole string ...
4
votes
2answers
66 views

Finding patterns in a string

I'm trying to find patterns of different length in a given string. How can I improve it? Are there problems? ...
3
votes
1answer
41 views

Length prefixed strings in C [closed]

In want to implement length prefixed strings in C (not null terminated), with some idiosyncrasies: malloc is prohibited, memory efficiency is important, each string (except for literal-backed ones) is ...
2
votes
1answer
72 views

StringRef - read only std::string like class similar to boost::string_ref

Idea behind the class is same as boost::string_ref or llvm::SrtingRef. StringRef is immutable and not-owning. I did not ...
7
votes
3answers
368 views

Count every word occurrence from file

How good is this algorithm? Personally I think it's over-complicated and needs some improvement. Should I be using iterators here (I think it's "harder" this way) or indexing? Should I stick with a ...
6
votes
2answers
145 views

Fastest C++ code to get common prefix length

In a C++ program, I have the following function to find the length of the longest common prefix between to char arrays a and b. ...
4
votes
1answer
62 views

Vigenère cipher 2

The following program is an updated version of this question, an implementation of the Vigenere cipher in C. It has been updated to take input from stdin and pipes, ...
2
votes
1answer
30 views

mIRC scripting like string token manipulation in Lua

I'm trying to reproduce in Lua the mIRC scripting manipulating tokens function: ...
1
vote
1answer
50 views

Permutation and sorting of Strings (parentheses problem similarity)

This algorithm runs in \$O(n!)\$ time and I wish I could make this a bit faster for larger elements. Is there a better approach to solving the parentheses problem in shorter time? ...
2
votes
1answer
37 views

String Concatenation in Scheme

As plain r5rs is lacking in useful string processing utilities, such as string-split and string-join (I'm using MIT/GNU Scheme), I decided to implement my own. My procedure, string-join, works just ...
4
votes
1answer
268 views

Vigenère cipher in C

For my second major project in C, I decided to write an implementation of the Vigenère cipher in C. My program uses command line options (optarg) and can read from both a file or from a string ...
2
votes
0answers
80 views

Validating Card Number in Delphi

As part of processing card payments, before even attempting to process, I need to check and validate the card number to make sure it's valid. For this, I've encapsulated this validation in a record ...
4
votes
2answers
50 views

Print the length of words as input as a histogram with horizontal bars

Input A list of words separated by any number of spaces. Output A horizontal ASCII art histogram, where the n-th line is composed by as many asterisks (*) as the ...
3
votes
2answers
114 views

Brute-force string generator

I have created a brute-force algorithm class in C# and I was wondering if I could speed up the process of creating a new string. There are two methods inside the class: one returns the brute-force ...
7
votes
3answers
129 views

Check a string for any occurrences of certain character classes

This is a warm-up programming exercise for learning string methods in Python from HackerRank: You are given a string S. Your task is to find if string ...