title: Kolmogorov-simple numbers

text:
# Question
Title: Kolmogorov-simple numbers
If you visit Code Golf often, you may have heard of Kolmogorov complexity. It's usually defined as the amount of bytes required to express some string in a programming language.

Here the Kolmogorov-complexity of a natural number is defined similarly: the number of bytes required to represent it in a programming language.

A number is Kolmogorov-simple if it's **more** space-efficient to represent it with the programming language, then with simply storing it in binary (base-256). In other words, if \\$b\\$ is the Kolmogorov-complexity of a number \\$n\\$, \\$n\\$ is Kolmogorov-simple iff \\$b\lt\log\_{256}(n+1)\\$. Every Turing-complete language has infinitely many Kolmogorov-simple numbers.

Your task is to find the smallest Kolmogorov-simple number. In other words, output the smallest number \\$n\\$ in \\$b\\$ bytes, such that \\$b\<\log\_{256}(n+1)\\$.

## Rules

* If you express the number \\$n\\$, your program has to be at most \\$\lceil \log\_{256}(n+1)\rceil-1\\$ bytes long.
* The number has to be a positive whole number
* Use a **reasonable** IO format. These *may* include: printing to stdout, expressions, functions, storing the number to a variable, pushing the number to stack or taking a number as input and comparing it the represented number. Try to stick to the convention. Floating point numbers, complex numbers and fractions are allowed, as long as it's **exactly** an integer.
* If you use a text-based format, your output should match this regex: `((\d+(\.\d*)?)|(\d*\.\d+))(e[+-]?\d+)?`. That is, it should be a decimal number. Trailing newlines etc. are allowed.

Smallest number outputted (i.e. the value \\$n\\$) per language wins!

# Answer
# Retina, 0 bytes, outputs `1`

Try it online!

Outputs `1`, and \\$\log\_{256} 2 = 0.125 \> 0\\$
> 10 votes

# Answer
# Jelly, 1 byte, outputs `256`

Try it online!

This outputs `256` in one byte, and \\$\log\_{256} (257) \approx 1.0007 \> 1\\$
> 7 votes

# Answer
# (& likely polyglot), 3 bytes, outputs 16777216 = 256\\$^3\\$

```
8^8

```

Try it online!
> 6 votes

# Answer
# 1+, 20 bytes, outputs \\$2^{160}\\$

*Reduced from \\$2^{2^8}\\$ due to @null*

```
11+"*"*"+"*"*"*"*"*:

```

Try it online!

The fastest way to get big numbers in 1+ (of which I am its creator) is to repeatedly square. \\$\lceil\log\_{256}(2^{160}+1)\rceil-1=20\\$.
> 4 votes

# Answer
## Batch, 38 bytes, outputs ≈2³⁰⁴

```
@for /l %%a in (1,1,92)do @cmd/cset/a3

```

`log₂₅₆(33...33) ≈ 38.004`
> 3 votes

# Answer
# brainfuck, 24 bytes, outputs (1063-1)/3

```
+[+++++>+<]++++[++++>.<]

```

Try it online!

This creates 51, the ASCII value of `3`, as 255/5, and then outputs it 63=252/4 times.

`+[+++++>+>+<<]>[->.<]` falls just short of working: in 21 bytes, it outputs `3` 51 times for ≈3.33×1050, while 25621≈3.74×1050.
> 3 votes

# Answer
# Vyxal `H`, 0 bytes

```

```

The `H` flag pre-sets the stack to 100.

$$log\_{256}\\;101 = 0.83227643534397 \> 0$$

Try it Online!

For a program without flags, you can use  to output 256, similar to caird coinheringaahing's Jelly answer.
> 3 votes

# Answer
# JavaScript (ES7), 8 bytes, `27368747340080914432`

(displayed as `27368747340080914000`)

```
_=>7**23

```

Try it online!

The actual value of \\$7^{23}\\$ is \\$27368747340080916343\\$ but we get \\$27368747340080914432\\$ because of IEEE-754 loss of precision.

We have \\$\log\_{256}(27368747340080914432+1)\approx 8.07\\$
> 2 votes

# Answer
# BQN, 3 bytes, outputs `16777216`

```
8⋆8

```

Run online!

$$\log\_{256}\left(8^8+1\right) \> \log\_{256}\left(8^8\right) = 3$$
> 2 votes

# Answer
# Husk, 2 bytes, outputs 9! = 362880 = 256^2.3

```
Π9

```

Try it online!
> 2 votes

# Answer
# x86-64 machine code, 7 bytes, outputs \\$2^{56}\\$

```
6A 01 58 48 0F C8 C3

```

Try it online!

Returns a value in RAX, as is standard.

In assembly:

```
.global f
f:  push 1      # (2 bytes) Push 1 onto the stack.
    pop rax     # (1 byte)  Pop it out into RAX.
    bswap rax   # (3 bytes) Reverse the order of the bytes in RAX.
    ret         # (1 byte)  Return.

```
> 2 votes

# Answer
# Stax, 3 bytes, outputs `100000000`

```
8|A

```

Run and debug it

$$\left \lceil{\log\_{256}\left(10^8+1\right)}\right\rceil - 1= 3$$
> 2 votes

# Answer
# Python 2, 11 bytes, outputs `5704427701027032306735164424192`

```
print 9<<99

```

Try it online!

$$\log\_{256}(5704427701027032306735164424192+1)-1 = 11.77$$
> 1 votes

# Answer
# Charcoal, 3 bytes, outputs `22222222`.

```
×⁸2

```

Try it online! Link is to verbose version of code. `log₂₅₆(22222222) ≈ 3.05` Explanation: Charcoal only prints strings by default, so something like `φ` (`Print(f);`) prints 1000 `-`s instead of `1000`; casting to string costs a byte, meaning we now need a value of at least `65536`, however no predefined variable now holds a suitable value. This means we now need to look for a 3-byte answer that prints at least `16777216`, which can most easily be achieved in a number of ways by repeating the character `2`.
> 1 votes

# Answer
# Python 3, 13 bytes, outputs `20282409603651670423947251286016`

```
print(16**26)

```

Try it online!

From what I can understand, this is the *absolute minimum* for a 13 byte program - it prints 256\**13, the minimum number that needs 13 bytes to store. Good luck getting anything below this in Python 3.

Bonuses I found:

```
print(18**25) # 19% bigger than the actual answer

```

```
print(27**22) # 52% bigger than the actual answer

```

```
print(15**27) # 2.8x as big as the actual answer

```
> 1 votes

# Answer
# GolfScript, 5 bytes, outputs 2565 = 420 = `1099511627776`

```
4 20?

```

Try it online!
> 1 votes

# Answer
# Python 3, 12 bytes, outputs `79228162514264337593543950336`

```
print(4**48)

```

Inspired by this answer.

Explanation:

```
4**48 == 16**24 == 256**12

```

Try it online!
> 1 votes

# Answer
# Ruby, 7 bytes, outputs `150094635296999121`

```
p 3**36

```

Similar to other answers, uses `p` to debug print the number. Fortunately for numbers the debug print value is the same as the normal output would be.

$$\left \lceil{\log\_{256}\left(3^{36}+1\right)}\right\rceil - 1= 7$$
> 0 votes

# Answer
# Excel, 5 bytes, outputs `1,09951E+21` ≈ 240 = 2565

```
=2^40

```
> 0 votes

# Answer
# APL, 2 bytes

```
!9

```

The program prints factorial of 9 = 362880. Validation of allowed length:

```
      1-⍨⌈256⍟1+!9
2

```
> 0 votes

---
Tags: number, code-challenge, kolmogorov-complexity, open-ended-function
---


title: Counting Fountains

text:
# Question
Title: Counting Fountains
A fountain is arrangement of coins in rows so that each coin touches two coins in the row below it, or is in the bottom row, and the bottom row is connected. Here's a 21 coin fountain:

---

Your challenge is to count how many different fountains can be made with a given number of coins.

You will be given as input a positive integer `n`. You must output the number of different `n`-coin fountains that exist.

Standard I/O rules, standard loopholes banned. Solutions should be able to calculate `n = 10` in under a minute.

---

Desired output for `n = 1 ... 10`:

```
1, 1, 2, 3, 5, 9, 15, 26, 45, 78

```

This sequence is OEIS A005169.

---

This is code golf. Fewest bytes wins.

# Answer
> 4 votes
## Python, 57 bytes

```
f=lambda n,i=0:sum(f(n-j,j)for j in range(1,i+2)[:n])or 1

```

As observed on OEIS, if you shift each row half a step relative to the row below it, the column sizes form a sequence of positive integers with a maximum upward step of 1.

The function `f(n,i)` counts the sequences with sum `n` and last number `i`. These can be recursively summed for each choice of the next column size from `1` to `i+1`, which is `range(1,i+2)`. Truncating to `range(1,i+2)[:n]` prevents columns from using more coins than remain, avoiding needing to say that negative `n`'s give `0`. Moreover, it avoids an explicit base case, since the empty sum is `0` and doesn't recurse, but `f(0)` needs to be set to `1` instead, for which `or 1` suffices (as would `+0**n`).

# Answer
> 5 votes
# Mathematica, 59 bytes

```
SeriesCoefficient[1-Fold[1-x^#2/#&,Range[#,0,-1]],{x,0,#}]&

```

Based on the Mathematica program on OEIS by Jean-François Alcover.

# Answer
> 3 votes
# Haskell, ~~60~~ 48 bytes

Thanks to @nimi for providing a way shorter solution!

```
n#p|p>n=0|p<n=sum$map((n-p)#)[1..p+1]|1<2=1
(#1)

```

Old version.

```
t n p|p>n=0|p==n=1|p<n=sum[t (n-q) q|q<-[1..p+1]]
s n=t n 1

```

The function calculating the value is `s`, implementation of the recursive formula found here: https://oeis.org/A005169

# Answer
> 3 votes
# Pyth, ~~21~~ 20 bytes

```
Ms?>GHgL-GHShHqGHgQ1

```

Try it online. Test suite.

This is a direct implementation of the recursive formula on the OEIS page, like the Matlab answer.

# Answer
> 3 votes
## Haskell, 43 bytes

```
n%i=sum[(n-j)%j|j<-take n[1..i+1]]+0^n
(%0)

```

See Python answer for explanation.

Same length with `min` rather than `take`:

```
n%i=sum[(n-j)%j|j<-[1..min(i+1)n]]+0^n
(%0)

```

# Answer
> 1 votes
# Matlab, ~~115~~ 105 bytes

```
function F=t(n,varargin);p=1;if nargin>1;p=varargin{1};end;F=p==n;if p<n;for q=1:p+1;F=F+t(n-p,q);end;end

```

Implementation of the recursive formula found here: https://oeis.org/A005169

```
function F=t(n,varargin);
p=1;
if nargin>1
    p=varargin{1};
end;
F=p==n;
if p<n;
    for q=1:p+1;
        F=F+t(n-p,q);
    end;
end;

```

# Answer
> 1 votes
# Julia, ~~44~~ 43 bytes

```
f(a,b=1)=a>b?sum(i->f(a-b,i),1:b+1):1(a==b)

```

This uses recursive formula on OEIS.

Explanation

```
function f(a, b=1)
    if a > b
        # Sum of recursing
        sum(i -> f(a-b, i), 1:b+1)
    else
        # Convert bool to integer
        1 * (a == b)
    end
end

```

Has anyone else noticed that strike through 44 is regular 44??

# Answer
> 0 votes
# Python 3, 88 bytes

```
f=lambda n,p:sum([f(n-p,q)for q in range(1,p+2)])if p<n else int(p==n)
t=lambda n:f(n,1)

```

# Answer
> 0 votes
# JavaScript (ES6), 63

Implementing the recursive formula at OEIS page

```
F=(n,p=1,t=0,q=0)=>p<n?eval("for(;q++<=p;)t+=F(n-p,q)"):p>n?0:1

```

# Answer
> 0 votes
# APL, 26 bytes

```
{⍵≥⍺:⍵=⍺⋄+/(⍺-⍵)∘∇¨⍳⍵+1}∘1

```

Straightforward implementation of the first formula from the sequence explanation page. Honestly, I didn't understand anything, so let's check the results:

```
      {⍵≥⍺:⍵=⍺⋄+/(⍺-⍵)∘∇¨⍳⍵+1}∘1¨⍳10
1 1 2 3 5 9 15 26 45 78

```

---
Tags: code-golf, sequence, combinatorics, restricted-time
---


title: This Challenge Makes Cents

text:
# Question
Title: This Challenge Makes Cents
I know, the title cracks you up

---

Given an amount of money, output the fewest number of **coins** that make up that amount.

## Examples

