571
\$\begingroup\$

This "sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to main. This is useful because writing a clear and fully specified challenge on your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the sandbox first.

Sandbox FAQ

Posting

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

  • Parts of the challenge you found unclear
  • Comments addressing specific points mentioned in the proposal
  • Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal, use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

\$\endgroup\$
2
  • \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$
    – None1
    Commented May 15 at 14:05
  • \$\begingroup\$ @None1 If you don't get feedback for a while you can ask in the nineteenth byte \$\endgroup\$
    – mousetail
    Commented May 29 at 13:27

4732 Answers 4732

1
2 3 4 5
158
0
\$\begingroup\$

Find the newest element

(Is this a duplicate, anyone please? It seems very basic!)

Given a finite sequence, each of its elements has a first occurrence. Your task is to output the symbol whose first occurrence is last in the sequence. If the elements represent posts and reposts of memes over time, we want to see the newest meme!

Example

Input: A-BANAL-BANANA-LAB

  • A first occurs at position 0 (it occurs at positions 0,3,5,9,11,13,16)
  • - first occurs at position 1
  • B first occurs at position 2
  • N first occurs at position 4
  • L first occurs at position 6

max(0,1,2,4,6) = 6, so

Output: L

Input/output format

You can assume that the input sequence is nonempty, and is either a string of printable non-whitespace ASCII characters or a list of nonnegative integers in any reasonable form (your choice). You will output one element of the input sequence.

And of course

This is , so the shortest solution in each language wins.

\$\endgroup\$
0
\$\begingroup\$

Three up to 729 & sum to 2048

(flexibly) Output 3 "random" integers such that:

  • Each number is 1 to 729 inclusive
  • Their sum is 2048
  • Each possibility is (hypothetically) equally likely

Unless explicitly designed otherwise, psuedorandom number generators in your language should be assumed to be uniform; for example, random.randrange(100) in Python and Math.floor(100*Math.random()) in JavaScript both hypothetically uniformly generate a random integer from 0 to 99 inclusive

Example: All of the following (and more) should be equally likely:

The 3 permutations of [648, 700, 700]
The 6 permutations of [628, 700, 720]

...and so on for every valid triplet of integers.

This is - shortest code in bytes "wins"

Sandbox stuff

  • I have no idea how pseudorandom generation distributions work in most common normal languages (C++, Python, JavaScript, C, Java, etc.) and golfing languages (Pyth, GolfScript, 05B81ESomething, <><, ><>, etc.)
  • What is random? What is randomness? Will we ever answer what randomness is? What is randomness in this question? How do we define randomness?
\$\endgroup\$
5
  • 1
    \$\begingroup\$ fastest-code is for optimizing for speed, here it doesn't make much sense as there's nothing to optimize. i suggest going for code-golf. \$\endgroup\$ Commented Jul 12 at 10:07
  • 1
    \$\begingroup\$ as for the randomness part, that's up to the people attempting the challenge. if they want to attempt the challenge, they have to pick a language that is able to do it, for the same reason people don't typically attempt graphical output challenges in BF. \$\endgroup\$ Commented Jul 12 at 10:10
  • \$\begingroup\$ Can you clarify whether the integers are ordered? Do 1000,1000,48 and 48,1000,1000 count as different "possibilities"? \$\endgroup\$
    – aeh5040
    Commented Jul 23 at 19:36
  • \$\begingroup\$ @aeh5040 Edited for clarity; also regarding your scenario, it should not happen as 1000 is not from 1 to 729 inclusive. \$\endgroup\$
    – W D
    Commented 4 hours ago
  • \$\begingroup\$ Thanks. Fair point about 48! 🙂 \$\endgroup\$
    – aeh5040
    Commented 3 hours ago
1
\$\begingroup\$

Rabinowitz-Wagon \$\pi\$ formula


In 1995, Stanley Rabinowitz and Stan Wagon found an interesting algorithm to generate the digits of \$\pi\$ one by one without storing the previous results. The algorithm is called the spigot algorithm. It is based on the following formula:

$$ \pi = 2 \left(1 + \frac{1}{3} \left(1 + \frac{2}{5} \left(1 + \frac{3}{7} \left(1 + \cdots \frac{k}{2k+1} \left(1 + \cdots\right)\right)\right)\right)\right) $$

This formula can be derived from the Leibniz formula for \$\pi\$ using the Euler's transformation.

