Questions tagged [string]

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

Filter by
Sorted by
Tagged with
20 votes
39 answers
2k views

Swap letter cases

Given a non‑empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that swaps the cases of A-Z and ...
bigyihsuan's user avatar
  • 9,218
17 votes
24 answers
3k views

Strings without twin letters

Consider an arbitrary set of letters \$L\$. It may either be \$\{A, B, C\}\$, \$\{M, N, O, P\}\$, \$\{N, F, K, D\}\$, or even contain all the 26 letters. Given an instance of \$L\$ and a positive ...
enzo's user avatar
  • 1,983
1 vote
2 answers
736 views

Compiler for LaTeX

Problem: Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or ...
3.14's user avatar
  • 373
-8 votes
1 answer
250 views

Print Goodbye World instead of Hello World

Make a cat program, with a catch. The program must refuse under all circumstances to output "Hello World", instead outputting "Goodbye World", with matching spacing (but matching ...
Devsman's user avatar
  • 155
0 votes
0 answers
241 views

How quickly can you type this string?

Given a string consisting of only printable ascii (letters, numbers, symbols, and spaces), how many keystrokes are required minimally to type out this string from scratch? That is, current text is ...
Larry Bagel's user avatar
  • 4,083
7 votes
4 answers
371 views

Busy Letters & Evil CEOs

Imagine you are given an array/string containing \$5\$ letters of the English alphabet, with each letter having any value from A to Z (inclusive). Every day, each letter will perform a job, which can ...
Trivaxy's user avatar
  • 337
16 votes
11 answers
1k views

Find the finest building blocks

Given a string \$X\$ we will say two strings, \$a\$ and \$b\$, are building blocks of \$X\$ if \$X\$ can be made by concatenating some \$n\$ \$a\$s with \$m\$ \$b\$s in any order. For example the ...
Wheat Wizard's user avatar
  • 97.8k
15 votes
19 answers
2k views

Doubleouble Talkalk

Input A non-empty string or list of capital letters k with length between 3 to 5000. Output A value indicating whether k can be ...
Sny Smartie's user avatar
5 votes
6 answers
464 views

Aircraft registration numbers

Write a program that takes a United States aircraft registration number and returns a 24-bit ICAO hex code corresponding to that registration and vice-versa. An aircraft registration number always ...
Chris's user avatar
  • 2,009
8 votes
8 answers
1k views

Find the child anagrams of a word

Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present ...
enzo's user avatar
  • 1,983
3 votes
7 answers
394 views

Heart plus diamond is spade-and-club: table puzzle

I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, ...
HelloWorld's user avatar
23 votes
12 answers
6k views

How long is this string, really?

In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to ...
emanresu A's user avatar
  • 37.3k
7 votes
12 answers
948 views

Can their first appearance happen together?

Given two non-empty 01 strings, check if there is string containing both given strings, and their first appearance end at same position. Test cases: ...
l4m2's user avatar
  • 22.3k
7 votes
11 answers
765 views

Convert tiers between credit rating system

Related: Sort these bond ratings Credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer. The rating business is mostly controlled by "Big Three" ...
matteo_c's user avatar
  • 6,192
12 votes
10 answers
1k views

Format Datetime in 30-Hour Clock Time

Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time. The 30-hour clock time works as: After 6 a.m., it is same as 24-hour ...
tsh's user avatar
  • 34.5k
21 votes
18 answers
6k views

Am I vaccinated?

Disclaimer: the content of this post is not medical information and should not be used for any medical purpose, as it is deliberately oversimplified for the purpose of the challenge. There are several ...
Someone's user avatar
  • 1,550
16 votes
2 answers
276 views

Translate Japanese hiragana into the flick input method

The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels: あかさ たなは まやら 小わ、 ...
bigyihsuan's user avatar
  • 9,218
10 votes
7 answers
1k views

Night hike partitioning

We want to go on a night hike with the youth group, but of course not everyone has their torch, even though we told them we planned to split up. What options are there for group formation if n teens ...
Philippos's user avatar
  • 2,391
10 votes
18 answers
3k views

Can the chefs go?

On the TV cooking show Guy's Grocery Games, the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. ...
Someone's user avatar
  • 1,550
16 votes
8 answers
953 views

One-dimensional map colouring

It is a well-known fact that you can colour a two-dimensional map with four colours in such a way that two countries with a common border always have different colours. There have already been enough ...
Philippos's user avatar
  • 2,391
16 votes
21 answers
2k views

Just another traffic jam!

One lane is closed, the vehicles have to thread their way in according to the zip-lock system: One car from one lane, the next car from the other lane, always taking turns. Input: Two vehicle queues, ...
Philippos's user avatar
  • 2,391
7 votes
1 answer
281 views

Literate Programming in Base 26

Your task is to convert non-empty strings - between strings using the 26 letters, and programs, which are strings of bytes, where each byte has 256 possible values. You should use the same codepage ...
Command Master's user avatar
32 votes
36 answers
6k views

aaabbabbc⠀⠀⠀⠀⠀⠀

One element of the list aa, ab, ba, bb, c has been removed, and the remainder shuffled and joined with no separator. Find the missing element. For example, if the ...
Sisyphus's user avatar
  • 14.7k
9 votes
8 answers
667 views

Produce the shortest suffix for an (almost) arbitrary string

I encountered some silly code from a game and I figured this would actually turn into a fun golfing problem, so: Given any ASCII string in the limited char range specified below. Append as few ...
Olipro's user avatar
  • 199
15 votes
19 answers
2k views

Last Week Day Of The Month

Introduction This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find! Task Your task, if you ...
I.T Delinquent's user avatar
11 votes
6 answers
801 views

Find the conflict-free sitting arrangement

Party time! All of your guests are sitting around a round table, but they have very particular seating requirements. Let's write a program to organize them automatically! Guests are represented by ...
Philippos's user avatar
  • 2,391
9 votes
8 answers
1k views

Is it a valid hidden word?

The Universal Crossword has a set of guidelines for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consists ...
Wheat Wizard's user avatar
  • 97.8k
13 votes
4 answers
522 views

Golf a LaTeΧ math expression

A problem I sometimes encounter is that when writing comments using LaTeX, the comment is too long. Today you will solve this, by writing code which, given a LaTeX math expression, will produce the ...
Command Master's user avatar
16 votes
14 answers
1k views

Implement the RegPack decompressor

The JavaScript compressor RegPack uses a very simple string compression algorithm. Given a piece of code, it will make a list of characters that aren't used in that code and use them to delimit ...
emanresu A's user avatar
  • 37.3k
8 votes
10 answers
2k views

Decrypt an Autokey Cipher

The autokey cipher is closely related to the Vigenère cipher (both were invented by Blaise de Vigenère). Decryption involves the encrypted message and the key. For simplicity, let us assume all ...
SquareFinder's user avatar
9 votes
12 answers
3k views

Funny Numbers :D

The task is to calculate the average "funniness" of a given number given the following scoring system: 1 point for each "420" in it 2 points for each "69" in it 3 points ...
Joseph's user avatar
  • 115
22 votes
10 answers
2k views

I (rev)?(pal)? the source code, you (rev)?(pal)? the input!

Just because the reverse and palindrome were not too challenging individually :) Write a program (full program or function) that satisfies the following: given a string input, the program as-is ...
Bubbler's user avatar
  • 75.2k
