title: Missing Odd Numbers

text:
# Question
Title: Missing Odd Numbers
A set of whole numbers (0-) will be given separated by a space. Some numbers will be missing between certain numbers in the set. Your job is to find the missing odd numbers between them.

## Conditions

1. The input will be a one line string.
2. Your code must left out a variable for inserting the input case string.
3. The output should be a **string** containing all the missing odd numbers in the set of numbers given as input.
4. **The numbers of the output must be separated by a comma - `,`**.
5. No extra characters should be included in the output.
6. If there are no odd numbers missing, the code should print out `null` or a blank line.

Here are some sample inputs and outputs according to its order :

## Input

```
4 6 8 10
5 15 18 21 26
2 15 6
1 20
1 3 5 7 9

```

## Output

```
5,7,9
7,9,11,13,17,19,23,25
3,5,7,9,11,13
3,5,7,9,11,13,15,17,19
null

```

The winner will be decided by the Code length.

**The calculation of code length won't include the variable that is left for the test case.**

# Answer
## GolfScript (20 chars)

```
~]$),\(),+-{1&},','*

```

Online demo

Dissection:

```
~]$   # Eval the string, wrap the resulting integers in an array, sort
),    # Extract the max and make an array A of 0 to max-1 inclusive
\(),  # Extract the min and make an array B of 0 to min inclusive
+-    # Combine B with the remaining numbers from the input and remove them from A
{1&}, # Filter A to odd numbers
','*  # Comma-separate

```
> 3 votes

# Answer
# Ruby, 74

```
s="insert your numbers here" # this line not counted per the rules
n=s.split.map &:to_i
puts (n.min..n.max).select{|x|x%2==1&&!n.index(x)}*?,

```

Output is identical to examples in question except that it outputs a blank line for no numbers found.
> 10 votes

# Answer
## Python, 82 chars

```
N=map(int,I.split())
R=','.join(`x`for x in range(min(N)|1,max(N),2)if x not in N)

```

Set `I` to your input string, `R` is the output string.
> 3 votes

# Answer
# Groovy, ~~92~~ ~~79~~ 72 chars

```
x=args; //Input does not count
x=x*.toInteger();print((x.min()..x.max()).minus(x).grep{it%2}.join(","))

```
> 3 votes

# Answer
# C#, 205 characters: 222 (total count) - 17 (total length of variable)

```
namespace System.Linq{class A{static void Main(){var a="4 6 8 10";var b=a.Split(' ').Select(int.Parse);Console.WriteLine(String.Join<int>(",",Enumerable.Range(b.Min(),b.Max()-b.Min()).Where(x=>x%2==1&&!b.Contains(x))));}}}

```

**Ungolfed code:**

```
namespace System.Linq
{
    class A
    {
        static void Main()
        {
            var a = "4 6 8 10";
            var b = a.Split(' ').Select(int.Parse);
            Console.WriteLine(String.Join<int>(",", Enumerable.Range(b.Min(), b.Max() - b.Min()).Where(x => x % 2 == 1 && !b.Contains(x))));
        }
    }
}

```

How it works: first, it splits the input string and parses each number into an integer. Then, it creates a range from the minimum occuring integer to the maximum and it takes all odd integers which do not occur in the input string.
> 2 votes

# Answer
# PHP 106

```
<?
$a = '4 6 8 10';
$a=split(' ',$a);foreach(range(min($a),max($a))as$i)if($i%2&&!in_array($i,$a))$d[]=$i;echo join(',',$d);

```

i'm not sure about what to discount from the char count, so i just discounted the line with the declaration
> 2 votes

# Answer
# ised, 23 characters (16 code + 7 flags)

This is what ised is best at!

```
ised --d, --l input.dat 'O[min$1max$1]\$1'

```

Not counting the name of the file (which could be replaced by `-` for standard input), this clocks in at 23 characters plus program name plus punctuation needed for spacing the command line arguments. The actual code is just `O[min$1max$1]\$1`.

Explanation: `--d,` sets the output delimiter. `--l <file>` signifies that the following code is applied to each line. `$1` represents the current line. The min and max elements are used to initialize the sequence constructor `[]`. `O` selects the odd numbers. `\$1` is the set-wise *without* operator, which removes the already given numbers from the generated sequence.

Please clarify how the characters should be counted. Does the name `ised` of the command count or not?
> 2 votes

# Answer
# PHP, 110 chars

```
$a=split(' ',$i);echo join(',',array_filter(array_diff(range(min($a),max($a)),$a),function($n){return$n&1;}));

```

More readable version:

```
$a = split(' ', $i);
echo join(',',
    array_filter(
        array_diff(
            range(min($a), max($a)),
            $a
        ),
        function($n) {
            return $n & 1;
        }
    )
);

```

This basically creates an array of all the numbers within the range and uses a bitwise `$n & 1` to check if the number is even or odd.

**Demo**
> 2 votes

# Answer
# Pyth, 20

```
JSrz7j\,-f%T2rhJeJJ

```

`J` is the list of integers, sorted. `rhJeJ` gives all of the possible integers between the min and max of the input. `f%T2` filters out the even numbers. `-_J` filters out the original elements of J. `j\,` joins the resultant list on commas, and the string is automatically printed.
> 2 votes

# Answer
In the spirit of @Kevin Cruijssen's answer:

# Vyxal, 7 bytes (flexible I/O)

```
₌htṡF'∷

```

```
₌ht      # push head and tail of input
   ṡ     # range(a, b + 1)
    F    # filter by elements not in input
     '∷  # filter by odds

```

Try it Online!

# Vyxal, 15 bytes (exact I/O)

```
⌈vI:₌htṡF'∷;\,j

```

Same principles, but `⌈vI:` takes input as a space separated list, and `\,j` formats the list to be comma separated.

Try it Online!
> 2 votes

# Answer
# Javascript (E6) 100 ~~110~~

Edit: join in output is unnecessary (stolen from nderscore but too obvious)
Edit2: see comments
Edit3: fixed bug, skip min if odd
Edit4: teamwork ... (loop for every number, then inside loop skip even ones)

```
t='13 15 20 2'; /* Not counted */
l=t.split(' ').sort((a,b)=>b-a);for(n=l.pop(o=[]);++n<l[0];)n%2&!l.some(x=>x==n)&&o.push(n);alert(o)

```
> 1 votes

# Answer
# GolfScript, ~~51~~ 40 characters

```
' '/{~}/]$:a),\(,\;-{.2%\a?-1=&},{','}/;

```

Input should be on STDIN. Test online

If input on STDIN is not allowed, then changing it so it allows variables only adds 1 character.

Ungolfed code with explanation:

```
' '/ # split input string
{~}/ # convert all strings into integers
]$   # put integers into an array and sort it
:a   # put array into variable a
)    # take last element from array
,    # create an array from 0 to the integer obtained from previous command
\    # swap new array and first array, first array is now on top
(    # take first element from first array
,    # create an array from 0 to the integer obtained from previous command
\;   # swap newest array and first array, and remove first array
-    # remove elements from second array if they also occur in third (newest) array
{    # this block will be used to process elements in the array
  .   # duplicate current item twice
  2%   # obtain the remainder when dividing it by 2
  \    # swap remainder and one of the duplicates
  a?   # obtain the index of the current item in the first array which is stored in variable a
  -1=  # check if index is -1 (the item is not found)
  &  # returns 1 if it is a missing odd number
},   # filter contents of array, only keep missing odd numbers
{','}/;  # separate results with commas

```
> 1 votes

# Answer
# Javascript (*ES6*) - 85

Edit: Undeleted, as I found a solution that's different enough from edc65's to justify it's own answer.

```
i='13 15 20 2' // input is not part of byte count
o=[];i.split(' ').sort((a,b)=>a-b).sort((a,b)=>{for(;++a<b;)a%2&&o.push(a)});alert(o)

```

Ungolfed / Commented:

```
o=[];               // array for output
i.split(' ').       // split input by spaces
  sort((a,b)=>a-b). // sort by numeric order
  sort((a,b)=>{     // abuse sort as a way to run a function on every pair of neighboring
                    // values the array in order
    for(;++a<b;)    // loop from a+1 to b-1
      if(a%2)       // if odd
        o.push(a)   // push to array
  });               // the sort function returns nothing, so the order of the array is
                    // unchanged and no pair is compared twice
alert(o)            // the array is cast to a string, which is comma separated by default

```
> 1 votes

# Answer
# J - 42 char

```
}.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:4 6 8 10

```

I exclude from the character count the `=:4 6 8 10` portion, but I include the `n` because that's part of the rest of the code—assignments can have return values in J.

Explained by explosion:

```
}.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:4 6 8 10  NB. missing odd numbers
                                         n=:4 6 8 10  NB. input assigned to n
                                      >./n            NB. maximum of n
                                  i.1+                NB. integers from 0 to max(n) incl.
                          (<./n)                      NB. minimum of n
                                }.                    NB. drop first min(n) values
                       l=.                            NB. assign this to l
                     2|                               NB. modulo 2: 0 for evens, 1 for odds
                  l#~                                 NB. keep the odd numbers from l
              n-.~                                    NB. discard numbers already in n
   (      )&.>                                        NB. for each number:
        ":                                            NB.   convert to string
    ',',                                              NB.   and prepend a comma
  ;                                                   NB. run together all results
}.                                                    NB. remove leading comma

```

Example usage:

```
   }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:4 6 8 10
5,7,9
   }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:5 15 18 21 26
7,9,11,13,17,19,23,25
   }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:2 15 6
3,5,7,9,11,13
   }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:1 20
3,5,7,9,11,13,15,17,19
   }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:1 3 5 7 9    NB. blank line

   # }.;(',',":)&.>n-.~l#~2|l=.(<./n)}.i.1+>./n=:1 3 5 7 9  NB. see? length is 0
0

```
> 1 votes

# Answer
# PowerShell, ~~101~~ ~~99~~ ~~95~~ ~~91~~ ~~78~~ 58 chars

```
$a=$args #input doesn't count
$a=$a|sort;($a[0]..$a[-1]|?{$_%2-and!($a-like$_)})-join','

```

It outputs the same results as the example, and new line if there are no odd numbers missing.

Ungolfed code:

```
#input doesn't count
$a=$args
# Sort input array
$a=$a | sort;
# Loop from numbers starting at first (min) and ending at last (max) elements of array
($a[0] .. $a[-1] | ?{
    # Ouptup if element is even and is not contained in original input array
    $_ % 2 -and !($a -like $_
# Print output elements joined by ","
})-join','

```
> 1 votes

# Answer
# PHP, 118 chars

```
// $n='4 6 8 11 14';
$o=[];$a=explode(' ',$n);foreach(range(min($a),max($a))as$b)if($b%2!=0&&!in_array($b,$a))$o[]=$b;echo implode(',',$o);

```

Expanded...

```
// Empty array to hold the output
$o = [];

// Put each number in a zero indexed array
$a = explode(' ', $n);

// Iterate through each number between the smallest number and the largest number, inclusive
foreach(range(min($a), max($a)) as $b) {

    // If the number is not even and it's not one of the numbers in the input,
    // then add it to the output array
    if ($b % 2 != 0 && !in_array($b, $a)) {
        $o[] = $b;
    }
}

// Glue the numbers in the output array together with a comma
echo implode(',', $o);

```
> 1 votes

# Answer
# Java: 173

```
public class R{
    public static void main(String[]a){
        int i=0,p=0;
        for(String s:a){
            int j=new Integer(s);
            i=i==0?j:i;
            while(++i<j)
            if(i%2==1)
                System.out.print((p++==0?"":",")+i);
        }
    }
}

//Compressed:
public class R{public static void main(String[]a){
int i=0,p=0;for(String s:a){int j=new Integer(s);i=i==0?j:i;
while(++i<j)if(i%2==1)System.out.print((p++==0?"":",")+i);}}}

```

To run:

```
java R 5 15 18 21 26

```

Produces:

```
7,9,11,13,17,19,23,25

```
> 1 votes

# Answer
## PowerShell - 59

This creates an array of integers bounded by the max and min values in the array of arguments and sends it through the pipeline. It then passes through the numbers that are odd and not in the array of arguments.

