Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [string]

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

Filter by
Sorted by
Tagged with
151
votes
267answers
40k views

1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
22
votes
40answers
8k views

Make me speak L33T

I want to be down with the kids of the 1990's and start speaking this L33T speak of their's. For any given input I would like the resulting L33T speech as an output. I don't want to go to far down ...
24
votes
34answers
2k views

Sort and Table a Sentence by Word Lengths

In as few bytes as possible, sort the input, a delimited string OR list/vector/array of words, words contain printable ASCII except space (ASCII values 33-126) into a numbered list, table, or ...
19
votes
9answers
2k views

Substitute Unprintable ASCII Characters

Sandbox Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control ...
62
votes
46answers
11k views

Oreoorererereoo

Oreoorererereoo Given an input string that is similar to the word "oreo", give an ASCII representation of the cookie that is as wide as the input string (to ensure cookie stability). Rules The ...
71
votes
60answers
16k views

Sing Baby Shark

"Baby Shark" is a children's song about a family of sharks. Having long been popular as a campfire song, it has been popularized since the mid-2000s by social media, online video and radio. - ...
20
votes
46answers
2k views

Detect rotated strings

Read two strings from stdin. Output Yes if one string is a rotated version of the other. Otherwise output ...
423
votes
759answers
128k views

“Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
38
votes
102answers
8k views

Print invisible text

Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string. For example, given the string Hello, World! ...
1
vote
3answers
148 views

snakes_are_bad, camelsAreBetter [duplicate]

Introduction All these snakes everywhere! I've had enough, and have decided that I much prefer camels. Therefore, I want you to convert my snakes to camels for me. Challenge Turn any ...
45
votes
129answers
14k views

Output programming language name

Challenge: In the programming language of your choice, take no input and output your programming language's name. Fair enough, right? Restrictions: You can't use any character that is included in ...
77
votes
60answers
6k views

From Programming Puzzles to Code Golf

Your task is to write a program that outputs the exact string Programming Puzzles (trailing newline optional), but when all spaces, tabs, and newlines are removed ...
5
votes
57answers
2k views

String analyser

Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) ...
10
votes
2answers
375 views
+100

Exploding Primes

At the time of writing this puzzle, there are soon to be 269 puzzles related to primes. To celebrate/mourn this event (269 is prime), this challenge will be about exploding primes. In preparation for ...
21
votes
14answers
2k views

ASCII texturing

Write a function or a full program that applies an ASCII texture to a 2d shape. Inputs: shape, texture, dimensions(optionally). Both Shape and Texture can be given by any convenient method (2d ...
41
votes
28answers
3k views

Marquee sign letters

Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the ...
27
votes
12answers
4k views

Identify the Eeveelutions

Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf. The objective is to, when given a type name as the input, output the name of the ...
46
votes
78answers
7k views

Answer to life, the universe, and everything

Task Given a String as input, your task is to output 42 only if the input String happens to be exactly the following : ...
59
votes
132answers
12k views

“DDoouubbllee ssppeeaakk!!”

Super simple challenge today, or is it? I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way... Double speak is when each and every character in a ...
58
votes
100answers
8k views

Reverse stdin and place on stdout

Requirements: Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.) Output the reverse ...
16
votes
37answers
3k views

Do you make me up?

Introduction Every string has an "alphabet", composed of the characters that make it up. For example, the alphabet of \$abcaabbcc\$ is \${a, b,c}\$. There are two operations you can do with alphabets:...
30
votes
12answers
2k views

What is my volume?

Given an input integer, output the volume corresponding to the value. The value will always be in the range \$[0,100]\$. Examples If the input \$=0\$: ...
14
votes
54answers
3k views

Average Two Letters

Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and ...
15
votes
5answers
3k views

Format a Swedish phone number

In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though. For this challenge, your task is to take the digits of a what is presumed to be a valid phone ...
11
votes
2answers
476 views

Shell Glob Golfing

This task is to output the shortest path to a file, after glob expansion. What is shell globbing? In most shells, you can use the * character in a path to ...
21
votes
26answers
3k views

An A , or An An?

In English, there is the fun and simple difference between an and a: you use an when ...
32
votes
19answers
3k views

The Improved Caesar Pig Latin Cipher

The problem with the Caesar cipher is the resulting words are often unpronounceable. The problem with Pig Latin is that it is easy to decode. Why not combine them? Input A word consisting of the ...
2
votes
0answers
60 views

Counting syllables [duplicate]

Challenge Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy. Rules The accuracy of the ...
10
votes
3answers
347 views

Translate a simple sentence from Toki Pona

Toki Pona is a linguist's code golf: A minimalist language with a vocabulary of around 120 words. Because of this, it has very few grammatical irregularities found in other languages, making it ideal ...
1
vote
5answers
221 views

Proportion of strings with ascending letters [closed]

Challenge Construct n strings, each with three distinct letters, chosen randomly with equal probability. Print the proportion ...
13
votes
5answers
500 views

Typing, but to the left [closed]

Background You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type. ...
36
votes
21answers
4k views

(A[l(t[e(r)n]e)s]t) a string!

Alternesting, is the act of taking a string and nesting it in alternating brackets. Here is how you alternest a string. For a string of length N, take the center N characters, and surround them in ...
23
votes
10answers
1k views

Shortest Uniquely Identifying Substrings

Given a list of strings, replace each string by one of its 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 <...
13
votes
22answers
4k views

Making Sandwiches

Introduction Bob runs a deli. His deli serves sandwiches to its customers. However, it is a bit unusual. At Bob's deli, instead of telling Bob what they want, customers show Bob an ASCII art drawing ...
2
votes
0answers
140 views

Test the endianness

Given a UTF-16 string, test its endianness. Rules: As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be ...
46
votes
73answers
9k views

Is it double speak?

In an earlier challenge I asked code golfers to produce strings which copy each character in a string. For example: TThhiiss iiss ddoouubbllee ssppeeaakk!! ...
-5
votes
2answers
211 views

Fastest N times Hello World (Java/C/ C++) [closed]

Not a new one: Input N, being n, 0 ≤ n ≤ 5. Output N times "Hello World." Example: Input 3 Output Hello World. Hello World. Hello World. These 2 are my ...
18
votes
16answers
3k views

Check the validity of a 10-digit telephone number

Your task is to write a program or function that checks if a string is a valid phone number. Given a string (or list of characters/codepoints) input, you will output a truthy value if the input is a ...
41
votes
30answers
7k views

There, I fixed it (with tape)

Challenge: Given a string only containing upper- and/or lowercase letters (whichever you prefer), put tape horizontally to fix it. We do this by checking the ...
44
votes
48answers
7k views

Is this string a square?

A string is considered to be square if the following conditions are met: Each line has the same number of characters The number of characters on each line is equal to the number of lines. Your task ...
25
votes
20answers
2k views

Draw an ASCIIrisk

There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table. Challenge Your task is to ...
-2
votes
10answers
596 views

Map of India - minimum number of bytes

Your challenge is to make a program(less number of bytes than what the below program takes) that should print the map of India with any special character of choice. TIO Link ...
-12
votes
21answers
345 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 ...
7
votes
5answers
391 views

Regular ASCII Polygons

There are 4 regular polygons that we can construct using ASCII art: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
73
votes
145answers
16k views

“99 Bottles of Beer”

Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: ...
40
votes
27answers
3k views

Difference should make no difference

Your company lately hired a new bunch of extremely dedicated sysadmins. They feel that just watching computer screens is quite limiting (I mean, 60Hz refresh rate is just NOT enough), so they hooked ...
21
votes
37answers
4k views

ASCII Expansion

Introduction Every number can be represented as ASCII. For example, \$0\$ comes in ASCII is \$48\$, \$1\$ is \$49\$, and so on. Using this method of translating numbers to other numbers, it is ...
36
votes
28answers
11k views

Java is to JavaScript as Car is to Carpet

Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java? Introduction Java and JavaScript are commonly used languages among programmers, and are currently ...
37
votes
18answers
6k views

Count to 100 in Danish

Print all the numbers from 0-100 in the right order using the Danish way of counting How they count Like English, they have dedicated words for 0-20, 30, 40 and 100 Instead of saying ...
45
votes
24answers
9k views

Cheat at Rock-Paper-Scissors-Lizard-Spock

When playing Rock-Paper-Scissors-Lizard-Spock, your robot reflexes let you see your opponent's throw before they make it. You just need to choose a throw that beats theirs, in as few bytes as possible ...