```
0.1
1 dime

0.01
1 penny

0.28
1 quarter 3 penny

0.56
2 quarter 1 nickel 1 penny

1.43
5 quarter 1 dime 1 nickel 3 penny

```

## Spec

* 100 cents in a dollar.
* The values of each type of coin is:
    + `penny` 1 cent
    + `nickel` 5 cents
    + `dime` 10 cents
    + `quarter` 25 cents

Built-ins which trivialize this task are not allowed.

## I/O

Input is a decimal representing the dollar value of the total

* No need to pluralize
* Order: `quarter` -\> `penny`
* Output should be `<#_of_coins> <coin type>`
* Separators: `,` or `,` (comma and a space) or

The only trailing whitespace allowed is a single trailing newline/space.

---

**If there is zero of a coin type, that coin type should not be shown**. E.g. `0.25` -\> `1 quarter` **not** `1 quarter 0 dime 0 nickel 0 penny`

# Answer
> 6 votes
# CJam, 60

```
q~e2i[25A5]{md}/]" quarterx dimex nickelx penny"'x/.+{0#},S*

```

This script seems to have alot of room for improvement but this is shorter than any so far. This makes use of the built in "md" command which returns both the integer result of a division and the remainder. It does the following:

* reads input (if it were a function I guess you can remove q~ for two less characters)
* multiples the input by 100 and converts it to an integer
* performs "md" using \[25 10 5\] which results in the remainders on the stack
* combines the numbers and coin names
* removes the number and coin name if the former is 0
* adds pre-number zeros

Try it here

prior versions:

```
q~e2i[25A5]{md}/]_:!:!" quarter x dime x nickel x penny"'x/.*.+e_0-
q~e2i[25A5]{md}/]_:!:!\" quarter x dime x nickel x penny"'x/.+.*

```

# Answer
> 13 votes
# JavaScript ES6, 107 bytes

```
n=>((n*=100)/25|0)+` quarter ${(n%=25)/10|0} dime ${n%10/5|0} nickel ${n%5|0} penny`.replace(/ ?0 \S+/g,"")

```

Simple maths.

# Answer
> 12 votes
## Python 2, 120 bytes

```
n=int(round(input()*100))
a=25
for b in"quarter","dime","nickel","penny":
 if n>=a:print"%d "%(n/a)+b,
 n%=a;a=40/a+5^12

```

Just to be safe, changed to something that definitely works to fix @Ogaday's comment, for now at least. I'm uncertain whether or not I need the `int()` as well, but I'm having trouble convincing myself that I don't.

```
print`n/a`+" "+b,

```

is an extra byte off, but prints an extra `L` for large inputs (although this code doesn't work for extremely large inputs anyway, due to float precision).

# Answer
> 7 votes
# dc, 104

Newlines added for *"readability"*:

```
[dn[ quarter ]n]sq
[dn[ dime ]n]sd
[dn[ nickel ]n]sn
[d1/n[ penny ]n]sp
?A0*
25~rd0<qst
A~rd0<dst
5~rd0<nst
d0<p

```

# Answer
> 6 votes
# Retina, 97

Thanks (as always) to @randomra - saved 1 byte.

Assumes input is either in the form `xxx.yy` or `xxx.y`.

```
\..$
$&0
\.

.+
$0$*:
(:{25})+
$#1 quarter
(:{10})+
$#1 dime
(:{5})+
$#1 nickel
(:)+
$#1 penny

```

Try it online.

# Answer
> 4 votes
# Vitsy, ~~110~~ ~~100~~ 97 bytes

Yeah, hold on, I'm still methodizing this.

```
aa**Dv52^1m([N' retrauq 'Z]v52^MDva1m([N' emid 'Z]vDvaM51m([N' lekcin 'Z]v5MD([N'ynnep 'Z]
/D1M-D
```

Explanation in soon-to-come verbose mode:

```
push a;
push a;
multiply top two;
multiply top two;
duplicate top item;
save top as temporary variable;
push 5;
push 2;
push second to top to the power of top;
push 1;
goto top method;
if (int) top is 0;
begin recursive area;
output top as number;
push " quarter ";
output stack as chars;
end recursive area;
save top as temporary variable;
push 5;
push 2;
push second to top to the power of top;
modulo top two;
duplicate top item;
save top as temporary variable;
push a;
push 1;
goto top method;
if (int) top is 0;
begin recursive area;
output top as number;
push " dime ";
output stack as chars;
end recursive area;
save top as temporary variable;
duplicate top item;
save top as temporary variable;
push a;
modulo top two;
push 5;
push 1;
goto top method;
if (int) top is 0;
begin recursive area;
output top as number;
push " nickel ";
output stack as chars;
end recursive area;
save top as temporary variable;
push 5;
modulo top two;
duplicate top item;
if (int) top is 0;
begin recursive area;
output top as number;
push " penny";
output stack as chars;
end recursive area;
:
divide top two;
duplicate top item;
push 1;
modulo top two;
subtract top two;
duplicate top item;
```

Try it online!

# Answer
> 4 votes
# LabVIEW, 62 LabVIEW Primitives

I created 2 arrays for the names and values and iterate through them from the top (index array with i) using a modulo operator (the R IQ thing). The remaining coins are passed into the shift register.

If the value is bigger than 0 I convert the number to string and concatenate the passed down string, the number and the name of the coin and put it back into the shift register.

I just realized my gif doesn´t show the false case but there is nothing to see anyway, it just passes through the string that came in.

# Answer
> 3 votes
# Java 8 lambda, 165 bytes

Expects input `y` as either double or float.

```
y->{int c,d=(int)(y*100);return(((c=d/25)>0)?c+" quarter ":"")+(((c=(d=d%25)/10)>0)?c+" dime ":"")+(((c=(d=d%10)/5)>0)?c+" nickel ":"")+(((d=d%5)>0)?d+" penny":"");}
```

So much ternary. ;-;

# Answer
> 2 votes
# JavaScript ES6, ~~202~~ 200 bytes

I hope this can be golfed...

```
r=>eval('i=[.25,.1,.05,.01];v=[0,0,0,0];for(k=0;k<4;k++)for(;r>=i[k];v[k]++,r-=i[k],r=((r*100+.01)|0)/100);v.map((x,i)=>x?x+" "+"quarter0dime0nickel0penny".split(0)[i]:"").join` `.replace(/ +/g," ")')

```

Ungolfed code:

```
function m(r){
    i=[.25,.1,.05,.01]
    v=[0,0,0,0]
    for(k=0;k<4;k++)for(;r>=i[k];v[k]++,r-=i[k],r=((r*100+.01)|0)/100);
    return v.map((x,i)=>x?x+" "+"quarter0dime0nickel0penny".split(0)[i]:"").join(" ").replace(/ +/g," ");
}

```

# Answer
> 2 votes
# MATL, 82 ~~106~~ ~~107~~

```
'%i quarter %i dime %i nickel %i penny'i[.25 .1 .05]"@2#\w]100*Yo5$YD'0 \S+ ?'[]YX

```

Try it at **MATL Online!**

# Answer
> 2 votes
## C, ~~147~~ ~~144~~ ~~142~~ 140 bytes

```
a[]={25,10,5,1},m,i=0;f(float n){for(m=n*100;i<4;m%=a[i++])m/a[i]&&printf("%d %s ",m/a[i],(char*[]){"quarter","dime","nickel","penny"}[i]);}

```

Ungolfed with tests:

```
#include <stdio.h>

a[]={25,10,5,1},m,i=0;

f(float n)
{
    for(m=n*100;i<4;m%=a[i++])
        if(m/a[i])
            printf("%d %s ",m/a[i],(char*[]){"quarter","dime","nickel","penny"}[i]);
}

int main()
{
    float test[] = {.1, .01, .28, .56, 1.43};
    for(int j = 0; j < 5; i = 0)
    {
        f(test[j++]);
        printf("\n");
    }
}

```

# Answer
> 2 votes
# Japt, 77 bytes

```
` {U*=L /25|0} quÂòr {U%=25 /A|0} ÜX {U%A/5|0} Íõel {U%5|0} p¿ny` r" 0 %S+" x

```

Thankfully, all four coin names are compressable. The `¿` should be the literal byte 0x81. Test it online!

# Answer
> 2 votes
# APL (Dyalog Unicode), ~~185~~ 176 bytes

```
{' '∘(1↓,(/⍨)1(⊢∨⌽)0,≠)⍕,⍉(z[1;]≠0)/z←'quarter' 'dime' 'nickel' 'penny',[0.5]⍨{(⌊(⍵÷25)),(⌊(25|⍵)÷10),(⌊(10|25|⍵)÷5),⌊5|⍵}⍵×100}

```

Try it online!

The decomposition is in two parts: Computation, and Formatting

Computation:

```
{(⌊(⍵÷25)),(⌊(25|⍵)÷10),(⌊(10|25|⍵)÷5),⌊5|⍵}⍵×100
{                                           }         A dfn that takes...
                                             ⍵×100    ...the input argument of the entire function, and multiplies by 100 to convert
                                                        from dollars-and-cents to cents, then generates a vector, consisting of ...
 (⌊(⍵÷25)),                                          ...the number of quarters, computed as the the round-down-to-integer of
                                                        the number of cents divided by 25, followed by...
           (⌊(25|⍵)÷10),                             ...the number of dimes, computed as the round-down-to-integer of the remainder of
                                                        the number of cents divided by 25, divided by 10, followed by...
                        (⌊(10|25|⍵)÷5),              ...the number of nickels, computed as the round-down-to-integer of the remainder
                                                        from dividing (the remainder of the number of cents divided by 25) by ten,
                                                        divided by five, followed by...
                                       ⌊5|⍵          ...the number of pennies, computed as the round-down-to-integer of the
                                                        remainder from dividing the number of cents by five.

```

Computation is complete, and gives a vector of coin counts; the remainder is formatting:

```
' '∘(1↓,(/⍨)1(⊢∨⌽)0,≠)⍕,⍉(z[1;]≠0)/z←'quarter' 'dime' 'nickel' 'penny',[0.5]⍨    Append the result of the computation to this expression
                                       'quarter' 'dime' 'nickel' 'penny'           Take a vector of coin names, and...
                                                                              ⍨    ...swap it with the computation result, then...
                                                                        ,[0.5]     ...append the two along a 'side-by-side' axis. This gives
                                                                                a matrix which, if printed out, would have the coin counts
                                                                                above the coin name.  Then...
                                    z←                                            ...assign it to a temporary variable, and...
                          (z[1;]≠0)                                               ...generate a vector of 1s and 0s such that the 0s in this
                                                                                vector are in the same position as any 0s in the computation, then...
                                   /                                              ...use that vector to compress out the columns in the matrix where the
                                                                                coin count is zero, then...
                         ⍉                                                        ...transpose the matrix along its main diagonal. This converts it to two
                                                                                columns; left is coin counts, right is coin names. Then...
                        ,                                                         ..."unravel" the matrix into a linear vector; the result now has the coin
                                                                                count followed by the coin name - but there will be too many spaces, so...
                      ⍕                                                          ...convert to a character representation instead of a vector of
                                                                                mixed objects, then...
' '               0,≠                                                            ...this is a fork, with left argument being the space all the way at the
                                                                                beginning (S), and right argument being the formatted string (F). It is
                                                                                interpreted as S 0 F , S ≠ F. S ≠ F generates a vector C of 0s and 1s,
                                                                                where the 0s are at the same positions as the spaces. S 0 F is a
                                                                                constant 0. 0 , C prepends a 0 to the vector C (C2). Then...
            1(⊢∨⌽)                                                               ...we "go up a level" and see a new fork, 1 (⊢∨⌽) C2. This is interpreted
                                                                                as S 1 F (which is constant 1) (⊢∨⌽) S C2 F (which is constant C2). The
                                                                                central (⊢∨⌽) is itself a fork with arguments 1 and C2, so is interpreted
                                                                                as (1⊢C2)∨(1⌽C2). Dyadic ⊢ is right-identity, or C2, and 1⌽C2 takes the
                                                                                zero at the beginning of C2 and moves it to the end (C3). ∨ is logical OR,
                                                                                so C2 OR C3 gives a vector C4 of 1s and 0s where the 0s are positioned to
                                                                                correspond with the first space of a pair of consecutive spaces. This...
       ,(/⍨)                                                                     ...becomes the right argument to /⍨ with the left argument being S , F.
                                                                                S , F is the formatted string with a space prepended (SF), so we now have
                                                                                SF /⍨ C4. ⍨ is an operator saying "swap the arguments of (in this case) /"
                                                                                so that we're really computing C4 / SF. Dyadic / with a left argument of
                                                                                1s and 0s is "compression"; it returns those elements of its right
                                                                                argument that corresponds to 1s in the left argument. So, where C4 has a 0,
                                                                                the corresponding character in SF is omitted. Since C4 only had 0s where
                                                                                there was a space immediately before another space, the result is the
                                                                                compression of all multi-space substrings to single spaces. Then...
     1↓                                                                          ...we drop the first character (a space) of the result. This gives us a string
                                                                                which contains no leading or trailing spaces, and no sequence of more than
                                                                                one space within the string.

```

# Answer
> 2 votes
# 05AB1E, 34 bytes

```
т*ò25‰`T‰`5‰`)“œ¤æáeàë×ä“#øʒнĀ}˜ðý

