Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [string]

A competition to solve a particular problem through the usage and manipulation of strings.

8
votes
22answers
199 views

Tower of strings

Given a string of text, output it as a 'tower'. Each slice of the string (of the form 0:n) is repeated 5*n times, so the first ...
10
votes
16answers
2k views

Codegolf Rainbow : Draw in Black-and-White

Introduction: (Source: Wikipedia) When we look at a rainbow it will always have the colors from top to bottom: Red; orange; yellow; green; blue; indigo; violet If we look at these individual rings, ...
18
votes
9answers
638 views

Maximum Hamming distance among a list of padded strings

The Hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different. If the strings are not of equal length, the Hamming distance is ...
29
votes
8answers
953 views

Make an alphabeTrie

Consider the following alphabetically sorted list of words: balderdash ballet balloonfish balloonist ballot brooding broom All of the words start with ...
8
votes
25answers
1k views

A function to take three integers and return a list of integers and alphabet-letters

Challenge We take three positive integers a, b, and c as input. Using these integers, first ...
12
votes
7answers
1k views

crossed out 44 is still regular 44 ;(

Introduction On March 24th, 2015 @isaacg golfed his Pyth answer from 44 to 42 bytes. Since a crossed out 44 (44) looks a lot like a regular 44, @Optimizer made the following comment: striked out ...
0
votes
1answer
100 views

Symmetric Numbers [duplicate]

write a function to tell if a number is symmetric or not. for example: input: 151 output: True input: 142 output: False and so on: 1111 True, 2390 False, 1226221 True
7
votes
3answers
157 views

Evaluate Words Based on “Rules” (Skeptics.SE Crossover)

I came across this picture, which I initially questioned and thought about posting to Skeptics. Then I thought they'll only tell me if this one case is true, but wouldn't it be great to know how true ...
14
votes
21answers
3k views

Test if a string is parenthesly balanced

We call a parens group the open paren (, its matching close paren ) and everything inside them. A parens group or string is ...
6
votes
2answers
176 views

What associativity was it again

Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following: $$ a-b-c ...
17
votes
32answers
2k views

Increment base-36 strings

This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by ...
16
votes
17answers
2k views

Alternating Pattern

In a now deleted stackoverflow question, someone posted the following: Write a program or function to print alternating patterns in * and ...
16
votes
30answers
1k views

Search text for a prefix and list all its suffixes in the text

I use "suffix" loosely here to mean "any sub-string that follows the prefix". "Prefix" here means the START of a word, where a word's start is defined as either after a space or from the first ...
12
votes
10answers
3k views

Golfing Emoticons

Introduction Your challenge today (inspired by this challenge) is to write a number of snippets, functions or full programs each that output various ascii emoticons, without reusing characters. ...
3
votes
0answers
174 views

Deficient OCR Software [closed]

Introduction My OCR (Optical Character Recognition) software sucks! I mean, I am grateful from the stackoverflow post that I copied it from, but I'd rather have it not work at all than most of the ...
24
votes
30answers
2k views

Count Consecutive Characters

Given a string containing only letters, output the length of the longest run of consecutive alphabetical letters the word contains, where order does not matter. An example algorithm may sort the word, ...
48
votes
28answers
7k views

Which Go rank is higher?

Players of the traditional board game Go measure their skill in a system of ranks: Players new to the game are ranked 30th kyū (written 30k) and progress counting ...
7
votes
10answers
512 views

How many bytes is it

This time, we want render the count of bytes in a human readable way to user. Let's write a program (a full one or a function or other acceptable formats) to do this. Input An non-negative integer, ...
14
votes
19answers
968 views

Addition-Subtraction of Numbers Within String

Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result. Rules The digits in the string are read from left ...
12
votes
23answers
2k views

Convert Numbers to Letters, and vice-versa in a string

Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result. List 1 = a 2 = b ...
29
votes
12answers
2k views

Pleasanortmanteaus

A portmanteau word is a combination of two words that takes part of each word and makes them into a single new word. For example, lion + tiger => liger. Let's write a program to generate portmanteaus ...
19
votes
3answers
564 views

Spoonerise words… in Finnish

This challenge is based on, and contains test cases from, a programming course I took at Aalto University. The material is used with permission. Two and a half years ago there was a challenge about ...
25
votes
25answers
2k views

Detect Perfect Pairings

Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap ...
25
votes
30answers
2k views

Let's design a digit mosaic

Challenge Given a positive integer \$N\$, repeat each of its digits \$d_1, d_2, d_3, \cdots, d_n\$ a number of times corresponding to its position in \$N\$. In other words, each digit \$d_k\$ should ...
22
votes
10answers
3k views

Bake me some moji

Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, ...
15
votes
4answers
300 views

Zigzag this string by collapsing duplicates

Given a string, your task is to collapse it into a zigzag-like structure as described below. Folding into a Zigzag We'll take the string "Mississippi" as an ...
13
votes
12answers
1k views

Fun with strings and numbers

Here's a programming puzzle for you: Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]]...
2
votes
8answers
265 views

Decode My String (Brackets) [duplicate]

Taken from StackOverflow Question Challenge Given an encoded string in format n[s] where n is the amount of times ...
7
votes
4answers
824 views

Insulate the Window Glass and Foil of your house

Introduction: The best options for the glass of your house will: 1. Let through as little heat as possible in both directions (insulation-value Ug). (2. Let ...
1
vote
5answers
297 views

String Array to JSON String

Introduction I've seen throughout the code-golf challenges several simple tasks involving JSON, such as interpreting JSON strings with RegExs, and almost every other manipulation I could think of. ...
15
votes
14answers
1k views

A Capital Cipher

Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126]. Reading the string character per character: each time you encounter a letter in lowercase,...
14
votes
10answers
1k views

Decoding the Kaadi system

You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been ...
7
votes
8answers
778 views

Divide two strings

One day, I saw the challenge to multiply two strings and I thought I might be able to do one better. That challenge was fake. It was elementwise maximum. It was not real multiplication. So I set out ...
-1
votes
2answers
188 views

Equal Pair sum of 10? [duplicate]

Challenge : Check : if there are exactly n exclamation marks ! between every pair and ...
25
votes
25answers
3k views

Golf A Parentheses Matching Algorithm

You will be given a string s. It is guaranteed that the string has equal and at least one [s and ...
-5
votes
9answers
196 views

Math Operations with Strings [duplicate]

Challenge : Inspired by Alphabet Position Finder Given an string and one of two possible mathematical operator (+ or -) as ...
-5
votes
1answer
142 views

split a string with two types of groups, ignoring characters in one [closed]

Example inputs and outputs: Input 1 "request.partner" Output 1 [request, partner] Input 2 ...
15
votes
4answers
449 views

Generate a Portmantout!

Background Three years ago, this guy Tom Murphy got it into his head to extend the idea of a portmanteau to all words in a language and called this a portmantout (portmanteau plus tout [French for ...
24
votes
19answers
3k views

Rememebere tehe vowelese!

Input A string of printable ASCII characters, for example: This is an example string. Output For every consonant (...
18
votes
9answers
841 views

Shortest Uniquely Identifying Substrings

Given a list of strings, replace each string by one of it's non-empty substrings which is not a substring of any of the other strings in the list and as short as possible. Example Given the list <...
33
votes
26answers
4k views

Exchange capitalization

Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins. ...
2
votes
1answer
92 views

Array-of-array string conversion to and from matrix [closed]

Matrix challenges are popular. There's an issue of how to provide test cases. A common method is the row-wise array-of-arrays representation, such as: ...
10
votes
38answers
2k views

Alphabet Position Finder

Inspired by the Codewars Kata. Your goal is to take an input string such as this one: "'Twas a dark and stormy night..." and return a string containing the ...
23
votes
19answers
6k views

New Password Idea: Word-walker

I thought of a new way to generate my passwords, and even though it's probably not very clever in the long run, it could still make for a fun code-golf. Taking a string of words, the password is ...
13
votes
6answers
2k views

Use that goodn't meme

There is currently a meme on the internet that consist of taking a sentence, reverse the meaning and adding n't at the end. For example, ...
-9
votes
18answers
256 views

How long is this string?

It's strange this question hasn't been asked yet, so here it is: Calculate the length of a string given through STDIN Rules As said, your string will be given through STDIN, not via command line ...
21
votes
25answers
2k views

Sort a string by a given ordering

Your challenge is to sort a string, but rather than by the normal alphabetical order (abc..xyz), you will be sorting strings by a specified alphabet. You must write a program or function that takes ...
10
votes
1answer
266 views

Self-enumerating pangrams

Pangrams The quick brown fox jumped over the lazy dog. This is an example of a pangram - a sentence that contains every letter of the alphabet at least once. A self-enumerating pangram is a ...
27
votes
14answers
3k views

Fridge magnet substitution

When writing a message with fridge magnets, you'll often find yourself substituting a 1 for an I. In this challenge, your goal ...
5
votes
5answers
345 views

M_ss_ng Lette_s

Given this list of all the words in english and a string with s_me missi_g lett__s, find one way to fill in the letters. Do note that some words on the list contain special characters (...