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)

5
votes
2answers
97 views

Function that shortens a String based on a term/abbreviation mapping

I have a function that takes a description as a String and returns a shortened version of the description. The shortening is done by checking if a word matches the ...
3
votes
2answers
26 views

Extracting and normalizing URLs in an HTML document

I have written code to get all urls on a webpage & put them in a set, and would like tips on simple changes I can make to increase its performance. ...
5
votes
5answers
367 views

Shorthand expansion exercise from K & R C (ex 3-3)

I have written a function to take some shorthand input and expand it into the full form, for example a-z0-9 becomes abcd...789. I added protection from buffer overflow exploits (knocks on wood), and ...
-5
votes
0answers
32 views

I want to see why my program keeps running the first line of code [on hold]

When I compile my code in the de-buggger its fine but my issue the user is not able too move past the first console.writeline statements ...
-4
votes
0answers
16 views

Checking for sorted elements [closed]

I have implemented of getting the string as integer input. I want to check whether they are sorted, if so print true, otherwise, print false ...
-4
votes
0answers
14 views

Testing if an integer has been sorted [closed]

This function gets the string as integer input and returns true if it's sorted otherwise it'll return false. ...
-6
votes
0answers
32 views

Picking a Server randomly out of a server list C Code [closed]

can someone help in writing a better code to pick a random server out of a list of servers from an Array, for some reason, when i run this it always picks the 1st or second server only, it is really ...
25
votes
4answers
1k views

Determining if two words are anagrams

I was given a this problem at a technical interview and failed miserably in the time given. Afterwards, I sat down and worked out what I think is a good solution. The task was actually to build an ...
4
votes
3answers
199 views

Get initials from full name

Going through a book, I encountered the following assignment: Write an application that asks for the user’s first, middle, and last names and replies with the user’s initials. Are there any ...
1
vote
2answers
53 views

Compensating for typos in strings by removing spaces and making uppercase for comparison

I'm working with a database that has typos in the values. To compensate for them I've made a function called standardizer() which removes spaces and converts all ...
5
votes
3answers
614 views

Function that adds two integer strings

I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing. How efficient is the code that I wrote? I am by no means a great ...
1
vote
2answers
42 views

Library class Project

I am creating a class project which involves two classes: Library and Book. I would like a general review on the code. ...
2
votes
0answers
20 views

Pass the password back

This code simply receives a very basic 'password' (numbers, letters, nothing fancy). After you press enter, it will display it back. The only special key I'm handling is backspace (code ...
1
vote
1answer
37 views

Generate all possible permutations from a string with character repetitions

I want to know if my code is good, with reasonable efficiency, and if it is possible to improve my code and how. What would you suggest? ...
0
votes
5answers
107 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
5answers
353 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 ...
6
votes
2answers
65 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
67 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
45 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
56 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
173 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 ...
6
votes
4answers
344 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
85 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
60 views

Getting the individual digits of a number

Approach 1: Repeated division-modulus operations: ...
11
votes
2answers
133 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
227 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
256 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
202 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
170 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
345 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
37 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
51 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
85 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
37 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
43 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
178 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
248 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
44 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
123 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
124 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
148 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
45 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
450 views

Determining if a word is an anagram of another

The question was to see if a word is an anagram of another word. How would you improve this? It returns True if an anagram, or False otherwise. ...
8
votes
4answers
326 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
118 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. ...