```

Outputs with spaces like the examples.

Try it online or verify all test cases.

**Explanation:**

```
т*              # Multiply the (implicit) input-decimal by 100
  ò             # Bankers-round this to the nearest integer (to both prevent floating point
                # inaccuracies, as well as removing the ".0" from the ouput-numbers)
   25‰          # Take the divmod-25
      `         # Push both values separated to the stack
       T‰       # Take the divmod 10 on the top value
         `      # Push both values separated to the stack
          5‰    # Take the divmod 5 on the top value
            `   # Push both values separated to the stack
             )  # Wrap all values on the stack into a list
“œ¤æáeàë×ä“     # Push dictionary string "quarter dime nickel penny"
           #    # Split it on spaces
            ø   # Zip/transpose, creating pairs with the earlier integer list
ʒ               # Filter this list by:
 н              #  Where the first item (the integer)
  Ā             #  Is not 0
}˜              # After the filter: flatten the list of pairs
  ðý            # And join this list with a space delimiter
                # (after which this is output implicitly as result)

```

See this 05AB1E tip of mine (section *How to use the dictionary?*) to understand why `“œ¤æáeàë×ä“` is `"quarter dime nickel penny"`.

# Answer
> 1 votes
# JavaScript, ~~156~~ ~~145~~ 144 bytes

No match to ETHproduction's formula answer, but anyway...

```
function c(t){n=['quarter','dime','nickel','penny'];v=[.25,.1,.05,.01];s='';for(i in v){c=t/v[i]|0;if(c>0)s+=c+' '+n[i]+' ';t-=c*v[i];}return s}

```

This is one of my first rounds of golfs, so any improvements are highly appreciated! I already stole ETH's "xor trunc" -- sorry man, it was just too smart :-)

More readable:

```
function c(t)
{
  n = ['quarter', 'dime', 'nickel', 'penny'];
  v = [.25, .1, .05, .01];
  s = '';
  for(i in v)
  {
    c = t/v[i]|0;
    if(c>0) s += c+' '+n[i]+' ';
    t -= c*v[i];
  }
  return s
}

```

Note: While testing I realised that JavaScript (at least on my machine?) divides `1.13 / 0.01` to `1.12999...`, making my (and probably all other JS submissions) not work 100% properly...

# Answer
> 1 votes
# Kotlin, 147 bytes

```
{listOf("quarter" to 25,"dime" to 10,"nickel" to 5,"penny" to 1).fold((it*100).toInt()){d,(n,a)->val z=d/a
if(z>0){print("$z $n ")
d-(z*a)}else d}}

```

## Beautified

```
{
    listOf(
            "quarter" to 25,
            "dime" to 10,
            "nickel" to 5,
            "penny" to 1).fold((it * 100).toInt()) { d, (n, a) ->
        val z = d / a
        if (z > 0) {
            print("$z $n ")
            d - (z * a)
        } else d
    }
}

```

## Test

```
import java.io.ByteArrayOutputStream
import java.io.PrintStream

var f:(Double)->Unit =
{listOf("quarter" to 25,"dime" to 10,"nickel" to 5,"penny" to 1).fold((it*100).toInt()){d,(n,a)->val z=d/a
if(z>0){print("$z $n ")
d-(z*a)}else d}}

val TEST = listOf(
        0.1 to "1 dime",
        0.01 to "1 penny",
        0.28 to "1 quarter 3 penny",
        0.56 to "2 quarter 1 nickel 1 penny",
        1.43 to "5 quarter 1 dime 1 nickel 3 penny"
)

fun main(args: Array<String>) {
    val temp = ByteArrayOutputStream()
    System.setOut(PrintStream(temp))
    for ((input, output) in TEST) {
        temp.reset()
        f(input)
        println()
        val text = temp.toString().trim()
        if (text != output) {
            throw AssertionError("$input '$output' != '$text'")
        }
    }
}

```

## TIO

TryItOnline

# Answer
> 1 votes
# T-SQL, 181 bytes

I added some linebreaks to make it readable

```
DECLARE @2 decimal(10,2)=1.43

DECLARE @ INT=@2*100
SELECT string_agg(left(nullif(c,0),99)
+' '+trim(substring('quarterdime    nickle  penny',b*8,8)),' ')
FROM(values(0,@/25),(1,@%25/10),(2,@%25%10/5),(3,@%5))p(b,c)

```

**Try it online**

# Answer
> 1 votes
# PowerShell, ~~133~~ ~~131~~ ~~130~~ ~~123~~ 110 bytes

-8 bytes by snagging several tricks from mazzy's answer
-13 bytes thanks directly to mazzy

```
$n=100*"$args"
''+(25,10,5,1|%{($y=$n/$_-replace'\..*');(echo quarter dime nickel penny)[$i++];$n%=$_}|?{+$y})

```

Try it online!

Each iteration (i.e. `25,10,5,1`) generates two lines of output through the pipeline: the number and the coin size. `|?{+$y}` is a where clause that filters out both generations if `$y` is 0, which is the truncated result of `$n/$coin_size`.

# Answer
> 1 votes
# PowerShell, ~~120~~ ~~118~~ 115 bytes

*Inspired by Veskah*

```
$n=100*"$args"
''+(25,10,5,1|%{for($i=0;($n-=$_)-ge0){++$i}$n+=$_
$i;(echo quarter dime nickel penny)[$p++]}|?{$i})

```

Try it online!

# Answer
> 1 votes
# Julia, ~~128~~ 127 bytes

* -1 byte: @MarcMush

readable version:

```
!s=(
  x=floor(Int,100s);
  join("$v $w "^(v>0) for (v,w)=zip(
      [25,10,5,1].|>u->(t=x÷u;x=x%u;t),"quarter dime nickel penny"|>split
    )
  )
)

```

Attempt This Online!

# Answer
> 0 votes
## Python 2, ~~167~~ 161 bytes

*Update 1:* Stole Sp3000's idea to use input() and make my code a script instead of a function.

```
a=input()*100;k={25:0,10:0,5:0,1:0}
for i in k:k[i]=a//i;a%=i
print' '.join(['%d %s'%(k[x],{25:'quarter',10:'dime',5:'nickel',1:'penny'}[x]) for x in k if k[x]])

```

# Answer
> 0 votes
# Perl 5 - ~~128~~ 124 bytes

I guess this can be re-written to be much shorter but I really can't see it.

```
$s=<>*100;@v=($s/25,$s%2.5,$s%25%10/5,$s%250%5);map{$l=int($_);print$l.$".qw(quarter dime nickel penny)[$i].$"if$l>0;$i++}@v

```

EDIT: Just a math trick to save 4 chars.

# Answer
> 0 votes
# Perl 6, 96 bytes

```
$/=get;put map {$_=Int($//$^a);$/%=$a;"$_ $^b" if $_},<.25 quarter .1 dime .05 nickel .01 penny>

```

```
$/ = get; # set $/ to the input

# print the following list with spaces between
# and a newline at the end
put map {
  # the parameters to this block are $a, and $b
  # which are declared as placeholder parameters $^a, and $^b

  $_ = Int( $/ / $^a ); # set $_ to the count of the current coin

  $/ %= $a;             # set $/ to the modulus of itself and the current coin

  "$_ $^b" if $_        # return a string if $_, otherwise return Empty
},
<
  .25 quarter
  .1  dime
  .05 nickel
  .01 penny
>

```

### Usage:

```
for amount in  0.1  0.01  0.28  0.56  1.43; do
  echo $amount | perl6 -e'…';
done

```

```
1 dime
1 penny
1 quarter 3 penny
2 quarter 1 nickel 1 penny
5 quarter 1 dime 1 nickel 3 penny

```

# Answer
> 0 votes
# C, 162 bytes

Unfortunately, doesn't work without the `#include`.

```
#include <stdlib.h>
i,a[]={25,10,5,1};main(c,v)char**v;{for(c=atof(v[1])/.01;c;c%=a[i++])c/a[i]?printf("%d %s ",c/a[i],"quarter\0dime\0   nickel\0 penny"+8*i):0;}

```

## Ungolfed

```
#include <stdlib.h>

i,a[]={25,10,5,1}; /* loop index, coin values */

main(c,v) char**v;
{
    /* Get dollar amount from command line, convert to pennies */
    for (c=atof(v[1])/.01;c;c%=a[i++]) /* loop while still change... */
    {
        c/a[i] /* if there are coins at this index... */
            ? printf("%d %s ", c/a[i], "quarter\0dime\0   nickel\0 penny"+8*i) /* print out how many */
            : 0;
    }
}

```

# Answer
> 0 votes
# Lua 5.3, 141 139 132 131 bytes

Sort of based on Sp3000's Python answer, but with my own magic formula.

```
n=.5+100*io.read'n'a=25
for s in("quarter dime nickle penny "):gmatch".- "do
_=n<a or io.write(s,~~(n//a)," ")n=n%a
a=35%a|#s%2
end

```

Edit -- improved the `a` formula. Previously it was `a=a*3%13~#s%4`.

Edit 2 -- previously I was using `math.ceil` to round and convert to integer. Now I am reusing `//` to round and adding `~~` to convert to integer.

Edit 3 -- shaved a character by changing the pattern from `"%w+ "` to `".- "`.

# Answer
> 0 votes
# K (oK), ~~95~~ 78 bytes

**Solution:**

```
{" "/,/`quarter`dime`nickel`penny{("";$y,x)y>0}'(-c,1)!'{y!x}\x,c:25 10 5}100*

```

Try it online!

**Example:**

```
{" "/,/`quarter`dime`nickel`penny{("";$y,x)y>0}'(-c,1)!'{y!x}\x,c:25 10 5}100*0.92
"3 quarter 1 dime 1 nickel 2 penny"
{" "/,/`quarter`dime`nickel`penny{("";$y,x)y>0}'(-c,1)!'{y!x}\x,c:25 10 5}100*0.95
"3 quarter 2 dime"

```

**Explanation:**

Modulo the input by each coin, then divide coins by the result.

Feed each result along with the name of the coin into a function, returning the string value of both if number of coins is non-zero.

Flatten everything down and join together with whitespace.

# Answer
> 0 votes
# Swift, 164 bytes

Assuming input is `i`

```
let m=[("quarter",25),("dime",10),("nickel",5),("penny",1)]
var b=Int(i*100)
print(m.reduce(""){o,t in
let(n,v)=t,
x=Int(b/v)
b-=x*v
return x==0 ?o:o+"\(x) \(n) "})

```

Try it

# Answer
> 0 votes
# Mathematica 30 bytes

This submission may not qualify, as it makes use of a readily available built-in! But some may find it useful for understanding the connection to Frobenius equations.

The task can be understood as a search for all solutions to the Frobenius equation, `25q+10d+5n+p=t`, where q, d, n, p, and t, represent *quarters*, *dimes*, *nickels*, *pennies*, and *total*, respectively.

```
FrobeniusSolve[{25,10,5,1},#]&

```

The Frobenius equation `25q+10d+5n+p=100` represents all cases that sum to 100 cents.

The first solution, below, represents 100 pennies; the second solution represents 1 nickel and 95 pennies. And so on...