(The formula was well-known before the algorithm was found, but I can't find a name for it. So I call it the Rabinowitz-Wagon \$\pi\$ formula as @aeh5040 suggested.)

Using this formula, we can approximate \$\pi\$ by a sequence of fractions. The first few terms are:

$$\begin{aligned} 2 &= 2, \\ \frac{8}{3} &= 2 \left(1 + \frac{1}{3}\right), \\ \frac{44}{15} &= 2 \left(1 + \frac{1}{3} \left(1 + \frac{2}{5}\right)\right), \\ \frac{64}{21} &= 2 \left(1 + \frac{1}{3} \left(1 + \frac{2}{5} \left(1 + \frac{3}{7}\right)\right)\right), \\ \dots&\dots \end{aligned}$$

Task

In this challenge, you need to output this sequence of fractions.

You can output a fraction \$\frac{a}{b}\$ in any reasonable format, e.g. a built-in rational type, a pair of integers \$(a, b)\$, or a string a/b. You don't need to simplify the fraction. For example, you can output \$\frac{8}{3}\$ as \$\frac{40}{15}\$.

As with standard challenges, you may choose to:

  • Take an integer \$n\$ as input and output the \$n\$th term of the sequence.
  • Take an integer \$n\$ as input and output the first \$n\$ terms of the sequence.
  • Take no input and output the sequence indefinitely.

The indices can be 0-based or 1-based.

This is , so the shortest code in bytes in each language wins.

Test cases

0 -> 2
1 -> 8/3
2 -> 44/15
3 -> 64/21
4 -> 976/315
5 -> 10816/3465
6 -> 141088/45045
7 -> 47103/15015
8 -> 2404096/765765
9 -> 45693952/14549535
10 -> 45701632/14549535
11 -> 80863232/25741485
12 -> 5256312832/1673196525
13 -> 3153846272/1003917915
14 -> 457311809536/145568097675
15 -> 833925152768/265447707525
16 -> 4725585805312/1504203675975
17 -> 14176771899392/4512611027925
18 -> 524540820979712/166966608033225
19 -> 104908189597696/33393321606645

Questions

  • Is it clear?
  • Is it duplicate?
  • Is there a better title? The original title is "A spigot algorithm for the digits of \$\pi\$". However, the challenge isn't really about the algorithm itself, but about the approximation formula used in the algorithm. The formula was well-known long before the algorithm was found, but I can't find a name for it.
\$\endgroup\$
2
  • 1
    \$\begingroup\$ The title seems rather misleading. Maybe Rabinowitz-Wagon pi formula, or something along those lines? \$\endgroup\$
    – aeh5040
    Commented yesterday
  • \$\begingroup\$ But otherwise seems nice! \$\endgroup\$
    – aeh5040
    Commented yesterday
0
\$\begingroup\$

.

\$\endgroup\$
1
\$\begingroup\$

Erase the loops

A nice simple one!

You are given a finite sequence. Find the earliest pair of equal elements, if any (where "earliest" refers to the position of the second element of the pair), and collapse them and the interval of elements between them into a single copy of the repeated element. E.g. abcda -> a. Repeat this operation until all elements are distinct, and return the resulting final sequence.

Note that the order of the collapsing operations matters.

(This arises in the construction of the "loop-erased random walk", which has important applications.)

Example

Input: abcbbcdeaeec

a[bcb]bcdeaeec
a(b)bcdeaeec
a[bb]cdeaeec
a(b)cdeaeec
[abcdea]eec
(a)eec
a[ee]c
a(e)c

Output: aec

Input/Output

You can assume that the input sequence is either a string of printable non-whitespace characters or a list (array, tuple, etc) of nonnegative integers (your choice). You can assume that it has at least 1 element. The output sequence should be in the same form.

Test cases

x            -> x
xxxx         -> x
ioioioio     -> io
1234321      -> 1
xyzxyzxyz    -> xyz
123213132    -> 132
abcbbcdeaeec -> aec

This is , so the shortest solution in each language wins.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice challenge, easily solvable with a recursive regex replace but I'm interested to see solutions in languages which don't support that. \$\endgroup\$ Commented yesterday
-3
\$\begingroup\$

Print an interesting number

An interesting number is a number which can be written as an expression which is shorter than the number itself.

The following 150-digit number is interesting. Write a function or program that outputs this number to the console.

654747700701377386126856657861679570529800895801424573182559133258946484061065580876771978236269380302819034101955696785289596873888391234225359484521

Rules

You may either print the output, or return a string or integer from a function. A trailing newline is allowed.

This is , so shortest answer in bytes wins!

\$\endgroup\$
5
  • \$\begingroup\$ OK, so I got two down-votes, but no comments! Can someone please comment so I can make improvements to the question. \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ printing a fixed string is too boring especially as the string is quite short \$\endgroup\$ Commented yesterday
  • \$\begingroup\$ If you mean 0x333497d0ef5042a6ea65420e47cc6489890b9be6ca3877c1862b31f09c9074d96ce7f90bde052cf23730fb0d1bb02c3462af4e4713aea20d5de105106f669 then almost every integer is interesting, which is not good. Unless generator of your number is given \$\endgroup\$
    – l4m2
    Commented 11 hours ago
  • \$\begingroup\$ @l4m2 The answer I have in mind is an expression of the form a** b+c** d. The numbers a,b,c,d are quite small. Would this be a more interesting question, if I added that hint to the description? \$\endgroup\$ Commented 10 hours ago
  • \$\begingroup\$ Then it's interesting but not here, maybe puzzle.SE \$\endgroup\$
    – l4m2
    Commented 9 hours ago
0
\$\begingroup\$

Reduce them to schwa!

(title from the comments on this video)

Challenge

Given a string of printable ASCII characters (0x20 to 0x7E), replace each character in aeiouAEIOU with ə (U+0259). If you cannot print or return the character ə, use uh instead.

Test cases

Input -> Output with schwa / Output with 'uh'
nest -> nəst / nuhst
apple -> əpplə / uhppluh
Ruby -> Rəby / Ruhby
igloo -> əgləə / uhgluhuh
cyclic -> cycləc / cycluhc
quarter -> qəərtər / quhuhrtuhr
rhythm -> rhythm / rhythm
REDUCE THEM TO SCHWA! -> RəDəCə THəM Tə SCHWə! / RuhDuhCuh THuhM Tuh SCHWuh!
CYCLIC -> CYCLəC / CYCLuhC

Other restrictions

Scoring

\$\endgroup\$
3
  • \$\begingroup\$ This is trivial in most languages. s/[aeiou]/ə/ig \$\endgroup\$ Commented Jul 24 at 13:43
  • \$\begingroup\$ I get a 404 from that link. \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ Suggest replacing them to t XD. A slash at end make it 404 \$\endgroup\$
    – l4m2
    Commented 2 days ago
0
\$\begingroup\$

Decide if a string appeared for infinite times in Fizzbuzz without separation 12Fizz4BuzzFizz78FizzBuzz11Fizz1314FizzBuzz....

Input will contain only letters and numbers, aka. match RegEx /^[a-zA-Z0-9]+$/.


Unlike the existing version, this one might be easier, since pattern /\D\d+\D/ is instantly rejected, and there's not many cases with /^\d*\D*\d*$/

\$\endgroup\$
2
\$\begingroup\$

Double dequer sort

\$\endgroup\$
2
  • \$\begingroup\$ Can all arrays be sorted with a finite number of passes? Then perhaps, instead of a decision problem, it would be more interesting to determine the number of passes needed to achieve a sorted array. \$\endgroup\$
    – Jitse
    Commented Jul 22 at 12:40
  • \$\begingroup\$ @Jitse I've done both versions and the decision problem is more interesting for golf. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Jul 22 at 13:24
3
\$\begingroup\$

A robber flipped some bits. This is what happened to the cop's code.

Objective

Cops shall pose a code that outputs a truthy or falsy value deterministically, depending on the input. The output must be truthy on some inputs and falsy on some other inputs.

Flipping exactly half of the bits in the code shall result in negating the output for every input. Robbers shall find such bits.

Winning criterion

For cops, the submission whose the cardinality of all valid inputs is the biggest shall win. The shortness of the code is a tiebreaker. In other words, this is primarily and secondarily . (Note that there may be infinitely many valid inputs, and its cardinality cannot exceed aleph-naught.)

For robbers, the submission whose the maximum number of consecutive flipped bits is the smallest shall win.

Rule

Cops must specify what the valid inputs are.

\$\endgroup\$
6
  • \$\begingroup\$ I think you should elaborate the 'cardinality of valid inputs' scoring criterion better. In Husk, a cop answer could be = increment. All integers are valid inputs (so they are infinite), and only -1 results in falsy output (zero). I don't think there's a single-byte Husk command that would make -1 truthy and everything else falsy, so it seems uncrackable. \$\endgroup\$ Commented Sep 1, 2023 at 12:25
  • 1
    \$\begingroup\$ @DominicvanEssen they way I understood the second sentence of the objective, there has to be a way to crack the program for the submission to be valid \$\endgroup\$
    – bsoelch
    Commented Sep 3, 2023 at 8:31
  • 1
    \$\begingroup\$ @bsoelch - ah, that makes sense… \$\endgroup\$ Commented Sep 3, 2023 at 9:30
  • \$\begingroup\$ Why is higher cardinality better? I would think it would be the opposite. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Sep 3, 2023 at 18:56
  • \$\begingroup\$ @WheatWizard If smaller cardinality were better, cop submissions might take no input, which gives cardinality 1. That's too trivial. \$\endgroup\$ Commented Sep 4, 2023 at 1:17
  • \$\begingroup\$ Isn't trivial better? It makes it harder to disguise things. But if trivial is bad what's to prevent someone from "taking" the input and ignoring it. That makes no real difference to the cop but makes their score in that infinity. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Sep 4, 2023 at 2:10
2
\$\begingroup\$

Wait, ASCII was 128 characters all along?

This question was posted.

\$\endgroup\$
1
  • \$\begingroup\$ I think base 128 works better, since it's less likely to be a built in than base 256 \$\endgroup\$ Commented Jul 16 at 22:33
0
\$\begingroup\$

Three-valued Satisfiability problem

Objective

Given an expression involving ternary values and free variables, decide whether the expression is satisfiable.

The caveat is, the output is a ternary value by itself. So this isn't really a ; it's a problem.

Ternary Values

The three truth values in question are the values of Haskell's Ordering, namely LT, EQ, and GT. They stand for "less-than", "equal-to", and "greater-than", respectively. Furthermore, they themselves have an order; LT is the least, and GT is the greatest.

Operators

The binary operators for the ternary values are Haskell's min, max, compare, and (<>), all instantiated for Ordering. They're defined as:

min|LT EQ GT
---|--------
LT |LT LT LT
EQ |LT EQ EQ
GT |LT EQ GT
max|LT EQ GT
---|--------
LT |LT EQ GT
EQ |EQ EQ GT
GT |GT GT GT
compare|LT EQ GT
-------|--------
  LT   |EQ LT LT
  EQ   |GT EQ LT
  GT   |GT GT EQ
(<>)|LT EQ GT
----|--------
 LT |LT LT LT
 EQ |LT EQ GT
 GT |GT GT GT

Classification

If the free variables have a combination of ternary values that lets the inputted expression evaluate to GT, the output shall be GT.

Otherwise, if the free variables have a combination of ternary values that lets the inputted expression evaluate to EQ, the output shall be EQ.

Otherwise, the output shall be LT.

I/O Format

Flexible. You may represent the values and the operators in an arbitrary way.

Examples

Here, the free variables are V1, V2, V3, and so on.

Input -> Output

EQ `min` V1 -> EQ
V1 `min` V1 -> GT
V1 `min` V2 -> GT
EQ `max` V1 -> GT
V1 `compare` GT -> EQ
V1 `compare` EQ -> GT
LT `compare` V1 -> EQ
EQ <> V1 -> GT
V1 <> LT -> GT
LT <> V1 -> LT
V1 `min` (EQ `compare` V1) -> EQ
V1 `min` (EQ `compare` V2) -> GT
V1 `max` (EQ `compare` V1) -> GT
(LT <> V1) `max` (L1 <> V2) -> LT
(V1 `compare` GT) `compare` (V1 `compare` LT) -> LT
V1 `compare` V1 -> EQ
(V1 `compare` V1) <> LT -> LT
V1 <> V2 <> V3 -> GT
LT `compare` LT -> EQ
EQ -> EQ
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think this is not very different from this, because you can substitute the variables in all possible ways, evaluate them, and take the minimum to get the correct answer, and implementing the evaluator is likely the longest part. \$\endgroup\$
    – Bubbler
    Commented Jul 15 at 23:36
0
\$\begingroup\$

String animations

Heya, I just discovered a fun text animation while sketching up my personal website. It's a scroll-jacking website and as you scroll the text unrandomizes itself. The idea is to present bullet points of information. At the beginning the strings are shuffled and progressively sort themselve as you scroll.

You can see the animation at https://javascript.moe

This perfectly translates into a code golf challenge and your task is to write a function or program which takes as input an array of strings, and an integer for progress.

const animate = (strings: string[], progress: number) => {
    // Compute a partially shuffled string...
}

The function will be called with n strings and a progress between 0 and 1. It shall output a progressively sorted string as the progress increases towards 1.

The logic is as follows:

  1. The first n characters are sorted / partially equal to the input. The rest of the string is sorted semi randomly. - *Where n is floor(length * progress).
  2. If the function is called twice the unsorted part needs to be shuffled again.
  3. When sorting / shuffling the partial string, it shall decrease randomness as progress increases. A progress of 1 means perfectly sorted, a progress of 0 means completely random and a progress of 0.5 means the random position is weighed equally to the sorted position. So, as the progress increases each character gets placed closer to its correct place instead of a completely random place. Depending on the sorting algorithm. It is ok if half of the characters end up at the correct place and half are completely random. Instead of sorting each character closer. The order must change on each call even if the progress doesn't change.

Examples

Input: ['Hello World', 'Goodbye'], 0 Output: 'elodHr llWo'

Input: ['Hello World', 'Goodbye'], 0.25 Output: 'Heodlr lWol'

Input: ['Hello World', 'Goodbye'], 0.75 Output: 'Goobdey'

Input: ['Hello World', 'Goodbye'], 0.8 Output: 'Goodbey'

Input: ['Hello World', 'Goodbye'], 0.9 Output: 'Goodbye'


Tags:

\$\endgroup\$
-1
\$\begingroup\$

Identify RARE Kpop Manifesto's AWK one-liners

RARE Kpop Manifesto is a Code Golf & Code Challenge StackExchange user who is known for an AWK golfer. He or she is famous for posting AWK answers with just variables of underscores, not trying to follow our style of posting, trying to play a game off from us, and advising AWK programming in Stack Overflow for over 1,000 times. Today I brought their 25 AWK codes; oldest one is posted on November 1, 2022 and newest one is on June 22, 2024.

How I brought code

As of July 10, 2024 they had posted 38 answers; I chose one-line AWK codes out of them. If the answer has several AWK codes I took first one.

If the program was

echo 'Hello, World!' |

gawk '{ print $0 }'

then I took

{ print $0 }

as a data. If the program had some assignments or flags, like

echo 1.1b2.2b3.3b4.4 |

mawk -F b 'BEGIN { __ = __^__ }; { for ( _=NF; _--; ORS = ORS ___ ) print $_ * ___; }' ___=`ps -Ao pid,etime,pcpu,vsz | cksum`

then I took

-F b 'BEGIN { __ = __^__ }; { for ( _=NF; _--; ORS = ORS ___ ) print $_ * ___; }' ___=`ps -Ao pid,etime,pcpu,vsz | cksum`

as data. The code may have some escapes because they were intended to be run from shell, but took as-is. E.g.

nawk \$_=RS=ORS

to

\$_=RS=ORS

Challenge

Given an one-line AWK program, identify on which answer post it appears.

Input

One of one-line AWK program shown in the dataset below, as a strings.

Output

An integer to indicate the post id of the answer corresponding to the input. However since every id is greater than 200,000 and less than 300,000, you may output only bottom five digits. E.g. if the answer is 234,567, then you may output 34,567 instead.

Scoring

Number of IDs your program or function answered correctly, which is N/25.

Tie-breaking

Dataset

The format is:

answer-id program

Here are 25 test cases:

253982 function __(_){return index("=anebarprayunulugepctovec",substr(_,2,2))/2}
254001 __=$(_^=___=_<_){++_;do{___+=__%_}while(__=int(__/_))}$!NF=___ ""
254007 -F\[^FU] NF=NF OFS=T
254012 NF+=sub("  ",OFS=" "tolower($2=$4=$1)" ")
255693 '{for(_=NF-2;1<_;_-=3)$_=","$_}NR' FS= OFS=
255694 ($_+=$2)_
255695 /%[dfrs]/
255696 -M 'function __(_){return _*_==_?+$_:$_*__(--_)}($_=__(NF*=!/0/))_' FS=
255709 $_*=$++_++/(_+_--)
256002 gsub("[^"$NF"]",_,$--NF)
256043 'function __(_){return $_=--_?_+=_=__(_):!_}__(NF=$_)' OFS=,
259913 ($_*=$2)_
260775 function ___(_,__) { gsub(".","\\&& ",__)gsub(".",__,_); return _ }$++NF = ___($++_, $++_)
260782 $__=sprintf("%.f",($5-($2$3))/(_+=$_)^!!_)
261246 BEGIN { print (_+=++_)!_!!_ _^_ }
261310 gsub(_,"!")
263592 func __(_){return(-_<_)-(_<-_)}
265230 function leap(_) { return _~"(([2468][048]|[13579][26]|(^|[0+-])[48])(00)?|0000|^[+-]?0*)$" ? "y" : "n" } ($2 = leap($1))^_
269628 '($++NF=(__=$++_)*(_!_)^((__=length(__))-$(_+_)%__)%((_!_)^__-_--))' FS=,
269629 NF=OFS=\$_
272251 $_=int(3E-3^-4)-102
273321 gsub(/./,"&&")_
273407 BEGIN{print$-($_=(_="*****")_)^gsub(/./,RS$_)}
273687 '$_=substr($2,$_,1)' FS=' ?"'
273743 'ORS=RT?length(RT):_' RS=0+

Notes

260775 was originally two-line answer but joined into one line. 265230 was originally three-line answer.

More rules

About source code

https://stackoverflow.com/help/licensing

Content contributed on or after 2018-05-02 (UTC) is distributed under the terms of CC BY-SA 4.0.

Meta

  • To @RareKpopManifesto: can I post this question?
  • Other tag ideas?
\$\endgroup\$
3
\$\begingroup\$

Is it a date format of YYMMDD, MMDDYY, and/or DDMMYY?

The date format varies between countries; the arrangement of date, month and year can be categorized into these three:

  • Year-month-date
  • Month-date-year
  • Date-month-year

In Gregorian calendar it's year of 2024 now (at this point I publish this problem); we often shorten the notation of year by using only bottom two digits: e.g. 24.

Month and date are usually represented as one or two digits.

Today you are having a triple desicion-problem who do something with date format.

Input

One of:

  • A string of six digits
  • An nonnegative integer up to 999999
  • Three nonnegative integers up to 99
  • Six nonnegative integers up to 9

Here is a Python snippet of generator to generate every input as string:

f"{d:06}" for d in range(999999+1)

Attempt This Online!

Output

A tuple of three boolean values whether it can be interpreted as YYMMDD, MMDDYY, and DDMMYY date format. As long as it is consistent, you can have flexible output. Examples but not limited to:

  • a set of data
  • an integer with possibly three bits
  • 0-3 characters of string consists of y, m and/or d to indicate it is truthy for YYMMDD, MMDDYY, and DDMMYY respectively
  • different exception classes

Specification

TLDR: Gregorian Calendar. YY is bottom two digits of the year. Handle leap year as usual. If YYMMDD is 000229 it is optional whether its format is valid or not.

A digit is a character one of 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

The YY format is any combination of two digits.

The MM format is one of 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, or 12.

The DD format varies depending on the YY and MM formats:

  1. if MM is one of 04, 06, 09, or 11, then the format is one of 01, 02, 03, ..., 09, 10, 11, 12, ..., 19, 20, 21, ..., 29, or 30.
  2. if MM is one of 01, 03, 05, 07, 08, 10, or 12 then the format is one of 01, 02, ..., 29, 30 or 31.
  3. if MM is 02 and YY is NOT a multiple of 4, then the format is one of 01, ..., 27, or 28.
  4. if MM is 02 and YY is 00 then the format is one of what rule 3 says or optionally a string of 29.
  5. if MM is 02 and YY is NOT 00 and is a multiple of 4, then the format is what rule 3 says or 29.

The YYMMDD format is a concatenation of the YY, MM and DD formats.

The MMDDYY format is a concatenation of the MM, DD and YY formats.

The DDMMYY format is a concatenation of the DD, MM and YY formats.

Test cases

In the following table, maybe means it is implementation-defined to output whether the value is truthy or falsey.

Input   YYMMDD MMDDYY DDMMYY
000000  false  false  false
000001  false  false  false
000099  false  false  false
000100  false  false  false
000101  true   false  false
000102  true   false  false
000131  true   false  false
000132  false  false  false
000199  false  false  false
000200  false  false  false
000201  true   false  false
000228  true   false  false
000229  maybe  false  false
000230  false  false  false
000300  false  false  false
000301  true   false  false
000331  true   false  false
000332  false  false  false
001130  true   false  false
001231  true   false  false
001232  false  false  false
010000  false  false  false
010001  false  false  false
010099  false  false  false
010100  false  true   true
010101  true   true   true
010102  true   true   true
010131  true   true   true
010132  false  true   true
010199  false  true   true
010200  false  true   true
010201  true   true   true
010228  true   true   true
010229  false  true   true
010300  false  true   true
010301  true   true   true
010331  true   true   true
010332  false  true   true
010430  true   true   true
010431  false  true   true
010531  true   true   true
010532  false  true   true
011231  true   true   true
011232  false  true   true
011299  false  true   true
011300  false  true   false
011399  false  true   false
011400  false  true   false
013199  false  true   false
013200  false  false  false
014567  false  false  false
019999  false  false  false
020000  false  false  false
020001  false  false  false
020099  false  false  false
020100  false  true   true
020101  true   true   true
020102  true   true   true
020128  true   true   true
020131  true   true   true
020132  false  true   true
020199  false  true   true
020200  false  true   true
020201  true   true   true
121212  true   true   true
121213  true   true   true
121230  true   true   true
121231  true   true   true
121232  false  true   true
121299  false  true   true
121300  false  true   false
121301  false  true   false
121399  false  true   false
121400  false  true   false
123100  false  true   false
123199  false  true   false
123200  false  false  false
129999  false  false  false
130000  false  false  false
130099  false  false  false
130100  false  false  true
990101  true   false  false
990202  true   false  false
991230  true   false  false
991231  true   false  false
991232  false  false  false
991233  false  false  false
999999  false  false  false

Every case truthy for all of YYMMDD, MMDDYY, and DDMMYY

Too long; pasted on GitHub Gists.

Test case generator

inputrange = list(range(200, 231)) + list(range(0, 1000000, 2763))

yymmdds, mmddyys, ddmmyys = [], [], []
maybey, maybem, maybed = [], [], []
for y in range(99+1):
  for m in range(1,12+1):
    if m == 2:
      dlast = 28 + (y%4==0)
    else:
      dlast = 31 - (m in [4,6,9,11])
    for d in range(1,dlast+1):
      yy, mm, dd = f"{y:02} {m:02} {d:02}".split(" ")
      ys, ms, ds=yy+mm+dd, mm+dd+yy, dd+mm+yy
      if (y,m,d) == (0,2,29):
        [maybel.append(s)for (maybel,s)in [[maybey,ys],[maybem,ms],[maybed,ds]]]
        continue
      yymmdds.append(ys)
      mmddyys.append(ms)
      ddmmyys.append(ds)

for x in [f"{x:06}" for x in inputrange]:
  y, m, d = ["maybe" if x in maybel else x in l for (maybel,l) in ((maybey,yymmdds),(maybem,mmddyys),(maybed,ddmmyys))]
  print(x, y, m, d)

Try it online!

Rules

See also

Challenges involving possibly ambiguous date format:

Meta

  • Is my specs adequant?
  • When I tried generating every test case (100K cases) to find it not realistic for my computer's ability; I need to enumerate every boundary test if possible.
  • More input formats; good idea for golfers?
\$\endgroup\$
1
0
\$\begingroup\$

Imagine a language that supports <> as brace and also as compare.

To avoid confusion like a<b>(c), <(less than) and >(greater than) are not allowed on same layer. a<b<c is still allowed, though. <> can't directly contain &, so a<b&c>(d) would be treated as lt and gt. Use a<(b&c)>(d) to mean the other.

Given an expression with lowercase letters and <>()+&, decide if it's valid.

Exact definition of valid is expr2 following:

expr1 = [a-z]* | +expr1 | expr1+expr1 | (expr2)
      | expr1<expr1> | expr1(expr2)
expr2a = expr1 | expr1 < expr2a
expr2b = expr1 | expr1 > expr2b
expr2 = expr2a | expr2b | expr2a & expr2 | expr2b & expr2

Test cases:

a<b>(c)      true
a<b<(c)      true
a<b<c        true
a<b>c        false
a<b&c>d      true
a<(b&c)>d    false
a>b<(c)      false
\$\endgroup\$
1
3
\$\begingroup\$

Sorting with a deque

\$\endgroup\$
0
\$\begingroup\$

When is My Holiday?

Background

I recently learned of a holiday, that occurred on August 20, 2023 and August 12, 2022. This got me wondering how on earth they were determining which day this holiday falls on.

The Challenge

In this challenge you will be given two dates which are from the same month but different years as input. You must construct the simplest possible description which applies to both dates.

Descriptions must be structured in a particular way. First, there are types of days

type cost
day 1
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday 1
weekday, weekend day 1
day which is a multiple of \$N\$ \$N\$

For the following we'll let \$D\$ be some type of day. We then have modifiers and constants.

modifier constant
the nth \$D\$ after the nth \$D\$
the nth \$D\$ before the nth to last \$D\$
the nearest \$D\$ to

A valid description consists of 0 or more modifiers followed by a single constant. The simplest description is the one with the lowest cost, which is the sum of the cost of each \$D\$ which appears in the description.

For the purposes of this challenge we define "nearest" to mean "nearer than all others" so if there is a tie, then neither day is nearest and the description is not valid. "Nearest" may include the day itself. "Before" and "after" do not include the day itself.

I/O

Standard I/O rules apply, the dates may be taken in any reasonable format. And since the challenge is not about supposed to be about date calculation you may choose to take in data about the month surrounding each day. Some examples of valid input formatting are as follows. A program would take two such inputs.

2023-08-22

8/22/23

22.8.23

[[xx, xx, 01, 02, 03, 04, 05]
 [06, 07, 08, 09, 10, 11, 12]
 [13, 14, 15, 16, 17, 18, 19]
 [20, 21, 22, 23, 24, 25, 26]
 [27, 28, 29, 30, 31, xx, xx]], 
[3, 2]

You may assume any input given will have a solution. Your description need not apply to all years, just the ones in the input (eg. August 2023 has no 5th monday, but "the 5th monday" is still correct for 2021-08-30, 2022-08-29). If two or more descriptions tie you may output any or all.

For output I'm going to be fairly lenient. You may choose your own encoding scheme to represent possible outputs. The most basic way to represent the output would just be to output the elements as seen in the tables above separated by spaces. But for golfing purposes you'll likely want to encode the outputs into some sequence which represents these elements. An example of what an encoding may look like is seen below.

element encoding
day wa
Monday wm
Tuesday wt
Wednesday ww
Thursday wh
Friday wf
Saturday ws
Sunday wu
weekday wd
weekend day we
day which is a multiple of \$N\$ w\$N\$
the nth \$D\$ after An\$D\$
the nth \$D\$ before Bn\$D\$
the nearest \$D\$ to Cn\$D\$
the nth \$D\$ Tn\$D\$
the nth to last \$D\$ Ln\$D\$
T4wa -> the 4th day
T5wm -> the 5th monday
B1w4T3wm -> the 1st day which is a multiple of 4 before the 3rd Monday

This is just an example, and you may design your own encoding scheme as long as it has a unique representation for all posiible outputs and it is at least halfway sensical. Please provide a description for your encoding scheme, and bonus points if you include a supplementary script to convert your ouput to the written out description.

Test Cases

These test cases follow the YYYY-MM-DD input format

2022-07-04, 2023-07-04 -> the 4th day
2021-08-30, 2022-08-29 -> the 5th monday
2022-08-12, 2023-08-20 -> the 1st day which is a multiple of 4 before the 3rd Monday


How clear is this?

I still plan to add more test cases.

\$\endgroup\$
0
\$\begingroup\$

Given array X, decide if there is real number x, s.t. X[i]=floor(x*i).

True cases: (1-index)

[1,2,3,4,5]
[1,2,3,5,6]
[0,0,0,1,1]
[1,3,5]

False cases:

[1,3,5,8]
[3,5]

Duplicate?

\$\endgroup\$
1
\$\begingroup\$

Draw a Regular Reuleaux Polygon

\$\endgroup\$
0
\$\begingroup\$

o y u

\$\endgroup\$
0
\$\begingroup\$

Is this a Hadamard matrix?

\$\endgroup\$
1
\$\begingroup\$

Automatic Pikmin Count

Inspired by the feature in Pikmin 4.

In Pikmin 4, you can have up to eight types of pikmin in an onion and up to three types of pikmin outside the onion. Each area recommends three types of pikmin to bring. The onion's interface has an "auto" button which selects pikmin in the following fashion:

  • If possible, select equal amounts of each suggested pikmin type.
  • If there aren't enough of one type, get all of them and equal amounts of the rest (e.g. if 30, 30, 30 isn't possible, it may do 20, 35, 35).
  • If there aren't enough of all the suggested types combined, grab everything there is.
  • If the number of pikmin to select isn't a multiple of three, it grabs more of the kind you have most of (e.g. if the number of pikmin of each type is 300, 200, 100 and it needs to select 100 pikmin, it selects 34, 33, 33)
  • ...unless there's a tie (e.g. if the pikmin counts are 200, 200, 100 and it needs to grab 100 pikmin, it selects 33, 33, 34).
  • If a tie needs to be broken arbitrarily (e.g. a three-way tie), select up to 1 more of the first tied type listed.

