When I was a kid, there was a "really cool" shortcut to count to 100:
1, 2, miss a few, 99, 100
Output the exact string above, in the fewest characters possible, without using these characters: 0
, 1
, 2
, 9
Browser only.
_=>atob`MSwgMiwgbWlzcyBhIGZldywgOTksIDEwMA`
Try it online! (with a polyfill)
_=>[4-3,5-3,'miss a few',33*3,5*5*4].join`, `
_=>[..."45x67"].map((c,i)=>i>=3?+(6+c)+33:c-3)
\$\endgroup\$
Commented
Feb 24, 2021 at 20:58
charPointAt
on the string 'miss a few' or use pi for strings, but again too long.
\$\endgroup\$
Commented
Feb 24, 2021 at 23:22
3-1
?
\$\endgroup\$
3-@
would work with the same byte count and no filesystem assumptions.
\$\endgroup\$
cat(T+F:T,"miss a few",3*33+F:T,sep=", ")
T
and F
are equal to TRUE
and FALSE
. They get coerced to integers 1
and 0
by the operators +
and :
.
99:100
as 66:67+33
\$\endgroup\$
Commented
Feb 22, 2021 at 18:46
<c>, <c>, miss a few, <d><d><c>, <c><style>c:before{content:counter(a);counter-increment:a}d{counter-increment:a 48}
9
and 0
may works for 9
and 0
. But I'm not getting a shorter solution with these escape sequence.
\$\endgroup\$
Saved 2 bytes thanks to Digial Trauma's suggestion to replace 8*8+35 = 99
with 33*3 = 99
.
Saved 1 byte by realizing that I could replace 8*8+36 = 100
with 4*5*5 = 100
.
Saved 4 bytes thanks to dingledooper's suggestion to use sep=', '
in the print
!
Saved 5 bytes thanks to ovs' suggestion to use bytes
objects.
print(*b"","miss a few",*b"cd",sep=", ")
The b"" is equivalent to b"\1\2".
print(f"{4-3}, {6-4}, miss a few, {33*3}, {4*5*5}")
8*8+35
with 3*33
.
\$\endgroup\$
Commented
Feb 22, 2021 at 17:51
*b"\1\2"
and *b"cd"
: Try it online!
\$\endgroup\$
b"\1\2"
charcaters don't show up in the answer becase they are unprintable. I'll see what I can do to fix this. The Tio links still work though.
\$\endgroup\$
3Ṗ,³ṭ’¤j“¤mɗʂɠẉ⁾»W¤j⁾,
One thing to note: Jelly has the Ṙ
atom, which prints a string Jelly representation of it's argument. Lists in Jelly do not use [
and ]
as open/close markers, instead they consist of comma-separated values:
1,2,3,4,5Ṙ
prints 1,2,3,4,5
, unfortunately, without spaces.
3Ṗ,³ṭ’¤j“¤mɗʂɠẉ⁾»W¤j⁾, - Main link. Takes no arguments
3 - Yield 3;
Ṗ - Pop from 3, yielding [1, 2]
¤ - Group the previous links into a nilad:
³ - 100
’ - Decrement; 99
ṭ - Tack; [99, 100]
, - Pair; [[1, 2], [99, 100]]
¤ - Group the previous links into a nilad:
“¤mɗʂɠẉ⁾» - The compressed string "miss a few"
W - Wrap; ["miss a few"]
j - Join; [1, 2, ["miss a few"], 99, 100]
j⁾, - Join with ", "; "1, 2, miss a few, 99, 100"
$><<[3/3,6/3,'miss a few',33*3,5*5*4]*", "
-4 from Jonah. Borrows from Arnauld's answer.
$><<"cd".bytes.insert(2,"miss a few")*", "
The three unprintables for codepoints 1, 2 and 3 are in the string containing "cd".
-2 from manatwork. Other version with same bytecount
.sub()
is enough, no need for its global brother.
\$\endgroup\$
Commented
Feb 23, 2021 at 0:44
>> Each 5 57
>> Then 7 3 6 3 4 3 54 3 8
> ", "
> "miss a few"
>> "L"
>> #3
>> #5
>> 53*6
>> #4
>> 8-7
>> Output 56
Explanation:
I use the fact that each line with the line number \$x\$ can be called with \$x + k \cdot n \$, where \$k \in \mathbb{N} \$ and \$n\$ is total number of lines of code.
Example from code with 11 lines: the reference to line 1
can be replaced by 12
, 23
, 34
, and so on.
Try the translated version online!
Line by line:
As always in Whispers, we run the last line first:
>> Output 56
This line outputs the result from line 56. Since the code does not have 56 lines it actually outputs line \$ 56 \mod 11 = 1\$:
>> Each 5 57
Applying the same trick again we can replace this line with:
>> Each 5 2
In line 5 we can expect a function and in line 2 an array. The function will be applied on each element of the array and it replaces the element with the result. Let us first look at line 5:
>> "L"
L
is an argument from the Each
statement in line 1. L
is converted to a string.
Now line 2:
>> Then 7 3 6 3 4 3 54 3 8
Then
creates an array with the arguments as its elements. If we would print this line we get the following array:
[1, ', ', 2, ', ', 'miss a few', ', ', 99, ', ', 100]
Explanation of the arguments:
Line 3 and 4: simple strings
Line 6: Returns the length of line 3, so we get 2
Line 7: Returns the length of line 5, so we get a 1
Line 8: Returns the result of line 53 (actually 9) raised to the power of the result of line 6, so we get 100
Line 54 (actually 10): Subtracts result of line 8 with the result of line 7, so we get a 99
printf('%c, %d, miss a few, %d, %o',7*7,5-3,33*3,64);
A printf
, some spices, stir
EDIT: -1 byte thanks to Digital Trauma
EDIT 2: -3 bytes thanks to Michael Dorgan for octal, thought about 153 with %x
for hex but it has a 1..
Also, less fun but 2 bytes shorter by manatwork, improved by BadHorsie (it seems that <?=
can also take multiple arguments with comas):
<?=5-4,', ',5-3,', miss a few, ',33*3,', ',5*5*4;
5-3
(with %d) is 1 shorter than 47+3
(with %c).
\$\endgroup\$
Commented
Feb 22, 2021 at 17:49
echo
with simply enumerated parameters would be shorter. Try it online!
\$\endgroup\$
Commented
Feb 23, 2021 at 0:57
<?=
instead of echo
to save a couple of bytes.
\$\endgroup\$
Commented
Feb 23, 2021 at 12:09
l(){printf("%c, %d, miss a few %d, %o",7*7,5-3,'c',64);}
Let's save a couple bytes using Octal for the 100. Thanks to Sheik Yerbouti for saving a byte and point out the no commas issue.
for(char x[]="4/#5/#plvv#d#ihz/#<</#433",*y=x;*y;)putchar(*y++-3);
\$\endgroup\$
main(i){for(i=5*5;i--;)putchar("334#/<<#/zhi#d#vvlp#/5#/4"[i]-3);}
\$\endgroup\$
'c'
instead of 33*3
\$\endgroup\$
Commented
Feb 27, 2021 at 22:18
cat(chartr("@-K","/-:","B, C, miss a few, JJ, BAA"))
Encodes numbers as uppercase letters and then applies character range translation. Since we can't directly type 0-9
, we expand the range by 1 character in both directions resulting in /-:
.
-[----->+>+>+>++>++<<<<<]>>>--.-----.------------.<-.------.>.>+++++++.>+++.<++++++..<.>>--------.<<.>>+++++.-.<++++.<<.>.<<++++++..>.>.<+++++.-..
A fairly straightforward 255/5=51 loop giving ASCII 51 and ASCII 102 as 333ff
in 5 consecutive cells, followed by hunt and peck strategy.
-[>+>+>+>++>++[<]>-----]>>>--.-----.------------.<-.------.>.>+++++++.>+++.<++++++..<.>>--------.<<.>>+++++.-.<++++.<<.>.<<++++++..>.>.<+++++.-..
\$\endgroup\$
$,=", ";say!!3,5-3,"miss a few",3*33,4*5*5
Sets the record separator, and prints a few numbers and a string.
say"C, D, miss a few, KK, CBB"=~y,A-L,/-:,r
Translates B-K to 0-9 (extended by one more ASCII code on each side of the range) and prints.
$,=", ";say unpack"c3/acc","
miss a fewcd"
Sets the record separator, and unpacks values to be printed.
()->join([b"";"miss a few";b"cd"],", ")
the first string is "\1\2"
which is allowed if I understand the challenge correctly
b"str"
converts the string in an array of the value of each character so b"\1\2" => [1,2]
and b"cd" => [99,100]
mȯ←←←"4/#5/#plvv#d#ihz/#<</#433
Explanation:
m Map the function...
ȯ←←← Decrement character 3 times
"4/#5/#plvv#d#ihz/#<</#433 desired string "ASCII-shifted" by 3
³ḊĖ.ịṚj“¤mɗʂɠẉ⁾»W¤j⁾,
A full program that prints the result.
³ḊĖ.ịṚj“¤mɗʂɠẉ⁾»W¤j⁾, - Link: no arguments
³ - 100
Ḋ - dequeue -> [2,3,...,99,100]
Ė - enumerate -> [[1,2],[2,3],...,[98,99],[99,100]]
. - 0.5
ị - index into -> [[99,100],[1,2]]
Ṛ - reverse
¤ - nilad followed by links as a nilad:
“¤mɗʂɠẉ⁾» - dictionary compression of "miss a few"
W - wrap in a list -> ["miss a few"]
j - join -> [1,2,"miss a few",99,100]
⁾, - ", "
j - join -> [1,", ",2,", ","miss a few",", ",99,", ",100]
- implicit print -> `1, 2, miss a few, 99, 100`
I don't think this would be shorter with 0
, 1
, 2
and 9
.
XY…š§€…†Óт<т„, ý
X # push 1
Y # push 2
…š§€…†Ó # push compressed dictionary string "miss a few"
т< # push 100-1
т # push 100
„, # push string ", "
ý # join the stack with this string
≠x
instead of XY
.
\$\endgroup\$
[]{for(int x:"4/#5/#plvv#d#ihz/#<</#433"s)putchar(x-3);}
Inspired by a comment.
Usage:
#include <string>
#include <stdio.h>
using namespace std;
int main() {
auto k = [](){for(int x:"4/#5/#plvv#d#ihz/#<</#433"s)putchar(x-3);};
k();
return 0;
}
[]{for(int x:"4/#5/#plvv#d#ihz/#<</#433"s)putchar(x-3);}
\$\endgroup\$
Commented
Feb 25, 2021 at 5:28
+n, +n, 'miss a few, '#44+#45+n, +n
This is my own esolang, follow the link for more info.
Increments the accumulator, prints it, implicitly prints some strings (,
and miss a few,
are implicitly printed), does a loop on accumulator incrementation, and finishes as it started.
Edit: I realized that "97" used a "9". smacks forehead
B, C, miss a few, JJ, BAA
T`L`d
Try it online! Explantion:
B, C, miss a few, JJ, BAA
Replace the empty input with the literal string.
T`L`d
Transliterate upper case letters to digits.
$k=3-3;((@(46+3),@(53-3),@('miss a few'),@(57,57),@((46+3),48,48))|%{$k++;if($k-eq3){$_}else{($_|%{[char]$_})-join''}})-join', '
[Text.Encoding]::Unicode.GetString([Convert]::FromBase64string('MQAsACAAMgAsACAAbQBpAHMAcwAgAGEAIABmAGUAdwAsACAAOQA5ACwAIAAxADAAMAA='))
print ', '.join(map(str,(4-3,5-3,'miss a few',33*3,5*5*4)))
Thanks to @arnauld for js answer
j+\,d[=hZhZ"miss a few"t=*TTT
Python 3.8 translation:
Z=0
T=10
print(", ".join(map(str,[(Z:=Z+1),Z+1,"miss a few",(T:=T*T)-1,T])))
i3, 3, miss a few, 8, <esc>|<C-x><C-x>l.l<C-a>ylp$pp<C-a>
<?=join(', ',[$i=3/3,++$i,'miss a few',$i=33*3,++$i]);
PHP doesnt really want to be typed short, but I liked coming up with this :)
3ɽ÷«eeȮǒḋp«₁‹₁W‛, j
3ɽ÷ # stack = [1, 2]
«eeȮǒḋp« # stack = [1, 2, "miss a few"]
₁‹₁ # stack = [1, 2, "miss a few", 99, 100]
W‛, j # join stack on ", "
0
,1
,2
,9
, do you mean source is only restricted to not contain ASCII/codepages48
,49
,50
and57
? \$\endgroup\$x=>'1, 2, miss a few, 99, 100'.normalize('NFKC')
a valid submission as it using1
not1
? \$\endgroup\$