4
\$\begingroup\$

Backstory:

I think that my boss might finally realize that I don't any enough work, despite being paid by the hour. I want to throw him off track, by writing as many valid programs as I can to send to him. Unfortunately, due to budget cuts, my keyboard only allows each key to be pressed once.

Specification:

Write as many different valid programs as you can for your language. You may not reuse any character at any time (even within the same program). A program is "valid" is it compiles and runs without any errors (warnings are acceptable), for any given input. Your score is the number of unique programs written.

It does not matter what the program actually does. It does not need to take input, produce output, or even terminate. The only restriction is that may never return an error.

Example (JavaScript):

  1. b=1
  2. alert(2)
\$\endgroup\$

closed as too broad by J42161217, user42649, Rɪᴋᴇʀ, FryAmTheEggman, xnor Jun 15 '17 at 1:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ "Any given input" is a bit problematic, we often define that input can be taken as command line arguments, and most compilers/interpreters will crash given some random argument. How about any input through one particular method chosen by the answerer? For complicated challenges like this I'd personally recommend using the sandbox. \$\endgroup\$ – FryAmTheEggman Jun 15 '17 at 0:07
  • \$\begingroup\$ Open virtual keyboard, no keys pressed, any byte entered [/sarcasm] \$\endgroup\$ – CAD97 Jun 15 '17 at 0:34
  • 1
    \$\begingroup\$ How do you define "return an error"? \$\endgroup\$ – Esolanging Fruit Jun 15 '17 at 1:15
  • 1
    \$\begingroup\$ I voted to close as unclear because of the "any input" issue. (It's labelled as too broad because that's what the majority chose.) \$\endgroup\$ – xnor Jun 15 '17 at 1:16
  • 1
    \$\begingroup\$ Yes, this is problematic in many esoteric languages, but it can be a very interesting challenge in others! My recent "How high can you count" challenge resulted in two gold badges and is somewhat similar to this one. A few suggestions off the top of my hat: 1. Ban languages where every single character is a valid complete program (e.g. Pingpong). 2. Ban symbol independent languages (Lenguage). 3. Require that the program does something (to disallow "programs" that consists of no-ops). 4. Skip the "any input" rule. I suggest you change the rule to: "The programs may optionally take input.". \$\endgroup\$ – Stewie Griffin Jun 15 '17 at 7:56
1
\$\begingroup\$

Jelly, 225 programs

(empty program)
¢
¤
¥
¬
®
µ
½
Æ
Ç
Ñ
×
Ø
Œ
ß
æ
ç
ð
ı
ȷ
ñ
÷
ø
œ
  (space)
!
$
%
&
(
)
*
+
,
-
.
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
A
B
C
D
E
F
G
H
I
J
K
L
N
O
P
Q
R
S
U
V
W
X
Y
[
]
^
_
a
b
c
e
f
g
h
i
j
k
l
m
n
o
p
q
r
u
v
w
x
|
~
¶
°
¹
²
³
⁴
⁵
⁶
⁷
⁸
⁹
⁺
⁻
⁼
⁽
⁾
Ɓ
Ƈ
Ɗ
Ƒ
Ƙ
Ɱ
Ɲ
Ƥ
Ƭ
Ʋ
Ȥ
ɓ
ƈ
ɗ
ƒ
ɦ
ƙ
ɱ
ɲ
ƥ
ʠ
ɼ
ʂ
ƭ
ʋ
ȥ
Ạ
Ḅ
Ḍ
Ẹ
Ḥ
Ị
Ḳ
Ḷ
Ṃ
Ṇ
Ọ
Ṛ
Ṣ
Ṭ
Ụ
Ṿ
Ẉ
Ỵ
Ẓ
Ȧ
Ḃ
Ċ
Ḋ
Ė
Ḟ
Ġ
Ḣ
İ
Ṁ
Ṅ
Ȯ
Ṗ
Ṙ
Ṡ
Ṫ
Ẇ
Ẋ
Ẏ
Ż
ạ
ḅ
ḍ
ẹ
ḥ
ị
ḳ
ḷ
ṇ
ọ
ṛ
ṣ
ṭ
ụ
ṿ
ẉ
ỵ
ẓ
ȧ
ḃ
ċ
ḋ
ė
ḟ
ġ
ḣ
ṁ
ṅ
ȯ
ṗ
ṙ
ṡ
ṫ
ẇ
ẋ
ẏ
ż
«
»
‘
’
“
”