The challenge is to write a function or program that takes three inputs: the number of pikmin that can be brought out (an integer in \$\left[0, 100\right]\$), the number of pikmin of each type (eight positive integers), and the recommended pikmin types (three indices into the previous array). You can take the pikmin types as 0- or 1-based indices, and you may assume they are sorted. It should then return an array of eight numbers indicating how many pikmin of each type are to be selected, which will always have at least five 0's. This is , so your score is your answer's length.

Test cases

Using 0-based indices

# to select; counts; indices => selections

100; [400, 450, 300, 250, 100, 30, 0, 10]; [0, 1, 2] => [33, 34, 33, 0, 0, 0, 0, 0]
100; [400, 450, 300, 250, 100, 30, 0, 10]; [3, 4, 5] => [0, 0, 0, 35, 35, 30, 0, 0]
37; [30, 30, 10, 20, 100, 5, 1, 100]; [0, 1, 3] => [12, 12, 0, 13, 0, 0, 0, 0]
38; [30, 30, 10, 20, 100, 5, 1, 100]; [0, 1, 3] => [13, 13, 0, 12, 0, 0, 0, 0]
38; [30, 30, 10, 20, 100, 5, 1, 100]; [0, 1, 2] => [14, 14, 10, 0, 0, 0, 0, 0]
39; [30, 30, 10, 20, 100, 5, 1, 100]; [0, 2, 3] => [15, 0, 10, 14, 0, 0, 0, 0]
39; [30, 30, 10, 20, 100, 5, 1, 100]; [0, 1, 2] => [15, 14, 10, 0, 0, 0, 0, 0]
37; [30, 30, 10, 20, 100, 5, 1, 100]; [2, 6, 7] => [0, 0, 10, 0, 0, 0, 1, 26]
0; [400, 450, 300, 250, 100, 30, 0, 10]; [5, 6, 7] => [0, 0, 0, 0, 0, 0, 0, 0]
20; [400, 450, 300, 250, 100, 30, 0, 10]; [5, 6, 7] => [0, 0, 0, 0, 0, 10, 0, 10]
100; [10, 10, 10, 10, 10, 10, 10, 10]; [1, 2, 3] => [0, 10, 10, 10, 0, 0, 0, 0]