```
$x=$args|sort;($x[0]..$x[-1]|?{$_%2-and$_-notin$x})-join','

```
> 1 votes

# Answer
## Haskell, 137 chars and almost no spaces

```
import Data.List
main=let n=(map read(words$s)::[Int])in putStr$intercalate","$map show$(filter(\x->x`mod`2==1)[minimum n..maximum n])\\n

```

I love how Haskell doesn't give one crap about spaces.

Put the string in a function `s`
> 1 votes

# Answer
# Perl 6, 60 50 bytes (55 47 chars)

HT to JoKing for shrinking it down a substantial number of bytes (mainly via the odd number generation and rearranging to kill some parentheses)

```
{join ',',keys (.min..^.max X+|1)∖$_}o+«*.words

```

Try it online!

Original answer:

```
(+«*.words).&{(.min+|1,*+2…*>.max-2)∖$_}.keys.join(',')

```

Try it online!

Here's the explanation for it:

```
(+«*.words)                                             # numberize each word in input (*)
           .&{                         }                # pass them to an inline method to
                                    ∖                   #   find the set difference of
              (       ,*+2…        )                    #     all odd numbers from
               .min+|1                                  #       1st (bitwise OR 1) to
                           *>.max-2                     #       last (first odd > max-2)
                                     $_                 #     and the original number set
                                        .keys.join(',') # print final values (.keys is
                                                        #     needed for quirk with Set)

```

If the output were just spaces, could use `.Str`instead of `.keys.join(',')`, but directly using `.join` on Set grabs the internal Bool values. I'm legitimately surprised there wasn't anything much smaller, but the input/output requirements really killed options
> 1 votes

# Answer
# 05AB1E, ~~20~~ 13 bytes

```
#DZÅÉsWL«K',ý

```

Matching the specs exactly.. Input as space-delimited string, output as comma-separated string, or a blank line if no odd integers are found.

Try it online or verify all test cases.

**With flexible/reasonable I/O rules this would be 8 bytes:**

```
ZÅÉsWL«K

```

Input as list, output `[]` if no odd integers are found.

Try it online or verify all test cases.

**Explanation:**

```
#               # Split the (implicit) input-string on spaces
 D              # Duplicate this list
  Z             # Get the maximum (without popping the list itself)
   ÅÉ           # Create a list of all positive odd integers in the range [1, max]
     s          # Swap so the input-list is at the top of the stack again
      W         # Get the minimum (without popping the list itself)
       L        # Create a list in the range [1, min]
        «       # Merge it with the input-list
         K      # Remove all values in this list from the odd list we created earlier
          ',ý  '# Join the result by ","
                # (and output the top of the stack implicitly as result)

```
> 1 votes

# Answer
# Ruby, 73

```
a=$*.map &:to_i;$><<(a.min..a.max).select{|n|n%2>0&&!a.index(n)}.join(?,)

```
> 0 votes

# Answer
# Perl, ~~88~~ ~~76~~ ~~74~~ ~~68~~ ~~63~~ 60 chars

```
@x=@ARGV; # Input doesn't count
sort{$a<=>$b}$x;say join",",grep{$_%2&"@x"!~$_}$x[0]..$x[-1]

```

This can be tested on console as:

```
perl -E '@x=@ARGV;sort{$a<=>$b}$x;say join",",grep{$_%2&"@x"!~$_}$x[0]..$x[-1]' 1 20

```

It outputs the same results as the example, and new line if there are no odd numbers missing.
> 0 votes

# Answer
## R, 59 chars:

```
b=range(a<-scan());d=b[1]:b[2];cat(d[!d%in%a&d%%2],sep=",")

```

Expanded a little:

```
a=scan() #Takes serie of integers as input
b=range(a) #Takes min and max
d=b[1]:b[2] #Creates sequence from min to max
cat(d[!d%in%a & d%%2], #Keep only those that are not in input and are odd
    sep=",") #Print them comma-separated

```

Usage:

```
> b=range(a<-scan());d=b[1]:b[2];cat(d[!d%in%a&d%%2],sep=",")
1: 2 15 6
4:
Read 3 items
3,5,7,9,11,13
> b=range(a<-scan());d=b[1]:b[2];cat(d[!d%in%a&d%%2],sep=",")
1: 5 15 18 21 26
6:
Read 5 items
7,9,11,13,17,19,23,25
> b=range(a<-scan());d=b[1]:b[2];cat(d[!d%in%a&d%%2],sep=",")
1: 1 3 5 7 9
6:
Read 5 items
>

```
> 0 votes

# Answer
**VB.net** (154c)

```
Dim a = From w In i.Split(" "c) Select Int32.Parse(w)
Console.WriteLine(String.Join(",",(From n In Range(a.Min,a.Max-a.Min)
                                   Where n Mod 2 = 1).Except(a))

```
> 0 votes

# Answer
# Haskell, 105 (168 with variable+comment)

This code splits the string into 'words', reads the words as integers, and takes all of the odd numbers in the list-difference between the range of the numbers (all integers between the smallest and the largest values) and the list of numbers itself. I then convert it to a string, remove the brackets from the conversion of a list to a string, and print the line.

```
import Data.List
s="1 4 9 12 8 20" -- not counted, in accordance with the rules
main=putStrLn$show[y|let x=(map read).words$s,y<-[minimum x..maximum x]\\x,odd y]\\"[]"

```
> 0 votes

# Answer
## TinyMUSH, 129

```
&_ me=ifelse(or(eq(words(%0),1),eq(strlen(setr(0,istrue(ldiff(lnum(lmin(%0),lmax(%0)),%0,),mod(##,2),,\\\,))),0)),%r,%q0)
\u(_,X)

```

Replace the "X" in the u() function with the list of whole numbers. The output is just a carriage return when there is one list item or a lack of odds to output. Otherwise, the code constructs a list of integers starting from the lowest to the highest in the input. The code then uses ldiff() to remove from that new list anything that appeared in the input. Then evens are filtered out with mod(), and the list gets "," as the new delimiter.
> 0 votes

# Answer
# Perl 5 - 66

66 characters including 3 for command line options

```
#!perl -lpa
%F=@F=sort{$a<=>$b}@F,@F;$_=join',',grep$_&!$F{$_},"@F"..pop@F

```

Takes multiple lines of data on the standard input.
> 0 votes

# Answer
# JavaScript 89

Five less characters and better typing thanks to WallyWest.

```
s='5 15 18 21 26' // not counted
s=s.split(" ");o="";for(i=0;j=+s[i++];)for(;++j<+s[i];)o+=0!=j%2?(o?",":"")+j:"";alert(o)

```

Originally 94 chars.

```
s='5 15 18 21 26' // not counted
s=s.split(' '),o='',i=0;while(j=s[i++])for(j*=1;++j<s[i]*1;)o+=j%2!=0?(o?',':'')+j:'';alert(o)

```
> 0 votes

# Answer
# Burlesque, 41

```
ln{wdrie!r@{2.%}f[}]m{{Jrij',==$$}f[}m[uN

```

The bloated length is mostly due to mostly formatting the output.
> 0 votes

# Answer
**Haskell ~~104~~ 96 Bytes**

```
import Data.List
l=sort.map read.words
f k=putStr$show[x|x<-[l k!!0..last$l k]\\l k,odd x]\\"[]"

```

A 136 byte version using only predule

```
l=map read.words
c x=foldl1 x.l
f k=putStr$[z|z<-show[x|x<-[c min k..c max k],x`notElem`l k,odd x], z`notElem`"[]"]

```

Details

```
    --words              |Take a string and break into list (implicit application since f=words is the same as f x = words x)
    --map read           |Convert all the words to a number (the type is inferred at run time based on input)

    l=sort.map read.words

    --[l k!!0..last$l k] |Generate sequence of all numbers from lowest to highest,
    --\\l k              |Remove any numbers in list l
    --odd x              |Only return odd.
    --show               |Convert to a string
    --\\"[]"             |Remove the [] characters from the string
    --putSTr             |Finally, put the string to the terminal.

    f k=putStr$[z|z<-show[x|x<-[l k!!0..last$l k]\\l k,odd x]]\\"[]"

```
> 0 votes

# Answer
# PHP, 71 bytes

```
<?=join(array_diff(range(min($a=explode(' ',$i))|1,max($a),2),$a),',');

```

Input as predefined variable `$i`, per spec.

Try it online!

**Ungolfed / explanation:**

```
// input is from predefined variable $i
$i = '4 6 8 10';

// split space-delimited string from input into array
$a = explode( ' ', $i );

// create an array of odd numbers starting with the lowest odd number from the input
// ex: [4, 6, 8, 10] => [5, 7, 9]
//     [3, 4, 6, 7]  => [3, 5, 7]
$o = range( min( $a ) | 1, max( $a ), 2 );

// remove any numbers in the input array from the array of odds
// ex: remove [3, 4, 6, 7] from [3, 5, 7] => [ 5 ]
$b = array_diff( $a, $o );

// output array as comma-delimited string
echo join( ',', $b );

```

Or **74 bytes** with input from `STDIN`, **63 bytes** with flexible I/O.
> 0 votes

# Answer
# Wolfram Language (Mathematica), 89 bytes

```
Complement[Range[Min@#~Floor~2+1,Max@#,2],#]~StringRiffle~","&@*ToExpression@*StringSplit

```

Try it online!

This script is a `Composition` of three functions, acting from right to left on the input string:

1. `StringSplit` splits the input string into a list of substrings separated by whitespace.
2. `ToExpression` then converts this list of substrings into a list of numbers.
3. The actual work is done in the function

```
StringRiffle[Complement[Range[Floor[Min[#], 2] + 1, Max[#], 2], #], ","] &

```

* `Range[Floor[Min[#], 2] + 1, Max[#], 2]` is the list of odd numbers spanning from the smallest to the largest in the supplied list of numbers.
    * With `Complement` we eliminate those odd numbers that are already present in the supplied list of numbers.
    * What is left is then recomposed into a comma-separated string with `StringRiffle`.

A more flexible I/O format would reduce this solution to 44 bytes.
> 0 votes

# Answer
# Javascript

```
function a(e){e=e.split(" ");var t=[];for(i=1;i<e.length*2;i+=2){if(e.join(",").indexOf(i)>-1){}else{t.push(i)}}return t.join(",")}

```

Ungolfed

```
function missingOdd(str) {
    str = str.split(' ');
    var out = [];
    for (i=1; i < str.length * 2; i+=2) {
        if (str.join(',').indexOf(i) > -1) {}else{
            out.push(i);
        }
    }
    return out.join(',');
}

```
> -1 votes

---
Tags: code-golf, number
---


title: There's a hole in the bottom of the sea

text:
# Question
Title: There's a hole in the bottom of the sea
Whilst trying (and failing) have persuade my infant son to eat his dinner, I tried singing to him. Mid way through this song I realised the formulaic structure might lend itself well to code golfing!

The task is to write a program or function which accepts no input and produces the following text:

```
There's a hole in the bottom of the sea
There's a hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a log in the hole in the bottom of the sea
There's a log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a bump on the log in the hole in the bottom of the sea
There's a bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a frog on the bump on the log in the hole in the bottom of the sea
There's a frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

```

Challenge rules:

* The text may be printed or returned as function output
* Each verse is separated by a single empty line
* Trailing whitespace is OK as long as it does not change the layout (so no leading whitespace or extra spaces between words)
* Trailing newlines are OK too.
* No leading newlines.
* All languages welcomed, and this is , so the shortest answer in bytes for each language wins!

# Answer
> 23 votes
# SOGL, ~~103~~ ~~94~~ 93 bytes

```
Ψ ~Δ№Q‘η¦»vζh‛←&M⁶╥7[P≈╔6≡⁸(φΔ\⅔Σ‚>≡ā⁷⁽○¹‘Ξ⁵K4s³‘⁽Bθ2n{@∑" the ”+Κ:bΚē‽:C}TPb"n@²‘+Tō, upcPøP

```

Try it here!

