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)

2
votes
1answer
54 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
50 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
143 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
39 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
21 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
175 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
181 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
367 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
76 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
66 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
47 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
81 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
77 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
772 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
60 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
89 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
125 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
174 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 ...
2
votes
1answer
26 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
660 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 ...
-1
votes
0answers
25 views

vxbase string parser

Is it possible to optimize the string parser? GitHub vxscripts.h ...
3
votes
1answer
43 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
73 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
43 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
39 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
66 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
361 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
138 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
29 views

mIRC scripting like string token manipulation in Lua

I'm trying to reproduce in Lua the mIRC scripting manipulating tokens function: ...
1
vote
0answers
41 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
31 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
244 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
74 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
49 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
112 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
124 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 ...
8
votes
3answers
322 views

ASCII value converter

I have written VERY simple code that converts a string to a character array and then displays the ASCII value of each character. Let me know if this is the most effective/safe way of doing what I ...
1
vote
4answers
137 views

Find the longest sequential same character array

I am a new guy to Java. I want to find the longest sequential same character array in a input character arrays. For example, this character array: bddfDDDffkl ...
4
votes
2answers
67 views

Function that shortens a String based on a term/abbreviation mapping with special cases

This is a update of this question since the requirements for this task changed. I have a function that takes a description as a String and returns a shortened ...
2
votes
1answer
37 views

Ruby-like squish in Haskell

squish is an onomatopoeic string function provided by Ruby on Rails that works on strings. Given a string, squish condenses all ...
4
votes
4answers
95 views

Efficiently concatenate substrings of long list of strings

I am having performance problems with the following python function: ...
20
votes
4answers
3k views

“ONCE”, “UPON”, “A”, “TIME”

I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, ...
8
votes
0answers
48 views

POSIX shell compatible and POSIX conforming dirname implementation

The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname. This is what I ended up with but I'm ...
6
votes
2answers
98 views

Reading awkward text fields

I have written nested while loops to read in some of the columns in a text file that looks like this: ...
7
votes
3answers
152 views

Finding the shortest excerpt that contains all search terms

Write a function called answer(document, searchTerms) which returns the shortest snippet of the document, containing all of the given search terms. The ...
6
votes
4answers
320 views

Getting a scrabble score from a word

My program is complete and runs, and gives me the output I expect. For example, if I enter the string "HELLO" I should get 8. ...