0
\$\begingroup\$

You're writing your favorite language and you want to display the following string: abcdefghijklmnopqrstuvwxyz to your happy customer. Unfortunately, your keyboard is broken and you can now only type symbols !+-*/[]().

You must submit a code that evaluates to be the string abcdefghijklmnopqrstuvwxyz or print the string abcdefghijklmnopqrstuvwxyz and contain only symbols !+-*/[](). For example, +![]+[] in javascript evaluates to be the string 0.

The shortest valid submission in 7 days wins. If there're multiple ones, I'll accept the one with the earliest last modification time. Good luck!

\$\endgroup\$
6
  • \$\begingroup\$ This looks similar to a previous code golf JSFuck challenge, which only allowed []()!+. Do you think the inclusion of *, -, and / makes this sufficiently different? \$\endgroup\$
    – xnor
    Commented Feb 23, 2020 at 3:10
  • \$\begingroup\$ @xnor I didn't know that challenge, but I think it's probably sufficient. \$\endgroup\$
    – newbie
    Commented Feb 23, 2020 at 3:11
  • \$\begingroup\$ I have allowed all languages. \$\endgroup\$
    – newbie
    Commented Feb 23, 2020 at 3:29
  • 5
    \$\begingroup\$ You have not allowed all languages. C can't have functions or even print anything without at least the underscore, numbers, and semicolon (plus whitespace). Can you allow everything except the alphabetic characters instead? \$\endgroup\$
    – S.S. Anne
    Commented Feb 23, 2020 at 5:28
  • 6
    \$\begingroup\$ @S.S.Anne - restricted-source often excludes some languages by virtue of the source restriction. (C is also by no means the only language "allowed" but impossible in which to actually compete in this case.) \$\endgroup\$ Commented Feb 23, 2020 at 7:29

4 Answers 4

10
\$\begingroup\$

Lenguage, \$1.5161 \times 10^{27}\$ characters

Everyone's favourite language when short of available characters!

A program consisting of any 1516111794593168227366643743 characters will print abcdefghijklmnopqrstuvwxyz then exit.

This is because that length in binary, left padded to a multiple of 3 bits with zeros is:

001 001 110 011 000 011 001 001 010 010 001 001 001 001 001 111
011 001 001 001 001 001 011 110 001 001 010 100 000 011 111

Which translated from Binaryfuck to Brainfuck is this  50 49 41  31 character program:

--[<+<-->>-----]<-----<[-->.+<]

Which we can easily try online!

How?

Brainfuck starts with an infinite tape of zeros, which may be incremented or decremented (\$0\$ decrements to \$255\$ and \$255\$ increments to \$0\$).
[...] or ] are ignored if the value under the head is \$0\$ otherwise ] loops back to its matching [
> and < move the head right and left respectively.
. prints the value under the head as a character.

--[<+<-->>-----]<-----<[-->.+<]  | print the alphabet  - tape = ". . n A x . ."
--                               | x -= 2  -> x = 254
  [            ]                 | while x != 0:
   <+                            |   move to A; A += 1
     <--                         |   move to n; n -= 2
        >>-----                  |   move to x; x -= 5
                                 |     -> 254//5 + 1 + 255//5 = 102 loops
                                 |        leaving n = 52, A = 102, x = 0
                <-----           | move to A; A -= 5
                      <          | move to n
                       [      ]  | while n != 0:
                        --       |   n -= 2
                          >.     |   move to A; print character(A)
                            +<   |   A += 1; move to n
                                 |     -> 52//2 = 26 loops, printing 'abc...xyz'

It might just be quicker to order a new keyboard though.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This makes me think that this challenge would have been better off being a code-bowling challenge rather than a code-golfing challenge. \$\endgroup\$
    – lyxal
    Commented Feb 23, 2020 at 4:38
  • 3
    \$\begingroup\$ ...I'm trying to golf it down :) \$\endgroup\$ Commented Feb 23, 2020 at 8:24
6
\$\begingroup\$

W c, 149 bytes

DISCLAIMER: This answer has nothing to do with the water closet.

The c flag confuses the interpeter with strings and character arrays, therefore outputting the lowercase alphabet. Note that I already had this idea before this challenge.

How to enter an empty input: just type "" as the input, W will not recognize this operand.

]+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Explanation