```
...‘                 push "bottom of the sea" - kept for the loop, here for
    ...‘             push "hole in log in bump on frog on wart on hair on fly on flea on smile on"
        ...‘         push "there's a "
            ⁽        uppercase the 1st letter of that
             B       save "There's a " in B
              θ      split the long data string on spaces
               2n    split in arrays of length 2

{                     for each of those:
 @∑                   join the current array with spaces - e.g. "hole in"
   " the ”+           append " the " to it
           Κ          prepend that to "bottom of the sea" (or whatever it is now)
            :         create a copy
             bΚ       prepend B to it - finishes current line
               ē‽:C}  if (E++), save a copy of that in C (for the last line)

TP                   print the current line twice
  b"...‘+            B + "hole" - "There's a hole"
         T           output that, keeping item
          ō,         output ", "
             up      print the kept item lowercased
               cP    print the contents of C
                 øP  print an empty line

```

# Answer
> 19 votes
# Stax, ~~90~~ ~~87~~ 75 bytes

```
¥▌▼h4█☻■Ω1gçΔ¶Zjµ│☺X▄)/╞▄╒)¥jêLqα╧ñu┌⌂½╧ûⁿ↕O◘╔╪kl<æàbπïfuσ♪╫qΓ╪ûQ├╘Te♥Æó♣ƒE

```

Run and debug it

Unpacked, ungolfed, and commented it looks like this.

```
`;$w]i"50h1&V~OP>F$`            compressed literal for "There's a hole in the bottom of the sea"
X                               store in register X without popping
zG                              push an empty string and jump to the target (trailing })
`hfUiVx}.|j~vG12])Bxk?v zF`j    split "log bump frog wart hair fly flea smile" into array of words
F                               for each word, execute the following
  i. o. i?                      (i ? " o" : " i") where i is the 0-based iteration index
  +                             concatenate to the word
  `_o9!`+                       concatenate "n the "
  G                             jump to target below, resume next foreach iteration when finished
}                               this is the target of `G`, execution resumes when finished
  As|@                          insert substring at position 10
  QQ                            peek and print with newlines twice
  x14(                          trim string to leftmost 14 characters
  q                             peek and print without newlines
  ., p                          print ", " without newline
  vP                            lowercase 14 characters and print with newline
  xP                            push value of register X, then print with newline
  zP                            print blank line

```

Run this one

# Answer
> 16 votes
# Perl 5, ~~158~~ 154 bytes

```
$_="There's a bottom of the sea
";for$,(<{{hole,log}" i",{bump,frog,wart,hair,fly,flea,smile}" o"}>){s/a/a $,n the/;say$_.$_.($t||=s/.{14}/$&, \l$&
$&/r)}

```

154 bytes

158 bytes

# Answer
> 13 votes
# Python 2, ~~202~~ ~~190~~ ~~187~~ ~~185~~ ~~183~~ ~~182~~ 181 bytes

```
s="bottom of the sea\n"
a="There's a "
for w in'hole log bump frog wart hair fly flea smile'.split():s=w+" %sn the "%'io'['g'in s]+s;print(a+s)*2+a+"hole, t%shole\n"%a[1:]+a+s[-30:]

```

Try it online!

Old alternatives to `'io'['g'in s]` (13 bytes):

* 14: `'oi'[s[5]<'n']`
* 15: `'io'[len(s)>30]`, `'ioo'[len(s)%3]`, `'ooi'[len(s)%4]`, and `'io'[w[1]=='o']`

---

Saved:

* -1 byte, thanks to Jonathan Allan
* -1 byte, thanks to Rod
* -1 byte, thanks to Erik the Outgolfer

# Answer
> 13 votes
# C (gcc), ~~261~~ ~~246~~ 236 bytes

```
#define X" on the "
char*a="smile"X"flea"X"fly"X"hair"X"wart"X"frog"X"bump"X"log in the hole in the bottom of the sea\n";f(i){for(i=0;i<9;)printf("T%s%sT%1$s%2$sT%1$shole, t%1$shole\nT%1$s%3$s\n","here's a ",a+"_TH<0$\31\r"[i++],a+95);}

```

-15 bytes, Thanks to Daniel Schepler
-10 bytes, Thanks to ceilingcat

Try it online!

# Answer
> 12 votes
# 05AB1E, ~~103~~ ~~100~~ ~~99~~ ~~97~~ ~~96~~ ~~93~~ 92 bytes

Saved a byte thanks to *Kevin Cruijssen*

```
“¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v’T€Î's a ’s„oiN2‹èy“ÿ ÿn€€ ÿ“©“—è€‚€€í™“JDN_iDU}X14£Dl‚„, ýXõ»,®

```

Try it online!

**Explanation**

`“¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v` starts a loop over the list `["hole", "log", "bump", "frog", "wart", "hair", "fly", "flea", "smile"]`. The words are compressed using the 05AB1E dictionary.

On each we do:

```
’T€Î's a ’    # push the string "There's a "
s             # move the string from the previous iteration to the top of the stack
              # will be an empty string the first iteration since there is no input
„oiN2‹è       # push "i" for the first 2 iterations and "o" otherwise
y             # push the current word
“ÿ ÿn€€ ÿ“    # use interpolacing to create the meat of the current iteration string
              # meaning "hole in the ", "log in the hole in the " and so on
©             # store a copy in the register for the next iteration
“—è€‚€€í™“    # push the string "bottom of the sea"
JD            # join the whole line together and duplicate it
N_iDU}        # if this is the first iteration, store a copy of the line in X
X14£          # push the first 14 chars of X, which is "There's a hole"
Dl            # make a lower-case copy
‚„, ý         # join the original with the lowercase copy on ", ", forming line 3
X             # push X which is line 4
õ             # push and empty string, to create the line break between sections
»,            # join the whole section on newlines and print
®             # push the register for the next iteration

```

# Answer
> 11 votes
# PowerShell, ~~194~~ ~~188~~ ~~185~~ ~~180~~ 174 bytes

```
$z=$a="in the bottom of the sea"
$b="here's a"
$h="$b hole"
echo hole log bump frog wart hair fly flea smile|%{,"T$b $_ $a"*2
$a='oi'[!$j++]+"n the $_ $a"
"T$h, t$h
T$h $z
"}

```

Try it online!

~~Can't quite seem to catch Python...~~

Basically, sets a few common strings to `$h`, `$a`, `$z`, and `$b`, then goes through a loop through each of the items (`hole`, `log`, ... `flea`, `smile`), each iteration outputting the appropriate verse. There's a little bit of logic with `!$j++` in the middle to account for the `in`/`on` switch that happens. Otherwise, all the strings are just left on the pipeline, and the default `Write-Output` gives us newlines for free.

*-6 bytes thanks to Arnauld.*
*-3 bytes thanks to mazzy.*
*-5 bytes thanks to Veskah.*
*-6 bytes thanks to mazzy.*

# Answer
> 9 votes
# JavaScript (ES6),  ~~201 194 189 188~~  187 bytes

*Saved 1 byte thanks to @Shaggy*

```
_=>`14log4bump5frog5wart5hair5fly5flea5smile5`.replace(/.+?\d/g,w=>`T0${(p=w+3+p)+p}1, t01
T01432
`.replace(/\d/g,n=>`here's a |hole|bottom of the sea
|n the | i| o`.split`|`[n]),p=`2T0`)

```

Try it online!

---

# JavaScript (ES6), 235 bytes

Simply RegPack'ed.

```
_=>[..."Z[]^_$cdjkqvxz{}~"].reduce((p,c)=>(l=p.split(c)).join(l.pop()),`Tj{{}qq}$$}~~}dd}__}xx}cc}[[v~ frogz$}v
Z{kZz on^x flyz_v], tj]Zkq log in^{k] in^ bottom of^ seajhere's ad wartz~c fleazx$ bumpzq_ hairzd^ the] hole[ smilezcZ
Tj`)

```

Try it online!

# Answer
> 8 votes
# Bash, ~~168~~ 160 bytes

```
r="There's a bottom of the sea
";for i in {hole,log}\ in {bump,frog,wart,hair,fly,flea,smile}\ on;{
r=${r/a/a $i the};t=${r:0:14};echo "$r$r${u=$t, ${t,}
$r}";}

```

160 bytes

168 bytes

Translated from my other answer in Perl.

# Answer
> 7 votes
# Japt `-Rx`, ~~126~~ ~~116~~ ~~113~~ ~~112~~ ~~111~~ ~~109~~ 107 bytes

It turns out that golfing a string compression challenge while on your phone down the boozer is incredibly difficult - who'd've thunk?!

```
`T's»dâ ÈÞomºfdÈ a`rdS
tE8
¯E
`logn¿mpnfgnØnirnf§nf¤Úè`qÍË2ÆiAV¯E©8 iF¯E ÔqVri'oÃpW+v iSi,)UPÃc

```

Test it

```
                                              :The first 3 lines get assigned to variables U, V & W, respectively
`...`                                         :The compressed string "There'sdadholedindthedbottomdofdthedsea"
     rdS                                      :Replace all "d"s with spaces
tE8                                           :Substring of U from 0-based index 14 (E), of length 8 (="  in the ")
¯E                                            :Slice U to index 14 (="There's a hole")
`...`                                         :The compressed string "lognbumpnfrognwartnhairnflynfleasmilent"
     qÍ                                       :Split on "n" (note that the last element is irrelevant)
       Ë                                      :Map each element at 0-based index E in array F
        2Æ                                    :  Map the range [0,2)
          iA                                  :    Insert the following in U at index 10
            V¯                                :      V sliced to index
              E©8                             :        Logical AND of E and 8 (=0 on first iteration, 8 on all others)
                  i                           :      Prepend
                   F¯E                        :        Slice F to index E
                       Ô                      :        Reverse
                        q                     :        Join with
                         Vri'o                :          Replace "i" with "o" in V
                              Ã               :  End map
                               p              :  Push
                                W+            :    W appended with
                                  v           :      W lowercased
                                    iSi,      :      Prepended with a space prepended with a comma
                                        )     :    End append
                                         UP   :    U and an empty string
                                           Ã  :End map
                                            c :Flatten
                                              :Implicitly join with newlines, trim & output