```
FrobeniusSolve[{25,10,5,1},100]

{{0, 0, 0, 100}, {0, 0, 1, 95}, {0, 0, 2, 90}, {0, 0, 3, 85}, {0, 0, 4, 80}, {0, 0, 5, 75}, {0, 0, 6, 70}, {0, 0, 7, 65}, {0, 0, 8, 60}, {0, 0, 9, 55}, {0, 0, 10, 50}, {0, 0, 11, 45}, {0, 0, 12, 40}, {0, 0, 13, 35}, {0, 0, 14, 30}, {0, 0, 15, 25}, {0, 0, 16, 20}, {0, 0, 17, 15}, {0, 0, 18, 10}, {0, 0, 19, 5}, {0, 0, 20, 0}, {0, 1, 0, 90}, {0, 1, 1, 85}, {0, 1, 2, 80}, {0, 1, 3, 75}, {0, 1, 4, 70}, {0, 1, 5, 65}, {0, 1, 6, 60}, {0, 1, 7, 55}, {0, 1, 8, 50}, {0, 1, 9, 45}, {0, 1, 10, 40}, {0, 1, 11, 35}, {0, 1, 12, 30}, {0, 1, 13, 25}, {0, 1, 14, 20}, {0, 1, 15, 15}, {0, 1, 16, 10}, {0, 1, 17, 5}, {0, 1, 18, 0}, {0, 2, 0, 80}, {0, 2, 1, 75}, {0,2, 2, 70}, {0, 2, 3, 65}, {0, 2, 4, 60}, {0, 2, 5, 55}, {0, 2, 6, 50}, {0, 2, 7, 45}, {0, 2, 8, 40}, {0, 2, 9, 35}, {0, 2, 10, 30}, {0, 2, 11, 25}, {0, 2, 12, 20}, {0, 2, 13, 15}, {0, 2, 14, 10}, {0, 2, 15, 5}, {0, 2, 16, 0}, {0, 3, 0, 70}, {0, 3, 1, 65}, {0, 3, 2, 60}, {0, 3, 3, 55}, {0, 3, 4, 50}, {0, 3, 5, 45}, {0, 3, 6, 40}, {0, 3, 7, 35}, {0, 3, 8, 30}, {0, 3, 9, 25}, {0, 3, 10, 20}, {0, 3, 11, 15}, {0, 3, 12, 10}, {0, 3, 13, 5}, {0, 3, 14, 0}, {0, 4, 0, 60}, {0, 4, 1, 55}, {0, 4, 2, 50}, {0, 4, 3, 45}, {0, 4, 4, 40}, {0, 4, 5, 35}, {0, 4, 6, 30}, {0, 4, 7, 25}, {0, 4, 8, 20}, {0, 4, 9, 15}, {0, 4, 10, 10}, {0, 4, 11, 5}, {0, 4, 12, 0}, {0, 5, 0, 50}, {0, 5, 1, 45}, {0, 5, 2, 40}, {0, 5, 3, 35}, {0, 5, 4, 30}, {0, 5, 5, 25}, {0, 5, 6, 20}, {0, 5, 7, 15}, {0, 5, 8, 10}, {0, 5, 9, 5}, {0, 5, 10, 0}, {0, 6, 0, 40}, {0, 6, 1, 35}, {0, 6, 2, 30}, {0, 6, 3, 25}, {0, 6, 4, 20}, {0, 6, 5, 15}, {0, 6, 6, 10}, {0, 6, 7, 5}, {0, 6, 8, 0}, {0, 7, 0, 30}, {0, 7, 1, 25}, {0, 7, 2, 20}, {0, 7, 3, 15}, {0, 7, 4, 10}, {0, 7, 5, 5}, {0, 7, 6, 0}, {0, 8, 0, 20}, {0, 8, 1, 15}, {0, 8, 2, 10}, {0, 8, 3, 5}, {0, 8, 4, 0}, {0, 9, 0, 10}, {0, 9, 1, 5}, {0, 9, 2, 0}, {0, 10, 0, 0}, {1, 0, 0, 75}, {1, 0, 1, 70}, {1, 0, 2, 65}, {1, 0, 3, 60}, {1, 0, 4, 55}, {1, 0, 5, 50}, {1, 0, 6, 45}, {1, 0, 7, 40}, {1, 0, 8, 35}, {1, 0, 9, 30}, {1, 0, 10, 25}, {1, 0, 11, 20}, {1, 0, 12, 15}, {1, 0, 13, 10}, {1, 0, 14, 5}, {1, 0, 15, 0}, {1, 1, 0, 65}, {1, 1, 1, 60}, {1, 1, 2, 55}, {1, 1, 3, 50}, {1, 1, 4, 45}, {1, 1, 5, 40}, {1, 1, 6, 35}, {1, 1, 7, 30}, {1, 1, 8, 25}, {1, 1, 9, 20}, {1, 1, 10, 15}, {1, 1, 11, 10}, {1, 1, 12, 5}, {1, 1, 13, 0}, {1, 2, 0, 55}, {1, 2, 1, 50}, {1, 2, 2, 45}, {1, 2, 3, 40}, {1, 2, 4, 35}, {1, 2, 5, 30}, {1, 2, 6, 25}, {1, 2, 7, 20}, {1, 2, 8, 15}, {1, 2, 9, 10}, {1, 2, 10, 5}, {1, 2, 11, 0}, {1, 3, 0, 45}, {1, 3, 1, 40}, {1, 3, 2, 35}, {1, 3, 3, 30}, {1, 3, 4, 25}, {1, 3, 5, 20}, {1, 3, 6, 15}, {1, 3, 7, 10}, {1, 3, 8, 5}, {1, 3, 9, 0}, {1, 4, 0, 35}, {1, 4, 1, 30}, {1, 4, 2, 25}, {1, 4, 3, 20}, {1, 4, 4, 15}, {1, 4, 5, 10}, {1, 4, 6, 5}, {1, 4, 7, 0}, {1, 5, 0, 25}, {1, 5, 1, 20}, {1, 5, 2, 15}, {1, 5, 3, 10}, {1, 5, 4, 5}, {1, 5, 5, 0}, {1, 6, 0, 15}, {1, 6, 1, 10}, {1, 6, 2, 5}, {1, 6, 3, 0}, {1, 7, 0, 5}, {1, 7, 1, 0}, {2, 0, 0, 50}, {2, 0, 1, 45}, {2, 0, 2, 40}, {2, 0, 3, 35}, {2, 0, 4, 30}, {2, 0, 5, 25}, {2, 0, 6, 20}, {2, 0, 7, 15}, {2, 0, 8, 10}, {2, 0, 9, 5}, {2, 0, 10, 0}, {2, 1, 0, 40}, {2, 1, 1, 35}, {2, 1, 2, 30}, {2, 1, 3, 25}, {2, 1, 4, 20}, {2, 1, 5, 15}, {2, 1, 6, 10}, {2, 1, 7, 5}, {2, 1, 8, 0}, {2, 2, 0,  30}, {2, 2, 1, 25}, {2, 2, 2, 20}, {2, 2, 3, 15}, {2, 2, 4, 10}, {2, 2, 5, 5}, {2, 2, 6, 0}, {2, 3, 0, 20}, {2, 3, 1, 15}, {2, 3, 2, 10}, {2, 3, 3, 5}, {2, 3, 4, 0}, {2, 4, 0, 10}, {2, 4, 1, 5}, {2, 4, 2, 0}, {2, 5, 0, 0}, {3, 0, 0, 25}, {3, 0, 1, 20}, {3, 0, 2,  15}, {3, 0, 3, 10}, {3, 0, 4, 5}, {3, 0, 5, 0}, {3, 1, 0, 15}, {3,  1, 1, 10}, {3, 1, 2, 5}, {3, 1, 3, 0}, {3, 2, 0, 5}, {3, 2, 1, 0}, {4, 0, 0, 0}}

```

# Answer
> 0 votes
# Pxem (`ABORT_ILLEGAL_INTEGER=0`), 139 bytes (filename only).

Backslash followed by four-digit of octet character means a character with the codepoint. Also this uses a implementation-defined feature that "pushes zero for non-integer input for `._`", which is adopted from nk.'s pxemi.7z (though the implementation is terrible).

```
._\0012.!.i.s.i0.-.+\0012.!._.+.c\0030.x.c\0031.$.n\0031.%.t quarter .p.mBB.a.c\0011.x.c\0012.$.n\0012.%.t dime .p.mBB.a.c\0004.x.c\0005.$.n\0005.$.t nickel .p.mBB.a.c.w.n penny.p.d.a

```

## Usage

* Full program.
* stdin/stdout.
* Input shall be a line and shall match this POSIX ERE: `^[0-9]+\.[0-9][0-9]?$`

Try it online!

---
Tags: code-golf, integer-partitions
---


# Question
Title: Do two numbers contain unique powers of 2
Break two numbers up into their powers of 2, if they share any, return a falsey value. Otherwise, return a truthy value.

If one input is `0`, the answer will always be truthy. if one input is `255`, the answer will be falsey if the other is not `0`.

# Example

Given 5 and 3

```
5 = 2⁰ + 2²
3 = 2⁰ + 2¹

```

Both share 2⁰, return falsey.

Given 8 and 17

```
8  = 2³
17 = 2⁰ + 2⁴

```

Neither share any powers, return truthy.

# I/O

Input and output can be through any standard means

Input will always be two integers in the range `0 <= n <= 255`

Output should be one truthy or falsey value

# Test Cases

```
Truthy:
1, 2
3, 4
2, 4
8, 17
248, 7

Falsey:
1, 3
6, 4
8, 8

```

Standard Loopholes apply.

This is , so fewest bytes wins!

# Answer
> 11 votes
# Actually, 2 bytes

```
&Y

```

Try it online!

Explanation:

```
&Y
&   bitwise AND
 Y  boolean negation

```

# Answer
> 7 votes
# x86 Machine Code, 5 bytes

```
20 C8 0F 95 C0

```

takes inputs in `al` and `cl`, and returns output in `al`, and is equivalent to:

```
and al, cl
setnz al

```

# Answer
> 4 votes
# Jelly, 2 bytes

Try it online!

Explanation:

```
&¬
&   bitwise AND
 ¬  logical negation

```

# Answer
> 3 votes
# Ruby, 12 bytes

```
->a,b{a&b<1}

```

Try it online!

# Answer
> 3 votes
# Mathematica, 12 bytes

```
BitAnd@##<1&

```

Pure function taking two positive integers as argument and returning `True` or `False`.

# Answer
> 2 votes
# Python, 18 bytes

```
lambda a,b:not a&b

```

Try it online!

# Answer
> 2 votes
# Bash, 10 bytes

```
!(($1&$2))

```

Input is via command-line arguments. Output is via exit code, so **0** is truthy and **1** if falsy.

Try it online!

# Answer
> 2 votes
# 05AB1E, 2 bytes

```
&_

```

Try it online!

# Answer
> 2 votes
# R, 28 bytes

```
f=function(a,b)!bitwAnd(a,b)

```

# Answer
> 1 votes
# JavaScript (ES6), 12 bytes

```
a=>b=>!(a&b)

```

Takes input in the currying format.

```
let f=

a=>b=>!(a&b)

console.log(f(1)(2));
console.log(f(3)(4));
console.log(f(2)(4));
console.log(f(8)(17));
console.log(f(248)(7));
console.log(f(1)(3));
console.log(f(6)(4));
console.log(f(8)(8));
```

# Answer
> 1 votes
## CJam, ~~23~~ 4 bytes

```
q~&!

```

It turns out my previous solution contained an implementation of what was essentially just bitwise AND (which is silly because it used `&` anyway).

# Answer
> 1 votes
# CJam, 4 bytes

```
{&!}

```

Try it online!

# Answer
> 1 votes
# R, 23 bytes

if allowed - this version can get multiple inputs as a1,a2,a3..... b1,b2,b3.....

```
!bitwAnd(scan(),scan())

```

# Answer
> 1 votes
# GolfScript, 3 bytes

```
~&!

```

Try it online!

# Answer
> 1 votes
## Pyke, 3 bytes

```
.&!

```

Try it here!

```
.&  -  bitwise_and(input_1, input_2)
  ! - not ^

```

# Answer
> 1 votes
# MATL, 3 bytes

```
Z&~

```

Try it at **MATL Online**.

**Explanation**

```
    % Implicitly grab both inputs
Z&  % Bit-wise AND
~   % Negate the result and implicitly display

```

# Answer
> 1 votes
# Chip, 80 bytes

```
 AZ BZ CZ DZ EZ FZ GZ HZ
,[',[',[',[',[',[',[',['*Z~S
`--)--)--)--)--)--)--)~aef

