20
\$\begingroup\$

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

\$\endgroup\$
12
  • 3
    \$\begingroup\$ When you say 0, 1, 2, 9, do you mean source is only restricted to not contain ASCII/codepages 48, 49, 50 and 57? \$\endgroup\$ – 640KB Feb 22 at 15:22
  • 10
    \$\begingroup\$ This is a nice challenge, but be aware that Do X without Y is discouraged because it's often very similar to other challenges with the same premise \$\endgroup\$ – Redwolf Programs Feb 22 at 16:25
  • 10
    \$\begingroup\$ This does belong on this site, and is on-topic. Redwolf was simply pointing out that Do X without Y often leads to low-quality challenges or duplicates, so it isn't always the best "approach" to have when thinking of a challenge \$\endgroup\$ – caird coinheringaahing Feb 22 at 17:21
  • 11
    \$\begingroup\$ Is x=>'1, 2, miss a few, 99, 100'.normalize('NFKC') a valid submission as it using not 1? \$\endgroup\$ – tsh Feb 23 at 2:29
  • 21
    \$\begingroup\$ Anyone else grow up with "skip a few"? \$\endgroup\$ – MooseBoys Feb 23 at 18:13

56 Answers 56

1
2
2
\$\begingroup\$

Standard ML (MLton), 65 bytes

print(String.map(fn c=>chr(ord c-3))"4/#5/#plvv#d#ihz/#<</#433");

Try it online!

"4/#5/#plvv#d#ihz/#<</#433" is "1, 2, miss a few, 99, 100" shifted by adding three to each ASCII code. String.map(fn c=>chr(ord c-3)) reverses this shifting by substracting three of each char's ordinal number.

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

CJam, 28 26 bytes

Two bytes off thanks to @Lyxal!

XY"miss a few"A_*_(\]", "*

Try it online!

Explanation

X              e# Push contents of variable X (predefined value): 1
Y              e# Push contents of variable Y (predefined value): 2
"miss a few"   e# Push this string
A              e# Push contents of variable A (predefined value): 10
_*             e# Duplicate, multiply: gives 100
_(             e# Duplicate, decrement: gives 99
\              e# Swap
]              e# Concatenate stack contents into an array
", "           e# Push this string 
*              e# Join the array entries with the specified string
               e# Implicit display 
\$\endgroup\$
2
2
\$\begingroup\$

Yabasic, 46 bytes

?5-4,", ",5-3,", miss a few, ",33*3,", ",5*5*4

Try it online!

Replaced calculated numbers for 1 and 2 with \x hex codes for ASCII 49 and 50 and saved 3 bytes!

