Questions tagged [string]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
81 views

Is there a way to optimize this? [closed]

I tried solving the following problem by following the suggested approach to solving the problem in the problem tutorial. However, the online judge still says my solution exceeds the time limit. Is ...
user avatar
  • 19
8 votes
3 answers
186 views

Change the quotations as if in Microsoft Word

I noticed that in Microsoft Word, single quotations are either or , but not in Notepad. Your task today is: given a string <...
user avatar
18 votes
30 answers
2k views

Divisor of a string

Challenge Given a positive-length string \$S\$, a divisor of \$S\$ is another (not necessarily distinct) string for which there exists a number \$a\$ such that when we repeat the divisor \$a\$ times, ...
user avatar
  • 1,017
21 votes
14 answers
2k views

Add parentheses to Polish notation

In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish ...
user avatar
  • 1,413
4 votes
3 answers
887 views

Python: can I shorten this code further for checking substrings

So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of ...
user avatar
15 votes
38 answers
2k views

Implement String Projection

Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection ...
user avatar
  • 3,233
15 votes
5 answers
1k views

Find The Average String Between Two Strings

Inspired by this Your task today: given two strings, find the string with the lowest maximum Levenshtein distance to the input strings. For example, using Steffan ...
user avatar
  • 3,337
6 votes
2 answers
216 views

Case Conversion Polyglot

Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of ...
user avatar
  • 22.6k
22 votes
16 answers
2k views

Remove redundant parentheses

Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that ...
user avatar
  • 1,625
12 votes
7 answers
290 views

Encode the systematic binary Varshamov–Tenengolts code

Background Here on CGCC, a commonly seen subgenre is radiation-hardening – writing a program that works even if one character is deleted. A similar problem is studied in the field of coding theory: ...
user avatar
17 votes
21 answers
2k views

Generate all Possibilities of Words

This is not the same as m-ss-ng-lette-s Challenge: Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words. Rules: The sequence of the characters in the ...
user avatar
10 votes
36 answers
3k views

Repeat Hello World according to another string's length

This was related to a program I am writing. Although the title is simple, the challenge is a lot more complicated. Your challenge You must write a program that takes an input, and your answer must ...
user avatar
31 votes
13 answers
4k views

Have you heard of tralindromes?

I haven't. :P So I decided to define one: A tralindrome is a string which contains three equal-length sections X, Y, Z such that all characters in the string are included in at least one of the three ...
user avatar
  • 64.8k
19 votes
22 answers
2k views

Rearrange to a palindrome

Given a string, shuffle it so that it becomes a palindrome. For example, adadbcc can be arranged into dacbcad, or ...
user avatar
  • 31.5k
21 votes
24 answers
2k views

Generate an arbitrary half of a string

Given a string \$ x \$, we say another string \$ y \$ is half of it, if both of the following properties are true: \$ y \$ is a (not necessarily continuous) subsequence of \$ x \$ - there exists a ...
user avatar
20 votes
23 answers
1k views

Letters to numbers to letters (poorly)

Every now and again, I'll encounter a large string of alphabetical text encoded as numbers from 1-26. Before I knew that I could just google a translator online, I had to personally, painstakingly ...
user avatar
8 votes
1 answer
402 views

Next Special String

Special String We call a binary string \$S\$ of length \$N\$ special if : substring \$S[0:i+1]\$ is lexicographically strictly smaller than substring \$S[i+1:N]\$ for \$ 0\leq i\leq N-2\$, Note: \$ ...
user avatar
  • 599
19 votes
20 answers
3k views

Next digit of rational number

Story: The π was recently computed with accuracy to 100 trillions digits, but it is useless to us. We can't do accurate enough math, because rational numbers are too boring and so we don't know that ...
user avatar
  • 1,295
19 votes
15 answers
2k views

Infinite quote escaping sequence

Related We start with the string a, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in ...
user avatar
13 votes
13 answers
1k views

Extract Strings from Text

In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is ...
user avatar
  • 30.7k
11 votes
11 answers
1k views

Convert Descriptive Notation to Algebraic Notation

Introduction Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending ...
user avatar
  • 11.2k
24 votes
30 answers
3k views

Backronymiser឵឵

Background A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be ...
user avatar
  • 22.2k
5 votes
7 answers
612 views

Convert from Greeklish to modern Greek

Greeklish, a portmanteau of the words Greek and English, is a way of writing modern Greek using only ASCII characters. This informal way of writing was extensively used in older applications / web ...
user avatar
  • 897
3 votes
0 answers
133 views

Build a file/directory tree [closed]

Task In this challenge, your task is to write a program or function which takes an array of paths with an additional boolean indicating it is a file or directory and outputs a file/directory tree in ...
user avatar
  • 161
23 votes
52 answers
3k views

