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)

6
votes
4answers
246 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. ...
6
votes
1answer
72 views

Random String Generation - Base36 and optimization

This is some fairly heavily optimized C#. Aside from reading like C++ code due to all of the pointers, does this pass sanity checks, and is there any way to improve it, while keeping its speed (or ...
6
votes
4answers
55 views

Join strings with different delimiters and some possibly empty strings

I want to construct a string from several substrings, each one of those with a different delimiter. If the string is present, the delimiter and the string should be added, if not, none of them should ...
-3
votes
0answers
37 views

How can I shorten this string? [on hold]

I have this which is used to enable GC logging: ...
1
vote
0answers
9 views

Join strings with different delimiters from possibly empty strings [duplicate]

I want to construct a string from several substrings, each one of those with a different delimiter. If the string is present, the delimiter and the string should be added, if not, none of them should ...
6
votes
1answer
52 views

Cleaning up HTML created by users

I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of HTML. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I ...
4
votes
2answers
45 views

Prompt user for input then create an acronym from it

My program is complete and working, but I would like second opinions on it. The program prompts the user to enter something like a phrase or some words. Then it will create an acronym of what was ...
5
votes
1answer
68 views

C implementation of a string

As C does not have a native string type, I decided to try making a similar type. It's not perfect by any means, so I was coming here to see what I could do to ...
5
votes
2answers
176 views

String to Array formatting

Trying to convert, from this formatted string $filtersStr = "id:1||name:alex"; to: ['id' => 1,'name' => 'alex'] My ...
3
votes
1answer
49 views

Twisting words! (boustrophedon formatting)

I decided to implement properly the Code Golf challenge about twisting strings. I report the assignement verbatim for convenience: Twisting Words! Given a string and a positive integer. You ...
4
votes
2answers
77 views

Palin Pairs (Pallindrome Counting) Code

In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time ...
7
votes
1answer
58 views

Print array of sentences vertically

Suppose I have an array of sentences: [ "How To Format", "put returns between paragraphs", "for linebreak add 2 spaces at end" ] I want to print it like this: ...
2
votes
1answer
66 views

Function to compare phone numbers

I got rejected in tech screen yesterday. I was asked to write a JavaScript function and send it over email. The question was(I have added the full question below). I have also added hiring manager's ...
6
votes
3answers
336 views

Finding the postion of a substring in a string

I am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code. ...
6
votes
1answer
55 views

printf-style string formatter

As part of a larger project I'm working on, I've made a function that aims to replicate, as best as I can, the placeholder part of the console.log() function usable ...
7
votes
3answers
366 views

n number of x on the y

Everyone knows "99 bottles of beer on the wall". Mat's Mug made a comment about mugs on the wall in The 2nd Monitor and I realized I never wrote a "beer on the wall" program. But that seemed way too ...
2
votes
1answer
23 views

Getting the character index of recurring substring

I created this function that allows you to declare a string, then multiple instances of a substring. This uses a hash map to keep track of strings that have already ...
4
votes
1answer
37 views

A rename utility in Scala

I made a commandline tool for renaming files, similar to the rename command in Ubuntu. Here is the code: ...
3
votes
4answers
291 views

Get string truncated to max length

This is an extension method to get a string that is truncated to a maximum length. Any comments? ...
0
votes
1answer
11 views

Java Loops and UIs

I've always found coding UIs in Java very inefficient, and hopefully this is because of my misunderstanding. Here's a great example. I have a UI class which is returning the String "Hours", which is ...
5
votes
2answers
106 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
34 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
378 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 ...
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 ...
6
votes
3answers
224 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
54 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
624 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
47 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. ...
3
votes
1answer
67 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
41 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
113 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
358 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
70 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
52 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
48 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
62 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
179 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
383 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
91 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
61 views

Getting the individual digits of a number

Approach 1: Repeated division-modulus operations: ...
13
votes
2answers
157 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
267 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
285 views

Abbreviation of names

I have a few confusions about writing Java code, and I need some clarifications: ...
-2
votes
2answers
48 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
208 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
172 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
347 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
40 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. ...