```

Try it online!

Takes input as two consecutive bytes. (In the TIO, the characters 'A' and '$' are used, corresponding to values 65 and 36.)

This solution has eight chunks, one per bit, plus an extra chunk at the end. Looking at these chunks:

`A` is bit `0x01` of the input. (The letters `A` though `H` correspond to a bit each.) `Z` holds on to a value for the next cycle while producing the previous value. Hence, `A` and `Z` are the current and previous values of bit `0x01`.

`[` is an AND-gate; it simply ANDs its two inputs together. So the full row of such gates is performing a bitwise AND of the two bytes.

Finally, `)` is an OR-gate. All eight AND results are OR'd together, giving us a True is there is a match, and a False otherwise. We want the inverse of that, so use a NOT-gate (`~`) before passing it to the output.

We output via `a`, `e`, and `f`. The `a`, which corresponds to bit `0x01` of the output, receives the result of the above computation. The other two bits `e` and `f` are unconditionally on, together forming `0x30`. Therefore, the output is either `0x30` or `0x31`, which are the codes for ASCII characters '0' and '1'.

The extra stuff is housekeeping, it prevents output for the first cycle (there is no previous value at this point, so there is no reason to do a comparison).

---

### Alternate solution, also 80 bytes

```
A~.B~.C~.D~.E~.F~.G~.H~.
Z~<Z~<Z~<Z~<Z~<Z~<Z~<Z~<*Z~S
 a[--[--[--[--[--[--[--'ef

```

This is very similar in style, but uses a different algorithm. Where above we AND each pair of bits, and use OR to reduce the result to a single value, here we OR the negation of each pair of bits, then use AND to reduce.

One thing to note: we use an implicit OR here, instead of a proper gate as above. We could have used implicit OR'ing above as well, but there is no byte-savings there.

# Answer
> 1 votes
# Java 13 bytes

```
a->b->(a&b)<1

```

# Answer
> 1 votes
# Desmos, ~~87~~ ~~85~~ ~~87~~ 80 bytes

+2 bytes to correct an error pointed out by @Steffan

-7 bytes thanks to @aiden-chow

```
D(n)=mod(floor(n/2^{[0...floor(log_2(n+0^n))]}),2)
f(a,b)=\{\total(D(a)D(b))=0\}

```

Try It On Desmos!

**f** returns `1` when they are "truthy" and otherwise `undefined`.

# Answer
> 1 votes
# Rust, 10 bytes

```
|a,b|a&b<1
```

Attempt This Online!

# Answer
> 0 votes
# Pari/GP, 18 bytes

```
x->y->!bitand(x,y)

```

Try it online!

# Answer
> 0 votes
# Javascript, 28

```
(a,b)=>!(256&(-~a|-~b)||a&b)

```

# Answer
> 0 votes
## QBIC, 12 bytes

```
?(: and :)=0

```

This returns `-1` for truthy inputs, and `0`otherwise. "Bitwise" is something QBasic isn't very good at, and I haven't built any of this stuff into QBIC either.

# Answer
> 0 votes
# , 13 bytes

```
(x,y)=>!(x&y)

```

Here, `(arg1,...)=>result` is the D lambda syntax, and the `!` and `&` are common notations for boolean negation and bitwise AND.

You can find the whole program coupled with the tests at tio.run.

# Answer
> 0 votes
# PHP, 25 Bytes

print 1 for true and nothing for false

```
<?=!($argv[1]&+$argv[2]);

```

Try it online!

# Answer
> 0 votes
# Lua, 19 bytes

```
a,b=...print(a&b<1)

```

Try it online!

# Answer
> 0 votes
# C (gcc), 18 bytes

Uses exit-code 0 as truthy.

```
f(a,b){exit(a&b);}

```

Try it online!

# Answer
> 0 votes
# Pyth, 6 bytes

```
!.&hQe

```

Test it online!

**Explanations**

```
!.&hQe

   hQ     Get first input number
     e    Get second (implicit) input number
 .&       Bitwise and
!         Negate

```

# Answer
> 0 votes
# Wise, 11 bytes

```
&::^~![&&]|

```

Due to a bug this does not currently work on tio, however it does work on the desktop version.

Here is a slightly longer version that works for both:

```
&::^~![?~&:]|

```

Try it online!

# Explanation

Most of our code goes into a logical not, in fact only the first byte is required if you want to get the *opposite* answer.

```
&             #Bitwise and
 ::^~![?~&:]| #Logical not

```

# Answer
> 0 votes
# Oracle SQL, 34 bytes

```
-- Begin test cases
WITH T (x, y, desired) AS (
  SELECT   1,  2, 1 FROM DUAL UNION ALL
  SELECT   3,  4, 1 FROM DUAL UNION ALL
  SELECT   2,  4, 1 FROM DUAL UNION ALL
  SELECT   8, 17, 1 FROM DUAL UNION ALL
  SELECT 248,  7, 1 FROM DUAL UNION ALL
  SELECT   1,  3, 0 FROM DUAL UNION ALL
  SELECT   6,  4, 0 FROM DUAL UNION ALL
  SELECT   8,  8, 0 FROM DUAL)
-- End test cases
SELECT T.*, -SIGN(BITAND(x, y)) + 1 result FROM T
/

```

# Answer
> 0 votes
# APL, 10 bytes

```
 ∧/⍲/⎕⊤⍨8⍴2

```

Take two (or more) numbers, convert them to binary, then apply the NAND to pairs of bits, then reduce by conjunction.

# Answer
> 0 votes
# Go, 30 bytes

```
func(a,b int)any{return a&b<1}
```

Attempt This Online!

---
Tags: code-golf, arithmetic, decision-problem, integer, bitwise
---


title: Next digit of rational number

text:
# Question
Title: 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 much digits of them!

**Challenge:**

Your task will be to write program or function which takes string of digits including decimal separator and outputs next digit of this number. You can get next digit by knowing, that the input is composed out of two strings (ignoring the decimal separator) like this `abb`. For example the number `0.1818` is composed of string `a` which is `0` and `b` which is `18` and the output will be first digit of `b`, which is `1`. If there are multiple choices for string `b` you have to use longest one. The string `a` can be empty.

The decimal separator is guaranteed to be in every number and won't be first or last character of input. You can choose which decimal separator you want to support from following characters: `.,·'`

**Testcases:**

| Input | a | b | Output |
| --- | --- | --- | --- |
| 0.1818 | 0 | 18 | 1 |
| 6.66 | 6 | 6 | 6 |
| 3.3 |  | 3 | 3 |
| 0.0526315789473684210526315789473684210 | 00 | 526315789473684210 | 5 |
| 37.0370 |  | 370 | 3 |
| 88.998899 |  | 8899 | 8 |
| 1657.7771657777 |  | 1657777 | 1 |
| 5.0000000 | 50 | 000 | 0 |
| 25885882588.588 |  | 2588588 | 2 |
| 9.99999 |  | 999 | 9 |
| 1.221122 | 12211 | 2 | 2 |
| 1.2112113211 | 121121132 | 1 | 1 |

# Answer
> 16 votes
# Regex (ECMAScript or better), ~~38~~ ~~34~~ 20 bytes

```
((.).*),?(.*)\1,?\3$

```

Uses `,` as the decimal separator. Returns its output as capture group `\2`.

Try it on regex101 \- ECMAScript (and can be switched to others)
Try it online! \- ECMAScript
Attempt This Online! \- PCRE2
Try it online! \- .NET

It occurred to me after writing both of the below regexes that an entirely different approach would also work.

```
# Search for a "first half", which is repeated exactly following itself
# (except that there can be a decimal point anywhere in either half, which
# is not repeated), with the end of the string following that in turn.
((.).*)      # \1 = part 1 of first half;
             # \2 = first digit of this half (the return value)
             # A decimal point may be here in the other half.
,?           # Skip a decimal point, if there is one in this half. If there isn't
             # one here in this half, there must be one here in the other half.
(.*)         # \3 = part 2 of first half
# Match the other half, which is an exact repetition of the first half
# except that a decimal point can occur anywhere in either half and is
# not repeated.
\1           # Match part 1
,?           # Skip a decimal point, if there is one here.
\3           # Match part 2
$            # Assert that we've reached the end of the string.

```

It even *almost* works in GNU ERE:
Attempt This Online! \- but fails on the `5.0000000` case, because this engine *really* doesn't like to backtrack much. The strangest thing is that if `REG_NOSUB` is enabled, it claims to match everything... is it lying? It's Schrödinger's match. (You can experiment with that by changing `SHOW_MATCH` to `0` in the test harness.)

This 20 byte regex obsoletes the other two below, as it runs at the same speed or faster... but I'm not sure if I want to delete them, since they're interesting in their own right. And they would still be the only working solutions if the entire string could be littered with any number of decimal points.

# Regex (.NET), 39 bytes

```
(?=((.),?)*$)(?<=(?(2)$)(?<-2>(\2),?)*)

```

Returns its output as capture group `\3`.

Try it online!

This works (using .NET's Balancing Groups feature) by pushing a portion of the end of the string onto the group `\2` capture stack, one digit at a time, and then scanning in reverse from the position it started from, popping off one digit at a time from the stack to check that they match. The last one popped off is then the return value, if it matches.

```
              # No anchor - This regex will try starting its match at each
              # character of the string until succeeding.
(?=           # Positive atomic lookahead - Match the following, but then
              # return to this position.
    (
        (.)   # Push a digit onto the group \2 capture stack.
        ,?    # Skip a decimal point if there is one here.
    )*        # Iterate the above as many times as possible, minimum zero
    $         # Assert we've reached the end of the string.
)
(?<=          # Lookbehind - evaluated right-to-left
              # (read this from the bottom up)
    (?(2)$)   # Assert that if the group \2 stack is not empty, we're at the
              # end of the string (which is impossible). Basically, assert
              # that the group \2 stack is empty.
    (?<-2>    # Pop a capture from the group \2 stack and match:
        (\2)  # \3 = digit that matches with \2
        ,?    # Skip a decimal point if there is one here.
    )*
)

```

Try it on regex101 \- putting this link down below here because regex101's .NET support is a bit buggy. With this example, it sees the capture groups in the wrong order, and thinks the return value is in group 1.

# Regex (PCRE2), 48 bytes

```
(?*(.).*(.*+))((.),?(?=.*(?=\2$)(\5?+,?\4)))+\5$

```

Returns its output as capture group `\1`.

Try it on regex101
Attempt This Online!

```
                   # No anchor - This regex will try starting its match at each
                   # character of the string until succeeding.
(?*                # Non-atomic lookahead - Match the following, but then return
                   # to this position; if a non-match is subsequently found,
                   # backtrack to here and try other possible matches.
    (.)            # Capture the first digit in \1; this will be our return value.
    .*(.*+)        # Search for a \2 that is the last instance of the entire
                   # repeating pattern, using non-atomic lookahead.
)
(                  # Loop the following:
    (.)            # \4 = a digit
    ,?             # Skip a decimal point if there is one here.
    (?=            # Positive atomic lookahead - Match the following, but then
                   # return to this position.
        .*(?=\2$)  # Skip to where \2 begins.
        (          # \5 = the following:
            \5?+   # The previous value of \5, or nothing if this is the first
                   # iteration and \5 is unset.
            ,?     # Skip a decimal point if there is one here.
            \4     # Match a copy of the digit captured in \4.
        )
    )
)+                 # Iterate as many times as possible (minimum one) to match the
                   # following assertion:
\5$                # Assert that the \5 we captured is identical to \2 and is
                   # located at the end of the string.

```

This uses a PCRE2 feature, non-atomic lookahead `(?*`...`)`. I'm pretty sure it's also possible to solve this without non-atomic lookahead, but I'll look into that later.

Note that the only reason this regex is so complicated is because of the presence of the decimal point. If not for that, the solution would be `(?=(.+)\1$|.$).` (which is what I came up with before realizing the decimal point was in the way, when I still wanted to return the output as the match instead of a capture group), or what is used in ovs's Retina solution, `((.).*)\1$`.

But this is a pure regex solution, and can't do any substitutions before doing its matching work.

## \\$\large\textit{Full programs}\\$

# Ruby `-n`, 27 bytes

```
~/((.).*),?(.*)\1,?\3$/;p$2

```

Try it online!

# Perl `-p`, 28 bytes

```
/((.).*),?(.*)\1,?\3$/;$_=$2

```

Try it online!

### \\$\large\textit{Anonymous functions}\\$

# Ruby, 33 bytes

```
->s{s=~/((.).*),?(.*)\1,?\3$/;$2}

```

Try it online!

# JavaScript (ES6), 37 bytes

```
s=>s.match(/((.).*),?(.*)\1,?\3$/)[2]

```

Try it online!

# Julia v0.4+, 38 bytes

```
s->match(r"((.).*),?(.*)\1,?\3$",s)[2]

```

Try it online!

# v4.1.0+, 48 bytes

```
\(s)gsub('.*?((.).*),?(.*)\\1,?\\3$','\\2',s,,1)

```

Attempt This Online!

# Java 8, 49 bytes

```
s->s.replaceAll(".*?((.).*),?(.*)\\1,?\\3$","$2")

```

Try it online!

Java's `split` method just doesn't work the right way to be useful for this.

# PHP, 54 bytes

```
fn($s)=>preg_split('/(?=(.+),?(.*)\1,?\2$)/',$s)[1][0]

```

Try it online!

# Python, 57 bytes

```
lambda s:re.split(r'(.+),?(.*)\1,?\2$',s)[1][0];import re

```

Try it online!

# Python, 61 bytes

```
lambda s:__import__('re').split(r'(.+),?(.*)\1,?\2$',s)[1][0]

```

Try it online!

(If it must be a pure lambda.)

# Answer
> 8 votes
# Retina, 19 bytes

Uses `,` as a decimal separator.

```
,

.*?((.).*)\1$
$2

```

Try it online!

# Answer
> 8 votes
# 05AB1E, ~~14~~ ~~13~~ ~~12~~ 9 bytes

```
RþηD2×Ãθθ

```

-1 byte porting *@JonathanAllan*'s Jelly answer
-3 bytes thanks to *@CommandMaster* with a very smart usage of `Ã` as golf on my 13-byter(s)

Try it online or verify all test cases.

**Explanation:**

```
R          # Reverse the (implicit) input
 þ         # Remove the dot by only keeping the digits
  η        # Pop and push a list of its prefixes
   D       # Duplicate this list of prefixes
    2×     # Double each string in the top prefixes-list
      Ã    # Only keep those doubled-prefixes from the prefixes-list
       θ   # Pop and push the last/longest
        θ  # Pop and push its last digit
           # (which is output implicitly as result)

```

# Answer
> 8 votes
# Jelly, 10 bytes

```
ḟṂŒHÐƤEƇFḢ

```

A monadic Link that accepts a string of digit characters containing a decimal point, `.`, and yields a digit character.

**Try it online!** Or see the test-suite.

### How?

```
ḟṂŒHÐƤEƇFḢ - Link: list of characters, N
 Ṃ         - minimum of N (guaranteed to be the '.')
ḟ          - filter ('.') from N
    ÐƤ     - for each suffix of that:
  ŒH       -   split into two halves
       Ƈ   - filter keep those which are:
      E    -   all equal (i.e first half = second half)
        F  - flatten
         Ḣ - head

```

# Answer
> 7 votes
# Python, ~~68~~ ~~62~~ 57 bytes

```
lambda x:re.split(r"(.+),?(.*)\1,?\2$",x)[1][0]
import re

```

Attempt This Online!

Takes in a string with `,` as the decimal separator.

---

-6 bytes from @loopy walt by using `$` instead of reversal.
-5 bytes from @loopy walt / @DeadCode using the matching regex to ignore the `,` instead of adding a `re.sub`

# Answer
> 6 votes
# Husk, 8 bytes

```
←ḟoE½ṫf±

```

Try it online!

```
      f   # filter to keep only
       ±  #  characters that are digits,
 ḟ        # now get the first
     ṫ    #  of all the tails (possible 'bb's)
  oE½     #  which is two copies of the same thing,
←         # and return the first element.

```

# Answer
> 5 votes
# Raku, 31 bytes

```
{+(S/\.//~~/((.).*?)$0$/)[0;0]}

```

Try it online!

`S/\.//` returns a copy of the input string with the decimal point removed. That string is matched with `~~` against the pattern `((.) .*?) $0 $`, which looks for the repeating portion at the end of the string. `[0; 0]` looks up the first submatch group of the first match group (ie, the digit matched by the `(.)`) and `+` converts that match object to an integer.

# Answer
> 4 votes
# Excel, ~~118~~ 104 bytes

```
=LET(a,MID(SUBSTITUTE(A1,".",),ROW(1:32767),2^15),b,LEFT(a,LEN(a)/2),LEFT(INDEX(b,MATCH(TRUE,a=b&b,0))))

```

Input is in cell A1 of the active sheet. Output is wherever the formula is. Breaking down the `LET()` function into the `variable,value,...,output` format, we get this for the first two terms:

* `a,MID(SUBSTITUTE(A1,".",),ROW(1:32767),2^15)` removes any decimal point and then creates an array 32767 rows tall where each row removes another character from the beginning of the string. Most of this array will be empty, of course, but this is to accommodate the max number of characters allowed per cell.
* `b,LEFT(a,LEN(a)/2)` creates an equally tall array of the first half of the first array.

Now it gets into the more complicated final term:

```
LEFT(INDEX(b,MATCH(TRUE,a=b&b,0))))

```
* `MATCH(TRUE,a=b&b,0)` finds the first row where `a` is exactly `b` twice.
* `INDEX(b,MATCH(~))` pull the entire value of `b` from the array at that point.
* `LEFT(INDEX(~))` outputs the first character of that result.

---

Screenshot with details for one of the test cases:

---

Screenshot with all the test cases:

# Answer
> 4 votes
# Vyxal, ~~13~~ 10 bytes

```
~±ÞKvI~≈fh

```

Try it Online!

```
~±ÞKvI~≈fh
~±         # Filter for numeric, to remove the ".". Converts to list of chars
  ÞK       # Suffixes
    vI     # Split each into a list of two halves
      ~≈   # Filter for all equal
        f  # Flatten
         h # First item

```

Original 13 bytes was porting UnrelatedString's Jelly answer, but porting Jonathan Allan's answer saved 3 bytes, so upvote those two!

Alternative:

# Vyxal, 10 bytes

```
goÞK½~≈hhh

```

Try it Online!

```
goÞK½~≈hhh
g          # Minimum (".")
 o         # Remove it
  ÞK       # Suffixes
    ½      # Split each into a list of two halves
     ~≈    # Filter for all equal
       h   # First list
        h  # First string
         h # First character

```

# Answer
> 4 votes
# Brachylog, 7 bytes

```
ịˢa₁~jh

```

Try it online!

```
ịˢ         Filter the input to only digits.
  a₁       For some suffix (tried longest first),
      h    output the first element of
    ~j     a list which repeated twice is the suffix.

```

# Answer
> 4 votes
# K (ngn/k), 26 bytes

```
**((~/2 0N#)')#(1_)\(46=)_

```

Try it online!

## Explanation

* `(46=)_` remove decimal
* `(1_)\` generate suffixes
* `((...)')#` filter each suffix...
    + `2 0N#` halve suffix
    + `~/` check if halves are equal
* `**` first of first

# Answer
> 3 votes
# Python, 74 bytes

```
f=lambda s,i=0:s[n:=i-len(s)]*(s[n:]==s[2*n:n])or f(s.replace(".",""),i+1)
```

Attempt This Online!

# Answer
> 2 votes
# Python 3.8 (pre-release), 65 bytes

```
f=lambda s:(s:=s.replace('.',''))[:s==s[:len(s)//2]*2]or f(s[1:])

```

Try it online!

# Answer
> 2 votes
# Jelly, 13 bytes

```
ḟ”.ŒHẆf/ƊÐƤFḢ

```

Try it online!

```
ḟ”.              Remove the radix point.
        ƊÐƤ      For each suffix:
   ŒH            Split it in half,
       /         and reduce
     Ẇ           the sublists of the pair of halves
      f          by filter left by membership in right.
           F     Flatten the results
            Ḣ    and yield the first element.

```

# Answer
> 2 votes
# JavaScript (Node.js), 46 bytes

```
s=>/^.*?(.*)\1$/.exec(s.replace('.',''))[1][0]

```

Attempt This Online!

# Answer
> 2 votes
# lin, 35 bytes

```
"\, !="`#"1`d"`it"`bi \`= `/"`?' `^

```

Try it here! Takes string with `,` comma.

I recently added string literals to lin, still not sure if I regret doing so...

For testing purposes:

```
"1,2112113211" ; outln
"\, !="`#"1`d"`it"`bi \`= `/"`?' `^

```

## Explanation

More readable version:

```
( \, != ) `# ( 1`d ) `it ( `bi \`= `/ ) `?' `^

```
* `( \, != ) `#` filter out comma
* `( 1`d ) `it` generate suffixes
* `(...) `?'` find first suffix that satisfies the following...
    + ``bi` split suffix in half
    + `\`= `/` check if both halves are equal
* ``^` first element

# Answer
> 1 votes
# Excel VBA, 107 bytes

```
Sub o(a)
a=Replace(a,".","")
b=Left(a,Len(a)/2)
If a=b &b Then MsgBox Left(b,1):Exit Sub
o Mid(a,2)
End Sub

```
1. Remove any decimal points from the input.
2. Get the first half (rounded up) of the input.
3. If the whole string is the first half twice, output the first digit of `b` to a message and exit.
4. Otherwise, remove the first letter from the input and recurse.

---

VBA will pad the code with spaces automatically. The above input is valid but here's what it looks like after that auto-formatting:

```
Sub o(a)
a = Replace(a, ".", "")
b = Left(a, Len(a) / 2)
If a = b & b Then MsgBox Left(b, 1): Exit Sub
o Mid(a, 2)
End Sub

```

# Answer
> 1 votes
# Python 3, 93 bytes

```
def f(s):s=s.replace(".","");return[s[-i:][0]for i in range(len(s))if s[-i:]==s[-2*i:-i]][-1]

```

Try it online!

# Answer
> 1 votes
# Charcoal, 22 bytes

```
§⊟ΦＥθ…⮌⁻θ.κ¬⌕⮌⁻θ.×²ι±¹

```

Try it online! Link is to verbose version of code. Explanation:

```
    θ                   Input string
   Ｅ                    Map over characters
        θ               Input string
       ⁻ .              With `.`s removed
      ⮌                 Reversed
     …                  Truncated to length
          κ             Current index
  Φ                     Filtered where
            ⌕           Index of
                   ι    Current reversed suffix
                 ×²     Repeated twice
               θ        In current string
              ⁻ .       With `.`s removed
             ⮌          Reversed
           ¬            Is zero
 ⊟                      Take the longest reversed suffix
§                   ±¹  Take its last character
                        Implicitly print

```

# Answer
> 1 votes
# Haskell, ~~95~~ 83 bytes

*-12 bytes thanks to @Unrelated String*

```
g.filter(>'.')
g x=[x!!d|d<-[0..],uncurry(==)$div(length x-d)2`splitAt`drop d x]!!0
```

Attempt This Online!

---
Tags: code-golf, string, rational-numbers
---


title: Tips for Code Golfing in Desmos

text:
# Question
Title: Tips for Code Golfing in Desmos
Desmos is mainly used as an online graphing calculator, but its graphical and mathematical functionalities can also be applied in certain coding challenges.

I know not that many people use Desmos on this site, but for the people that do, what are some tips for golfing in Desmos?

As usual, please keep the tips somewhat specific to Desmos, and one tip per answer.

# Answer
(This is mainly a \\$\LaTeX\\$ trick that can save some bytes. This tip can likely apply to other languages that use \\$\LaTeX\\$.)

When dealing with exponents(e.g. `x^{2}`) or other operators that require the usage of brackets(e.g. `\sqrt{5}`), you can take out the brackets that are automatically there if there is only one digit/character in the exponent. So, `x^{2}` can be written as `x^2`. Likewise, `\sqrt{5}` can be shortened to `\sqrt5`.

Note that you cannot take out these brackets if there is more than one digit. For example, `x^{10}` is not the same as `x^10`.

---

This exponent trick can even work in summations, where it uses the same notation when indicating the stopping value.

For example, instead of writing...

```
\sum_{k=0}^{n}k^{3}

```

...it can be written as:

```
\sum_{k=0}^nk^3

```

---

Because if this trick, it is better if you can find a way to maximize the amount of one digit exponential terms in your code, to eliminate the brackets.

For example, it is actually more byte efficient to write `a^xa^y` (6 bytes) instead of `a^{x+y}` (7 bytes).
> 13 votes

# Answer
### Edit #2:

(Referring to the example in the first edit)

Apparently you can add a `\` at the beginning of the function to make it work(see this comment), which I did not know as well. I guess that invalidates this tip, again.

### Edit:

In fireflame241's comment, he brought to my attention that it is not required to have the `\left` and `\right` accompanying the bracket pairs. This is true for most cases. But after some testing, there are some cases where taking out the `\left` and `\right` does break the code. Specifically, if you are using any function(e.g. `total` or `max`) in addition to these brackets, the function will not work(see example below).

Example:

Suppose you want to compare the corresponding elements of two lists, `a` and `b`, and see how many of those corresponding elements are the same. That is, something like `a=[1,2,3,4]` and `b=[2,2,3,5]` will output `2`(the second and third elements of each list are the same).

Here's what someone might do, after learning that you can take out the `\left` and `\right`:

```
total(\{a=b:1,0\})

```

In theory, this should work perfectly fine, but in reality, Desmos gives an error and it doesn't work. I'm pretty sure it's because it considers `l` to be a function, and `t`, `o`, and `a` to be variables in this situation. `l`, `o`, and `t` are not defined, so it gives an error saying so.

In cases like this, it would be better to do:

```
total(1-sign(a-b)^2)

```

as suggested by the tip below.

---

First tip to start it off.

When doing comparisons in your code, most of the times, it is better to try not to use brackets `{ }` in your code, because they always require a `\left` and a `\right` to go with them, which increases byte count unnecessarily. Instead, we can utilize the `sign` function.

Consider a naive implementation that returns `0` if `a=b`, and returns `1` otherwise:
(22 bytes)

```
\left\{a=b:0,1\right\}

```

Instead of doing this, we can save 9 bytes by doing a little math instead:
(11 bytes)

```
sign(a-b)^2

```

This works because `sign(x)` returns `-1` if `x` is negative, `0` if `x=0`, and `1` otherwise. `a-b` is `0` only when `a=b`, so `sign(a-b)` would be `0` only when `a=b`. If `a` does not equal `b`, it returns either `-1` or `1`. The `^2` is just to convert the `-1` to a `1`.

Even if we wanted to return `1` if `a=b` and `0` otherwise, we can still save 9 bytes by doing `1-sign(a-b)^2` instead of `\left\{a=b:1,0\right\}`.
> 7 votes

# Answer
# You can use /

Pasting in `x/5` or `8/3` will give the same result as typing it, just not properly formatted - so in some cases, you don't need the bulky `\frac{x}{y}`.
> 7 votes

# Answer
## Parentheses are not always required for trig functions

For example, `tan35.6x=0` is valid and treated as `tan(35.6x)=0`.

Similarly, `tan^23x` is treated as `tan^{2}(3x)`.
> 7 votes

# Answer
### Change `\prod` to  and `\sum` to

`\prod` can be replaced with , saving 2 bytes, and `\sum` with  to save 1 byte. Important to note that these are not capital pi `Π` or capital sigma `Σ`, but their own distinct characters.

Similarly, `\to` can be replaced with , but this loses a byte to `->`. in either case ( or `->`), you can omit the next `\` from a function.

Example: `x\to\join(x,y)` =\> `x->join(x,y)` saves 2 bytes.

(special thanks to @Aiden Chow for the correction about `->`)
> 6 votes

# Answer
# Logical negation

If you want to swap numbers that represent falsy and truthy values, you can use `0^x`, where `x` is the value that needs to be logically negated. To make it work for negative numbers, you can use the absolute value (`0^{abs(x)}`), suggested by Aiden Chow.
> 5 votes

# Answer
You can use function parameters to assign variable values outside of that function, even though it throws an error. Using this, we can save bytes when we repeat expressions inside of functions.

For example, look at this code:

(45 bytes)

```
f(a)=sort(a)[1]+sort(a)[length(a)]-sort(a)[2]

```

There is a lot of `sort(a)`'s in that code, maybe we can shorten it?

Here is what many people might try to do to shorten this:

(49 bytes)

```
b(a)=sort(a)
f(a)=b(a)[1]+b(a)[length(a)]-b(a)[2]

```

It seems like making a function just for `sort(a)` should have helped, but in reality this is actually 4 bytes longer than the initial code.

What can we do then? Well, the following code will do it:

(37 bytes)

```
b=sort(a)
f(a)=b[1]+b[length(a)]-b[2]

```

`b` is using a function parameter `a` in declaring it, and Desmos is throwing an error because it seemingly doesn't understand this, but at the end, it still works somehow, so it is valid.
> 4 votes

# Answer
Here's a cool piecewise trick.

When writing piecewise expressions in the form `\{(condition):1,n\}` for some value `n`, you can actually replace them with `\{(condition),n\}`, saving 2 bytes. I'm not aware of the full details on why this works, but the premise is that with any piecewise in the form `\{(condition)\}`, like `\{x>0\}`, if the `(condition)` is true, then it will return 1, otherwise, it will return `undefined` (if you are wondering why these values, it is because piecewise expressions are also used in domain/range restrictions). Notice how there is no `true` or `false` output in these type of piecewise experssions. This is because 1 and `undefined` are the "default" values when the `true` and/or `false` output is omitted. When writing `\{(condition),n\}`, you are omitting the `true` output, which means that it will default to 1, so it is essentially the same as `\{(condition):1,n\}`.
> 4 votes

# Answer
For functions that use `\operatorname{(function name)}`, you can simply take out the entire `\operatorname` part and use the `(function name)`. For example, instead of `\operatorname{total}`, you can simply write `total`.
> 3 votes

# Answer
# Use the dot calls of built-in functions

For most list built-ins that don't require any arguments, they can be called using dot calls instead.

Let's say that the built-in function is called `f`, and the list is `L`. You can then use a dot call to use the function like `L.f` (3 bytes) instead of `f(L)` (4 bytes), which saves 1 byte. For example, instead of using `mean(L)`, you can instead use `L.mean` for -1 bytes.

Here is some examples of dot calls being used on a list, and you can find a full list of the built-in functions that allow for dot calls here (Find the folder that is named "Functions that allow dot call"). Note that the full list does put parentheses `()` after the dot call (like `L.mean()`), but that can be taken out (`L.mean` works).
> 3 votes

# Answer
# Regressions

A regression can be used to solve an equation and can be shorter than explicitly typing out the expression for its solution.

For example, the golden ratio can be calculated in 6 bytes, `aa-a~1`, with the result being stored in `a`, which is shorter than the 11-byte equivalent `5^{.5}.5+.5`.
> 3 votes

# Answer
When constructing a list with `...`, commas can usually be eliminated. For example, one might write `[0,...,9]` if they did not know about this, but you can actually save 2 bytes by writing `[0...9]` instead.

In cases where you want to specify the second element(to set your own common difference), the comma is only required between the first and second element. For example, instead of `[0,2,...,50]`, you can write `[0,2...50]` instead.

Basically, you can replace `,...,` with `...` to save 2 bytes.
> 2 votes

# Answer
### List comprehension tips

If you are unaware, a new feature has been released in Desmos a few months ago: list comprehensions

They are similar to Python list comprehensions, where you can essentially use loops to construct lists. This functionality now allows us to be able to emulate nested for loops in Desmos, which was previously much harder to do.

List comprehensions follow the below form:

```
[(expression in terms of var1, ... ,varN) for var1 = (list1), var2 = (list2), ... , varN = (listN)]

```

This will construct a list by looping through each `var1, var2, ... , varN` in a nested fashion.

There are some golfs you can do to save bytes in list comprehensions.

Let's take a simple list comprehension below:

```
\left[\left(a,b\right)\operatorname{for}a=\left[1...10\right],b=\left[1...10\right]\right]

```

Like any other function, you can simply take out the `\operatorname` from the `for` and it will still work. So all in all, you have something like this:

```
[(a,b)fora=[1...10],b=[1...10]]

```

Even though the `for` and `a` are together, Desmos will still be able to distinguish between them.

---

A quirk with list comprehensions (and nested for loops in general) is that you will actually get different lists based on the order of each list. Here's an example to illustrate my point (obviously not golfed completely for readability):

```
[a+b for a = [1,2,3], b = [2,4,6]] --> [3,4,5,5,6,7,7,8,9]
[a+b for a = [2,4,6], b = [1,2,3]] --> [3,5,7,4,6,8,5,7,9]

```

(Graph)

Generally, a list comprehension is generated following the pseudocode below (using the general list comprehension form that I mentioned earlier):

```
SET result to empty list

FOR each varN in (listN)
    .
     .
      .
    FOR each var2 in (list2)
        FOR each var1 in (list1)
            ADD (expression in terms of var1, ... , varN) to the end of result
        END FOR
    END FOR
      .
     .
    .
END FOR

PRINT result

```

A certain ordering of the lists can potentially save a few bytes over another if a code golf challenge requires the list output to be ordered in a certain way.
> 2 votes

# Answer
# Removing `\left`'s and `\right`'s from piecewise expressions

(A clarification of this tip that's been edited to oblivion)

When using a piecewise expression, you may have noticed that if you took out the `\left` and `\right` from a piecewise expression, it doesn't work. So, for example, the following doesn't work when directly pasted into Desmos:

```
\{x<0:x,x^3\}

```

But if you include the `\left` and `\right`, it does work:

```
\left\{x<0:x,x^3\right\}

```

To fix this issue, you can add a newline in front of the expression that includes the piecewise. In our case, the code to paste into Desmos is:

```

\{x<0:x,x^3\}

```

Even though the actual expression doesn't render properly, the graph of the piecewise expression should still show. Note that the piecewise expression will be fragile, which means that while you have selected the expression, most button presses (including buttons like `Ctrl`) will break the code.

---

The downside of doing this trick is that every built-in function with the expression that includes the piecewise is not recognized by the Desmos parser. That means that you have to add a `\` in front of every built-in function to force Desmos to recognize it as a built-in function, adding one byte per built-in. For example, the following code won't work:

```

f(l)=min(\{l=0:l.max,l\})

```

But the following code does work:

```

f(l)=\min(\{l=0:l.\max,l\})

```

As a result, if you use too many built-in functions in the same expression as a piecewise expression, you should consider another approach that doesn't involve any piecewise expressions.

For example, consider the following code (it doesn't do anything useful, but it has a whole bunch of built-in functions):

(64 bytes)

```

f(l)=\{\sort([1...l.\max+1],\join(l,2,3,l.\mean))=l.\median,0\}

```

It can be shortened by doing the following:

(60 bytes)

```
f(l)=0^{(sort([1...l.max+1],join(l,2,3,l.mean))-l.median)^2}

```

---

Overall, code in the form:

```

\{a=b,0\}

```

which includes \\$k\\$ built-in functions, can be shortened to:

```
0^{(a-b)^2}

```

given that \\$k\ge2\\$. It will save \\$k-1\\$ bytes.

Similarly, code in the form:

```

\{a=b:0,1\}

```

which includes \\$k\\$ built-in functions, can be shortened to:

```
1-0^{(a-b)^2}

```

given that \\$k\ge2\\$. It will save \\$k-1\\$ bytes.

These are just two common examples. Techniques will vary based on what you are trying to do.

---

Because of this, code that includes piecewise expressions usually will have to be pasted in one expression at a time. This is because if you paste the entire code at once, expressions that don't have a piecewise expression in them will still have to include `\`'s in front of every built-in function in order to work. If you instead paste in the expressions that include piecewise expressions separately, you can avoid this issue.

For example, consider the following code:

```
L=l.length
f(l)=\{\sort([1...L],l)<L/2,0\}

```

If you paste this entire code into Desmos all at once, it will not work, because it expects a `\` in front of `length`.

But if you first paste in:

```
L=l.length

```

Then paste in:

```

f(l)=\{\sort([1...L],l)<L/2,0\}

```

The code will work.
> 2 votes

# Answer
# Counting the number of digits of a number

The number of digits of a non-negative integer `n` is:

(19 bytes)

```
floor(log(n+0^n))+1

```

This works because when Desmos calculates a number to the power of zero, it will automatically convert the entire exponential term to 1. We use this to our advantage with `0^n`, which returns 1 for `n=0` (because any number to the power of 0 is calculated as 1, even though the base is 0), and returns 0 for any positive integer.

If `n` is guaranteed to be a positive integer (`n` can't be zero), then the formula becomes:

(13 bytes)

```
floor(logn)+1

```

If you need to find the number of digits of any integer `n`, then the formula is:

(28 bytes)

```
k=abs(n)
floor(log(k+0^k))+1

```

<sup>^ (Could probably be shorter but I can't see it at the moment)</sup>
> 1 votes

---
Tags: code-golf, tips
---


title: Output code-sized Lorem Ipsum

text:
# Question
Title: Output code-sized Lorem Ipsum
Output the same length of Lorem ipsum your code is!

Rules:

* Code can't be identical to output
* No compression libraries
* Shortest program in two weeks wins
* No network usage, file reading and other tricks which with one could easily solve any code golf problem (with `eval`, `exec`, etc)

Example

```
Your code with length 25.

```

Output

```
Lorem ipsum dolor sit ame

```

# Answer
> 9 votes
## GolfScript (122 or 138 bytes)

There seems to be a very small ambiguity in the rules: what precisely does "output" mean? Many programs assume that the "output" of a program doesn't include a final newline, which is there to ensure that the next line of the shell input begins on a separate line.

```
00000000  27 80 38 6e df 07 55 f7  a7 8f c0 42 9d dc 1e e7  |'.8n..U....B....|
00000010  7d 48 9a 88 79 03 92 c1  fb ed 8a af 51 92 52 24  |}H..y.......Q.R$|
00000020  2c b7 0b 17 d4 eb dc b0  d8 ce 8c 82 0f 94 0d 18  |,...............|
00000030  42 71 58 8a dd e6 b9 70  9b 48 74 f5 f0 70 c2 bb  |BqX....p.Ht..p..|
00000040  e0 5b 1d e1 f2 a7 29 3e  87 b4 f0 4d 3a 22 5c 71  |.[....)>...M:"\q|
00000050  55 3d d1 fd 77 12 e2 52  73 24 89 00 9b c3 e5 47  |U=..w..Rs$.....G|
00000060  0c b4 17 1a 27 32 35 36  62 61 73 65 20 39 30 62  |....'256base 90b|
00000070  61 73 65 7b 33 32 2b 7d  25 2b                    |ase{32+}%+|
0000007a

```

is 122 bytes and outputs 122 bytes of lorum ipsum and a trailing newline.

```
00000000  27 75 24 b6 ac 4e 36 10  aa 62 7f 2b 35 67 cc ee  |'u$..N6..b.+5g..|
00000010  c2 fa d4 9a 7a 54 96 e9  f0 0b 38 58 63 79 97 f8  |....zT....8Xcy..|
00000020  d5 7e 8a bc 4e e6 9b ee  88 ed f0 87 b5 9e 78 8c  |.~..N.........x.|
00000030  ff 4e ac 59 49 d5 71 f1  94 51 f5 4e 6a 58 57 24  |.N.YI.q..Q.NjXW$|
00000040  f6 4a 07 40 d6 06 bb a3  34 55 8d 83 aa ce d4 41  |.J.@....4U.....A|
00000050  46 04 26 c7 ef e2 f7 00  a2 61 a9 d2 40 8c 00 d9  |F.&......a..@...|
00000060  78 9a a7 53 d6 ea 85 16  23 fd c6 2c 8d a6 cb 09  |x..S....#..,....|
00000070  0a 27 32 35 36 62 61 73  65 20 39 30 62 61 73 65  |.'256base 90base|
00000080  7b 33 32 2b 7d 25 2b 3a  6e 3b                    |{32+}%+:n;|
0000008a

```

is 138 bytes and produces 138 bytes of lorum ipsum with no trailing newline.

# Answer
> 13 votes
# rot13 (1)

i'm surprised nobody came up with this before :)

```
Y

```

and as a bonus, a very simple perl solution

# Perl (252)

```
s//LoremIpsumDolorSitAmet,ConsectetuerAdipiscingElit,SedDiamNonummyNibhEuismodTinciduntUtLaoreetDoloreMagnaAliquamEratVolutpat. UtWisiEnimAdMinimVeniam,QuisNostrudExerciTationUllamcorperSuscipitLobortisNislUtAliquipExE/;s,([^ ])([A-Z]),$1$"\l$2,g;print

```

# Answer
> 8 votes
# Golfscript - 161

Edit: python solution output a different length than its own, so I did a better one with golfscript. This is also my first golfscript answer.

```
[' ,.LUabcdeghilmnopqrstuvwy''zä{~4ú›Úˆ2©JfÖØélq¤öäpDÎ;bÐô(;ÆXÔZo´dZ]e§B¥×ûba(šX†Cf½ÇUÃ0~3i‰d<Ú{¡º¯ŠÛ„å4B9W}˜$ûã–'{1-}%255base{.26%@.@=\@26/.}do;;]''+

```

I'm not sure how this is encoded here, so here is a link to the file.

# Answer
> 7 votes
# Mathematica, 8

I make the assumption that *visually* identical output is acceptable. I therefore use this character in place of ASCII "i" which causes the two Symbols to be automatically sorted in the correct order:

```
іp*Lorem

```

> ```
> Lorem іp
>
> ```

# Answer
> 5 votes
# Python 2 - 332

```
print''.join([x,'tmoi eiidoqa  ua  lde  rsernponutsatmnci  '[ord(x)%21::21]]['.'<x<'D']for x in'LAe@1su@2lA6i?9et,;3sectetu/7d1Bc0gC<t,6e=di9:3ummy:ibhCuBmo=t0cidun?8 laAee?2lA>magna7<49Cr5 vol8p5. U?wBiCni@a=m0i@veni9, 4B:ostru=ex/ci t5i3 ull9cAp/6usc1i?lobAtB:Bl 87<41CxCa;ommo2;3se45. DuB78e@velCu@iriur>2lA 0 hendr/i?0 vulp85>')

```

If anybody cares, here's a partial list of improvements:
1181 -\> 630 -\> 549 -\> 510 -\> 456 -\> 416 -\> 381 -\> 332

# Answer
> 3 votes
## Bash, 156

Because using a real "compression library" is forbidden, I'll abuse `base64` from coreutils instead. (`xxd -r` to decode submission)

```
0000000: 7461 696c 202d 3120 2430 7c62 6173 6536  tail -1 $0|base6
0000010: 3420 2d77 307c 7472 2058 595a 205c 202c  4 -w0|tr XYZ \ ,
0000020: 2e0a 6578 6974 0a2e 8ade 9978 a9b2 e997  ..exit.....x....
0000030: 7689 68ad 7b22 b576 a67a d617 7289 ec79  v.h.{".v.z..r..y
0000040: cb5e b6e7 ab5d a762 a62b 1c8a 7817 7a58  .^...].b.+..x.zX
0000050: ad61 7b1e 7577 626a 65e7 a27b a69b 25e7  .a{.uwbje..{..%.
0000060: 89b8 577a e8ac 9a87 57b6 29dc 89db a7b5  ..Wz....W.).....
0000070: 7bad 5e56 a8ad e7ad 5dda 25a2 b797 99a8  {.^V....].%.....
0000080: 2769 76a5 8aab 9a99 77ab 6ad5 efa2 5bad  'iv.....w.j...[.
0000090: a5ab 595d 4b57 c22b 225d e9e2            ..Y]KW.+"]..

```

I generated the above code using this PHP program:

```
<?php

$lorem = '<text here>';

$enclorem = base64_decode( strtr( $lorem, ' ,.', 'XYZ' ) );

$prog = "tail -\$3 \$0|base64 -w0|tr XYZ \\ ,.\nexit\n$1";

for ( $i = 0, $n = strlen( $lorem ); $i < $n; $i++ ) {
    $cutlorem = substr( $lorem, 0, $i );
    for ( $j = 0, $o = strlen( $enclorem ); $j < $o; $j++ ) {
        $cutenclorem = substr( $enclorem, 0, $j );
        if ( substr( strtr( base64_encode( $cutenclorem ), 'XYZ', ' ,.' ), 0, $i )  === $cutlorem ) {
            break;
        }
    }
    $out = strtr( $prog, array(
        '$1' => $cutenclorem,
        '$2' => $i,
        '$3' => substr_count( $cutenclorem, "\n" ) + 1,
    ) );
    echo "\$i=$i strlen(\$out)=" . strlen( $out ) . "\n";
    if ( $i === strlen( $out ) ) {
        break;
    }
}

echo "\nHexdump:\n";
$p = popen( 'xxd', 'w' );
fwrite( $p, $out );
pclose( $p );

echo "\nFinal output check: ";
$tmp = tmpfile();
fwrite( $tmp, $out );
$md = stream_get_meta_data( $tmp );
ob_start();
passthru( 'bash ' . escapeshellarg( $md['uri'] ) );
$buf = rtrim( ob_get_clean() );
echo $buf === substr( $lorem, 0, strlen( $out ) ) ? 'PASS' : 'FAIL', "\n$buf\n";

```

# Answer
> 1 votes
# Mathematica 47 46 44

With 2 bytes saved thanks to Imanton1

Not sure if this is fair play. Mathematica has the 'full' text of Lorem ipsum in its example data. The following simply tells Mathematica to take a string of a particular length from the built-in example of Lorem Ipsum.

```
#@#["Text"][[19]]&@ExampleData~StringTake~44

```

> "Lorem ipsum dolor sit amet, consectetuer adi"

# Answer
> 1 votes
# Windows batch, 878 720

Tested on Windows XP and Windows 7, but should work for every cmd with extensions (IIRC, Windows NT and later).

Has to be run using `CMD /V:ON /C batchfile` to turn on delayed variable extension, but I prefer that to having non codegolf friendly `SETLOCAL EnableDelayedExpansion` inside the batch file.

```
@ECHO OFF
SET A=Lore2ipsu21 si0amet,6ctetu7 adip3cing4lit, sed dia2nonummy nibh4u3mod tincidun0u0laoree018magna aliqua27a0volutpat. U0w3i4ni2ad mini2veniam, qu3 nostrud4x7ci tation ullamcorp7 suscipi0lobort3 n3l u0aliquip4x4a commodo6quat. Du3 aute2vel4u2iriur81 in hendr7i0in vulputat8veli0ess8molestie6quat, vel illu21e4u feugia53 a0v7o4ros40accumsan40iusto odio dign3si2qui blandi0praesen0luptatu2zzril deleni0augu8du3 18t8feugai5i. Na2lib7 tempor cu2soluta nob34leifend option congu8nihil imp7die0doming id quod mazi2plac7a0fac7 possi2assum. Typi non haben0claritate2insitam;4s0usus legent3
FOR %%I IN ("8=e ","7=er","6= conse","5=0nulla facil3","4= e","3=is","2=m ","1=dolor","0=t ") do SET "A=!A:%%~I!"
ECHO %A%

```

# Answer
> 1 votes
## J (144)

Would've been 128 if I hadn't needed to make it a proper script so you can measure the output.

```
exit[stdout'utsrponmligfedcbaVLI., '{~#._5>\,#:a.i.'�F��$f����`kg�c������$NI�f!!��`�L�:����l���5l�0A����Fـ���T�X ��@g�I�`��'

```

How it works: there are only 23 unique characters in the text, so this can be represented in a 5-byte encoding. The characters in the encoded string are converted to their ASCII numbers (`a.i.`), then each of the numbers is turned into their base-2 representation (`#:`), then the bits are grouped in groups of five (`_5>\,`), then each of these groups is converted to its value (`#.`), and these are used as an index into the lookup table. (`{~`).

The lookup table actually needed some tinkering, because a J string literal cannot contain `\n`, `\r` or `\0`.

Hexdump:

```
0000000: 7865 7469 735b 6474 756f 2774 7475 7273
0000010: 6f70 6d6e 696c 6667 6465 6263 5661 494c
0000020: 2c2e 2720 7e7b 2e23 355f 5c3e 232c 613a
0000030: 692e 272e 4691 d9c3 1024 660f 0595 841d
0000040: da90 6007 676b c214 8263 81c0 b483 921a
0000050: 4e24 9549 2166 a521 60a6 4cb1 8c1d 3a03
0000060: 02d0 ca80 6cd9 9302 d800 35c5 c56c 4130
0000070: ac80 d600 00c3 0346 80d9 88ad 8001 b454
0000080: 2058 e0a5 0f40 1467 49cd 60d8 e080 0a27

```

# Answer
> 1 votes
# 05AB1E, 12 bytes

```
.•ÿ₆∊ÃÌ¦R•.ª

```

Try it online!

```
.•ÿ₆∊ÃÌ¦R•.ª  # full program
.•ÿ₆∊ÃÌ¦R•    # "lorem ipsum "...
          .ª  # in sentence case
              # implicit output

```

# Answer
> 1 votes
# LaTeX \+ lipsum, 125 bytes

```
\documentclass[12pt]{article}
\usepackage{lipsum}
\pagenumbering{gobble}
\begin{document}
    \lipsum[1][1-2]
\end{document}

```

Output:

> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.

# Answer
> 0 votes
# FEU, 545 bytes

```
a/Lorem ipsum dolor sit amet!consectetuer adipiscing elit. Integer nunc augue!feugiat non!egestas ut!rutrum eu!purus. Vestibulum condimentum commodo pede. Nam in metus eu justo commodo posuere. Nunc varius dui id nulla. Fusce porttitor pretium leo. Quisque in diam. Nulla pellentesque. Donec vitae urna et arcu lobortis varius. Aenean velit eros!varius ac!semper sit amet!lacinia eget!sem. Phasellus mollis nunc a pede cursus fermentum. Proin et odio. Nullam turpis. Fusce eget arcu. Mauris placerat ultricies lectus. Nullam pede nisl!u
s/!/, /g

```

Try it online!

It just so happened to work.

# Answer
> 0 votes
# Vyxal, 5 bytes

```
`Lo≥›

```

Try it Online!

# Answer
> 0 votes
# Perl 5 \+ `-M5.10.0`, 35 bytes

If anything that starts `Lorem ipsum` is acceptable this should work:

```
say"\u@{[<'{,do}lor{em ipsum,}'>]}"
```

Try it online!

---

# Perl 5 \+ `-M5.10.0`, 42 bytes

However if it needs to start `Lorem ipsum dolor sit amet`, you'll need this:

```
$}=" dolor sit ame";say"Lorem ipsum$}t,$}"
```

Try it online!

---

# Perl 5 \+ `-M5.10.0`, 72 bytes

But, if it needs to start `Lorem ipsum dolor sit amet, consectetur adipiscing elit.`, then I think this is the shortest I can manage:

```
$}="Lorem ipsum do";say"$}lor sit amet, consectetur adipiscing elit. $}"
```

Try it online!

---
Tags: code-golf, string, compression, self-referential
---