Erverse Hte Ifrst Wto Eltters fo Aech Owrd

Inspired by this accidental misspelling If you could read the title, then you already know what the challenge is about. If not, then I'll tell you. Easy: simply take each word (single space delimited)...
user avatar
  • 3,337
18 votes
11 answers
882 views

Word stays a word after taking away a letter

This is a repost of this challenge Challenge There is an old, popular riddle: Find an English word with 8 letters that, taken away one letter, creates a new valid word. Repeat that until there are ...
user avatar
  • 4,621
9 votes
1 answer
311 views

Which R version is it? It's Peanuts!

This challenge will be based on an R language trivia: every release is named and it's a reference to Peanuts comic strips (see here and here). Task Given a release name, output its number. For ...
user avatar
  • 12.1k
20 votes
20 answers
2k views

Decipher a squashed sequence

Given a string containing a sequence of ascending consecutive positive integers, but with no separators (such as 7891011), output a list of the separated integers. ...
user avatar
  • 22.2k
26 votes
7 answers
3k views

Fix my FizzBuzz

FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz&...
user avatar
  • 31.5k
3 votes
0 answers
61 views

Extract the word containing this index [duplicate]

For this challenge, a word is defined as a string of letters, separated by spaces. Given a string of words, and an integer i representing an index into that string, ...
user avatar
  • 22.2k
18 votes
9 answers
2k views

ro1000an nu1000era50 en100o501ng

In the hovertext of this xkcd: There's an "encoding" based on replacing runs of roman numerals with their sums. To do this: Find all runs of at least 1 roman numeral (...
user avatar
  • 31.5k
25 votes
24 answers
3k views

backwardS_hybriD-snakE_kebaB-cameL_case

There are a bunch of different casing conventions, like camelCase, PascalCase, snake_case ...
user avatar
  • 31.5k
20 votes
25 answers
1k views

Truncate words in a sentence

Inspired by wezl. Your challenge is to take words (sequences of [a-zA-Z]) and truncate them to length 3. For example, ...
user avatar
  • 31.5k
10 votes
6 answers
410 views

Parenthetical Names

Parenthetical names Your challenge is to build a program that puts parentheses around the 'title' part of names. For example, Sonic the Hedgehog is converted to <...
user avatar
22 votes
10 answers
3k views

Tell me how many there are, in Polish

Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland. Given a number and a noun, output a Polish sentence telling me that there are that many ...
user avatar
23 votes
37 answers
2k views

Count /[^a-z]/ig with /[a-z]/ig

Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character ...
user avatar
9 votes
8 answers
416 views

Durable Durations

Introduction Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though ...
user avatar
  • 199
11 votes
17 answers
1k views

Extract the contained powers of two!

Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases ...
user avatar
  • 1,443
23 votes
23 answers
10k views

`lol` is an ambigram, `dad` isn't

Given a word, decide if it is an ambigram. When rotated: b > q d > p l > l n > u o > o p > d q > b s > s u > n x > x z > z Assume ...
user avatar
14 votes
8 answers
2k views

But is it a pretty place?

Your challenge, should you choose to accept it, is to take as input: A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions) A list of pairs of integers, henceforth ...
user avatar
  • 1,443
18 votes
31 answers
2k views

Reverse hex cipher

Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, ...
user avatar
  • 12.1k
33 votes
33 answers
5k views

Eh, codegolf shmodegolf

This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order ...
user avatar
  • 663
13 votes
12 answers
2k views

I want 8 bits for every character!

This is the reverse of this challenge. Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string. For example, given the encoded list <...
user avatar
  • 8,956
12 votes
15 answers
5k views

LOOOOONG TEEEEEXT

Definition of long text Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is ...
user avatar
11 votes
9 answers
409 views

Convert Alpha-2 to Alpha-3

The Task The task is easy: given an Alpha-2 country code, output the Alpha-3 equivalent. The input may be in any case you choose, and the output in any consistent case of your choosing. Here are the ...
user avatar
  • 3,337
27 votes
5 answers
4k views

Haplololololololology!

Haplology Haplology is a linguistic term: the omission of one occurrence of a sound or syllable that is repeated within a word, for example probly for probably. For this challenge, it means ...
user avatar
21 votes
8 answers
2k views

ASCII-Art n'th Root

Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal ...
user avatar
26 votes
28 answers
2k views

Derivative of a product

In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function f(x) can be marked as ...
user avatar
  • 31.5k
21 votes
16 answers
4k views

Who needs 8 bits for one character?

Given a string and the characters used to encode it, you need to compress the string by only using as many bits as each character needs. You will return the character codes for each character needed ...
user avatar
  • 8,956
11 votes
7 answers
646 views

Shortest restricted superstring

Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$. There are almost always multiple possible ...
user avatar
  • 22.2k

1
2 3 4 5
43