(Can't do the above because it results in \x31 and \x32 which of course contain 1 and 2...)

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

x86_16 machine code, 146 bytes

Thank's to @mik for tips and trick :))

Replace : add al, "0" / add dl, "0" with add al, 2fh + inc al and add dl, 2fh + inc dl to avoid "0" in the source code.

B3 04          MOV BL, 4
B1 03          MOV CL, 3
2A D9          SUB BL, CL
B4 0E          MOV AH, 0EH
8A C3          MOV AL, BL
04 2F          ADD AL, 2FH
FE C0          INC AL
CD 10          INT 10H
B0 2C          MOV AL, ","
CD 10          INT 10H
80 C3 2F       ADD BL, 2FH
FE C3          INC BL
FE C3          INC BL
8A C3          MOV AL, BL
CD 10          INT 10H
B8 2C 0E       MOV AX, 0E2CH
CD 10          INT 10H
B4 09          MOV AH, 09h
BA 7A 01       MOV DX, OFFSET TXT
CD 21          INT 21H
B8 2C 0E       MOV AX, 0E2CH
CD 10          INT 10H
                                      
B8 20 0E       MOV AX, 0E20H
CD 10          INT 10H
               
B0 21          MOV AL, 33
B3 03          MOV BL, 3
F6 E3          MUL BL
B3 0A          MOV BL, 10
33 C9          XOR CX, CX
           LOOP1:
33 D2          XOR DX, DX
F7 F3          DIV BX
52             PUSH DX
41             INC CX
85 C0          TEST AX, AX
75 F6          JNZ LOOP1
    PRINT_DIGIT1:
5A             POP DX
80 C2 2F       ADD DL, 2FH
FE C2          INC DL
B4 02          MOV AH, 02H
CD 21          INT 21H
E2 F6          LOOP PRINT_DIGIT1
                                      
B8 2C 0E       MOV AX, 0E2CH
CD 10          INT 10H
B8 20 0E       MOV AX, 0E20H
CD 10          INT 10H
                                      
B0 04          MOV AL, 4
B3 05          MOV BL, 5
F6 E3          MUL BL
F6 E3          MUL BL
B3 0A          MOV BL, 10
33 C9          XOR CX, CX
           LOOP2:
33 D2          XOR DX, DX
F7 F3          DIV BX
52             PUSH DX
41             INC CX
85 C0          TEST AX, AX
75 F6          JNZ LOOP2
    PRINT_DIGIT2:
5A             POP DX
80 C2 2F       ADD DL, 2FH
FE C2          INC DL
B4 02          MOV AH, 02H
CD 21          INT 21H
E2 F6          LOOP PRINT_DIGIT2
            EXIT:
B8 00 4C       MOV AX, 4C00H
CD 21          INT 21H
                                                                              
20 6D 69 73 73 20 61 20 66 65 77 24   TXT DB " miss a few$"

Run is DOSBox :

enter image description here

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 0 appears in the code (ASCII 30) \$\endgroup\$ – mik Mar 6 at 7:53
  • 1
    \$\begingroup\$ the goal of this challenge is to avoid such constructions, you can e.g. add 2fh and then increment \$\endgroup\$ – mik Mar 6 at 10:42
  • \$\begingroup\$ @mik Thank's for tips and trick :)) I edited my answer now \$\endgroup\$ – VIII Mar 6 at 11:33
2
\$\begingroup\$

Javascript (ES6), 70 bytes

Old 75:

a=8-7;b=8-6;c=8-8;d=4+5;_=>`${a}, ${b}, miss a few, ${d}${d}, ${a}${c}${c}`

New 50:

_=>[8-7,8-6,'miss a few',(4+5)*(5+5)+4+5,(8-7)*(55+55-5-5)].join(', ')

by far not the best js answer, ill widdle.

\$\endgroup\$
2
+50
\$\begingroup\$

factor, 66 61 bytes

Shaved 5 bytes thanks to @Bubbler!

4 3 - 5 3 - 33 3 * CHAR: d "%d, %d, miss a few, %d, %d"printf

Try it online!

Original version:

4 3 - 5 3 - 33 3 * dup 3 - 4 + "%d, %d, miss a few, %d, %d" printf

My first factor line. Probably can be shorter…

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ You're using 0 in 0x63 and 0x64. \$\endgroup\$ – Bubbler Mar 15 at 7:46
  • \$\begingroup\$ @Bubbler ha I missed it.. fixed now, but it is even longer.. \$\endgroup\$ – hdrz Mar 15 at 10:26
  • \$\begingroup\$ You can use CHAR: d for 100, and you can omit a space after string literals. (61 bytes) \$\endgroup\$ – Bubbler Mar 19 at 6:17
1
\$\begingroup\$

Zsh, 47 bytes

Not very creative. Oh well.

echo $[3/3], $[6/3], miss a few, $[##c], $[##d]

Try it online!

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

Charcoal, 21 bytes

”'3?Sxv7´D|λ*§ξ¬E‹Dαg

Try it online! Compression again. Best I could do without compression is 23 bytes:

⪫⟦LψLχmiss a few℅c℅d⟧, 

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

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

PHP, 30 bytes

This contains unprintables so the link is to a Bash program that reconstructs the file and validates it.

<?=~.........................;

Try it online!

Explanation

prints the bitflipped (~) string 1, 2, miss a few, 99, 100.

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

Rust, 68 Bytes

fn main(){print!("{}, {}, miss a few, {}, {}",4-3,5-3,66+33,63+37)}

This is my first attempt at code golf Yahoo! Try it online

Rust, 56 bytes

Cutting out the main{} on tio saves 12 bytes

print!("{}, {}, miss a few, {}, {}",4-3,5-3,66+33,63+37)

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to the site, and nice first answer! Be sure to check out our Tips for golfing in Rust page for ways you can golf your program, and we hope you enjoy your time on the site! \$\endgroup\$ – caird coinheringaahing Mar 9 at 16:02
  • \$\begingroup\$ Thanks for the welcome! I'm just having fun with restricted source, I'm not looking to be very competitive! \$\endgroup\$ – AbleTheAbove Mar 9 at 16:10
1
\$\begingroup\$

BRASCA, 41 36 bytes

`<0x01>, <0x02>, miss a few, `I,[o]H{n` ,`ooHn

Replace <0x01> and <0x02> with ascii codepoints 1 and 2.

Try it!

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

AWK, 53 bytes

$a=++x", "++x", miss a few, "(z=(++y y)-x)z", "++z--y

Try it online!

This abuses a couple of AWK language features, including that all variables are initialized to blank/0/False (context sensitive), that it will happily convert strings to numeric values to make an arithmetic operator work, and it will also convert numeric values to strings in order to append characters to it.

First it gets 1, by incrementing variable x

++x", "

then 2, miss a few, just does the same thing again...

++x", miss a few, "

getting a 9 is a bit more work,

(++y y)-x

which works by getting a 1 with ++y then appended it to itself to get 11 then subtracting 2 with -x.

Using that to set the variable z means we can appended another 9 on the end with,

(z=...)z

That just leaves the last bit , 100 which we can get by incrementing the 9 and appending to that 1 decremented.

", "++z--y

I'm pretty sure there are other ways to do this in AWK that are shorter, but I like that this doesn't use any numbers.

One last thing I forgo to mention... The string is printed since,

$a=...

is interpreted as $0=... which evaluates to True, causing AWK print the value of $0, which was just set to the output we want.

\$\endgroup\$
7
  • \$\begingroup\$ I think assuming input to be "" is not correct, you can only assume an empty input. \$\endgroup\$ – mik Apr 13 at 9:21
  • \$\begingroup\$ That might have been a bad assumption on my part (that it was OK to send empty input), so I asked a comment to clarify. I don't see anything about input in the original question or the comments added. \$\endgroup\$ – cnamejj 2 days ago
  • \$\begingroup\$ but you are passing two quotes as input, and not an empty string \$\endgroup\$ – mik 2 days ago
  • \$\begingroup\$ An empty string works too, I don't know how to do that in TIO \$\endgroup\$ – cnamejj 2 days ago
  • 1
    \$\begingroup\$ for me empty string does not work \$\endgroup\$ – mik 2 days ago
1
\$\begingroup\$

GolfScript, 34 bytes

!.)', ':c.@\'miss a few'3c\33*.c\)

Try it online!

!                                   Push 1 to the stack.
 .)                                 Copy the 1 and increment.
   ',':c                            Define c as ', ' to save characters when commas are needed.
        .@\                         Copy the ', ' and move stuff around into the right order.
           'miss a few'             Push the string to the stack.
                       3c\          Push 3 and ', ' then swap them.
                          33*       Multiply 3*33 to get 99.
                             .c\)   Copy the 99, push ', ' then swap them and increment the last 99.