```

# Answer
> 7 votes
# XML, 719 673 603 514 493 486 bytes

```
<!DOCTYPE a[<!ENTITY T "There's a"><!ENTITY O " on the"><!ENTITY a " hole in the bottom of the sea
"><!ENTITY b " log in the&a;"><!ENTITY c " bump&O;&b;"><!ENTITY d " frog&O;&c;"><!ENTITY e " wart&O;&d;"><!ENTITY f " hair&O;&e;"><!ENTITY g " fly&O;&f;"><!ENTITY i " flea&O;&g;"><!ENTITY z "&T; hole, there's a hole
&T;&a;
">]><a>&T;&a;&T;&a;&z;&T;&b;&T;&b;&z;&T;&c;&T;&c;&z;&T;&d;&T;&d;&z;&T;&e;&T;&e;&z;&T;&f;&T;&f;&z;&T;&g;&T;&g;&z;&T;&i;&T;&i;&z;&T; smile&O;&i;&T; smile&O;&i;&z;</a>

```

You can "execute" it with `xmlstarlet sel -t -m '//a' -v . -n <xml_file_here>`.

This would be a lot easier if XML wasn't so verbose, but on the bright side, this is less than 25% the size of the original text.

# Answer
> 5 votes
# Retina 0.8.2, 150 bytes

```

THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE
N
$&$'¶TH
O^$`

.+
$&¶$&¶THW, tHW¶THE¶
H
here's a
E
W iNbottom of the sea
W
hole
N
n the

```

Try it online! Explanation:

```

THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE

```

Insert the last verse.

```
N
$&$'¶TH

```

Compute all the verses.

```
O^$`

```

Put the verses in the correct order.

```
.+
$&¶$&¶THW, tHW¶THE¶

```

Complete each verse and add the chorus.

```
H
here's a
E
W iNbottom of the sea
W
hole
N
n the

```

Expand some placeholders.

# Answer
> 5 votes
# , ~~237~~ 231 bytes

```
i=" in the "
for(j in 0:8)cat(f<-c(t<-"There's a ",paste(c("log","bump","frog","wart","hair","fly","flea","smile")[j:0],collapse=" on the "),if(j)i,h<-"hole",i,b<-"bottom of the sea
"),f,t,h,", there's a ",h,"
",t,h,i,b,"
",sep="")

```

Try it online!

# Answer
> 5 votes
# PHP, ~~180~~ 178 bytes

```
foreach([hole,log,bump,frog,wart,hair,fly,flea,smile]as$w)echo$a=T.($b="here's a ").($s="$w ".io[++$i>2]."n the $s").$c="bottom of the sea
",$a,T,$b.=hole,", t$b
T$b in the $c
";

```

Run with `-nr` or try it online.

Yields warnings in PHP 7.2; to fix, put quotes around
the array elements, `io`, `hole` and the two standalone `T`.

# Answer
> 4 votes
# C (gcc), ~~334~~ ~~328~~ ~~307~~ 299 bytes

```
char*s="here's a \0smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea\n";i;k=105;a[]={0,1,1,1,1,0,1,2,2};main(j){for(;i<9;k-=11+a[i++])do{printf("T%s%s",s,s+k);}while(j++&1||!printf("T%shole, t%shole\nT%s%s\n",s,s,s,s+105));}

```

Try it online!

# Answer
> 4 votes
# Japt `-R`, 142 bytes

```
`—¤clogc¿mpcfžgcØÖŽrcf§cf¤acsÚè`qc
`ˆ e Þom  e  a`
`T”œ's a `
£W+U¯YÄ ÔËE?"io"gE<Y +`n e `:P +DÃ¸+` {V}
` ²+W+`—¤, t”œ's a —¤
{W}—¤ {V+R

```

Try it online!

# Answer
> 4 votes
# Perl 6, 166 bytes

```
($/=@(($!="There's a")X [\R,](<hole log bump frog wart hair fly flea smile>Z(<i o>[$++>1]~"n the")xx*)X"bottom of the sea
")).map:{say "$_$_$! hole, {$!.lc} hole
$0"}

```

Try it online!

# Answer
> 4 votes
# Ruby, ~~173~~ 170 bytes

```
a="T#{["here's a hole"]*3*"%s"%[", t","
T"]+c=" in the "}bottom of the sea

"
b=a[31,39]
%w{log bump frog wart hair fly flea smile x}.map{|i|puts b,b,a;b[9]+=i+c;c[1]=?o}

```

Try it online!

# Answer
> 4 votes
# Haskell, ~~243~~ 215 bytes

Reduced to 215 bytes with great help from nimi

```
c[[l n,l n,'T'#h++", "++'t'#h,l 8,""]|n<-[8,7..0]]
t#u=t:"here's a "++u
h="hole"
c=concat
l n='T'#c(drop n$map(++" on the ")(words"smile flea fly hair wart frog bump")++["log in the ",h," in the bottom of the sea"])

```

Try it online!

(Old 243 byte version is here).

A quite straightforward solution.

```
-- main function producing a list of lines
v = concat [[
    l n,
    l n, -- second line of each verse equals to its first line
    'T' # h ++ ", " ++ 't' # h,
    l 8, -- last line of each verse is the same in all verses
    ""
  ] | n <- [8,7..0]]

-- a small helper to construct similar strings
t # u = t : "here's a " ++ u

h = "hole"

-- construct a first line of n-th verse (with n = 8 is the first and n = 0 is the last one)
-- Every such line begins with a constant prefix followed by expanding list of nested entities
l n = 'T' # concat (
      drop n $
         map (++ " on the ") (words "smile flea fly hair wart frog bump")
         ++ ["log in the ", h, " in the bottom of the sea"]
    )

```

# Answer
> 4 votes
## Batch, 267 bytes

```
@echo off
set r=i
set t= There's a hole
set s=bottom of the sea
for %%w in (hole log bump frog wart hair fly flea smile)do call:c %%w
exit/b
:c
set s=%1 %r%n the %s%
echo%t:~,11%%s%
echo%t:~,11%%s%
echo%t%,%t:T=t%
echo%t%%s:~-25%
echo(
if %1==log set r=o

```

`t` contains a string repeated in the chorus, `s` contains most of the verse line, while `r` chooses between `in the` and `on the`. In the verses, only the first 11 characters of `t` is needed, while in the first chorus line the second copy of `t` has its `T` lowercased and the second chorus line reuses the last 25 characters of `s`.

# Answer
> 3 votes
# JavaScript (Babel Node), 239 bytes

*-7 bytes from @Oliver `*.*`*

```
(x=0,r='hole0log0bump0frog0wart0hair0fly0flea0smile'.split`0`).map(a=>(t=(i="There's a ")+a+r.slice(0,x++).reverse().map((h,_)=>` ${"io"[_<x-2|0]}n the ${h}`).join``+(o=` in the bottom of the sea
`))+t+(`${k=i+"hole"}, ${k}
`)+k+o).join`
`

```

Try it online!

# Answer
> 3 votes
# Python 3, ~~213 206 198~~ 193 bytes

```
k='n the ';o=e='bottom of the sea\n';b="There's a ";h='hole'
for j in[h]+'log bump frog wart hair fly smile'.split():o=j+' '+'io'['g'in o]+k+o;print(b+o+b+o+b+h+', t'+b[1:]+h+'\n'+b+h+' i'+k+e)

```

Try it online!

---

-15 bytes thanks to @Sara
-5 bytes thanks to @ASCII-only

Probably a bit more golfable, but not much.

# Answer
> 2 votes
# Clean, 267 bytes

```
import StdEnv,Text,Data.List
t="here's a "
h="hole"
b=" in the bottom of the sea"
f=foldr((+)o\s#p="T"+t+join" on the "(reverse s)+" in the "+h+b
=join"\n"[p,p,"T"+t+h+", t"+t+h+"\nT"+t+h+b+"\n\n"])""(tl(inits["log","bump","frog","wart","hair","fly","flea","smile"]))

```

Try it online!

# Answer
> 2 votes
# Charcoal, ~~115~~ 106 bytes

```
≔There's a holeθＥＥ⁹⁺…θχ⪫⮌…⪪”↶±∧⟲!↶⁼,(_⎇ＲB↧ω⪪zθⅉＱθ`✳＆⬤⸿◧σ⁻y▷»ΣＫ▶↙⁻υＸ`SξQ6 /ι⁹Ｗq”x⁺²ιn the ⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵

```

Try it online! Link is to verbose version of code. Edit: Saved 9 bytes by copying my Batch code for the last line of the chorus. Explanation:

```
≔There's a holeθ

```

Save the string `There's a hole`, which is used twice as-is, a third time in lower case, and also a fourth time but just the first 10 characters.

```
⪪”↶±∧⟲!↶⁼,(_⎇ＲB↧ω⪪zθⅉＱθ`✳＆⬤⸿◧σ⁻y▷»ΣＫ▶↙⁻υＸ`SξQ6 /ι⁹Ｗq”x

```

Split the string `bottom of the seaxhole ixlog ixbump oxfrog oxwart oxhair oxfly oxflea oxsmile o` on `x`s.

```
Ｅ⁹⁺…θχ⪫⮌…...⁺²ιn the

```

Loop over the 9 verses, taking the first `i+2` elements of the array, reversing them, joining them with `n the`, and prefixing `There's a` to the result.

```
Ｅ...⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵

```

Expand each line into a verse by duplicating the line and constructing the chorus. Each line of the verse is then implicitly printed on each own line, and each verse is implicitly separated by a blank line.

# Answer
> 2 votes
# cQuents, ~~238~~ 219 bytes

```
|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@

::"","log in the","bump"~c3,"frog"~c3,"wart"~c3,"hair"~c3,"fly"~c3,"flea"~c3,"smile"~c3
:"here's a ","hole in the bottom of the sea"," on the"

```

Try it online!

This challenge made me finally implement lists and strings in my language. This language is built for integer sequences, so it did pretty well!

## Explanation

```
:"here's a ","hole in the bottom of the sea"," on the"

    helper line: c1), c2), and c3) access the three terms in this list

::"","log in the","bump"~c3,"frog"~c3,"wart"~c3,"hair"~c3,"fly"~c3,"flea"~c3,"smile"~c3

    helper line: yields a list containing the first n terms in it, accessed with bx)
    for example, the first three terms are:

"","log in the","bump"~c3

    so b3) would yield ["","log in the","bump on the"] (~ is concatenation and c3 is " on the")

|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@

|@
                              join sequence on literal newline
#36::                         output first 36 terms in sequence joined together
                              following are the 4 terms in the sequence, which will cycle through 9 times (for a total of 36 terms)
"T"~c1)~j\rbk));@ )~c2,       first term
"T"~c1)~                      "T" concat "here's a " concat
        j\rbk));@ )           the first k terms of b, reversed, and joined on " "
                   ~c2,       concat "hole in the bottom of the sea"
Z,                            second term - same as previous
"T"~c1)~"hole, t"~c1)~"hole", third term
"T"~c1)~                      "T" concat "here's a " concat
        "hole, t"~c1)~"hole", "hole, t" concat "here's a " concat "hole"
"T"~c1)~c2)~@
                              fourth term - "T" concat "here's a " concat "hole on the bottom of the sea" concat newline

```

# Answer
> 2 votes
# Perl 5, 194 bytes

*@ASCII-only shaved off 6 bytes with literal newlines and a `\l` trick I forgot about*

```
$"=" on the ";say+($b=($e="There's a ").hole,$c=" in the bottom of the sea",$/)x2,$.="$b, \l$b
$b$c
";say"$e@a[-$_..-1] in the hole$c
"x2,$.for 1..(@a=qw/smile flea fly hair wart frog bump log/)

```

Try it online!

# Answer
> 2 votes
# C# (Visual C# Interactive Compiler), 220 bytes

```
string b="There's a ",d="hole in the bottom of the sea\n",e,f;" log bump frog wart hair fly flea smile".Split().Any(s=>Write((e=b+(f=s!=""?s+(f!=""?" o":" i")+"n the "+f:s)+d)+e+b+$@"hole, there's a hole
{b+d}
")is int);

```

Try it online!

-5 bytes thanks to @ASCIIOnly and -2 bytes thanks to @someone!

I have a small child and can assure you this song is equal parts catchy and annoying.

# Answer
> 2 votes
# , 184 170 bytes

```
4iThere's a hole in the bottom of the sea
kky5w5eá,lpD5brtHj4yyGp4w8ion the 2briilog 3bibump 3bifrog 3biwart 3bihair 3bifly 3biflea 3bismile 7ñ4yykp4wd3wñ8ñÄ5jñ

```

Try it online!

## Explanation:

* `4iThere's a hole in the bottom of the sea<\n><esc>` Insert "Theres' a hole in the bottom of the sea" 4 times.
* `kk` Move to the third line
* `y5w` copy "There's a hole"
* `5eá,` insert a comma after "There's a hole"
* `lp` paste after the comma
* `D` delete the rest of the line
* `5brt` lowercase the second T
* `Hj4yy` copy 4 lines from the second line
* `Gp` Paste everything after the first line
* `4w8ion the <esc>`(at the end of the first verse) move to first "hole" in second verse and insert "on the " 8 times
* `2briilog <esc>` move backwards to the last "on", replace the o with an i and then insert "log "
* `3bibump <esc>3bifrog <esc>3biwart <esc>3bihair <esc>3bifly <esc>3biflea <esc>3bismile <esc>` Move backwards through the line, inserting the appropriate words between each "on the"
* `7ñ4yykp4wd3wñ` execute `4yykp4wd3w` 7 times
    + `4yykp` duplicate the verse before this one
    + `4wd3w` move to the first word after "There's a hole" and delete 3 words
* `8ñÄ5jñ` duplicate the first line of each verse after the first (there are 8 of these to do)

# Answer
> 2 votes
# Slashalash, 216 bytes

```
/V/\/\///U/\/ VS/TCVR/iBVQUtheVPUoBVOUholeVN/RASVM/ASO, tCO
SA
VL/RMSVKUlog VJUbumpPKVIUfrogPJVHUwartPIVGUhairPHVFUflyPGVEUfleaPFVDUsmilePEVC/here's aVB/nQVA/O R bottom ofQ sea
/SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM

```

Try it online!

This sort of task is the one and only thing that Slashalash is reasonably good at. :D Hey, the result is shorter than C, C# or Java!

The output from this program ends in *two* trailing line breaks; hope that's not a deal-breaker.

Anyway, there's no real cleverness here. I simply identified repeated strings and defined one-character shortcuts for them, and repeated until I didn't see any more repeated strings. I did this in a more-or-less naive and greedy fashion. I did, however, intentionally define a shortcut for "smile on the flea on the ... sea", followed by "flea on the fly on the ... sea", and so forth, in order to form a chain of shortcuts. The result is that the whole sequence of new nouns is clearly visible in the code, and I find that pretty pleasing. :)

After V and U are replaced, we have the following more readable code:

```
/S/TC//R/iB//Q/ the//P/ oB//O/ hole//N/RAS//M/ASO, tCO
SA
//L/RMS//K/ log //J/ bumpPK//I/ frogPJ//H/ wartPI//G/ hairPH//F/ flyPG//E/ fleaPF//D/ smilePE//C/here's a//B/nQ//A/O R bottom ofQ sea
/SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM

```

# Answer
> 2 votes
# LaTeX, 265 ~~268~~ characters

```
\documentclass{book}\input{pgffor}\def\i{bottom of the sea}\let~\i\def\b{here's a }\def\h{hole}\def\s#1{ in}\begin{document}\foreach\x in{\h\s,log\s,bump,frog,wart,hair,fly,flea,smile}{\xdef~{\x{ on} the ~}T\b~\\T\b~\\T\b\h, t\b\h\\T\b\h\,in the \i\par}\enddocument

```

compiles into a nice PDF, with paragraph indentations and everything.

Ungolfed and commented:

```
\documentclass{book}
\input{pgffor}
\def\i{bottom of the sea}   %for re-use in the last two verses
\let~\i                     %here I keep attaching words
\def\b{here's a }
\def\h{hole}
\def\s#1{ in}               %this replaces the next token with "in", useful for log and hole where "in" is used instead of"on"
\begin{document}
\foreach\x in{\h\s,log\s,bump,frog,wart,hair,fly,flea,smile}{
    \xdef~{\x{ on} the ~}   %keep attaching words and on/on to ~
    T\b~\\                  %verse 1
    T\b~\\                  %verse 2
    T\b\h, t\b\h\\          %verse 3
    T\b\h\,in the \i\par    %verse 4
}
\enddocument

```

Of output:

# Answer
> 1 votes
# Shell, 291 bytes

```
echo 'smile,flea,fly,hair,wart,frog,bump,log,hole'|awk -F, 'BEGIN{z="here'\''s a ";a="T"z;c=a "hole";b=" in the bottom of the sea"}function f(n){printf a $n;for(j=n+1;j<=NF;j++){printf " on the " $j};print b;}{for(i=NF;i>=1;i--){printf (i<NF)?"\n":"";f(i);f(i);print c", t" z "hole";f(NF)}}'

```

I'm sure it can be golfed further (definitions of vars & function) ...

# Answer
> 1 votes
# C# (.NET Core), ~~315~~, ~~320~~, 290 bytes

EDIT: Forgot to repeat the first line. :C

EDIT2: Thanks to recursive for -30 bytes! Switched to using a .Split() to form the string array and added a really cool switch for flipping between "in" and "on".

```
s=>{var b="hole/log/bump/frog/wart/hair/fly/flea/smile/here's a / in the bottom of the sea\n".Split('/');string c=b[9]+b[0],t="";for(int k,j=0;j<9;t=""){t+="T"+b[9];for(k=j++;k>-1;k--)t+=b[k]+(k<1?"":" "+"oi"[1/k]+"n the ");t+=b[10];t+=t+"T"+c+", t"+c+"\n"+"T"+c+b[10]+"\n";s+=t;}return s;}

```

Try it online!

# Answer
> 1 votes
# Java (OpenJDK 8), ~~320~~ 344 bytes

Long but wanted to try with java, no streams and java 8 things.

\*Edited to fix some problems.

```
static String w(){String[]a={"hole","log","bump","frog","wart","hair","fly","flea","smile"};String n="T",m="t",q=" ",t="here's a ",s="bottom of the sea \n",y="in the ",o="on the ",b=t+a[0],f="",v,l="\n",c=y+s,h=a[0]+q+c,z=n+b+", "+m+b+q+l+n+b+q+c;for (int i=0;i<9;i++){v=n+t;for(int j=i;j>0;j--){v+=a[j]+q+(j>1?o:y);}v+=h;f+=v+v+z+l;}return f;}

```

Try it online!

# Answer
> 1 votes
# ink, ~~231~~ 229 bytes

```
LIST W=hole,log,bump,frog,wart,hair,fly,flea,smile
VAR T="here's a "
~temp H=T+"hole"
VAR B="bottom of the sea"
-(i)~W=W((i+1)/2)
T{T}<>
-(k){W} {W-2:o|i}n the <>
~W--
{W:->k}{B}
{i%2:->i}
T{H}, t{H}
T{H} in the {B}
\
{i<17:->i}

```

Try it online!

* `-2 bytes` by changing `"{T}hole"` to `T+"hole"` and removing a rogue space

# Answer
> 0 votes
# Zsh, 162 bytes

```
set hole in the 'bottom of the sea'
0="There's a "
alias D="<<<\"$0\$@
$0\$@
$0$1, ${0:l}$1
$0$*
\"&&4=$"@
D
for 1 (log bump frog wart hair fly flea smile)D&&2=on
```

Attempt This Online!

---
Tags: code-golf, kolmogorov-complexity
---


title: Shortest code to write longest code

text:
# Question
Title: Shortest code to write longest code
Your challenge is to **create a shortest code** in your language of choice which writes on a **`.txt`** file **the longest code to multiply two numbers by taking two numbers as input and output the answer**.

*NO INPUT NEEDED TO YOUR CODE WHICH IS DOING THE WRITING JOB*!

**The generator code and generated code can be in any languages**

**Do NOT** use unlimited series or progression to make text file big.
**Do NOT** use unnecessary statements to increase the score.

### SCORING

```
( size of text file generated in bytes )  (without any unnecessary white spaces, tabs or newlines)
-----------------------------------------
     ( size of your code in bytes )

```

# Winner

**Winner** will be chosen **after 1 week** from now with the **highest score**.

**EDIT :** range of input in code multiplying two numbers should be in between -32768 to 32767

# Answer
# perl/perl, unlimited score under original rule with unlimited range

Here's some code which doesn't win:

```
$l=-2**5-1;
$h=2**5;
sub p{print@_}
p"sub add {(\$i,\$j)=\@_;\n";
for($i=$l;$i<=$h;++$i){
  for ($j=$l;$j<=$h;++$j){
    p" return ".($i*$j)." if (\$i == $i) && (\$j == $j);\n";
  }
}
p"}print add(<>,<>)\n";

```

The output has this form:

```
sub add {($i,$j)=@_;
 return 1089 if ($i == -33) && ($j == -33);
 return 1056 if ($i == -33) && ($j == -32);
 return 1023 if ($i == -33) && ($j == -31);
 return 990 if ($i == -33) && ($j == -30);
...
 return 928 if ($i == 32) && ($j == 29);
 return 960 if ($i == 32) && ($j == 30);
 return 992 if ($i == 32) && ($j == 31);
 return 1024 if ($i == 32) && ($j == 32);
}print add(<>,<>)

```

the output file is 181030 bytes long, but after stripping spaces and newlines, it is only 133109 bytes long. so, the score is 133109/248 = 536.7289...

Here's some other code that doesn't win - it is the same program except the first 2 lines:

```
$l=-2**6-1;
$h=2**6;

```

the output file is 718138 bytes long, but after stripping spaces and newlines, it is only 532233 bytes long. so, the score is 532233/248 = ~2146. better! using 7 yields a score of ~8750, 8 yields ~35347, 9 yields ~149129, 10 yields 151100000 non-space / 250 = 604,400 ....

of course we can do this as long as we want. the size of the source program, n, will increase as O(log(n)). the size of the output program is O(2\**n). The limit of 2*\*n/log(n) as n goes to infinity is clearly infinity, so if I just substitute in my favorite large number, a googolplex, I win (until someone suggests googolplex+1).
> 11 votes

# Answer
# C, 27297/245 = 111.4

### Source code (245 bytes)

```
#include<stdio.h>
main(int c,char**v){char*s;FILE*f=fopen("/tmp/x.c","w");fprintf(f,"#include<stdio.h>\n#include<stdlib.h>\nmain(){int a=%s,b=%s;printf(\"%s * %s = %%d\\n\",a*b);}",v[1],v[2],v[1],v[2]);fclose(f);system("cc -E /tmp/x.c >add.c");}

```

When compiled and run with two integer arguments on the command line, this generates another C file containing the necessary code to calculate their product, and compiles it with the `-E` flag. This flag specifies that the compiler should stop after the preprocessing stage and output the processed source code (which will include the entire contents of `stdio.h` and `stdlib.h`).

### Output file (27297 bytes)

```
# 1 "/tmp/x.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/tmp/x.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 64 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/_types.h" 1 3 4
# 27 "/usr/include/_types.h" 3 4
# 1 "/usr/include/sys/_types.h" 1 3 4
# 32 "/usr/include/sys/_types.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 33 "/usr/include/sys/_types.h" 2 3 4

```

`********* LINES 13-1273 OMITTED *********`

```
long long
  strtoq(const char *, char **, int);
unsigned long long
  strtouq(const char *, char **, int);

extern char *suboptarg;
void *valloc(size_t);

# 3 "/tmp/x.c" 2
main(){int a=6,b=7;printf("6 * 7 = %d\n",a*b);}

```

### Result of running the output code

The output file is saved as `add.c`, which can be compiled and run normally:

```
$ ./a.out 6 7
$ cc add.c -o add
$ ./add
6 * 7 = 42
$

```
> 10 votes

# Answer
# perl, 125 chars, score 1,630,326,497.312

Same basic approach as my other answer, but this time bounded between -32768 and 32767 per the updated rules, and all unnecessary whitespace stripped completely:

```
$l=-($h=32767)-1;print"sub a{";for$i($l..$h){print"return ".$i*$_." if\$_[0]==$i&&\$_[1]==$_;"for$l..$h;}print"}print a<>,<>"

```

The output program begins like so:

```
sub a{return 1073741824 if $_[0]==-32768&&$_[1]==-32768;return 1073709056 if $_[0]==-32768&&$_[1]==-32767;

```

and ends:

```
return 1073643522 if $_[0]==32767&&$_[1]==32766;return 1073676289 if $_[0]==32767&&$_[1]==32767;}print a<>,<>

```

The output program is 190GB long. More precisely, 203790812164 bytes. Score = 203790812164 / 125 = 1630326497.312
> 4 votes

# Answer
## Windows Command Script: ~1,000,000,000 pts

Code: 158 bytes

Output: ~158000000000 bytes

```
echo>.txt @goto :%%1_%%2
set,=for /l %%a in (-32768 1 32767) do call :
%,%1 %%a
:1
%,%2 %1 %%a
:2
set/a]=%1*%2
echo :%1_%2>>.txt
echo @echo.%]%^&exit/b0>>.txt

```

The output pretty much consists of:

```
@goto :%1_%2
:-32768_-32768
@echo.1073741824&exit/b0
:-32768_-32767
@echo.1073709056&exit/b0
...
:32767_32767
@echo.1073676289&exit/b0

```
> 4 votes

# Answer
# Python, 142 bytes

```
c='def m(a,b):\n'
L=32768
a=-L
while(a<L):
 b=-L
 while(b<L):c+=f' if a=={a}and {b}==b:return {a*b}\n';b+=1
 a+=1
F=open('c.txt','w')
F.write(c)

```

Score unknown for the moment, ~~but I think it's more than a billion.~~ Nope, probably just below a billion.

## Score update

The program has a minimum length of `111669149696` or about 111 billion. This means that the minimum score of this answer is roughly 780 million.

It also has a maximum length of roughly 150 billion, which indicates that **the score is between 730 and 1050 million**. My score is most likely in the middle of that range, i.e. about **890 million**.

Basically writes a function `m` to a file `c.txt` using two while loops.
> 2 votes

---
Tags: code-challenge
---


title: Monkeys at a Typewriter

text:
# Question
Title: Monkeys at a Typewriter
Sometimes when you press a key on a keyboard, the letter doesn't always display on screen. Whether this is because of a dodgy connection or otherwise, you have decided to write a script to control the probability of a letter displaying on screen when the corresponding key is pressed.

One day, you decide to buy a monkey and sit it down at a keyboard. Being curious, you decide to find out what the key probabilities are to help the monkey to write Hamlet in its entirety.

Your challenge is to calculate the probabilities for each character so that the passage is typed out in the least number of characters.

Here's a list of all of the characters you should consolidate:

```
qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!"':;.()?,

```

Newlines and spaces are included in the above list. You must only use the characters in the list, discounting all other characters (remove them from the passage).

The program must be a program with the passage supplied via STDIN. The output must be to STDOUT.

Since this is a Rosetta Stone challenge, you must write as many programs in different languages as possible.

To win, you need to have the shortest code in the most number of languages.

## Test case 1

> Shall I compare thee to a summer's day?
> Thou art more lovely and more temperate:
> Rough winds do shake the darling buds of May,
> And summer's lease hath all too short a date

Answer:

```
{
'\n': 0.017543859649122806,
' ': 0.16959064327485379,
'!': 0.0,
'"': 0.0,
"'": 0.011695906432748537,
'(': 0.0,
')': 0.0,
',': 0.0058479532163742687,
'.': 0.0,
'0': 0.0,
'1': 0.0,
'2': 0.0,
'3': 0.0,
'4': 0.0,
'5': 0.0,
'6': 0.0,
'7': 0.0,
'8': 0.0,
'9': 0.0,
':': 0.0058479532163742687,
';': 0.0,
'?': 0.0058479532163742687,
'A': 0.0058479532163742687,
'B': 0.0,
'C': 0.0,
'D': 0.0,
'E': 0.0,
'F': 0.0,
'G': 0.0,
'H': 0.0,
'I': 0.0058479532163742687,
'J': 0.0,
'K': 0.0,
'L': 0.0,
'M': 0.0058479532163742687,
'N': 0.0,
'O': 0.0,
'P': 0.0,
'Q': 0.0,
'R': 0.0058479532163742687,
'S': 0.0058479532163742687,
'T': 0.0058479532163742687,
'U': 0.0,
'V': 0.0,
'W': 0.0,
'X': 0.0,
'Y': 0.0,
'Z': 0.0,
'a': 0.08771929824561403,
'b': 0.0058479532163742687,
'c': 0.0058479532163742687,
'd': 0.046783625730994149,
'e': 0.093567251461988299,
'f': 0.0058479532163742687,
'g': 0.011695906432748537,
'h': 0.052631578947368418,
'i': 0.011695906432748537,
'j': 0.0,
'k': 0.0058479532163742687,
'l': 0.046783625730994149,
'm': 0.046783625730994149,
'n': 0.023391812865497075,
'o': 0.070175438596491224,
'p': 0.011695906432748537,
'q': 0.0,
'r': 0.052631578947368418,
's': 0.052631578947368418,
't': 0.058479532163742687,
'u': 0.029239766081871343,
'v': 0.0058479532163742687,
'w': 0.0058479532163742687,
'x': 0.0,
'y': 0.017543859649122806,
'z': 0.0
}

```

## Test case 2

> Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.
> Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

Answer:

```
{
'\n': 0.0036036036036036037,
' ': 0.18018018018018017,
'!': 0.0,
'"': 0.0,
"'": 0.0,
'(': 0.0,
')': 0.0,
',': 0.010810810810810811,
'.': 0.0090090090090090089,
'0': 0.0,
'1': 0.0,
'2': 0.0,
'3': 0.0,
'4': 0.0,
'5': 0.0,
'6': 0.0,
'7': 0.0,
'8': 0.0,
'9': 0.0,
':': 0.0,
';': 0.0,
'?': 0.0,
'A': 0.0,
'B': 0.0,
'C': 0.0,
'D': 0.0,
'E': 0.0,
'F': 0.0018018018018018018,
'G': 0.0,
'H': 0.0,
'I': 0.0018018018018018018,
'J': 0.0,
'K': 0.0,
'L': 0.0,
'M': 0.0,
'N': 0.0018018018018018018,
'O': 0.0,
'P': 0.0,
'Q': 0.0,
'R': 0.0,
'S': 0.0,
'T': 0.0,
'U': 0.0,
'V': 0.0,
'W': 0.0036036036036036037,
'X': 0.0,
'Y': 0.0,
'Z': 0.0,
'a': 0.082882882882882883,
'b': 0.0054054054054054057,
'c': 0.025225225225225224,
'd': 0.03783783783783784,
'e': 0.10270270270270271,
'f': 0.016216216216216217,
'g': 0.023423423423423424,
'h': 0.041441441441441441,
'i': 0.057657657657657659,
'j': 0.0,
'k': 0.0,
'l': 0.027027027027027029,
'm': 0.0072072072072072073,
'n': 0.063063063063063057,
'o': 0.066666666666666666,
'p': 0.010810810810810811,
'q': 0.0018018018018018018,
'r': 0.050450450450450449,
's': 0.028828828828828829,
't': 0.093693693693693694,
'u': 0.010810810810810811,
'v': 0.014414414414414415,
'w': 0.014414414414414415,
'x': 0.0,
'y': 0.0054054054054054057,
'z': 0.0
}

```

See the theory here.

## Leaderboard

```
C - 371 - Gerwin Dox
Java - 788 - Luminous

```

# Answer
> 1 votes
# Java ~~788~~ 743

**Edit**

Found so much I could golf down. Replaced whole words w/ letters, made method for putting keys into the `HashMap`, and moved all integer variables to one declaration.

---

Not expecting this to beat any records, but oh well. This version REQUIRES you to enter how many lines of input your giving it since java likes to block on any methods that takes input.

So example would be:

> 4
> Shall I compare thee to a summer's day?
> Thou art more lovely and more temperate:
> Rough winds do shake the darling buds of May,
> And summer's lease hath all too short a date

```
import java.util.*;class A{static HashMap<Character,Double>m=new HashMap<Character,Double>();public static void main(String[]g){Scanner s=new Scanner(System.in);int n,k,e,i='@';for(;i++<'[';)g((char)i);for(i='`';i++<'{';)g((char)i);for(i='/';i++<':';)g((char)i);char[]r={' ','!','"','\'',':',';','.','(',')','?',','};p(r);e=s.nextInt();s.nextLine();String l="";n=0;k=0;while(k<e){l=s.nextLine();for(i=0;i<l.length();i++){char c=l.charAt(i);m.put(c,m.get(c)+1);n++;}k++;n++;}m.put('\n',(double)(e-1));for(Iterator b=m.entrySet().iterator();b.hasNext();){Map.Entry p=(Map.Entry)b.next();System.out.println(p.getKey()+" = "+((double)p.getValue())/(n-1));b.remove();}}static void p(char[]a){for(char b:a)g(b);}static void g(char a){m.put(a,0.0);}}

```

UnGolfed

```
import java.util.*;
class A{
static HashMap<Character,Double>m=new HashMap<Character,Double>();
public static void main(String[]g){
    Scanner s=new Scanner(System.in);
    int n,k,e,i='@';
    for(;i++<'[';)g((char)i);
    for(i='`';i++<'{';)g((char)i);
    for(i='/';i++<':';)g((char)i);
    char[]r={' ','!','"','\'',':',';','.','(',')','?',','};
    p(r);
    e=s.nextInt();
    s.nextLine();
    String l="";
    n=0;
    k=0;
    while(k<e){
        l=s.nextLine();
        for(i=0;i<l.length();i++){
            char c=l.charAt(i);
            m.put(c,m.get(c)+1);
            n++;
        }
        k++;
        n++;
    }
    m.put('\n',(double)(e-1));
    for(Iterator b=m.entrySet().iterator();b.hasNext();){
        Map.Entry p=(Map.Entry)b.next();
        System.out.println(p.getKey()+" = "+((double)p.getValue())/(n-1));
        b.remove();
    }
}
static void p(char[]a){
    for(char b:a)g(b);
}
static void g(char a){
    m.put(a,0.0);
}

```

}

# Answer
> 0 votes
# C, 324 bytes (can someone check that for me?)

Maybe I need to resharpen my method, it's a bit long.

```
main(){char*d="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!\"':;.()?,\n ",*p,*s,*c=calloc(1,1000),*r=c;int n=-1;do{scanf("%c",++r);for(p=d;*p;p++)n+=*p==*r?1:0;}while(*((short*)(r-1))!=2570);p=d;for(;*p;p++){int q=0;for(s=c;*(s+1);s++)q+=(*s==*p?1:0);printf("'%c':%f\n",*p-10?*p:244,(float)q/n);}free(c);}

```

Also, I can prove that it works.

# Answer
> 0 votes
# Python 3, 92 bytes

```
lambda n:{chr(x):n.count(chr(x))/len(n)for x in{10,*range(32,123)}-{*b"#$%&*+-/<=>@[\\]^_`"}}

```

If I understand the question correctly.

Default argument won't work for some reason, probably something to do with `k`'s reference not being updated between calls. Thanks to Jakque for informing me about a bug and shaving off some bytes while fixing the bug,

---
Tags: code-challenge, rosetta-stone
---


title: Print a 3D shape

text:
# Question
Title: Print a 3D shape
Write a program or a function to print the following cube (if you allow me to call it so) in different sizes:

```
          ^L^L^L^L^L^L^L^L^L^L^L
         //^L^L^L^L^L^L^L^L^L^L^L
        ////^L^L^L^L^L^L^L^L^L^L^L
       //////^L^L^L^L^L^L^L^L^L^L^L
      ////////^L^L^L^L^L^L^L^L^L^L^L
     //////////^L^L^L^L^L^L^L^L^L^L^L
    ////////////^L^L^L^L^L^L^L^L^L^L^L
   //////////////^L^L^L^L^L^L^L^L^L^L^L
  ////////////////^L^L^L^L^L^L^L^L^L^L^L
 //////////////////^L^L^L^L^L^L^L^L^L^L^L
////////////////////^L^L^L^L^L^L^L^L^L^L^L
\\\\\\\\\\\\\\\\\\\\ " " " " " " " " " " "
 \\\\\\\\\\\\\\\\\\ " " " " " " " " " " "
  \\\\\\\\\\\\\\\\ " " " " " " " " " " "
   \\\\\\\\\\\\\\ " " " " " " " " " " "
    \\\\\\\\\\\\ " " " " " " " " " " "
     \\\\\\\\\\ " " " " " " " " " " "
      \\\\\\\\ " " " " " " " " " " "
       \\\\\\ " " " " " " " " " " "
        \\\\ " " " " " " " " " " "
         \\ " " " " " " " " " " "
           " " " " " " " " " " "

```

The shape is made of pairs of characters: `^L`, `"`, `\\`, `//`

### Input:

An integer greater than 1, representing the size of the shape.
The one showed above has a size of 11 because each side of each face is made of 11 pairs of characters.
Note that only two faces are fully displayed.

### Output:

A cube of the given size.

Here's another example, with a size of 5:

```
    ^L^L^L^L^L
   //^L^L^L^L^L
  ////^L^L^L^L^L
 //////^L^L^L^L^L
////////^L^L^L^L^L
\\\\\\\\ " " " " "
 \\\\\\ " " " " "
  \\\\ " " " " "
   \\ " " " " "
     " " " " "

```

This is , the shortest in bytes wins.

Even though you are not required to do so, it would be nice if you could provide an easy way to check the output of your code

# Answer
# Python 2, 81 bytes

```
k=n=input()
while 1:k-=1;i=k^k/n;print' '*i+(n+~i)*2*'\/'[k/n-1]+'^ L"'[k<0::2]*n

```

Try it online!

Reuses some ideas from my answer on Draw an ASCII hexagon of side length n, including using the index `k/n-1` both to select between `/` and `\` in an order where the `\` doesn't need escaping, as well as to terminate the loop with error at the end.
> 9 votes

# Answer
# Canvas, ~~27~~ 22 bytes

```
｛╷２×/×^L⁸×＋］：↕vL∙ "╋∔ｒ

```

Try it here!

## Explanation

```
{|2×/×^L⁸×+]:↕vL∙ "╋∔r
{          ]           map each i from 1 to n:
 |2×                   decrement and double i
    /×                 repeat "/" that many times
      ^L⁸×             repeat "^L" n times
          +            add that to get one line
            :          copy the top half
             ↕         mirror vertically (mirrors characters)
              vL∙" ╋   replace 'vL' with '" '
                    ∔  and add vertically
                     r center the whole art

```
> 6 votes

# Answer
# JavaScript (Node.js), 121 bytes

```
s=>(j=n=>' '[b="repeat"]((a=n>=s)?n-s:s+~n)+(a?"//":"\\\\")[b](a?s*2-n:n+1)+(a?"^L":' "')[b](s)+'\n'+(~n?j(--n):''))(s*2)

```

Try it online!
> 5 votes

# Answer
# Ruby, 78 bytes

```
->n{puts (0...n).map{|i|puts ' '*(j=n+~i)+?/*i*2+'^L'*n;' '*i+?\\*j*2+' "'*n}}

```

Builds an array for the bottom half while printing the top half, then dumps the bottom half at the end. I also tried recursion but it was longer.

Try it online!
> 5 votes

# Answer
# 05AB1E, ~~28~~ 26 bytes

-2 bytes thanks to Kevin Cruijssen!

Without this bug, `»∊¶¡` could be just .

```
L<·'/×»∊¶¡„^L„ "‚I×Iδи˜ø.c

```

Try it online!

**Commented**:

```
L<·'/×»∊¶¡      # generate the left part
L               # push the range [1..n]
 <              # decrement to get [0..n-1]
  ·             # double each value: [0, 2, ..., 2*(n-1)]
   '/           # push the string '/'
     ×          # for each number in the list, repeat the string this many times
      »∊¶¡      # vertically mirror to get lower left half

„^L„ "‚I×Iδи˜   # generate the right part
„^L             # push the string '^L'
   „ "          # push the string ' "'
      ‚         # pair into a list: ['^L', ' "']
       I×       # repeat each string input times
         Iδи    # for each string create a list containing the string input times
            ˜   # flatten into a single list

 ø              # zip both parts to get the rows
   .c           # join each row, centralize and join by newlines

```

Try it with step-by-step output!

Some slightly longer alternatives:

```
L<·'/×»∊¶¡εNI@i„ "ë„^L}I×«}.c
L<·'/×»∊¶¡ε„^LNI@i„ "}I×yì}.c
L<·Â«εNI@i'\×„ "ë'/×„^L}I×«}.c

```
> 4 votes

# Answer
# K (ngn/k), 69 bytes

```
{` 0:,/',/$(`" "`"//"`"^L";`" "`"\\\\"`" \"")@'&''(t;|t:+(|!x;!x;x))}

```

Try it online!

Not a great fit for the language, but an interesting exercise...

* `(t;|t:+(|!x;!x;x))` build a nested list containing the number of copies of each type of symbol to take. (i.e. spaces from x..0,0..x, slashes from 0..x,x..0, and x copies of `^L` and  `"`).
* `&''` convert to indices, e.g. `3 1 5` =\> `0 0 0 1 2 2 2 2 2`
* `(`" "`"//"`"^L";`" "`"\\\\"`" \"")` build another nested list (of the same shape), this time containing symbol versions of the output characters. This avoids having to enlist the individual strings and simplifies the list notation a bit. Since they contain special characters (as opposed to being alphanumeric), the contents need to be enclosed in `"`'s, with `"` and `\` also needing to be escaped.
* `(...)@'(...)` retrieve the correct number of copies of each type of symbol
* `,/',/$` stringify the symbols, and raze them into the lines of the output
* `` 0:` print them (this elides the wrapping `"`s and `\` escapes otherwise present)
> 4 votes

# Answer
# Java 11, ~~148~~ 136 bytes

```
n->{String r="",t=r;for(int i=n;i-->0;t+=" ")r=t+"//".repeat(i)+"^L".repeat(n)+"\n"+r+t+"\\\\".repeat(i)+" \"".repeat(n)+"\n";return r;}

```

-12 bytes thanks to *@OlivierGrégoire*.

Try it online.

**Explanation:**

```
n->{                        // Method with integer parameter and String return-type
  String r="",              //  Result-String, starting empty
         t=r;               //  Temp-string, starting empty as well
  for(int i=n;i-->0         //  Loop `i` in the range [input, 0):
      ;                     //    After every iteration:
       t+=" ")              //     Append a space to `t`
    r=...+r+...;            //   Change the result-String to:
                            //    Prepend to the result-String:
      t                     //     The spaces `t`
      +"//".repeat(i)       //     plus '//' repeated `i-1` amount of times
      +"^L".repeat(n)       //     plus '^L' repeated the input amount of times
      +"\n"                 //     plus a newline
                            //    Append to the result-String:
      t                     //     The spaces `t` again
      +"\\\\".repeat(i)     //     plus '\\' repeated `i-1` amount of times
      +" \"".repeat(n)      //     plus ' "' repeated the input amount of times
      +"\n";                //     plus a newline again
  return r;}                //  After the loop, return the result-String

```
> 4 votes

# Answer
# PowerShell, 88 bytes

```
param($n)$n..1|%{($l=' '*--$_)+'//'*($j=$n-$_-1)+'^L'*$n
$b=,($l+'\\'*$j+' "'*$n)+$b}
$b

```

Try it online!

---

# PowerShell, ~~104~~ ~~102~~ 92 bytes, Alternative

```
param($n),{$l='//';'^L';$i++}*$n+,{$l='\\';--$i;' "'}*$n|%{.$_}|%{' '*($n-$i-1)+$l*$i+$_*$n}

```

Try it online!

The script generates the array of scriptblocks and executes its in the same context. Less golfed:

```
param($n)filter g{' '*($n-$i-1)+$l*$i+$_*$n}
,{$l='//';'^L'|g;$i++}*$n+,{$l='\\';--$i;' "'|g}*$n|%{.$_}

```
> 4 votes

# Answer
# Charcoal, ~~42~~ 32 bytes

```
ＮθＧ⌈⊖θ\↓‖Ｃ‖Ｍ↑Ｆθ«Ｐ×^Lθ↘»Ｆθ«Ｐ×" θ↙

```

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

```
Ｎθ

```

Input the size.

```
Ｇ⌈⊖θ\↓

```

Print a small triangle of `\`s.

```
‖Ｃ‖Ｍ↑

```

Reflect it twice, once horizontally to complete the bottom left block of `\`s, once vertically with mirroring to produce the top left block of `/`s.

```
Ｆθ«Ｐ×^Lθ↘»

```

Print the top right block of `^`s and `L`s.

```
Ｆθ«Ｐ×" θ↙

```

Print the bottom right block of `"`s and spaces.
> 3 votes

# Answer
# Zsh commit 2a96748, ~~123~~ ~~121~~ 119 bytes

```
alias R=repeat
R "i=a=$1" {s=${(l:--i:)};R b++ s+=//;R a s+=^L;<<<$s}
R a {s=${(l:i++:)};R a-i s+='\\';R a s+=' "';<<<$s}

```

Try it online!

This specific version fixes a bug that would otherwise require `i=a=$1` to be in quotes. TIO doesn't have that version obviously, so the linked one is two bytes longer.
> 3 votes

# Answer
# Python 3.8 (pre-release), ~~97 93~~ 92 bytes

```
lambda a:sum(zip(*((' '*(x:=a+~i)+'//'*i+'^L'*a,' '*i+r'\\'*x+' "'*a)for i in range(a))),())

```

Try it online!

Output is a tuple of lines.

*-4 by @Seb*

*-1 by @Danis*
> 3 votes

# Answer
# C (gcc), ~~160~~ ~~135~~ 130 bytes

Saved 5 bytes thanks to ceilingcat!!!

```
p(n,c){for(;n--;)printf(L"\n//\\\\L^ \"  "+c+n%2);}i;t;f(n){for(t=i=1;i;i+=t,t=i>n?i=n,-1:t)p(n-i,9),p(!p(2*n,6-t),p(2*~-i,2-t));}

```

Try it online!

### Explanation (before some golfs)

```
d;p(n,c){                             // p is a helper function that prints
                                      // n/2 pairs of chars
  for(d=0;n--;d^=1)                   // loop n times, flipping d between
                                      //   0 and 1 each time
    printf(L"                         // print one char of a pair of
                                      //   chars based on c (then select the
                                      //   other one on the next loop as d
                                      //   flips between 0 and 1):
             //                       //   c==0: '//'
               \\\\                   //   c==2: '\\'
                   ^L                 //   c==4: '^L'
                      \"              //   c==6: '" '
                                      //   c==7: any number of spaces
                          \n"         //   c==9: p(1,9) prints a newline
             +c+d);                   // use c and d to select char
}                                     // returns 0
i;t;f(n){                             // f is the main function
  for(t=i=1;                          // main loop i goes from 1 to n and
                                      // back down to 1 again
    i;                                // loop until i is 0
    i+=t,                             // bump i up for 1st half and then
                                      // bump i down for 2nd half
         t=i>n?i=n,-1:t)              // flip t from 1 to -1 half way thru
               p(n-i,7),              // print leading spaces
               p(2*~-i,1-t),          // print left side slashes
               p(2*n,5-t),            // print right side of cube
               p(1,9);                // print newline
}                                     //

```
> 3 votes

# Answer
# Jelly, 30 bytes

```
ḶṚżḤƊØ.xⱮ;€3,5ẋ$;ṚḤ$$ị“/\^"L ”

```

A monadic Link accepting a positive integer which yields a list of lists of characters (a list of lines).

**Try it online!** (The footer calls the Link and joins the resulting lines with newline characters.)

### How?

```
ḶṚżḤƊØ.xⱮ;€3,5ẋ$;ṚḤ$$ị“/\^"L ” - Link: integer, n    e.g. 3
Ḷ                              - lowered range            [0,1,2]
    Ɗ                          - last three links as a monad - f(that):
 Ṛ                             -   reverse                [2,1,0]
   Ḥ                           -   double                 [0,2,4]
  ż                            -   zip together           [[2,0],[1,2],[0,4]]
        Ɱ                      - map with:
     Ø.                        -   bits                   [0,1]
       x                       -   repeat elements        [[0,0],[0,1,1],[1,1,1,1]]
               $               - last two links as a monad - f(n):
           3,5                 -   three pair five        [3,5]
              ẋ                -   repeat (n times)       [3,5,3,5,3,5]
         ;€                    - concatenate each = x     [[0,0,3,5,3,5,3,5],[0,1,1,3,5,3,5,3,5],[1,1,1,1,3,5,3,5,3,5]]
                    $          - last two links as a monad - f(x):
                   $           -   last two links as a monad - f(x):
                 Ṛ             -     reverse              [[1,1,1,1,3,5,3,5,3,5],[0,1,1,3,5,3,5,3,5],[0,0,3,5,3,5,3,5]]
                  Ḥ            -     double               [[2,2,2,2,6,10,6,10,6,10],[0,2,2,6,10,6,10,6,10],[0,0,6,10,6,10,6,10]]
                ;              -   concatenate            [[0,0,3,5,3,5,3,5],[0,1,1,3,5,3,5,3,5],[1,1,1,1,3,5,3,5,3,5],[2,2,2,2,6,10,6,10,6,10],[0,2,2,6,10,6,10,6,10],[0,0,6,10,6,10,6,10]]
                      “/\^"L ” - list of characters = '/\^"L '
                     ị         - index into (1-indexed & modular, i.e. 10->")
                                                     -> ['  ^L^L^L',
                                                         ' //^L^L^L',
                                                         '////^L^L^L',
                                                         '\\\\ " " "',
                                                         ' \\ " " "',
                                                         '   " " "',
                                                        ]

```
> 3 votes

# Answer
# Stax, 27 bytes

```
ü╚lTà╨ú%Ñ►F↔33j♦ü♂D▄P;L.⌂î↑

```

Run and debug it
> 3 votes

# Answer
# PHP, ~~134~~ 116 bytes

```
for($f=str_repeat;$i<$n=$argn;)$s=($t=$f(" ",$i++).$f("//",$n-$i).$f("^L",$n)."
").$s.strtr($t,'/^L','\\ "');echo$s;

```

Try it online!

Yes, much shorter to build the string..

**EDIT:** a huge 18 bytes saved thanks to optimization from Dom Hastings

**Old version kept just for the fun:**

# 157 bytes

```
for($f=str_repeat;$i<2*$n=$argn;$s.='//')$i++<$n?printf("%".($n-2+$i)."s%s",$s,$f("^L",$n)."
"):printf("%".(5*$n-$i)."s",$f('\\',4*$n-2*$i).$f(' "',$n)."
");

```

Try it online!

Here is an infamous PHP answer based on `printf`. Couldn't think of an uglier looking piece of code for now, but I'll work on it (starting to think it would be better to build the whole string)!
> 3 votes

# Answer
# Wolfram Language (Mathematica), 172 bytes

```
(m=MapThread[Join,{DiamondMatrix[#][[1;;#+1,1;;#]],2BoxMatrix[#][[1;;#+1,1;;#+1]]}];Print/@StringJoin@@@(Join[m,4Reverse[m]]/.{0->" ",1->"//",2->"^L",4->"\\\\",8->" \""}))&

```

Try it online!

**Brief explanation**:

Construct the upper part `m` with DiamondMatrix and BoxMatrix:

```
m = MapThread[Join, {DiamondMatrix[n][[1 ;; n + 1, 1 ;; n]], 2BoxMatrix[n][[1 ;; n + 1, 1 ;; n + 1]]}]

```

Derive the whole matrix `M` from `m`:

```
M = Join[m, 4*Reverse@m]

```

you can visualize it with:

```
MatrixPlot[M, Frame -> None]

```

when n = 10, it's like this:

Replace each number from the matrix with corresponding string:

```
M/.{0->" ",1->"//",2->"^L",4->"\\\\",8->" \""}

```

Convert each row to string and print it:

```
Print/@StringJoin@@@%

```
> 3 votes

# Answer
# batch ~~317~~ ~~309~~ ~~301~~ ~~291~~ ~~284 bytes~~ 276 bytes

```
Cls&@Set $=@Set
%$%/Ah=%1*2,z=0
%$%F=@For /L %%a in (1 1 &%$%P=@^<nul set/p&%$%C= @If ,%%y LEQ %1
%f:a=y%!h!)Do @(%$%/Aw=%1-z
%F%!w!)Do %P%=ESCC
%F%!z!)Do%C%(%P%=//)Else %P%=\\
%F%%1)Do%C%(%P%=^^L)Else %P%^"=ESCC""
%C:EQ=SS%(%$%/A z+=1)Else%C:,=not %%$%/Az-=1
Echo()

```

**Cube.bat**

Notes:

* *must be run from the command line using:* `Echo(cube.bat n|Cmd /V:on` *where `n` is an integer representing cube size and cube.bat is the filename of the file*
* lines `1` and`3` end wth trailing spaces
* **requires windows 10 with virtual terminal support**
* `ESC` is a stand in for the ANSI escape character, As it can't be pasted here, the scripts raw paste data can be found here.
    + Or it can be generated by opening the command prompt and typing:
        - `>"%TEMP%\escape.chr" Echo(``ALT`+`027` then pressing `ENTER`
    + Or output using a for loop with `Echo off`:
        - `(For /F "skip=4 DELIMS=" %a in ('Echo(prompt $E^|cmd')Do Echo(%a) >"%TEMP%\escape.chr"`

Vt sequence `ESCC` *('cursor right')* is used to get around `<nul set /p`'s inability to output leading spaces.

example output:
> 3 votes

# Answer
# Jelly, 37 bytes

```
Ḷ,Ṛ$ạ’;,ʋ³ẋ@"ɗ€"“ “//“^L”,“ “\\“ "”ẎY

```

Try it online!
> 2 votes

# Answer
# Lua (LuaJIT), 122 bytes

```
r=n.rep;for i=1,n*2 do print(i<=n+0 and r(' ',n-i)..r("/",i*2-2)..r('^L',n)or r(' ',i-1-n)..r("\\\\",n*2-i)..r(' "',n))end

```

Try it online!

(Above code abuses the TIO's input string-type to save 1 byte, see Not abused version)
> 2 votes

# Answer
# GolfScript, 68 bytes

```
~:i,.-1%]zip.-1%]{{~" "*\["//""\\\\"]0=*+["^L"' "']0=i*+}%1:0;n*}%n*

```

Try it online!

Its really messy, but it works and I don't really know a better way to do it.
> 2 votes

# Answer
# Excel, 114 bytes

```
=LET(x,A1,q,SEQUENCE(2*x),b,q>x,r,IF(b,q-x-1,x-q),REPT(" ",r)&REPT(IF(b,"\\","//"),x-r)&REPT(IF(b,"""""","^L"),x))

```

Link to Spreadsheet
> 2 votes

# Answer
# Regenerate, 84 bytes

```
(( {#2-1}| {$~1-1})(//$3|)(^L){$~1}\n){$~1}(( $6|)(\\{#7-2}|\\{#3})( "){$~1}\n){$~1}

```

Takes the size as a command-line input. Try it here!

### Explanation

Spaces are replaced with underscores for improved visibility.

Top half:

```
(( {#2-1}| {$~1-1})(//$3|)(^L){$~1}\n){$~1}
(                                    )       Group 1: one row of the top half
 (                )                           Group 2: leading spaces
  _{#2-1}                                      Either one less space than the previous row
         |_{$~1-1}                             or (input-1) spaces if this is the first row
                   (     )                    Group 3: slashes
                    //$3                       Either the previous row's slashes plus two more
                        |                      or empty string if this is the first row
                          (^L)                Group 4: ^L
                              {$~1}           Repeat group 4 (input) times
                                   \n         Newline
                                      {$~1}  Repeat group 1 (input) times

```

Bottom half:

```
(( $6|)(\\{#7-2}|\\{#3})( "){$~1}\n){$~1}
(                                  )       Group 5: one row of the bottom half
 (    )                                     Group 6: leading spaces
  _$6                                        Either the previous row's spaces plus two more
     |                                       or empty string if this is the first row
       (               )                    Group 7: backslashes
        \\{#7-2}                             Either two fewer slashes than the previous row
                |\\{#3}                      or the same number of slashes as in the last match
                                              of group 3 if this is the first row
                        (_")                Group 8: space-quote
                            {$~1}           Repeat group 8 (input) times
                                 \n         Newline
                                    {$~1}  Repeat group 5 (input) times

```
> 2 votes

# Answer
# Perl 5 \+ `-M5.10.0 -pa`, 71 bytes

```
say,$\=y'/^L'\ "'r.$/.$\for map$"x("@F"-$_--)."//"x$_."^L"x"@F",1..$_}{

```

Try it online!
> 1 votes

# Answer
# Julia, ~~79~~ ~~73~~ 69 bytes

output is a list of lines

```
f(N,a=-N+1:0,b=0:N-1)=@.[" "^-a*"//"^b*"^L"^N;" "^b*"\\"^-2a*" \""^N]

```

Try it online!
> 1 votes

# Answer
# Vyxal `j`, 26 bytes

```
ʁd\/*m‛^L‛ ""?*ƛw?ẋ;fZvṅøĊ

```

Try it Online!
> 1 votes

# Answer
# Japt `-R`, 31 bytes

```
Æç'Li^)i'/pXÑÃû
c¡Xd`/\\^ L"`Ãw

```

Try it

```
Æç'Li^)i'/pXÑÃû\nc¡Xd`...`Ãw     :Implicit input of integer U
Æ                                :Map each X in the range [0,U)
 ç                               :  U times repeat
  'Li^                           :    "L" prepended with "^"
      )                          :  End repeat
       i                         :  Prepend
        '/p                      :    "/" repeated
           XÑ                    :    X*2 times
             Ã                   :End map
              û                  :centre pad each element with spaces to the length of the longest
               \n                :Reassign to U
                 c               :Concatenate
                  ¡              :  Map each X in U
                   Xd`...`       :    For each pair of characters in the string, replace all occurrences of the first in X with the second
                          Ã      :  End map
                           w     :  Reverse
                                 :Implicit output joined with newlines

```
> 1 votes

---
Tags: code-golf, ascii-art, 3d
---


title: Is it an emoji?

text:
# Question
Title: Is it an emoji?
I've been working on this iOS app recently and I encountered a (rather easily solved) problem: How do I determine if my string is comprised only of emojis?

Well, that's your job today!

### Input

A string. If the presence of unicode characters is problematic for you then you may use a different reasonable format. Please state what you do if you do something different from a regular string for taking input.

### Output

Print or return a truthy value if the input string contains only emojis, and a falsey value if it contains any characters other than emojis.

### Wait a sec... what's an emoji?

An emoji is a character that falls in these ranges:

```
0x1F600...0x1F64F  // Emoticons
0x1F300...0x1F5FF  // Misc Symbols and Pictographs
0x1F680...0x1F6FF  // Transport and Map
0x2600...0x26FF    // Misc symbols
0x2700...0x27BF    // Dingbats
0xFE00...0xFE0F    // Variation Selectors

```

(I think)

### This is , so shortest code in bytes wins❕

### Test cases

```
"Is it an emoji? " -> False
"code-golf" -> False
"    " -> False
"I have no fancy emojis :(" -> False

"" -> True
"" -> True

```

For you poor souls who cannot see emojis, here is an image of the test cases.

# Answer
# Ruby, ~~61~~ 56+1 = ~~62~~ ~~57~~ 47 bytes

Uses the `-n` flag and takes input from STDIN. Prints `0` for truthy and `nil` for falsy.

-5 bytes because for some reason I initially thought the regex solution would not work???

-10 bytes from NieDzejkob for noticing a code point overlap that I missed :o

```
p$_=~/^[--☀-➿-]*$/

```

Try it online!
> 3 votes

# Answer
# Emojicode, 179 bytes

```
a➡na◀n 9728▶n 10175◀n 65024▶n 65039◀n 127744▶n 128591◀n 128640▶n 12876701

```

A callable that takes a list of integers representing the codepoints and returns 1 or 0.

Try it online!

# Emojicode, 187 bytes

```
a➡iani◀n 9728▶n 10175◀n 65024▶n 65039◀n 127744▶n 128591◀n 128640▶n 128767

```

A callable that takes a string and returns a boolean.

Try it online!

## Ungolfed and explained

```
 A callable that takes a  called input and returns a
 input  ➡
  For each character in input
  character  input
   Create a frozen called n containing the unicode codepoint of character
   n  character
   If the value is in one of specific ranges, return  (if the current character is not an emoji)
  ◀n 9728▶n 10175◀n 65024▶n 65039◀n 127744▶n 128591◀n 128640▶n 128767

  Since we're here, all characters are an emoji, so return

```

Try it online!
> 13 votes

# Answer
# JavaScript (V8), 39 bytes

Since the proposal for Unicode property escapes is now part of V8, this can also be addressed without manually specifying ranges. Granted, this comes years after the original question was asked, but I think it is an interesting addition none the less.

```
a=>/^\p{Emoji_Presentation}*$/u.test(a)

```

Try it online!
> 3 votes

# Answer
# Python, 87 bytes

```
lambda x:re.match('^[---☀-➿-]*$',x)and 1
import re

```

Try it online!

Returns `1` as truthy value and `None` as falsy value.
> 1 votes

# Answer
# Proton, 54 bytes

```
map(/[--☀-➿-]/.match)+all

```

Try it online!

-9 bytes (3 chars) thanks to NieDzejkob

"Borrowing" Uriel's regex :P This is shorter thanks to Proton's obscure features and regex literals
> 1 votes

# Answer
# QuadR, 47 bytes

```
''≡⍵
[--☀-➿-]

```

Try it online!

Is…

`''≡⍵` an empty string identical to the result when…

`[--☀-➿-]` all emojis are…

replaced with nothing

?
> 1 votes

# Answer
# JavaScript, ~~83~~ 61 bytes

-22 bytes thanks to @Shaggy

`s=>(s.match(/\ud83d[\ude00-\ude4f]/g)||"").length==s.length/2`

**Demo**

```
f=s=>(s.match(/\ud83d[\ude00-\ude4f]/g)||"").length==s.length/2

document.writeln(f("code-golf")) //false
document.writeln(f("    ")) //false
document.writeln(f("I have no fancy emojis :(")) //false
document.writeln(f("")) //true
document.writeln(f("")) //true
```
> 0 votes

---
Tags: code-golf, string, decision-problem, unicode
---