After compilation, it looks like this:

] % Roll the whole stack into a list (surrounding the input).
  % The stack: []

+ % W is short of operands, so an implicit argument is added.
  % The input is 0 by default if it's empty.
  % The stack: [0]

) % Increment all (automatically vectorizes)
  % The stack: [1]

+ % Join with the implicit input
  % The stack: [0,1]
)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+)+

% After all that boring stuff, the stack becomes:

% [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

97+

% For clarity the 97 )'s are converted to addition. Stack:

% [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]

Flag:C % Convert the numeric array to a string

% Output: abcdefghijklmnopqrstuvwxyz
```
\$\endgroup\$
1
  • \$\begingroup\$ Aww, I was totally thinking I could use this as a bathroom! Doesn't matter! :P \$\endgroup\$
    – lyxal
    Commented Feb 23, 2020 at 10:31
6
\$\begingroup\$

Brain-Flak, 396 bytes

((((((((((((((((((((((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])[()])

Try it online!

Explanation

This answer is pretty simple. We push z by doing a bunch of ()s

( () × 122 )

Then we use that as a starting place to count down each letter subtracting one each time.

( ... [()])

Where the ... is the code that pushed all the letters prior.

The unfortunate thing is that the structure of the goal string actually makes it a lot harder to do anything fancy. [] is basically useless since by the time we have anything on the stack we just want to count down. And as if that weren't enough all of the fun operations {...}, {} and <> are unusable.

This answer is likely optimal for brain-flak (without using -r).

Brain-Flak -r, 296 bytes

((((((((((((((((((((((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())())())())())())())())())())())())())())())())())())())())())())())())())())

Try it online!

Explanation

This works like the last one except we start at a and count up. This is cheaper since a has a smaller code point and adding one is cheaper than subtracting one. It saves exactly 100 bytes because there are 26 letters in the alphabet, going down to 'a' from 'z' saves 2 bytes per letter down which is 50 and changing minus one to plus one saves 2 bytes per letter, which is another 50.

The one issue is that this method does put things in the reverse order so we need -r to correct it, which is a flag that just reverses the order that things are output.

\$\endgroup\$
3
\$\begingroup\$

Javascript, 19793 9031 3318 chars

(![]+[])[+!![]]+([][(!![]+[])[!![]+!![]+!![]]+([][[]]+[])[+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([![]]+[][[]])[+!![]+[+[]]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]]()+[])[!![]+!![]]+([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+([][[]]+[])[!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[+[]]+(+(!![]+!![]+!![]+[!![]+!![]+!![]+!![]]+(!![]+!![])+(!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!![]+!![]+!![])+(!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(+!![])+(+[])+(!![]+!![])+(!![]+!![]+!![]+!![]+!![]+!![])+(+!![])+(+!![])+(!![]+!![]+!![])))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([]+[])[([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+(!![]+[])[+!![]]][([][[]]+[])[+!![]]+(![]+[])[+!![]]+([]+(+[])[([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+(!![]+[])[+!![]]])[+!![]+[+!![]]]+(!![]+[])[!![]+!![]+!![]]]](!![]+!![]+[!![]+!![]+!![]+!![]+!![]+!![]+!![]])+(!![]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(+(!![]+!![]+!![]+!![]+!![]+[!![]+!![]+!![]]+(!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(!![]+!![]+!![]+!![]+!![])+(+!![])+(+!![])+(!![]+!![]+!![]+!![]+!![])))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([]+[])[([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+(!![]+[])[+!![]]][([][[]]+[])[+!![]]+(![]+[])[+!![]]+([]+(+[])[([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+[]]])[+!![]+[+[]]]+(!![]+[])[+!![]]])[+!![]+[+!![]]]+(!![]+[])[!![]+!![]+!![]]]](!![]+!![]+!![]+[!![]+!![]+!![]+!![]+!![]+!![]])

See, this is what happens when people can't be bothered to write javascript by hand. They use generators. Still, that was an interesting challenge!

A better generator dropped over 10k 16k chars. Wow.

\$\endgroup\$
1
  • \$\begingroup\$ If you switch to new browsers only on jscrew.it you can even drop 6K more. Not working on TIO tho. \$\endgroup\$
    – newbie
    Commented Feb 23, 2020 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.