\$\endgroup\$
1
\$\begingroup\$

Arn, 22 bytes

˜▒çc>åžî¼#(¸“├)øW§Ò┴Ì"

Try it!

Explained

Just the string literal. Pretty boring, the next-shortest I could get without this was 29 bytes.

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

Scratch, 110 bytes

Try it online!

Easy sauce. Alternatively, 12 blocks.

when gf clicked
say(join((4)-(3))(join[, ](join((5)-(3))(join[, miss a few, ](join((3)*(33))(join[, ]((66)+(34
New contributor
Nilster is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 187 178 bytes

{iiiii}dcdddddc{d}ddc{ii}ddcddddddc{d}ddc{{i}dd}dddcddddc{i}cc{{d}ii}dddc{{i}dddd}iiiiic{{d}iiii}dddddc{{i}ddd}cdc{i}{i}ddc{{d}iii}dddddc{d}ddc{ii}iiiiicc{d}dddc{d}ddc{ii}dddcdcc

The previous version was bad.

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ 184 bytes: Try it online! \$\endgroup\$ – a stone arachnid Apr 12 at 16:11
  • \$\begingroup\$ @astonearachnid This was made using my old generator, which was bad. Thanks! I fixed some stuff. \$\endgroup\$ – A username Apr 13 at 5:20
0
\$\begingroup\$

TeX, 41 bytes

In TeX you can print the ASCII-value of a character using \number`CHAR.

\def~{\number`}~^A, ~^B, miss a few, ~c, ~d

Replace ^A and ^B in the above code with SOH and STX.

Using just the printable range of ASCII, the following works as well without modifications (4 bytes more):

\def~{\number`}~^^A, ~^^B, miss a few, ~c, ~d

Complete TeX file:

\def~{\number`}~, ~, miss a few, ~c, ~d
\bye

To copy the code above (the complete file), hit on the edit-button, so that you can copy the unprintable ASCII-letters, which are displayed in the editor.

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

Elixir, 58 49 bytes

[?b-?a,?c-?a,"miss a few",?c,?d]|>Enum.join(", ")

Try it online!

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

C++17

#include <iostream>
main()
{
  std::cout << 4 - 3 << ", " << 5 - 3 << ", miss a few, " << 33 * 3 << ", " << 5 * 5 * 4 << "\n";
}
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to CGCC. Note that return 0 contains zero, which is one of the restricted characters. I don't know much about C++ but I think your code might work without the return statement anyway? \$\endgroup\$ – Dingus Mar 6 at 12:06
  • \$\begingroup\$ It will. Also, using std::cout; doesn't save any bytes. \$\endgroup\$ – Kamila Szewczyk Mar 6 at 17:55
0
\$\begingroup\$

Templates Considered Harmful, 129 bytes

Cat<Cat<Cat<Cat<Cat<T,St<44,' '>>,Add<T,T>>,St<44,' ','m','i','s','s',' ','a',' ','f','e','w',44,' ',57,57,44,' '>>,T>,St<48,48>>

Try it online!

Tries to represent each character as its ascii value. If that contains a forbidden number, replace it with its char literal. This only leaves 1 and 2 to deal with.

1 is replaced with T, which evaluates to I<1> which is cast into string 1 when concatenated.
2 is replaced with Add<T,T>, which evaluates to I<2> which is cast into string 2 when concatenated.

Cat<
 ...
     T,                                                                    # "1"
     St<44,' '>>,                                                          # ", "
    Add<T,T>>,                                                             # "2"
   St<44,' ','m','i','s','s',' ','a',' ','f','e','w',44,' ',57,57,44,' '>>,# ", miss a few, 99, "
  T>,                                                                      # "1"
 St<48,48>>                                                                # "00"
\$\endgroup\$
0
\$\begingroup\$

x86 opcode, 42 41 bytes

BE 8F 81 04 08 29 C9 B1 | 1A AC 04 6E AA E2 FA C3
BE B2 C4 BE B2 FF FB 05 | 05 B2 F3 B2 F8 F7 09 BE
B2 CB CB BE B2 C3 C2 C2 | 92 
fun:	mov esi, src
	sub ecx, ecx
	mov cl, srcEnd-src
x:	lodsb
	add al, '1'-0xC3
	stosb
	loop x
src:	ret
	db ', 2, miss a few, 99, 100', 0
srcEnd:
repeat srcEnd-src-1
	load a byte from src+%
	store byte (a-'1'+0xC3) and 0xFF at src+%
end repeat
funEnd:

Try it online!

Function that output to [esi] assuming enough space, should be placed on right place such that src contain no invalid chars

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

CSASM v2.1.1, 145 bytes

func main:
push 4
push 3
sub
push ", "
add
push 5
push 3
sub
add
push ", miss a few, "
add
push 33
push 3
mul
add
push ", "
add
push 5
dup
mul
push 4
mul
add
print
ret
end

Commented:

func main:
    ; Push 4 - 3
    push 4
    push 3
    sub
    ; String concatenation:  1 + ", "
    push ", "
    add
    ; Push 5 - 3
    push 5
    push 3
    sub
    ; String concatenation:  "1, " + 2
    add
    push ", miss a few, "
    ; String concatenation:  "1, 2" + ", miss a few, "
    add
    ; Push 33 * 3
    push 33
    push 3
    mul
    ; String concatenation:  "1, 2, miss a few, " + 99
    add
    push ", "
    ; String concatenation:  "1, 2, miss a few, 99" + ", "
    add
    ; Push a 5 and multiply it by itself
    push 5
    dup
    mul
    ; Push 25 * 4
    push 4
    mul
    ; String concatenation:  "1, 2, miss a few, 99, " + 100
    add
    ; Print the value on the top of the stack:
    ;   Stack: [ "1, 2, miss a few, 99, 100" ]
    print
    ret
end
\$\endgroup\$
0
\$\begingroup\$

Pxem, Filename: 32 bytes + Content: 4 bytes = 36 bytes, depends on ASCII-compatible.

  • Filename (escaped unprintables): \001.n.e\002.n.emiss a few.p.ec.n.ed.n
  • Content: , .p

Try it online!

How it works

  • Pxem is a stack-based procedure language.
  • .n is printf("%d",pop) unless empty.
  • .e calls subroutine (which is content).
  • .p is putc pop until empty.
  • Other non-command substrings are literal: pushed from backward.
\$\endgroup\$
0
\$\begingroup\$

Javascript, 54 bytes

[`MSwgMi`,`OTksIDEwMA`].map(atob).join`, miss a few, `

*inspired by @arnauld 's answer

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

APL (Dyalog Unicode), 45 bytes

(5↓7⌽∊'miss a few, ',⍨(', ',⍨⍕)¨5↑(3-5)⌽⍳77+!4)

 5↓ ⍝ Drop the first 5 elements
   7⌽ ⍝ Rotate left 7
     ∊'miss a few, ', ⍝ Concatenate and enlist
       ⍨ ⍝ Swap arguments
         (', ',⍨⍕)¨ ⍝ Encode as character and concatenate after swapping arguments
           5↑ ⍝ Take the first 5 elements
             (3-5)⌽ ⍝ Rotate right 2
               ⍳77+!4 ⍝ Create range from 0–100 inclusive

Try it online!

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

PHP, 69 bytes

<?=55-54,', ',floor((5*4)/7),', ','miss a few ',64746/654,', ',5*5*4;
New contributor
Dominic F is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
1
  • 7
    \$\begingroup\$ Unfortunately, 0, 1, 2 and 9 are banned characters for this challenge, so this answer is invalid \$\endgroup\$ – caird coinheringaahing Apr 12 at 13:44
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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