27
\$\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\$
13
  • 5
    \$\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, 2021 at 15:22
  • 12
    \$\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\$ Feb 22, 2021 at 16:25
  • 11
    \$\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\$ Feb 22, 2021 at 17:21
  • 12
    \$\begingroup\$ Is x=>'1, 2, miss a few, 99, 100'.normalize('NFKC') a valid submission as it using not 1? \$\endgroup\$
    – tsh
    Feb 23, 2021 at 2:29
  • 30
    \$\begingroup\$ Anyone else grow up with "skip a few"? \$\endgroup\$
    – MooseBoys
    Feb 23, 2021 at 18:13

71 Answers 71

1 2
3
1
\$\begingroup\$

C#, 68 bytes

System.Console.Write($"{4-3}, {5-3}, miss a few, {33*3}, {64*4:X}");
\$\endgroup\$
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\$

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, 2021 at 12:06
  • \$\begingroup\$ It will. Also, using std::cout; doesn't save any bytes. \$\endgroup\$ Mar 6, 2021 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\$

!@#$%^&*()_+, 34 bytes

^!# ,@@^# ,wef a ssim ,(@)c# ,@@d#

Try it online!

Explaination:

^!# ,@@^# ,wef a ssim ,(@)c# ,@@d# (implicit push 0)
^                                  Top of stack += 1
 !#                                Output Top of stack as number without popping
    ,@@                            Output ", "
       ^                           Top of stack += 1
        #                          Output Top of stack as number
          ,wef a ssim ,(@)         Output ", miss a few, "
                          c#       Push 99 onto the stack and output
                             ,@@   output ", "
                                d# Push 100 onto the stack and output
\$\endgroup\$
0
\$\begingroup\$

Uiua 0.11.0, 29 bytes

-3"4/#5/#plvv#d#ihz/#<</#433"

Explanation:
  "4/#5/#plvv#d#ihz/#<</#433" # A string 
-3                            # Shift each character to the left by 3 (in Unicode)

See it in action

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

Perl 5 + -M5.10.0, 31 bytes

Bit of a boring answer, calls say using (stringwise) bitwise negation operator (~) on the bitflipped string.

say~"........................."

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ what does -M5.10.0 mean? How can flipping the bits of . produce such output? \$\endgroup\$
    – phuclv
    Apr 21 at 3:30
  • \$\begingroup\$ oh I checked the demo link and the characters aren't dot at all, but the copy-pasted string from the answers contain all dots \$\endgroup\$
    – phuclv
    Apr 21 at 3:32
  • \$\begingroup\$ @phuclv seems like you got it all but, -M5.10.0 brings Perl up to a standard version set that provides say. The dots are just to signify unprintables as they're all high-byte characters that would differ depending on the character set used. Hope that helps! \$\endgroup\$ Apr 21 at 14:18
1 2
3

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.