Questions tagged [whitespace]
For challenges related to the processing and placement of whitespace characters (mainly, but not limited to spaces, tabs and line feeds), like challenges related to indentation. For challenges about the esoteric programming language Whitespace, use [whitespace-language] instead.
40 questions
16
votes
19
answers
2k
views
Capture the longest leading whitespace substring from lines
The Challenge
Given a multiline string, return the longest substring of leading whitespace present in every line, ignoring empty lines or lines composed only of whitespace. If input is empty or ...
27
votes
7
answers
2k
views
Ungolf my tinylisp code
I like golfing in tinylisp:
(d M(q((x)(i x(i(disp x)0(M x))0
But I also like posting explanations with nicely formatted code:
...
21
votes
16
answers
5k
views
Write a Stack Exchange compliant brainfuck explainer
You are to take a string representing a piece of brainfuck code and Explanations, containing only printable ASCII characters and newlines ( to ...
1
vote
0
answers
59
views
Reverse a sentence word by word [duplicate]
The setting
"Well I actually wrote the sql library they, the maintainers actually.."
"Right, but do you have any experience working with django?"
" ...no I don't use ...
5
votes
19
answers
481
views
How many spaces are there? [duplicate]
Your task is to input a string, and output the number of spaces in the string.
This is code-golf, so least number of bytes win. Your
Test Cases
Double quotes are not part of the test cases.
...
-1
votes
1
answer
141
views
Remove indentation [duplicate]
Write a program which removes any common leading spaces from the input string. For example, if the least indented line started with 3 spaces, and every other line has ...
15
votes
23
answers
3k
views
Implement a whitespace golfer
Some two-dimensional esolangs, such as Forked, and some non-esolangs, such as Python, can sometimes require spaces before lines of code. This isn't very golfy. Also, I'm lazy and writing a 2d lang ...
10
votes
2
answers
317
views
Reindent Java/C/C++/etc. code
Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done:
No line should contain more than one of ...
6
votes
1
answer
211
views
Expand elastic tabs
Background
The tabs versus spaces war in programming has been going on a long time, basically because spaces are too low-level to have all the properties you'd want for alignment and indentation, but ...
33
votes
55
answers
4k
views
Reversing of Words
Sona is in her house with her 10 year old daughter. She needs to go to school to bring back another child from school, as school is over at 2 pm. It's hot outside, so she wants to leave her younger ...
88
votes
64
answers
8k
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 ...
17
votes
20
answers
3k
views
Get rid of whitespace on otherwise empty lines
Ah, yet another of my selfish uses of this Stack.
Being a Chromebook owner, I'm a frequent user of the Ace IDE, the editor used by Cloud9. It has lots of tools for dealing with excess whitespace, but ...
20
votes
48
answers
3k
views
Create a codeblock tool
When using Markup, like on the SE network, an indentation of four spaces before a line of text denotes it as part of a code block, as I hope you know. If you don't, here's an example (with ...
19
votes
18
answers
3k
views
Significant Whitespace: Robbers
This is part of a Cops and Robbers challenge. Go here for the cops' part.
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most ...
55
votes
27
answers
6k
views
Significant Whitespace: Cops
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, ...