29 votes
10 answers
3k views

What's my type? Well... Probably

There are a lot™ of pokemon. One of the defining characteristics of pokemon is their type, of which every1 pokemon has up to two types, a primary type and an optional secondary type. There are ...
DJMcMayhem's user avatar
8 votes
9 answers
1k views

Compile TailwindCSS to CSS

TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from ...
noodle man's user avatar
  • 6,290
14 votes
10 answers
3k views

When in {country}, do as the {countrians} do

(or: Output the plural demonym.) When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, ...
noodle man's user avatar
  • 6,290
10 votes
12 answers
2k views

Encrypting Emojis

Problem You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from ...
3.14's user avatar
  • 373
12 votes
18 answers
1k views

Print a meter of numbers to a specified limit

Given a positive integer n, output a number meter formatted like this: ...
TKDKid1000's user avatar
19 votes
17 answers
1k views

Compute the convolution of two strings

While implementing polynomial multiplication in Itr I found the following interesting operation on strings To compute the convolution of two strings (for instance ...
bsoelch's user avatar
  • 5,945
17 votes
13 answers
2k views

Efficient censorship

This challenge was originally posted on codidact. You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in ...
Wheat Wizard's user avatar
  • 97.8k
28 votes
17 answers
4k views

s-n-a-k-e-a-r-o-u-n-d--->

This ascii-art challenge is about walking around a string like a snake. s-n-a-k .---. e d <-' a n-u-o-r You will be given a string \$ S \$ of length \$ l \$ and ...
noodle man's user avatar
  • 6,290
13 votes
15 answers
2k views

Can you perform swaps?

Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check ...
Huỳnh Trần Khanh's user avatar
17 votes
24 answers
3k views

Meta-cat program

Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline ...
Dadsdy's user avatar
  • 2,065
9 votes
17 answers
976 views

Continuously Count Consecutive Cases

Background Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the ...
Jacob Creutzfeldt's user avatar
7 votes
4 answers
295 views

Simulate Keyboard Inputs

Background You know how in text editors and just text fields in general, there's always that blinking bar where you type? Yeah, simulate typing there. You'll be given 3 inputs: The current text field, ...
Jacob Creutzfeldt's user avatar
11 votes
11 answers
1k views

(Robbers) Fast and Golfiest Season 1: The Lord of the Strings

Fast and Golfiest Robbers Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
Shiran Yuan's user avatar
17 votes
15 answers
1k views

(Cops) Fast and Golfiest Season 1: The Lord of the Strings

Fast and Golfiest Cops Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
Shiran Yuan's user avatar
13 votes
8 answers
703 views

Generate all linked chains

A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge. Linking chains We define a chain to be a string ...
caird coinheringaahin g's user avatar
14 votes
15 answers
1k views

Two Parallel Linked Chains

Background We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=". ...
Jacob Creutzfeldt's user avatar
10 votes
6 answers
930 views

Translate the keitai input method into Japanese hiragana

The keitai input method is a method for writing Japanese kana on a 12-key phone keypad. Similar to Western keypads, each kana is assigned to a key; when the key is pressed multiple times, it cycles ...
bigyihsuan's user avatar
  • 9,218
1 vote
0 answers
109 views

Bunny Shakespeare poetry [closed]

Suppose you have a grid of cells that is 6 wide and arbitrarily tall. In each cell is a word. Let the bottom row, which is row #1, be the last 6 words of sample.txt in order. Let the second to last ...
mikebolt's user avatar
  • 121

1
2 3 4 5
44