Sandbox questions

  • Besides , what else should this be tagged?
  • I feel like the wording is terrible and I would appreciate help cleaning up the specification and examples
  • Are there any edge cases I missed?
  • What should be the requirements for range for the total pikmin counts? In theory it can be up to 9999 of each type, but practically I don't think I've ever exceeded 500 or 600. Not that this matters for most languages, but I think it's best to be explicit.
\$\endgroup\$
1
\$\begingroup\$

The Winner of a Trick in Zole

The Challenge

Write a function that determines the winner of a single trick in the Zole card game.

Background

The idea for this challenge was suggested by a guy from one chat, who noticed my highly golfed code for this specific task. Initially, I wanted to write a highly optimized code for the task, getting rid of branches and stuff like that wherever I could. At the end, I wrote a proof-of-concept of a code in JS (with the aim to rewrite it later in C and make it truly branchless), and then, just for fun, I golfed the JS code as much as I could. I ended up writing a JS function which is 122 characters long (I'll submit my solution once the challenge is posted). It was a fun challenge for me, hopefully you'll like it as well.

A Short Intro into Zole

For those unfamiliar with Zole, a quick intro into the rules that are necessary for the task - the rules that determine the winner of a single trick. If you are interested, you can find the rest of the rules online, but they are not needed for a challenge.

Zole is a traditional Latvian card game, derived from the family of Schafkopf card games. The exact origins of Zole are unknown. This card game is highly popular in Latvia but is mostly unknown elsewhere.

Zole is played using 26 cards - 14 trumps and 12 non-trumps. The deck includes all Aces, Kings, Queens, Jacks, Tens, Nines, Diamond Eight and Diamond Seven. All Queens, Jacks and Diamonds are trumps, other cards are non-trumps. Each trick in played with each of three players playing one card, one player after another. Meaning, each trick consists of three cards, and the order of the cards in the trick is important. The winner of each trick is determined once all three cards are on the table.

The Rules

The rules of determining the winner are following:

  1. If there is at least one trump in a trick, the strongest trump in the trick wins. This case is the simplest because in Zole, all trumps have different strength, or there's no two trumps of equal strength. Trumps ordered by strength (lowest to highest) are:

7♦, 8♦, 9♦, K♦, 10♦, A♦, J♦, J♥, J♠, J♣, Q♦, Q♥, Q♠, Q♣

Yes, the ten is stronger than the king, and jacks and queens are stronger than the ace. Any trump is stronger than any non-trump. The queen of clubs is the strongest card in the game, and takes any trick it is in.

In case when there's at least one trump, the order of the cards plays no role to determine the winner. The strongest trump wins, the end.

Examples:

  • 10♦, Q♦, K♣ - The king of clubs is not a trump, and the queen is stronger than the ten, the queen wins.
  • 9♥, A♥, 7♦ - the seven is the only trump in a trick, it wins.
  • J♠, J♣, A♠ - The jack of clubs is stronger than the jack of spades, and the ace of spades is not a trump, the jack of clubs wins.
  1. When there's no trump in a trick, then the suit of a winning card (sometimes called the requested suit) is determined by the first played card in this trick. Cards by strength (lowest to highest) are: 9, K, 10, A (again, the ten is stronger than the king). The strongest card of a requested suit wins. All cards in a trick that are not trumps and are of another suit play no role in determining the winner.

Examples (note that there are no trumps in these cases):

  • 10♥, K♠, 10♣ - Requested suit is hearts, no one added other heart, so the first card (the ten of hearts) wins.
  • 9♠, 10♥, A♠ - Requested suit is spades, the ace of spades is stronger than the nine of spades, the ten is out of suit and plays no role, the ace of spades wins.
  • K♣, 9♣, 10♣ - Requested suit is clubs, the ten is stronger than the nine or the king, the ten wins.

If you understood these rules then it should be clear that there can be no case when the winner is not determined. Your goal is to write a function that gets three parameters (three random cards from 26-card Zole deck) and returns the number of a card that wins the trick (0, 1 or 2).

A Few Test Cases

 K♠  Q♥  Q♦ The winner is 1 ( Q♥)
 K♥  K♦  8♦ The winner is 1 ( K♦)
 K♠  A♣  9♠ The winner is 0 ( K♠)
10♠  9♠  A♦ The winner is 2 ( A♦)
 9♣ 10♣  A♠ The winner is 1 (10♣)
 Q♦  9♦ 10♠ The winner is 0 ( Q♦)
 Q♠  Q♥  J♠ The winner is 0 ( Q♠)
 8♦  A♦  J♣ The winner is 2 ( J♣)
 9♥  A♠ 10♠ The winner is 0 ( 9♥)

Additional Info

For the sake of simplicity, let's assume that the first argument of your function is the first played card in the trick, the second argument is the second card etc. Let's also ignore all the rules regarding who should go first, what cards are allowed to play etc. What we need to know is that any combination of three cards from 26-card Zole deck is theoretically possible in a game (some are just less probable, but we ignore the probability). So, the sought-for function shouldn't follow the whole game, but should simply process one single trick. Or, in our case, three random cards.

You can choose how to define the data type for cards (simple integer, character, object, structure etc). You can be creative in defining cards as integers or similar types. Add the description of your data type in the comment.

Your code need not include the output function - just return 0, 1 or 2. Your code can also ignore the validation and sanitization of the data, let's assume that the data is correct (famous last words), and the input contains three different, valid cards.

\$\endgroup\$
1
\$\begingroup\$

Is it an option for the ls utility specified in POSIX.1-2017?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I don't think it's relevant to add a bonus related to XSI; bonuses are frowned upon, and it doesn't significantly change the problem. i'm not sure if a new challenge would be that different either, but maybe you can spin it in a materially different challenge. \$\endgroup\$ Commented Jun 27 at 7:39
  • 1
    \$\begingroup\$ d appears twice in the string provided in the output section. \$\endgroup\$
    – Arnauld
    Commented Jun 28 at 8:29
0
\$\begingroup\$

Given some conditions with form %th of [A%, A%, A%] is %, decide if it's possible.

Test case 1: (Here 1st mean smallest)

1st of [A1, A2, A3] is 1
1st of [A2, A3] is 2
2nd of [A1, A3] is 3
=> true (A1=1, A2=2, A3=3)

Test case 2:

1st of [A1, A2, A3] is 1
2nd of [A2, A3] is 2
3rd of [A1, A2, A3] is 3
-> true (A1=3, A2=2, A3=1)

Test case 3:

1st of [A1, A2] is 1
1st of [A2, A3] is 2
1st of [A1, A2, A3] is 3
-> false

Test case 4:

1st of [A1, A2] is 1
2nd of [A2, A3] is 3
3rd of [A1, A2, A3] is 3
-> true (A1=1, A2=1 to 3, A3=3)

\$\endgroup\$
0
\$\begingroup\$

Given an array A={0,1,2,3,4,5,6,7}. Each time, you can swap two values or copy one value to another. Given another array, find the minimum steps to convert A into the given array. You can assume it's possible.

Test cases:

0,1,2,3,4,5,6,7 => 0 ()
1,0,2,3,4,5,6,7 => 1 (s01)
1,1,2,3,4,5,6,7 => 1 (m01)
1,2,2,3,4,5,6,7 => 2 (m01 m12)
1,2,0,3,4,5,6,7 => 2 (s01 s12)

Shortest code wins

Sandbox Notes:

  • Need output the solution?
\$\endgroup\$
0
\$\begingroup\$

Detect revokes in Jass

\$\endgroup\$
2
\$\begingroup\$

Plot the ground path of a satellite

\$\endgroup\$
0
\$\begingroup\$

Vo we l spa ci ng

To da y yo u a re ha vi ng a si lly pro ble m.

To da  y   yo    u     a      re       ha        vi         ng          a           si            lly             pro              ble               m.

Challenge

Given an English text, apply "vo wel spa ci
ng" (see below).

Input

One line of string with these constraints:

  • Consist of alphabet with both cases, space, comma and period.
  • At least 1 letter and at most (at your choice) 15, 16, 31, 32 or 50 letters.
  • Match /^([A-Za-z]+[.,]? )*[A-Za-z]+[.,]?$/ in POSIX ERE; in English, it's a list of space-separated words with just alphabets but no punctuation; some words may contain a punctuation of either a full stop or a comma but not both. No leading spaces, no trailing spaces, separated with exactly one space.

Output

Result of "vo wel spa ci ng". Your output may have trailing spaces but no leading spaces.

"Vo we l spa ci ng" specification

The "Vo we l spa ci ng" is an algorithm who takes a string of input to return a string of output. The procedure is:

  1. For each vowel that is not the last letter of its word, append a space.
  2. For each space (let it N-th space. 1-indexed), replace it with N spaces.
  3. The implementation of this algorithm may append some spaces to the end of the string.
  4. Return the final string.

In the procedure above,

  • A vowel is a letter that is one of the following ten letter: AEIOUaeiou.
  • A word is a consequence concatenation of one or more alphabets but nothing else: e.g. "word", "WORD", "wOrD", "w", "o", "r", or "d" but not "word,", "word.", or "w o r d"
  • The last letter of the word is: (a) if it has only a letter, then the letter is the last letter of the word. (b) Otherwise (i.e. it has two or more letters), the last letter of the word without first letter is the last letter of the word. E.g. "word" => "d", "A" => "A".
  • A space is an ASCII character with code point of 0x20 or equivalent in other encoding system.

Test cases

The format is:

Input
=> Output

Here are test cases. Very wide:

Input
=> In pu  t

Output
=> O u  tpu   t

Test cases
=> Te st  ca   se    s

Hello, world.
=> He llo,  wo   rld.

Vowel Spacing
=> Vo we  l   Spa    ci     ng

Today you are having a silly problem.
=> To da  y   yo    u     a      re       ha        vi         ng          a           si            lly             pro              ble               m.

Code Golf and Code Challenge StackExchange
=> Co de  Go   lf    a     nd      Co       de        Cha         lle          nge           Sta            ckE             xcha              nge

AAAAAAAAAAAAAAAAAAAAA
=> A A  A   A    A     A      A       A        A         A          A           A            A             A              A               A                A                 A                  A                   A                    A

BBBBBBBBBBBBBBBBBBBBBB
=> BBBBBBBBBBBBBBBBBBBBBB

QwErTyUiOp AsDfGhJkL zXcVbNm
=> QwE rTyU  i   O    p     A      sDfGhJkL       zXcVbNm

qWeRtYuIoP aSdFgHjKl ZxCvBnM
=> qWe RtYu  I   o    P     a      SdFgHjKl       ZxCvBnM

Given an English text,
=> Gi ve  n   a    n     E      ngli       sh        te         xt,

apply vo we l spa ci ng.
=> a pply  vo   we    l     spa      ci       ng.

rhythm
=> rhythm

FORTRAN LISP COBOL ALGOL
=> FO RTRA  N   LI    SP     CO      BO       L        A         LGO          L

This is code golf. Shortest code wins.
=> Thi s  i   s    co     de      go       lf.        Sho         rte          st           co            de             wi              ns.

I
=> I

am here to, kick out, leading spaces.
=> a m  he   re    to,     ki      ck       o        u         t,          le           a            di             ng              spa               ce                s.

Rules

See also

Meta

  • Does title get rendered as monospace?
\$\endgroup\$
1
2 3 4 5
158

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .