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
4answers
55 views

std::string implementation

Following is my attempt for a simple implementation for the std string class. Please review my changes and share your feedback. string.h ...
7
votes
4answers
285 views

CodeEval Challenge: Remove specified characters from a string

Question Write a program which removes specific characters from a string. The first argument is a path to a file. The file contains the source strings and the characters that need to be ...
5
votes
1answer
31 views

String sequence in Haskell

Given a string sequence and a string, the function should output the next string of that sequence. For example, for sequence "abc": ...
4
votes
1answer
57 views

Matching strings

Basically I solved this question on one of the competitive websites: Given the total n number of String on first input, n input follows: We have to find such pairs of string (i,j) such that ...
-3
votes
1answer
50 views

Compare counts of string occurrences

Knowing my solution ... Return True if the given string contains an appearance of "xyz" where the ...
3
votes
0answers
41 views

String sequence in ES6

Given an unique string that represents a sequence of characters, the class should implement three methods (getNextChar, getNextString and the genSequence generator). How it works We give a sequence ...
3
votes
1answer
53 views

Checking for uniqueness within a string

I saw this interview question in the book Cracking the Coding Interview: Implement an algorithm to determine if a string has all unique characters The authors solution uses bit-shifting for a ...
1
vote
3answers
165 views

Confirming existence of lapindromes

The following description is taken from CodeChef.com's Lapindrome problem. Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same ...
-1
votes
0answers
21 views

Cant understand the difference between char and strings [on hold]

Trying to solve a problem, I cant understand why my struct of arrays are getting overwritten although it should not. Well, I have tried different methods and saw that my sorting algorithm works fine ...
6
votes
4answers
308 views

Conversion of hexadecimal string to string

Given a C# string which is a set of hexadecimal numbers such as: string HexString = "202048656c6c6f20576f726c64313233212020"; Where those hexadecimal numbers ...
0
votes
1answer
75 views

Immutable C++ String class

I have project where I will need to create lots of immutable strings. If I am using std::string, which has huge overhead - about 60-70% against ...
1
vote
1answer
54 views

Getting the individual digits of a number

Approach 1: Repeated division-modulus operations: ...
-2
votes
0answers
23 views

C# Konvertierung Problem with a funktion [closed]

His say it cant Konvert in a string. ...
11
votes
2answers
117 views

How to speak Brainfuck: for beginners

The following code transforms multi-line input into the the Brainfuck equivalent. One line turns into one program. The resulting programs are split by newlines for readability. Brainf.cpp ...
5
votes
2answers
218 views

Alien Name Generator (using blocks of consonants and vowels)

This is my first script in Python, and I am looking for tips and constructive criticism about code style, whether there are more efficient ways of doing things, etc. (not as interested in tips about ...
4
votes
2answers
233 views

Abbreviation of names

I have a few confusions about writing Java code, and I need some clarifications: ...
-2
votes
2answers
46 views

Manipulating strings and character positions

Write a program that manipulates two strings. The program inputs two strings (string1 and string2) and a character (...
10
votes
2answers
196 views

You need to diversify your strings

Challenge: Write a program which prints all the permutations of a string in alphabetical order. Specifications: Your program should accept a file as its first argument. The file contains ...
7
votes
2answers
167 views

Complete “Is it simple or is it hard?” challenge from Code Golf

Having written C# for half a year now, I decided to take on a fairly complex first challenge for C++: the Is it simple or it is hard? challenge from Code Golf Stack Exchange. (This is only practice, ...
8
votes
2answers
336 views

These words are so dirty

Challenge: Write a program that will clean up the words from extra numbers and symbols. Specifications: The first argument is a path to a file. Each line includes a test case with a list ...
6
votes
1answer
34 views

Sentence maker with thesaurus

I'm teaching myself Ruby by rewriting PHP solutions, such as this one. The program should match words in a sentence with a dictionary of synonyms and then make combinations with them. ...
6
votes
1answer
46 views

String replacement using dictionaries

I've always been bothered by the fact that there weren't any built-in functions that could replace multiple substrings of a string in Python, so I created this function. Essentially, you supply it ...
5
votes
1answer
73 views

Reading a pointer to a string

What it is doing basically is reading an std::string from a given pointer. I was told that using a StringBuilder as I am is not ...
2
votes
1answer
35 views

Implementing SQL function STR

I am writing a piece of code in c# that mimics the behaviour of following SQL function STR in the following case: ...
0
votes
2answers
42 views

Function that check's file type based on certain keywords

I have a function that breaks up a source file and checks each token against a keyword list to determine whether its a particular file type. How can I improve this function? ...
0
votes
3answers
166 views

Function to erase a character in a string

void chrrem (char arr[], size_t len, size_t pos) { memmove(arr + pos, arr + (pos + 1), (len - pos) + 1); } It is supposed to be just fast. Erases the ...
6
votes
1answer
237 views

Checking if two strings are anagrams

I have a piece of code that checks if two strings are anagrams. I would like this to be as pythonic as possible. ...
2
votes
1answer
34 views

Pattern search in a text

Is this a practical algorithm for pattern matching in a text? Assume text can be very large, is there anything I can do to speed up the performance? ...
3
votes
2answers
41 views

Slurp JSON trading cards to valid HTML

For Cardshifter TCG we pretty frequently update our list of available cards, so I tried to think of a way to make it easy to transform an exported JSON file containing all the cards into a decent HTML ...
7
votes
2answers
114 views

Finding longest substring containing k distinct characters

Below is my method to find the longest substring having k distinct characters. I have used Set to keep track of distinct ...
6
votes
3answers
120 views

Capitalised initials of username

Given a list of words, this program outputs the starting letters of the words capitalized. I was reviewing this question that solves the same task, but over time so many changes accumulated, that I ...
5
votes
2answers
129 views

Get initials from name input by user

This was an exercise from cs50. The goal was to get the initials in upper letter of a name that we got from user. So for "barack obama" we would get "BO", input like "abc" should output "A" and so on. ...
5
votes
2answers
41 views

The Geppy String: Regex vs Iteration

We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the g's in the given string are happy. ...
3
votes
4answers
425 views

Finding out if a word is an Anagram of another

The question was to see if a word is an anagram of another word. Here's my working solution. How would you improve it? Returns True if anagram, False otherwise. ...
8
votes
4answers
322 views

String related problem from CodingBat

I was trying this problem and I was wondering if there is a way to check for the edge cases inside the for-loop. The problem statement: We'll say that a lowercase 'g' in a string is "happy" if ...
18
votes
2answers
1k views

Please Save My Name

I wanted to create a save game system for my city building game that did not require the player to input a name for the city. It was also important to allow infinite save games, so I could not just ...
4
votes
2answers
112 views

Trim leading zeroes from second component of a string

I have a collection of strings as follows: 44.01 44.02 44.03 44.04 44.12 46.05 46 ... and so on. I want to remove leading zeros from the component of the string after the full stop. ...
4
votes
1answer
61 views

Balancing words

A word is balanced at the index if the sum of the alphabet positions of all the chars multiplied by the distance to the index is zero. This description is equivalent to the one given by ...
7
votes
5answers
722 views

Most common letter in string

Problem: Write a method that takes in a string. Your method should return the most common letter in the array, and a count of how many times it appears. Note: I solved it with Ruby, but the ...
5
votes
2answers
87 views

Splitting string by words to new strings

Function: ...
5
votes
1answer
57 views

A repeated string formatting operation

As I'm reading the Java code of some other people, I found him using an approach of assigning a format string to a variable and using the variable for String.format ...
2
votes
1answer
42 views
-4
votes
2answers
95 views

Reverse the words of a string using Java [closed]

I wrote this program which reverses the words in a given string. Please review and give your inputs. ...
4
votes
2answers
44 views

Count chars difference between two strings

Given two strings with the same length, we check how many chars on the same positions are different. For example: ABCD and ABBD should return 1. Here is a link to a gist with tests, to have a better ...
5
votes
1answer
35 views

Finding capitalized characters and printing their position & ASCII value

I was trying to find out if a string contained a capitalized letter and if it did I wanted to know the position of the character and its ASCII code. I might have refactored a little to much. Given an ...
10
votes
3answers
154 views

Function to return last line's length of a string

I am completely re-writing the textbox GUI widget. In order to set the position cursor after the last character in the last line of a text, it is good if you know the exact column of it. So I created ...
3
votes
4answers
83 views

Are the words isomorph?

Are the words isomorphs? (Code-Golf) This is my non-golfed, readable and linear (quasi-linear?) in complexity take of the above problem. For completeness I include the description: Two words are ...
2
votes
1answer
67 views

Finding the longest repeated substring in a string

After optimising my code it still seems pretty brute force and I am looking for ideas to fundamentally improve it. I have tried improving performance by: Avoiding creating substrings as much as ...
3
votes
1answer
36 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
7
votes
2answers
56 views

Text centering function in bash

I wanted to center some text in my commandline application, so I came up with this function. ...