224 characters in Jelly's 256-byte codepage are valid, non-error-throwing programs on their own, plus an empty program. The other characters could be used in literals, but since all the literal-denoting characters are already in use on their own, no new programs can be made from them.

All of these were tested, one by one, on tio.run.

\$\endgroup\$
  • \$\begingroup\$ @JonathanAllan Not according to the codepage. Are you thinking of a linefeed? \$\endgroup\$ – scatter Jun 15 '17 at 0:47
  • \$\begingroup\$ Oopsie yes I was! \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 0:49
  • \$\begingroup\$ You could add t€, d/ and s\ . \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 0:52
  • \$\begingroup\$ The rules are rather unclear to me, but many of these programs error given certain inputs. \$\endgroup\$ – FryAmTheEggman Jun 15 '17 at 0:55
  • \$\begingroup\$ The any input might trounce this count :( (was about to suggest changing d/ to t/ and adding ). \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 1:08
1
\$\begingroup\$

APL (Dyalog Unicode) version 16.0, 8384 programs

⍝ empty program
 ⍝ single space
	⍝ single tab
0
1
2
3
4
5
6
7
8
9
+
-
×
÷
⌈
⌊
*
⍟
|
!
○
~
∨
∧
⍱
⍲
<
≤
=
≥
>
≠
≡
≢
⍴
,
⍪
⍳
↑
↓
?
⍒
⍋
⍉
⌽
⊖
∊
⊥
⊤
⍎
⍕
⌹
⊂
⊃
∪
∩
⍷
⌷
→
⎕
1 2 3           ⍝ input for above program
⍞
Hello, World!   ⍝ input for above program
/
⌿
\
⍀
¨
&
⍨
⌶
#
⊆
⊣
⊢
⌸
⍸
⍝
⋄
L:
⍬
{}
⍝ just a newline
⍝ this line belong with the previous one

Try it online! (except for two which cannot run on TIO's version 15.0)

Explanations:

Most of the programs just print their content. Exceptions are:

  • The four whitespace ones do nothing.
  • terminates
  • asks for evaluated input
  • asks for character input
  • is a comment
  • is a statement separator (i.e. two statements that each do nothing)
  • prints an empty numeric list (i.e. just a newline)
\$\endgroup\$
  • \$\begingroup\$ @Uriel I keep forgetting that this isn't that other challenge. \$\endgroup\$ – Adám Jun 15 '17 at 1:13
  • \$\begingroup\$ Yup. These should already have a tag, like polysnippets or something else \$\endgroup\$ – Uriel Jun 15 '17 at 1:15
0
\$\begingroup\$

Python REPL, 24 programs

[empty]
[space]
[tab]
[newline]
0
1
2
3
4
5
6
7
8
9
sum
pow
chr
next
id
()
{}
[]
#
\
\$\endgroup\$
  • \$\begingroup\$ How about this set of six... sum, pow, id, all, chr, next? Also _ is valid. \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 0:35
  • \$\begingroup\$ @JonathanAllan all isn't valid because internal repeats aren't allowed. \$\endgroup\$ – xnor Jun 15 '17 at 0:37
  • \$\begingroup\$ @xnor oh yeah :p well five there, maybe there is another set of six somewhere... \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 0:38
  • \$\begingroup\$ ...in which case hash, '', ..., and "" must go. \$\endgroup\$ – Jonathan Allan Jun 15 '17 at 0:44
  • \$\begingroup\$ @JonathanAllan _ on a clean repl would throw a name error - it is assigned only after each evaluation \$\endgroup\$ – Uriel Jun 15 '17 at 1:04

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