# What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on the first try can be difficult. There is a much better chance of your challenge being well received if you post it in the Sandbox first.

See the Sandbox FAQ for more information on how to use the Sandbox.

## Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

## Very rough outline of a challenge that rewards short programs that take a long time.

Probably a no input and output can be anything except an error challenge.

Is there a nice way to exclude things like sleep(), wait() etc?

Would be required for 1 person to run all the programs for the timing to be fair.

Thinking that answers would include loops, recursion, testing of complex criteria.

• I think you would have to post your challenge as a popularity contest ... a slippery slope indeed. – Jonathan Frech Mar 15 at 23:43

## Design a Stack With Increment Operation

Design a stack that supports the following operations.

Implement the CustomStack class:

• CustomStack(int maxSize) Initializes the object with maxSize which is the maximum number of elements in the stack or do nothing if the stack reached the maxSize.
• void push(int x) Adds x to the top of the stack if the stack hasn't reached the maxSize.
• int pop() Pops and returns the top of stack or -1 if the stack is empty.
• void inc(int k, int val) Increments the bottom k elements of the stack by val. If there are less than k elements in the stack, just increment all the elements in the stack.

### Test Case:

Input

["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"]
[[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]

Output

[null,null,null,2,null,null,null,null,null,103,202,201,-1]

Explanation

CustomStack customStack = new CustomStack(3); // Stack is Empty []
customStack.push(1);                          // stack becomes [1]
customStack.push(2);                          // stack becomes [1, 2]
customStack.pop();                            // return 2 --> Return top of the stack 2, stack becomes [1]
customStack.push(2);                          // stack becomes [1, 2]
customStack.push(3);                          // stack becomes [1, 2, 3]
customStack.push(4);                          // stack still [1, 2, 3], Don't add another elements as size is 4
customStack.increment(5, 100);                // stack becomes [101, 102, 103]
customStack.increment(2, 100);                // stack becomes [201, 202, 103]
customStack.pop();                            // return 103 --> Return top of the stack 103, stack becomes [201, 202]
customStack.pop();                            // return 202 --> Return top of the stack 102, stack becomes [201]
customStack.pop();                            // return 201 --> Return top of the stack 101, stack becomes []
customStack.pop();                            // return -1 --> Stack is empty return -1.


This is code-golf so shortest submission in bytes wins! If you liked this challenge, consider upvoting it... And happy golfing!

• This would be limited to Java and C++. I could almost guarantee that this will be downvoted and closed as unclear if posted. – S.S. Anne Mar 15 at 15:45
• I agree with @S.S.Anne; terms like class, void and even the concept of operations are not existent in a majority of languages. – Jonathan Frech Mar 15 at 23:35
• One possibility of altering the challenge may be to supply a finite number of stack instructions as a series of text commands and ask how the stack looks at the end ... Kind of asking to implement an interpreter for a basic stack-based language. – Jonathan Frech Mar 15 at 23:36

## Find the longest common subsequence

Given two integer arrays. Find the longest common subsequence

Test Case:

Input:

a=[1,5,2,6,3,7]
b=[5,6,7,1,2,3]


Output:

Return
[1,2,3] or [5,6,7]


This is code-golf so shortest submission in bytes wins! If you liked this challenge, consider upvoting it... And happy golfing!

• Similar to this challenge. – Jonathan Frech Mar 15 at 23:29
• @JonathanFrech Yeah Similar, But not Same. Am I supposed to post the challenge?? – Pluviophile Mar 17 at 15:52
• Posting is up to you. I would not, since I think it would be righteously closed as a duplicate. – Jonathan Frech Mar 17 at 16:27

# The (All But) Quine challenge

Like a quine challenge, but the opposite. Print everything except source code

# Challenge

Write a program, which takes no input, and outputs all the strings of printable characters which are the same length as the source code of the program, except the source code of the program.

# Scoring

The shortest program (per language) to accomplish the above task, wins

• By 'printable characters' you mean printable ASCII characters (code-points [32,126])? What if I use a language that don't contain any ASCII characters in its source code? – Kevin Cruijssen Mar 20 at 13:38
• If your program is in ASCII, then you would need to print all of the ASCII characters, if the program is in Unicode, then you would have to print all of the Unicode characters – Benji Mar 20 at 14:40
• @Benji Would you consider a Python 3 source file as being "in Unicode"? – Jonathan Frech Mar 22 at 17:49
• If there are any Unicode characters that are used in the file, then no. If Unicode characters are used, then I would consider it to be Unicode – Benji Mar 23 at 14:47

## Maximum Performance of a Team

There are $$\n\$$ engineers numbered from 1 to $$\n\$$ and two arrays: speed and efficiency, where $$\speed[i]\$$ and $$\efficiency[i]\$$ represent the speed and efficiency for the i-th engineer respectively. Return the maximum performance of a team composed of at most $$\k\$$ engineers, since the answer can be a huge number, return this modulo $$\10^9 + 7.\$$

The performance of a team is the sum of their engineers' speeds multiplied by the minimum efficiency among their engineers.

Test Case 1:

Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2

Output: 60


Explanation:

We have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = $$\(10 + 5) * min(4, 7) = 60.\$$

Test Case 2:

Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3

Output: 68


Explanation:

This is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = $$\(2 + 10 + 5) * min(5, 4, 7) = 68.\$$

Test Case 3:

Input: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4

Output: 72


This is code-golf so shortest submission in bytes wins! If you liked this challenge, consider upvoting it... And happy golfing!

• Since this is a challenge from another site, I don't think you'd be allowed to post it here without express permission. – xnor Mar 19 at 16:38

## Numbers by index

Challenge

Print the numbers:

0
1
22
333
4444
55555
666666
7777777
88888888
999999999


In that order.

I/O

Takes no input. The numbers can have any delimiters desired (or none). Example outputs:

0122333444455555666666777777788888888999999999

[0,1,22,333,4444,55555,666666,7777777,88888888,999999999]

etc....


Code Example

This is an un-golfed example that may perhaps act as algorithm guide (or maybe not):

# Turing Machine Code, 553 bytes

0 * 0 r K
K * _ r 1
1 * 1 r L
L * _ r 2
2 * 2 r a
a * 2 r M
M * _ r 3
3 * 3 r b
b * 3 r c
c * 3 r N
N * _ r 4
4 * 4 r d
d * 4 r e
e * 4 r f
f * 4 r O
O * _ r 5
5 * 5 r g
g * 5 r h
h * 5 r i
i * 5 r j
j * 5 r P
P * _ r 6
6 * 6 r k
k * 6 r l
l * 6 r m
m * 6 r n
n * 6 r o
o * 6 r Q
Q * _ r 7
7 * 7 r p
p * 7 r q
q * 7 r r
r * 7 r s
s * 7 r t
t * 7 r u
u * 7 r R
R * _ r 8
8 * 8 r v
v * 8 r w
w * 8 r x
x * 8 r y
y * 8 r z
z * 8 r A
A * 8 r B
B * 8 r S
S * _ r 9
9 * 9 r C
C * 9 r D
D * 9 r E
E * 9 r F
F * 9 r G
G * 9 r H
H * 9 r I
I * 9 r J
J * 9 r halt


Try it online!

This prints out the numbers with a space delimiter:

0 1 22 333 4444 55555 666666 7777777 88888888 999999999


Challenge Type

, so shortest answer in bytes (by language) wins.

Edit: Link to the related challenge. Curiously, there is one answer on there where if it was by index, and the zero was included, it would be shorter.

• Nice challenge! Are preceding & trailing whitespace (during string output) permitted? – user92069 Mar 11 at 3:22
• I think it should also be kolgomorov-complexity. – PkmnQ Mar 11 at 5:19
• I don't like how the zero breaks the pattern of having the digit N appear N times -- it seems like an exceptional edge case. I think it would be better for 0 not to appear, so the numbers would just start from 1. – xnor Mar 11 at 7:06
• @xnor, I knew you wouldn't like it (and probably a few other won't as well) That's on purpose. It just seems a little too easy otherwise. – ouflak Mar 11 at 7:28
• @a'_', Yes. @ PkmnQ, Noted. – ouflak Mar 11 at 7:29
• I don't really see how adding a fixed zero to the beginning makes the challenge harder in almost any language. In some, the empty string will actually convert to zero, which makes it more natural but still fairly trivial. I feel like you probably either want to go with omitting the zero, or finding a different way to make the challenge more complicated. – FryAmTheEggman Mar 11 at 14:53
• @FryAmTheEggman, How can you have a challenge about indexes and not have zero? That just seems wrong. – ouflak Mar 11 at 15:31
• Most people start counting from one - only people who use computers a lot default to starting at zero. And separately, I think finding another way to incorporate it is better than leaving it out (I just also think both are better than having an unexplained outlier). – FryAmTheEggman Mar 11 at 15:40
• @FryAmTheEggman, But it's not really unexplained is it? It's the index of the first number. – ouflak Mar 11 at 15:46
• As per what xnor said, it doesn't match the pattern of the others. That behaviour is not explained. Comments aren't really for a discussion like this; if you disagree that is fine. I've just given feedback on how I think you could improve the challenge. – FryAmTheEggman Mar 11 at 16:15
• I do want to make sure that everyone knows that I am VERY grateful for the feedback! I also appreciate having a Sandbox where we can have this discussion here instead of on the main site. – ouflak Mar 11 at 16:18
• @FryAmTheEggman, It's not that I disagree. I kind of agree. I like that leading zero in there to represent the index location of the initial value. I considered this when I thought of the question, before posting it here. It breaks up a trivial loop sequence answer a bit, or maybe even inspires a clever solution that nobody considered. I'd like to keep it because it stands out like that, not despite that. – ouflak Mar 11 at 16:21
• I posted an example implementation above. The zero wasn't a big deal. – ouflak Mar 11 at 16:31
• My guess is that you're excited about the arithmetic expression 10**n/9*n or similar. But I don't think that's much more interesting than the obvious loops that removing the zero would allow unmodified. – xnor Mar 11 at 21:59
• @ouflak I contrast, I am very excited about arithmetic expressions :) – xnor Mar 12 at 21:16

# A malbolge interpreter

The challenge today is to write a Malbolge interpreter.

## Specification

Malbolge

I hereby relenquish any and all copyright on this language,
documentation, and interpreter; Malbolge is officially public domain.

------------------------------------------------------------------------

Malbolge

Introduction
^^^^^^^^^^^^

It was noticed that, in the field of esoteric programming languages,
there was a particular and surprising void: no programming language
known to the author was specifically designed to be difficult to program
in.

Certainly, there were languages which were difficult to write in, and
far more were difficult to read (see: Befunge, False, TWDL, RUBE...).
But even INTERCAL and BrainF***, the two kings of mental torment, were
designed with other goals: INTERCAL to have nothing in common with any
major programming language, and BrainF*** to be a very tiny, yet still
Turing-complete, language.

INTERCAL's constructs are certainly tortuous, but they are all too
flexible; you can, for instance, quite easily assign any number to a
variable with a single statement.

BrainF*** is lacking the flexibility which is INTERCAL's major weakness,
but it fails in that its constructs are far, far too intuitive.
Certainly, there are only 8 instructions, none of which take any
arguments--but it is quite easy to determine how to use those
instructions.  Subtract 8 from the current number?  With a simple
'--------' you are done!  This kind of simple answer was unacceptable to
the author.

Hence the author created Malbolge.  It borrows from machine, BrainF***,
and tri-INTERCAL, but put together in a unique way.  It was designed to
be difficult to use, and so it is.  It is designed to be
incomprehensible, and so it is.

So far, no Malbolge programs have been written.  Thus, we cannot give an
example.

"Malbolge" is the name of Dante's Eighth Circle of Hell, in which
practitioners of deception (seducers, flatterers, simonists, thieves,
hypocrites, and so on) spend eternity.

Environment
^^^^^^^^^^^

In many languages, the environment is easy to understand.  In Malbolge,
it is best to understand the runtime environment before you ever see a
command.

The environment is, roughly, that of a primitive trinary CPU.  Both code
and data share the same space (the machine's memory segment), and there
are three registers.  Machine words are ten trits (trinary digits) wide,
giving a maximum possible value of 59048 (all numbers are unsigned).
Memory space is exactly 59049 words long.

The three registers are A, C, and D.  A is the accumulator, used for
data manipulation.  A is implicitly set to the value written by all
write operations on memory.  (Standard I/O, a distinctly non-chip-level
feature, is done directly with the A register.)

C is the code pointer.  It is automatically incremented after each
instruction, and points the instruction being executed.

D is the data pointer.  It, too, is automatically incremented after each
instruction, but the location it points to is used for the data
manipulation commands.

All registers begin with the value 0.

When the interpreter loads the program, it ignores all whitespace.  If
it encounters anything that is not one of an instruction and is not
whitespace, it will give an error, otherwise it loads the file, one non-
whitespace character per cell, into memory.  Cells which are not
initialized are set by performing op on the previous two cells
repetitively.

Commands
^^^^^^^^

When the interpreter tries to execute a program, it first checks to
see if the current instruction is a graphical ASCII character (33
through 126).  If it is, it subtracts 33 from it, adds C to it, mods it
by 94, then uses the result as an index into the following table of 94
characters:

+b(29e*j1VMEKLyC})8&m#~W>qxdRp0wkrUo[D7,XTcA"lI
.v%{gJh4G\-=O@5_3i<?Z';FNQuY]szf$!BS/|t:Pn6^Ha It then checks it against the characters listed below, and performs an appropriate action. If the result is not one of the characters listed below, it is treated as a nop. If the original character is not graphic ASCII, the program is immediately ended. When the interpreter parses the input file, it checks each non- whitespace character with the process above. If any result is not one of the eight characters below, the file will be rejected. After the instruction is executed, 33 is subtracted from the instruction at C, and the result is used as an index in the table below. The new character is then placed at C, and then C is incremented. 5z]&gqtyfr$(we4{WP)H-Zn,[%\3dL+Q;>U!pJS72FhOA1C
B6v^=I_0/8|jsb9m<.TVacuY*MK'X~xDl}REokN:#?G"i@

j
sets the data pointer to the value in the cell pointed to by the
current data pointer.

i
sets the code pointer to the value in the cell pointed to be the
current data pointer.

*
rotates the trinary value of the cell pointed to by D to the right 1.
The least significant trit becomes the most significant trit, and all
others move one position to the left.

p
performs a tritwise "op" on the value pointed to by D with the
contents of A.  The op (don't look for pattern, it's not there) is:

| A trit:
________|_0__1__2_
0 | 1  0  0
*D  1 | 1  0  2
trit 2 | 2  2  1

Di-trits:
00 01 02 10 11 12 20 21 22

00  04 03 03 01 00 00 01 00 00
01  04 03 05 01 00 02 01 00 02
02  05 05 04 02 02 01 02 02 01
10  04 03 03 01 00 00 07 06 06
11  04 03 05 01 00 02 07 06 08
12  05 05 04 02 02 01 08 08 07
20  07 06 06 07 06 06 04 03 03
21  07 06 08 07 06 08 04 03 05
22  08 08 07 08 08 07 05 05 04

<
reads an ASCII value from the stdin and converts it to Trinary, then
stores it in A.  10 (line feed) is considered 'newline', and
2222222222t (59048 dec.) is EOF.

/
converts the value in A to ASCII and writes it to stdout.  Writing
10 is a newline.

v
indicates a full stop for the machine.

o
does nothing, except increment C and D, as all other instructions do.

Turing-Completeness
^^^^^^^^^^^^^^^^^^^

Though I have not proven it, I _think_ Malbolge to be Turing-complete.
To be Turing-complete, there must be some data construct which can be
used to do any mathematical calculation.  I believe that using *p in
various clever ways on the tritwords can fulfill this requirement.

Turing-completeness also requires three code constructs: sequential
execution (which Malbolge obviously has), repetition (provided by the
i and, indirectly, j instructions), and conditional-execution (provided,
I believe, by self-modifying code and altering i destinations).

I do have my doubts, particularly about data constructs, but I *think*
this works...

Appendix: Trinary Conversion Table
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Trinary to ASCII to decimal to hex table, provided, strangely enough,
for the convenience of Malbolge programmers.

00000 NUL 000 00    01012   032 20    02101 @ 064 40    10120  096 60
00001 SOH 001 01    01020 ! 033 21    02102 A 065 41    10121 a 097 61
00002 STX 002 02    01021 " 034 22    02110 B 066 42    10122 b 098 62
00010 ETX 003 03    01022 # 035 23    02111 C 067 43    10200 c 099 63
00011 EOT 004 04    01100 $036 24 02112 D 068 44 10201 d 100 64 00012 ENQ 005 05 01101 % 037 25 02120 E 069 45 10202 e 101 65 00020 ACK 006 06 01102 & 038 26 02121 F 070 46 10210 f 102 66 00021 BEL 007 07 01110 ' 039 27 02122 G 071 47 10211 g 103 67 00022 BS 008 08 01111 ( 040 28 02200 H 072 48 10212 h 104 68 00100 HT 009 09 01112 ) 041 29 02201 I 073 49 10220 i 105 69 00101 LF 010 0a 01120 * 042 2a 02202 J 074 4a 10221 j 106 6a 00102 VT 011 0b 01121 + 043 2b 02210 K 075 4b 10222 k 107 6b 00110 FF 012 0c 01122 , 044 2c 02211 L 076 4c 11000 l 108 6c 00111 CR 013 0d 01200 - 045 2d 02212 M 077 4d 11001 m 109 6d 00112 SO 014 0e 01201 . 046 2e 02220 N 078 4e 11002 n 110 6e 00120 SI 015 0f 01202 / 047 2f 02221 O 079 4f 11010 o 111 6f 00121 DLE 016 10 01210 0 048 30 02222 P 080 50 11011 p 112 70 00122 DC1 017 11 01211 1 049 31 10000 Q 081 51 11012 q 113 71 00200 DC2 018 12 01212 2 050 32 10001 R 082 52 11020 r 114 72 00201 DC3 019 13 01220 3 051 33 10002 S 083 53 11021 s 115 73 00202 DC4 020 14 01221 4 052 34 10010 T 084 54 11022 t 116 74 00210 NAK 021 15 01222 5 053 35 10011 U 085 55 11100 u 117 75 00211 SYN 022 16 02000 6 054 36 10012 V 086 56 11101 v 118 76 00212 ETB 023 17 02001 7 055 37 10020 W 087 57 11102 w 119 77 00220 CAN 024 18 02002 8 056 38 10021 X 088 58 11110 x 120 78 00221 EM 025 19 02010 9 057 39 10022 Y 089 59 11111 y 121 79 00222 SUB 026 1a 02011 : 058 3a 10100 Z 090 5a 11112 z 122 7a 01000 ESC 027 1b 02012 ; 059 3b 10101 [ 091 5b 11120 { 123 7b 01001 FS 028 1c 02020 < 060 3c 10102 \ 092 5c 11121 | 124 7c 01002 GS 029 1d 02021 = 061 3d 10110 ] 093 5d 11122 } 125 7d 01010 RS 030 1e 02022 > 062 3e 10111 ^ 094 5e 11200 ~ 126 7e 01011 US 031 1f 02100 ? 063 3f 10112 _ 095 5f 11202 128 80 12221 160 a0 21010 192 c0 22022 224 e0 11210 129 81 12222 161 a1 21011 193 c1 22100 225 e1 11211 130 82 20000 162 a2 21012 194 c2 22101 226 e2 11212 131 83 20001 163 a3 21020 195 c3 22102 227 e3 11220 132 84 20002 164 a4 21021 196 c4 22110 228 e4 11221 133 85 20010 165 a5 21022 197 c5 22111 229 e5 11222 134 86 20011 166 a6 21100 198 c6 22112 230 e6 12000 135 87 20012 167 a7 21101 199 c7 22120 231 e7 12001 136 88 20020 168 a8 21102 200 c8 22121 232 e8 12002 137 89 20021 169 a9 21110 201 c9 22122 233 e9 12010 138 8a 20022 170 aa 21111 202 ca 22200 234 ea 12011 139 8b 20100 171 ab 21112 203 cb 22201 235 eb 12012 140 8c 20101 172 ac 21120 204 cc 22202 236 ec 12020 141 8d 20102 173 ad 21121 205 cd 22210 237 ed 12021 142 8e 20110 174 ae 21122 206 ce 22211 238 ee 12022 143 8f 20111 175 af 21200 207 cf 22212 239 ef 12100 144 90 20112 176 b0 21201 208 d0 22220 240 f0 12101 145 91 20120 177 b1 21202 209 d1 22221 241 f1 12102 146 92 20121 178 b2 21210 210 d2 22222 242 f2 12110 147 93 20122 179 b3 21211 211 d3 12111 148 94 20200 180 b4 21212 212 d4 12112 149 95 20201 181 b5 21220 213 d5 12120 150 96 20202 182 b6 21221 214 d6 12121 151 97 20210 183 b7 21222 215 d7 12122 152 98 20211 184 b8 22000 216 d8 12200 153 99 20212 185 b9 22001 217 d9 12201 154 9a 20220 186 ba 22002 218 da 12202 155 9b 20221 187 bb 22010 219 db 12210 156 9c 20222 188 bc 22011 220 dc 12211 157 9d 21000 189 bd 22012 221 dd 12212 158 9e 21001 190 be 22020 222 de 12220 159 9f 21002 191 bf 22021 223 df  ## Notes Note that the original specification has one quirk: after encountering an illegal instruction, the interpreter hangs. You may choose which behaviour do you want to implement (hang or exit). ## I/O rules The program or function has to take input in any reasonable way (for the program), and somehow supply the input and output features to the malbolge program (either by return value / parameter, tty or a file). ## Sandbox stuff note: I'm a bit unsure about the scoring criterion: would popularity-contest be good? I'm mostly looking for creative answers • add interpreter ? – Wezl Apr 30 at 22:00 • I think popularity-contest would be adding Do X creatively to an already relatively non-interesting challenge [unless if you somehow managed to create a Malbolge self-interpreter and that is the trick you're planning to use to win your own competition with it :) ] – my pronoun is monicareinstate May 1 at 2:15 • hmm right; I'm not planning on submitting a malbolge interpreter on malbolge :P, I'd like to see what people can think of. Also I've been thinking about fastest-code contest that would possibly allow me to switch my tolling a bit :P – Szewczyk May 1 at 10:54 • I'd probably participate if this was [fastest-code], but I doubt there are enough interesting optimizations here. – my pronoun is monicareinstate May 2 at 3:26 • there is a lot of room for optimization, you just need to investigate the challenge a little bit further – Szewczyk May 2 at 17:46 Write two programs (likely functions since IO for float convert to/from stream, losing info as mentioned later), one given $$\n\geq 2\$$ real points on a 2D plane, returning $$\2n-3\$$ real numbers; another given the $$\2n-3\$$ real numbers, return the same shape and size given to first program. Order of points matters. Returning a mirrored shape is fine. You must use an in-language float and assume it is infinitely precise, but converting to types like string or trying to handle the bits in RAM truncate the precision. There's no requirements on how you map, so you can even just pack some real numbers into one if your language happens to have way to do that. • Should the last sentence be "you can't"? – user202729 Jun 16 at 11:43 • Is the rotation (orientation) important? (if it doesn't, I assume that it's possible to use 2n-4 real numbers?) – user202729 Jun 16 at 11:44 • @user202729 Rotation not important, size important. You are allowed if able, but as I know no language do that – l4m2 Jun 16 at 12:38 • But it's not an observable behavior (although there's no built-in for it, it's possible to simply interleave the digits, while it's not possible to do it in finite time for irrational floating point numbers -- alternatively you can assume that only coordinates with finite binary representation are valid input). You can require that the mapping is (almost everywhere) continuous, however. – user202729 Jun 16 at 13:26 • Can I use multiple floating point types in a language (e.g. float and double in C)? – Bubbler Jun 17 at 3:39 • @Bubbler What may it be used to? – l4m2 Jun 17 at 6:33 • Combine two floats into a double at the bit level. – Bubbler Jun 17 at 6:49 • @Bubbler It'll likely result in nan – l4m2 Jun 17 at 6:54 • No, simple concatenation of two floats (not a NaN or Infinity) is guaranteed to give a value that is neither NaN nor Infinity. cf. Single, Double – Bubbler Jun 17 at 7:12 • @Bubbler Anyway now doing such lose precision – l4m2 Jun 17 at 7:15 • OK, that would work. – Bubbler Jun 17 at 7:19 • (you didn't answer my last question.) – user202729 Jun 17 at 10:16 • @user202729 How 2n-4? – l4m2 Jun 17 at 10:34 • No, the latter question about unobservable behavior. – user202729 Jun 17 at 10:59 • @user202729 What does the it refer? – l4m2 Jun 17 at 11:29 # What day is it today? atomic-code-golf Given a date y4y3y2y1-m2m1-d2d1, output the day in the week w. 0 as Sunday, 1 as Monday, and so on. You can assume the date is valid, and we use the current date rule and leap rule. Each submission should be written in this specific programming language: • A program consists of a mapping from string of digits to digits, and a sequence of instructions. • Each instruction has the format: var=[var|dgt],[var|dgt],...,[var|dgt], which assigns the value of looking up the string constructed by concatenating the values of the right hand side elements ([var|dgt],[var|dgt],...,[var|dgt]) together in the table and put it into the var on the left. A program is valid if: • None of the lookup step fails for all valid input date. • Given any valid date in the format mentioned above (initially assigned to the 8 variables y4 y3 y2 y1 m2 m1 d2 d1), after the program is run, the correct result is assigned to the variable w. You can create as many variables as you like(though bounded by amount of instructions), each variable only containing a digit. Solution win if there's no strictly better solution, aka. no solution that take less or same amount of items in mapping table, less or same amount of instrucions, and at least one of amounts of items and instructions is less. For example, this is a solution that wins: # 3652425 items 1 instruction 003000101 -> 6 003000102 -> 0 003000103 -> 1 ... 993991231 -> 5 ------------- w=y4,y3,3,y2,y1,m2,m1,d2,d1  Here, the 3 on 3rd position can be used without any extra cost. This can be used to create multiple mappings, and sometimes save elements when there are more mapping instructions. A checker is provided here. • I completely don't understand the entire You can have a mapping table and some instructions, each instruction write var=[var|dgt],[var|dgt],...,[var|dgt], meaning search the element [var|dgt],[var|dgt],...,[var|dgt]from table and put i into the var on the left. Failure on searching is not allowed. You can create as many variables as you like(though bounded by amount of instructions), each variable only containing a digit. part. – my pronoun is monicareinstate Jun 15 at 8:32 • I'm very confused about this. Are you sure you're not making assumptions about language features? – Adám Jun 15 at 8:32 • @Adám I'm requiring using only this language – l4m2 Jun 15 at 8:40 • @mypronounismonicareinstate That mainly mean the only operation is lookup, there's nothing like plus, multiply or whatever – l4m2 Jun 15 at 8:41 • @l4m2 I still do not understand a word. The whole proposal definitely requires a serious rewrite. – my pronoun is monicareinstate Jun 15 at 8:42 • @mypronounismonicareinstate If it hadn't needed some more time it isn't here – l4m2 Jun 15 at 8:45 • "Solution win if there's no strictly better solution" is not a valid winning criterion because it allows multiple winners. – Bubbler Jun 15 at 9:23 • @Bubbler Multiple winners is common – l4m2 Jun 15 at 9:34 • @l4m2 Do you mean something like ties in code golf? IMO, code golf ties are fine because they can be seen as equally good, while your criterion is not because it allows potentially multiple answers that can't be compared to each other at all. – Bubbler Jun 15 at 9:44 • @Bubbler I mean like multiple languages each only comparing to self – l4m2 Jun 15 at 9:50 • @l4m2 The winning criterion is the guide to optimize one's solution in one direction. "Shortest solution in each language wins" does not harm this spirit. Yours don't give which one to optimize for: mapping table size or instruction size? – Bubbler Jun 15 at 10:05 • @Bubbler Your link claims you wrong – l4m2 Jun 15 at 11:59 • @l4m2 OK, let me say it in a different way. You already showed a "winning" solution with minimal instructions. Then there will be a "winning" solution with minimal table, and then there can be thousands of "winning" solutions in between. Given any "winning" solution, one can tweak a little to get another "winning" solution. Do you really think it is fun? – Bubbler Jun 15 at 23:02 • @Bubbler Yea an exact bound of table size for each instruction count, if exist, makes its sense – l4m2 Jun 16 at 5:06 • @Bubbler You don't like to see lots of winners because you think "win" is a big issue? – l4m2 Jun 16 at 5:06 # Natural Language Identification Using Only Regular Expressions For example: const regex = /English(?=\w+ Hello World)|Spanish(?= Hola Mundo)/; console.log('EnglishSpanish Hello World'.match(regex)); // English console.log('EnglishSpanish Hola Mundo'.match(regex)); // Spanish These wordlists are to be used, and words are to be rewritten entirely using the ASCII characters A-Z and a-z. Languages which use characters that cannot be easily transcribed into ASCII without special knowledge or firsthand experience in that language, are excluded. For instance, the Albanian word të is easily transcribed without special knowledge as te, so Albanian is allowed. But the Arabic word من cannot be, so Arabic is excluded. The regular expression must match the language exactly, so appending a list of all languages you are testing before each word is allowed. But however you organize this list, it must be the same for every word you test. See the example above for clarification. ## Sandbox Questions Ideally, brevity of regex, accuracy of language identification, and number of languages taken into account by the regex should all be considered when determining the winner. But I have not decided on that yet, and am very open to suggestions. In fact this is my first sandbox post and I hope someone can help me format this properly with good rules so that it makes for an interesting and fun challenge. I got this idea from some other contest somewhere where the goal was to identify languages with at least 60% accuracy. But I can't find it anymore. • So only regex submissions are allowed? – user202729 Jul 22 at 6:02 • Although there are options to "weight" the 3 scores differently, the easiest way is to require the other two scores to be larger than some limit (say, at least 2 languages and at least 60%) then compete for the shortest regex. – user202729 Jul 22 at 6:04 • Also, are there any similar challenge before? – user202729 Jul 22 at 6:05 • Yes, only regex is allowed. A very similar challenge I've found is this: codegolf.stackexchange.com/questions/49596/… – GirkovArpa Jul 22 at 6:26 • Also this one, which is linked in the other: codegolf.stackexchange.com/questions/42206/… – GirkovArpa Jul 22 at 6:27 • Pretty similar. But the huge size of the word list will make the solutions different. – user202729 Jul 22 at 6:33 • you should specify a particular flavor of regex. – user202729 Jul 22 at 6:34 • I would have said JavaScript but I thought there could be a winner for each programming language? – GirkovArpa Jul 22 at 6:35 • If you decide to restrict to 2 languages, you may ask for a regex that matches words from list 1 and not match words from list 2. (it may (do anything|never matches) the words that are not in lists) – user202729 Jul 22 at 6:37 • Good idea, I'll do that. – GirkovArpa Jul 22 at 6:39 # Create a Drawing Guide for a Polygram Poor old Jim, he's just terrible at drawing polygrams, and he's asked you to create a "drawing guide" for him - an ascii polygram with numbered edges, so he can follow the instructions. ## Challenge Write a program to produce an ascii polygram with P <= 10; each edge of the polygram should be made of a single digit 0-9, showing the order in which the edges should be drawn. ## Input Your program should receive (via STDIN, as function arguments, or some other language-appropriate method): P, the number of edges/vertices of the polygram, and Q, the spacing. In the notation as per the Wikipedia link, you'll be drawing a {p/q} polygram. ## Output Either print to STDOUT or return (or something else language-appropriate) a multiline string showing the drawing guide for the given polygram. The string can be any size you like, as long as it's large enough to display a clear polygram. ## Notes Your code should be able to handle compound regular polygons as well as regular regular polygons, and also inputs of q > p/2 (poor old Jim doesn't realize that the polygram for {p/q} is the same as for {p/p-q}). ## Example Output for {10,3}  5 5 4 4 21 5 888 2 11115 8888 7 2 5111888 4 7 2 888111 4 7 2 888 111 7 8885 4117 8882 4 711 8 2 5 7 111 25 47 9 5 7 0 9 2 74 0 52 7 0 9 2 7 4 5 92 7 04 9 70 4 5 2 7 5 29 7 4 6666 2 9 07 33 666 0 7333 2 696 337 2 9666 333 7 2 9 66633 0 7 2 333 666 7 2 339 666 7 2333 9 0 67 9 0 0  ## Scoring This is code-golf, so shortest in bytes wins. Tiebreaker goes to the most votes. • I have a python solution to this which is ~600 bytes, so it's definitely doable, and it's not easy... – sirpercival Apr 27 '15 at 4:31 • I think the spec needs to be more prescriptive for this to make a good question, especially since the example seems to indicate that you're not currently even prohibiting the lines from having gaps. At a minimum I would say that you should require the lines to be equivalent to those produced by Bresenham's algorithm, and specify how overlaps should be handled; at the extreme, you could tie it down so tightly that it becomes a parameterised kolmogorov-complexity. – Peter Taylor Apr 27 '15 at 9:34 # Pointer to pointers to pointers to pointers You should choose a language supporting pointers like C. And your task is simple: demonstrate a legitimate use of the most level of pointers. You should justify your code by describing an algorithm that: • Has only plain text, number or an array of those as input and output. • You think it will make things easier to write those code as a part of the implementation of this algorithm. • This implementation would have optimum memory usage (only declared variables and parameters, explicitly allocated space, and the return addresses for recursive functions count). Other rules: • They must be pointers to pointers directly, i.e. a pointer to an object containing a pointer doesn't count. It's better if nobody using this code will want to extend some pointer to an object later. • Each pointer must have a different type (if your language can somehow make them the same type). • You should create at least one pointer, and either dereference or compare two non-null pointers once in each level. • Using pointers as arrays is only half as interesting. • Iterators, etc, are considered in essence pointers and allowed in this challenge. But you can't define new types implementing iterators for this purpose. • Could you specify "legitimate"? This sounds a bit like code bowling (and seems to have the same issues). With enough imagination I'm sure I can justify any depth of pointers. – Martin Ender Apr 30 '15 at 17:43 • @MartinBüttner Edited but, basically, it is subjective. – jimmy23013 Apr 30 '15 at 17:57 • @MartinBüttner Added a restriction to have optimum memory usage. I'm not sure whether it works. – jimmy23013 Apr 30 '15 at 18:19 # Winning Tic-Tac-Toe lines For a given tic-tac-toe board of size N**D (for example, a normal tic-tac-toe game is 3**2), the number of winning lines of length N is given by the expression: $$2^{D-1} + \sum_{S=1}^{D-1}2^{S-1}DN^{D-S}$$ (Basically, you are summing the number of lines in each S-dimensional slice of the board.) # The challenge: Given N and D, your answer should output a list of D-dimensional coordinates for each winning line. Input and output are any reasonable format. You can assume that both N and D are positive integers, with N > 1. (Degenerate cases of N=1, D>1 not included.) Since this is , fastest answer wins. Please explain your algorithm! • How do you intend to determine which of two answers is fastest? – Peter Taylor May 12 '15 at 19:37 • yes, @randomra made the same point on chat. i'll edit this in, but i guess... i'll put together some test cases and then time them? i dunno, i was going back and forth between this and code-golf, but i'd prefer interesting and readable algorithms. – sirpercival May 12 '15 at 20:10 • i posted this here because i really want the answer, and i hate coming up with brute force solutions... :D – sirpercival May 12 '15 at 20:16 • Um. Given that you're asking people to enumerate an exponentially large set, in what sense will the answers not be brute force? – Peter Taylor May 12 '15 at 20:28 • well, there's brute force and then there's brute force. but really it's because i don't want to do it myself, haha. – sirpercival May 12 '15 at 20:34 • also, making use of symmetry can severely reduce the computation. – sirpercival May 12 '15 at 20:40 • I imagine that the runtime in any such algorithm will be basically proportional to the number of things you print, so there won't be any good way to improve by algorithm and the speed will be very platform-dependent. – xnor May 12 '15 at 23:40 # Ayn Random number generator Inspired by xkcd 1277: Write a random number generator that takes no input and generates a random integer between 1 and 100. When run less than 200 times, the frequency of all numbers needs to be between 0 and 2, but when it's ran 50 000 times, the number 42 (obviously) should have a frequence that's more than 4 standard deviations higher than the mean. Format is code-golf. Your score is the bytecount of your code. • 1. I think it's difficult to decide objectively whether a PRNG appears to be fair at first sight. 2. The term more often should probably be quantified. – Dennis May 18 '15 at 21:49 • I see lots of C rand()%1000 and the like incoming... – rorlork May 18 '15 at 22:05 • @Ypnypn I have changed the criteria to have much lower numbers so they're easier to verify. – Nzall Jun 6 '15 at 13:04 • @Dennis I have rewritten the question to clarify what "being fair" is and what "more often" actually entails. – Nzall Jun 6 '15 at 13:05 • 1. Are you thinking of a standalone program that you run multiple times or a function that is allowed to keep a state? In the first case, not even a perfect RNG will, with overwhelming probability, satisfy the first condition. 2. Do you mean the mean and standard deviation of a perfect, uniform RNG or the one the code implements? – Dennis Jun 6 '15 at 23:44 • @Dennis I'm thinking of just a function AynRandom() that gets called. The frequency of numbers with a small number of iterations is subject to change, maybe from 0 to 4. The mean and Standard Deviation must be the one the code implements. – Nzall Jun 7 '15 at 9:49 • between 0 and 2 ? so print 42 would be a valid program ? – Falco Jun 11 '15 at 15:32 • @Falco No, because 42 would appear more than 2 times (unless you only run it twice). The problem is that I need a way to indicate that the RNG is fair with a low iteration count, but unfair with higher iteration counts. The only way I can make it work is by stating that with low iteration counts, all numbers should appear about equally often, which is either 0, 1 or 2 times. – Nzall Jun 11 '15 at 15:36 Please nitpick this. If there's anything that wouldn't work or would be inconvenient, however small of an issue it is, tell me about it! Also, suggestions for [adjective] are more than welcome. # Determine how [adjective] a number is (code-golf) A number would be considered [adjective] if 0 is the result of multiplying its digits together, then multiplying the digits of the resulting number, then repeating until a single-digit number is produced. The more steps it takes to reach 0, the more [adjective] the number is; if the resulting number is not 0, though, the number is not [adjective] regardless of how long it took to finish. The formula used to determine [adjective]-ness is 10-10/T where T is however many numbers it took to reach 0 (including 0 and the initial input) Your goal is, as the title says, to write a program or function that determines how [adjective] a number is, and prints every iteration along the way. Here are some example inputs/ouputs: in: 879 out: 879 <- (T=1) 504 <- 8*7*9 (T=2) 0 <- 5*0*4 (T=3) <- optional newline 6.6... <- 10-10/3 (repeating decimals can be expressed in any way you want) in: 2468 out: 2468 <- T=1 96 <- (T=2) 2*4*6*8 54 <- (T=3) 9*6 20 <- (T=4) 5*4 0 <- (T=5) 2*0 8 <- 10-10/5 in: -888 out: -888 -512 <- -8*-8*-8 -10 <- -5*-1*-2 0 <- -1*0 6.6... <- 10-10/3 in: 1344 out: 1344 48 32 6 0 <- did not produce 0, so the prog/func returns 0  Your program must follow these rules: -Takes input from STDIN. -Throws an "error" (printed to STDOUT) and halts immediately after input if the input has one or more 0s in it or if it's less than three digits in length. The error must be a string, and as it's supposed to be printed to stdout, cannot be one generated by the language itself (eg 1/int(min(input())) to check if it's zero). Lastly, the error message has to clearly define what the error is; ERR:0 and ERR:LEN, for example, would suffice. Bonuses/Penalties: -25 if it properly handles decimals. For instance, an input of 99.22 would first turn into 9*9 + 0.(2*2), or 9*9 + 0.4, and so on. This is , so the shortest answer in bytes wins. • I don't like the +15 penalty. Whether strings are used is vague in some languages. The constant amount +15 is too little deterrent for some languages but huge for very concise ones. The fact that you've found a short solution you don't like is sign you should rethink the problem, not try to plug the hole. – xnor Jun 17 '15 at 7:48 • @xnor that's reasonable. I suppose it is a valid way of doing it, anyway, so I removed all mention of strings in that section. Should I also inc/decrease the bonus for decimals? – M. I. Wright Jun 17 '15 at 22:29 • The programming languages I know either don't allow throwing user-defined errors or print them to STDERR. Now, if you just want us to print a message and exit immediately... – Dennis Jun 17 '15 at 23:32 • ...and should be printed to STDOUT. I had a feeling that wasn't clear; I edited it, is it better now? – M. I. Wright Jun 17 '15 at 23:33 • It's the word throw that throws me off (no pun intended). To throw an error usually means something rather specific. Print an error message to STDOUT (or closest alternative) would be less confusing in my opinion. Also, since this is code golf, I think you should require specific error messages. There's no fun in losing a contest because you chose ERR:LEN and somebody else got away with EL. – Dennis Jun 18 '15 at 3:16 • Remove bonuses altogether. It's in the list of things to avoid. – mbomb007 Mar 1 '16 at 21:31 • The error if the input contains a zero seems like a separate challenge. It may be better received if there is only one challenge. There is community support for avoiding Chameleon challenges. – trichoplax Aug 10 '16 at 11:40 # Represent a Number in the Strangest Way You Can Think Of.. while staying under 8 unique characters Your goal is to represent some numbers in the strangest way possible. ### Rules: • The result must be a number that can be used in the programming language like any other ordinary number. For instance, <my expression> + 3 should return 3 more than the value of <my expression>. • The code must be under 20 kilobytes. That's a rather large size for a number so you should be all set. • The expression must have under 8 unique characters! The length of it can be as long you want, just keep it under 8 unique characters. aaaaaaaaaaaaaaaaaa is valid (if it works in the programming language) but abcdefghijklm isn't valid because it uses 8 or more unique characters. ### Guidelines: • The goal here is to represent a number in the strangest and most interesting way possible, so if I ask you to represent the number 35 it would be a good idea to respond with something more interesting than 35 or 12 + 23. • This isn't a ! Feel free to make your code as long as you want, so long as it's under 20 kilobytes. Fancy code can look nice! • The code doesn't need to support decimals (floats) but if it does, it will get 10 extra points (see below). • The code also doesn't need to support negative numbers (for instance -37) but if it does, it will get 10 extra points (see below). • Try to make your post follow the below: ### Post format: # Language Description ### 0 ...  ### 1 ...  ### 30 ...  ### 108 ...  ### 1337 ...  ### 1234567890 ...  ### 3.1415 [10 bonus points if you can get this!] ...  ### -25 [10 bonus points if you can get this!] ...  ## Bonus numbers: ... The points is equivalent to the number of votes on the answer plus 10 if it supports decimals with 10 more points if it supports negative numbers. Whoever has the highest points is considered the current winner. Have fun! This is my first go at making a popularity contest so if you have any tips those would be appreciated.. :) • This is a great challenge... whoever downvoted this has to rethink their concept of code-restriction challenges... – WallyWest Jul 15 '15 at 22:49 • Ah, thank you. :) – Florrie Jul 15 '15 at 23:28 • Updated again with negative numbers added (-25), as well as 1 and 0. – Florrie Jul 15 '15 at 23:33 • @Sp3000 8 unique chars, not 8 total. – isaacg Jul 16 '15 at 10:04 • @isaacg Didn't I state that? – Florrie Jul 16 '15 at 11:11 • @liam_ You did, the person I was responding to who deleted their comment missed it. – isaacg Jul 16 '15 at 11:32 • TBH, I think this is such a poor popcon that it can't be rescued, but if you want to at least make it clear what you're asking then: 1. You talk about representing "a" number, but also about "support[ing] decimals" and "support[ing] negative numbers". What exactly do you want? A function which maps numbers to code? But if so, the "Post format" makes no sense. 2. What is the code which has a 20kB limitation? Total for all the numbers listed in the "Post format"? Each individual number listed in the "Post format"? Something else? 3. Are the 8 distinct characters per number or for all numbers? – Peter Taylor Jul 17 '15 at 16:19 # Wrong tool for the task ### Task Write two full programs in the same programming language that solve the following two tasks: 1. Read two positive integers from STDIN and print their sum to STDOUT. 2. Read two positive integers from STDIN and print their product to STDOUT. Additional details: • Given enough time and memory, your programs has to support arbitrarily large integers. • All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed. ### Scoring The first task is code golf, so your objective is to make your program as short as possible. The second task is code bowling, so your objective is to make your program as long as possible. Your score is defined as follows: The highest score wins! ### Robbing a language There's a catch! Only the submission with the shortest program in a particular language will be considered valid for task 2, so there can only be one valid answer per language. This means that you cannot deliberately write a huge program for task 2; you actually have to pick the "wrong tool" for the task. Additional details: • Task 1 exists merely to provide the proper denominator for the score (and robbers have no moral anyway), so byte-per-byte copies of somebody's program for task 1 are allowed. • If two answers use the same language and have programs of the same length for task 2, the answer that achieved that length first will be considered valid. • If somebody invalidated your answer, you may attempt to golf your answer to revalidate yours and invalidate his. • I suspect this will come down to people writing code in unary and disagreeing on what input/outputs formats are valid for such a language. – xnor Jul 20 '15 at 20:17 • @xnor I'm not sure I understood your comment. The format for I/O is purposedly restrictive, so an answer's validity should be clear-cut. – Dennis Jul 20 '15 at 20:25 • @feersum I think the log scoring does benefits unary. Say (making up numbers) task 1 takes 100 chars of BF and task2 takes 150 chars. Then, those are translated to 300 chars and 450 chars of binary, and so 2^(300) and 2^(450) chars of unary, giving a score of 1.5. In comparison, if the tasks take 20 chars and 50 chars in another language, that's about a score of 1.3. I guess this is surmountable though (20 and 100 gives 1.5). – xnor Jul 20 '15 at 20:33 • Are the inputs decimal numbers? For a language like BF, can the numbers be taken as byte values rather than characters? What separator should be used between the numbers? Are leading zeroes OK in the output? I think you'll have to be pedantic and precise about everything given how much of the character count may depend on details, but it's doable. – xnor Jul 20 '15 at 20:35 • Yeah that's right, it is only for Unary. – feersum Jul 20 '15 at 20:37 • @xnor All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed. – Dennis Jul 20 '15 at 20:42 • @Dennis Wow, you anticipated everything and I missed it. I take it then that input must be as a string of numerical characters? Also, do I understand right that you have to print a newline for output (say, print a+b,"\n" in Python)?. – xnor Jul 20 '15 at 20:45 • @xnor Yes to both. The newline is required and you have to use numerical characters. I'd specify the exact character range, but I don't want to exclude non-ASCII languages.I'll think of a way to make it clearer. – Dennis Jul 20 '15 at 20:51 # GitHub Gist command-line client Create a command-line tool that publishes a list of files as one public GitHub Gist. ## Specification The following bullet points describe the behavior of the program. If a bullet point has "must", you must implement that point. If a bullet point has "can optionally" or "should optionally" you can implement that point on your own volition. 1. It must be a complete command-line program. 2. It must use the GitHub Gists API. 3. It must post an anonymous Gist (that is, not as a GitHub user). 4. Gisted files must use the filename provided on the command-line. 5. The command-line must accept multiple positional arguments. 6. If no arguments are specified, it must print this usage to STDOUT: gist: usage: <file> [file...] verbatim then exit with code 0. 7. If something else goes wrong, it must print this message to STDERR: gist: unable to gist =( verbatim then exit with code 1. 8. If everything is successful it must print the Gist's HTML URL to STDOUT. 9. It can optionally accept a flag for description -d <description. floor(score * .9) 10. It can optionally accept a flag for private gisting -p. floor(score * .9) 11. In the case that a description flag is not used or implemented it must set the description to an empty string. ## Example Input/Output The number before the prompt is the exit code of the previous command. 0$ gist
gist: usage: <file> [file...]
0 $gist no-such-file.txt gist: unable to gist =( 1$ gist hello.txt
https://gist.github.com/anonymous/1e645596ce7bceeb1ec9
0 \$


## Scoring

This is a so shortest answer wins. As stated above, the following multipliers are in effect:

• (9): score = floor(score * .9)
• (10): score = floor(score * .9)
• Both (9) & (10): score = floor(floor(score * .9) *.9)
• What's up with the Example Input/Output code snippet? The editor's preview displays it correctly. – Winny Jul 27 '15 at 20:17
• For the usage, should those literal strings be used regardless of the name and invocation of the program, or should it substitute the correct invocation for the leading gist? I'm thinking particularly of cases like Java, which doesn't support hashbangs. – Peter Taylor Jul 27 '15 at 20:32
• Literal string, I think. – Winny Jul 27 '15 at 20:34
• That's a good point about Java. I think I'll remove the item about shebangs since it's unfair. – Winny Jul 27 '15 at 20:41
• If both bonuses are done, is it floor(score * .9 * .9), or floor(floor(score * .9) * .9)? – Maltysen Jul 27 '15 at 23:48
• Also, if the bonuses are done, do we have to make the usage string reflect that, or just print it verbatim? – Maltysen Jul 27 '15 at 23:50
• Output strings verbatim. And floor(floor(score * .9) * .9) for both. I'll update the question momentarily. – Winny Jul 28 '15 at 2:07
• I'm curious why this challenge is being downvoted. – Winny Jul 28 '15 at 2:28

# Golf these arrays

Gzip base64: (too long, will be added if I'll post this question).

## Rules

• You don't have to output them all. And you can output the arrays in any order. But the order of items in the arrays must be kept as is.
• You can print other arrays, which wouldn't be counted towards your score. The number of arrays you print must be no more than 10,000, and the total number of arrays, subarrays and numbers must be no more than 10,000,000.
• You can use any convenient format to represent the arrays (and the list of outputted arrays).

## Scoring

If your program or function has n bytes, and it printed k distinct arrays from the above list, your score would be n*(128/k)2. Lowest score wins.

### Problems

It looks too boring.

• It also looks too broad. – Peter Taylor Aug 8 '15 at 7:55

## The Perfect Keyboard

Back in the 1970s, keyboard designers respected the needs of programmers and languages. For example, see the IBM 2741 keyboard, designed for APL (from Wikipedia):

Today, sadly, most code golfers are forced to struggle with standard keyboards, which are badly suited to the needs of their language. This has to change!

## The challenge

1. Choose a programming language.
2. Design a keyboard, which would best suit the needs of a developer (or specifically a code golfer) in said language.
3. Post the keyboard layout as an answer.
4. Explain how your keyboard enhances the programming experience.
6. Optional - if you are the winner, start a Kickstarter project to build the thing.

This section is, of course, for the sandbox only.

I don't really expect a keyboard design which would actually improve functionality of programs in an actual serious language. I'd expect fun answers, where the keyboard design highlights soemthing fun/interesting/absurd about the language. But my expectations don't matter so much, because it's not me rating the answers, but the other users.

Example (not very good ones):

1. A Brainfuck keyboard with only 4 keys.
2. A Lisp keyboard where half the keys are parentheses.
3. A Piet keyboard - I'm sure someone will come up with something nice.

• I'm note sure if it's a valid challenge since there is no programming actually involved in answering this – Fatalize Sep 3 '15 at 9:28
• @Fatalize, You're right, but it is a programming-related challenge. It requires knowledge of programming languages and people may find it interesting or amusing. I may be pushing the boundaries, I don't know. – ugoren Sep 3 '15 at 9:45
• I would personally be ok with that challenge but I don't know if other, more prominent users would find this challenge off-topic. – Fatalize Sep 3 '15 at 9:48
• Judging from this Meta post, there seems to be a fairly clear consensus that a question must involve programming to be on topic, not merely be programming related. So this question is fairly clearly not valid. – isaacg Sep 3 '15 at 10:08
• You could always include programming the driver or some kind of special interface for the keyboard – Beta Decay Sep 3 '15 at 10:28
• @BetaDecay, This challenge is about crazy creative answers. Requiring a driver implementation seems to me like a way to kill this creativity. – ugoren Sep 3 '15 at 11:01
• @isaacg, trichoplax writes "I judge it by whether the answers to it demonstrate skill and determination, or just aesthetic style" - I think a good answer to this challenge requires undestdanding a language and designing something that relates to its properties. Does it qualify as "skill and determination"? I can't say I'm sure. – ugoren Sep 3 '15 at 11:06
• The art/programming debate was specifically about popcon questions where the answers were programs. There's no doubt whatsoever that a popcon where the answers are just images would be an art question rather than a programming question. On the same basis, this is not a programming question, and does not belong on this site. – Peter Taylor Sep 4 '15 at 13:58
• @PeterTaylor - I don't think it's an art question. The challenge isn't to get a pretty picture of a keyboard, but to design something that suits the language in an interesting way. But I posted it here to get the communities opinion, and it seems quite clear what it is. – ugoren Sep 5 '15 at 19:00
• Since I wrote that meta answer the rules on popularity contests have been tightened up, and I think that is a good thing. I stand by my answer, but I think it is right that popularity contests be judged strictly, to reflect the fact that it is very difficult to write one that is a good fit for the site. – trichoplax Sep 4 '16 at 11:56
• Although it's possible someone will come up with an ingenious approach to designing a keyboard, the challenge itself seems to lean towards "make me laugh" rather than "impress me". This is why I don't think this is a good fit for the site. – trichoplax Sep 4 '16 at 12:03
• I'd love to see what keyboards the community comes up with, but I think it would need to be hosted somewhere other than main. For things which are appealing to the PPCG community, but not quite a fit for main, there's Code Golf Chat. People often post "mini challenges" which aren't well specified enough to be challenges on main, but can end up inspiring people to write a full challenge. – trichoplax Sep 4 '16 at 12:06
• I think it's important to keep testing the boundaries of existing winning criteria, and to try to come up with new ones. The people who put the effort into this will have a long run of rejections, but I really hope these don't come across as "don't try". – trichoplax Sep 4 '16 at 12:19

# Technologic - Now what's THAT command do??

Daft Punk's song "Technologic" is all about actions that a user or computer does when it's working and being used. You goal is to write a program that has one command we will call the Technologic Command. This command will executes all of the actions like "buy it", "lock it", "code it", and "write it" in the order the lyrics are written on 'it'. What 'it' is is up to you, but you gotta let me know.

# Rules

• Any language can be used.
• The song refers to an 'it'. That can be a block a memory, algorithm, function, file, or anything else a computer can manipulate directly or indirectly.
• You must specify what 'it' is you will be performing these actions on. If you don't, you can only earn a maximum of 160 points.
• Points will be deducted otherwise if a command is not used.
• I'm not aware of any 'buy' command, method, function, subroutine or instruction so use a thesaurus and find the closest word you can actually program. I don't expect the program to actually buy or snap anything. Other words like mail and fax are possible, but not recommended.
• If you have to use a synonym, you are not allowed to use that command again
• Encompassing multiple objects into one artifact does not count. For example, taking the command "name it" literally means you won't be able to name an array of bytes, but you can name a file. Creating an object that holds both a file and an array of bytes is not allowed. That would make this too easy to get the maximum amount of points.

# Scoring

• There are 16 commands with a total possible score of 190 points.
• 10 points for executing a command on the specified 'it' of your choosing (160 total)
• 2 points for executing each command consecutively that references your 'it' (30 total)
• 5 points for executing a command on something other than your 'it'
• -3 points for every command skipped.

# Command List

lyrics

Buy it, use it, break it, fix it,
Trash it, change it, mail - upgrade it,
Charge it, point it, zoom it, press it,
Snap it, work it, quick - erase it,
Write it, cut it, paste it, save it,
Load it, check it, quick - rewrite it,
Plug it, play it, burn it, rip it,
Drag and drop it, zip - unzip it,
Lock it, fill it, call it, find it,
View it, code it, jam - unlock it,
Surf it, scroll it, pause it, click it,
Cross it, crack it, switch - update it,
Name it, rate it, tune it, print it,
Scan it, send it, fax - rename it,
Touch it, bring it, pay it, watch it,
Turn it, leave it, start - format it.

• This conversation has been moved to chat. – Dennis Sep 17 '15 at 21:06
• I count way more than 16 commands here. There are 16 lines each with several commands on them. If we cound the hyphenated commands as two, there are 16 x 4 = 64 commands. – Level River St Sep 22 '15 at 22:01
• @steveverrill A slight oversight. haha. I must've counted the lines knowing there were 4 commands on each line and didn't multiply the two together. – Luminous Sep 23 '15 at 12:31

# Just Golf 2016 code-golfkolmogorov-complexity

(Related: A Kingdom Hearts VGM challenge) Sandbox note: potential duplicate?

Just Dance 2016 is coming out soon, and I know I'm definitely excited! However, let's take a quick trip back to 2009, when the original Just Dance was released. There are a lot of great songs, but I don't know who sung half of them!

## The Challenge

Write a program that accepts a Just Dance song name from input and outputs the song's artist (as credited in-game.)

Here is the list of all songs and artists from Just Dance 1:
list pending

## Rules and Assumptions

• You may assume that the song will always be valid.
• The song's title and artist must be properly capitalized.
• You may not read any external files - the song data must be hardcoded.
• If a song is covered (which several have been for various reasons), the program should return the cover artist (as they are credited in the game.)

## Test Cases

Input: Eye of the Tiger
Output: Survivor

Input: Fame
Output: Irene Cara

## Bonuses

• Each game has had one song everyone was really excited about. This year, it's Ievan Polkka by Hatsune Miku. You get a bonus of -50 points if you accept this song as valid input.

• Just Dance is fun, but why should we stop there? If you additionally accept songs fron the rest of the main series (Just Dance 2, 3, Greatest Hits/Best Of, 4, 2014, and 2015, not including DLC and skipping over any duplicates), you get a whopping -2009 points. Here is the full list for those games:
list pending

• Note that this doesn't include Just Dance 2016 songs.
• This can be combined with the other bonus to get a total of -2059 bytes.

## Meta Questions

• Are the bonuses too big? (I'm mainly talking about the -2009 point bonus for including every song.)
• Has anything been left out?
• Is this enough of a challenge?
• This looks like a dupe of codegolf.stackexchange.com/q/53678/194 . – Peter Taylor Sep 24 '15 at 20:24
• @PeterTaylor I would say it isn't, that one asks for input in the form of a game and boss and returns a song, mine asks for a song and returns an artist. That one also has different scoring rules, and mine requires all items to be implemented. – ASCIIThenANSI Sep 25 '15 at 13:51
• They're both "golf this given map / dictionary / associative array". Why would the techniques used be any different? – Peter Taylor Sep 25 '15 at 15:22
• @PeterTaylor According to this meta post, the main qualification for duplicates is "Can answers from one question be copied over to the other with little or no modification and still be competitive?". I looked at the answers for the question you linked, and it doesn't seem like either would do very well if those techniques were used in this challenge. – ASCIIThenANSI Sep 25 '15 at 15:35
• Would this be kolmogorov-complexity? – LegionMammal978 Sep 26 '15 at 17:16
• @LegionMammal978 Yes. – ASCIIThenANSI Sep 27 '15 at 14:48

# Literally just printing the source code

Wait a second. We already have a contest where you print the source code. Right? Wrong.

## The challenge

Print out the source code. Not to STDOUT, but to a physical printer.

The rules:

• You must write a complete program that prints out its own source code with a printer connected to the computer.
• No STDIN (or input of any kind), STDOUT, or STDERR.
• No standard loopholes (includes no file input). No using lp(r/d) or similar commands.
• The printed code should be a reasonable size (between size 8 and 18) and a legible font (pretty much means no wingdings).
• You may assume that the user doesn't cancel the process and answers affirmatively to any system print dialogs.
• You can assume that the printer works, is ready, doesn't need new ink/paper, etc.
• If the language doesn't support printing, it is ineligible.
• This is so shortest code, in bytes, wins.
• This is a trivial extension of the quine challenge. All you have to do is say you're running it on Unix/Linux and pipe the output to lpr. – Mego Nov 1 '15 at 22:21
• This needs a much tighter spec on the hardware. E.g. I assume you would consider it cheating to post an ordinary quine and say "On this computer, all console output is also logged to a continuous print spool", but there are computers which are configured like that for audit reasons. – Peter Taylor Nov 2 '15 at 14:39

# Print a sourcecode

Given 2 inputs(First input is truthy/falsy, second input is program in same language as submission):

1. If the first input is truthy then transform the second input into same program but printing the source code(After modification) first.
2. If the first input is falsy then transform the second input into same program but after the program finished it prints the source code(After modification). If the program doesn't halt, you may or may not modify the program.

It's code-golf, so the shorter answer is the winner.

For example in CJam, I don't write the program to do this. (> means output)

0 q
>{"_~"q}_~
0 0 1{_@+}11*;
>{"_~"0 0 1{_@+}11*;}_~
1 q
> {q](\o"_~"}_~

• Sorry, I'm not quite sure what this question is asking. Would it be okay if you posted examples? – Sp3000 Nov 5 '15 at 14:29
• @Sp3000 Please undo your downvote. The example is fixed. – Xwtek Nov 7 '15 at 7:39
• I didn't downvote though... – Sp3000 Nov 7 '15 at 8:13

# Restricted "Hello, World!"

The task is very simple, output Hello, World! to STDOUT. The thing that makes this different are the rules:

• You need to provide a full functioning program, taking no input and outputting via STDOUT.
• The program must not write anything to STDERR
• The maximum amount of bytes you can use is 50
• The program may only contain printable ASCII characters. Programs using CP437 and other encoding systems are not allowed
• If a programming language is already used, you cannot use this same language again.
• You cannot use any character of the prohibited character list. This is the twist:

### Prohibited character list (PCL):

The prohibited character list is a list full of characters, which cannot be used in the following programs. For example:

If the list was: He\., you need to create a program, without the characters H, e, \ and .. These are not case-sensitive.

If you succesfully manage to write a program that doesn't use any characters, you may add new one character to the prohibited character list.

e.g.

If the old PCL was He\., and you managed to write a program that doesn't use any of these characters, you may add a new character to this list. For example  (whitespace). The new PCL will be He \. (notice that the whitespace character is added).

### Posting Snippet:

#[Language Name], N bytes

[code]

(explaination etc.)

New PCL: [list + new char]


In the beginning, the PCL is empty. The last person who managed to create a program without a new program made in 2 days, wins!

I'm not really sure if it is flawed or not. If you have any suggestions or comments, feel free to post them below in the comment section :)

• Already exists. – Arcturus Nov 22 '15 at 23:38

# What day of the week is Christmas?

Christmas is coming quickly, which leads to the question, what day of the week is Christmas this year? But what day of the week is Christmas for any year? Write a program that can do this. This is code golf, so the shortest code wins!

However, there is a major twist. No builtin functions to do this task is allowed!

Bonuses:

1. If the program can handle B.C. years as negative numbers, then -25%
2. If the program prints "The first Christmas!" for an input of -4 (4 B.C. is assumed to be when Jesus Christ was born), then -30 bytes
3. If, for some reason, you really like builtins, +90%! So try NOT to use it!
• The bonus for printing extra should be steeper, or no esolangs are going to go for it. – Addison Crump Nov 29 '15 at 1:45
• @VoteToClose so more like 25% as well? – TanMath Nov 29 '15 at 1:48
• No - I'd go static. Plus, this is really close to being a dupe... – Addison Crump Nov 29 '15 at 1:51
• Near dupe of codegolf.stackexchange.com/questions/1003/… – Calvin's Hobbies Nov 29 '15 at 1:52
• It's unspecified what format we should output in or what calendar we should use, and whether -4 should mean 4 BC or 5 BC. – lirtosiast Nov 30 '15 at 5:57
• @ThomasKwa it should be obvious from the sentence that 4 B.C. is -4. Use the Gregorian calendar, output can be in MMDDYY – TanMath Nov 30 '15 at 6:09
• How is MMDDYY a day of the week? – lirtosiast Nov 30 '15 at 16:32
• @ThomasKwa sorry, it was pretty late when I wrote that so I mistakenly wrote MMDDYY. Just printing the day of the week is fine i.e. print "Sunday", "Monday", "Tuesday", etc. – TanMath Nov 30 '15 at 19:57

# Broken FizzBuzz - Greg Is Confused underhandedcode-golfpopularity-contest

(FizzBuzz suggested by quartata in chat)

Meet Greg. Greg is the new debugger at your company, and he deals with checking programs to see if they work. If they don't, he tries to find out why and fix them.

Greg is rather new to programming and understands the basics, but still gets tripped up by some advanced things. Sometimes, programs don't work and he doesn't know why.

You don't really like Greg, so you decide to play a game. You create two nearly-identical FizzBuzz-style programs - one which works, and one which doesn't.

For example:

n = input()
if (n % 3 == 0) {
print "Fizz"
}
if (n % 5 == 0) {
print "Buzz"
}


works, but

n = input()
if (n % 3 = 0) {
print "Fizz"
}
if (n % 5 == 0) {
print "Buzz"
}


doesn't. Greg is confused (but not by something as simple as this).

And because Greg has a desk only a few feet away from you, your code must be as small as possible, so he doesn't catch on.

## Rules

• Your correct program must accept an integer as input and return output as specified below, and your incorrect program must do something else (such as throwing an error or giving invalid output).
• The valid program's output must print "Fizz" if the number is divisible by 3, "Buzz" if it divisible by 5, "FizzBuzz" if it divisible by both 3 and 5, and nothing if it isn't divisible by 3 or 5.
• The invalid program's output may do anything else.
• Greg knows all programming languages to date, including super-obscure ones. Therefore, your answer may be in any language you choose (providing it was created before this challenge was posted.)
• You MUST have the two programs be nearly identical, except for one small change. The more concealed or insignificant-looking, the better.
• Greg uses PPCG and has participated in underhanded challenges before, so he knows about the C trigraph (??/). You can't trick him with it.
• Greg has also seen replacing ASCII characters with nearly-identical Unicode or abusing fonts, meaning that won't work either. Therefore, your program's change must work with all fonts, any may not exploit visual similarity between characters with different code-points.
• Changing an a to an A is allowed, as long as it's not obvious that that's what broke the program. However, changing a to <unicode character that looks exactly the same> is forbidden.
• Both programs must be written in the same language with the same version.
• The language both programs are written in
• Two programs: one FizzBuzz program, and another that is broken
• How to run both of them (the commands must be identical with identical arguments)
• Why one doesn't work (in spoilertext)
• The output of the broken one
• Your programs must have a Levenshtein distance of no more than 10 from one-another. (Meaning that you may add, delete, or change up to 10 characters in the broken code from the correct one.)
• Your score is the total bytecount of both of your programs.
• The winner is the post with the smallest score over 20 votes.

Meta Questions

• Is 10 too small a maximum Levenshtein distance? I was also considering 15.
• Are any of my rules already forbidden by the standard loopholes? I'd like to remove them if possible to make the post shorter.
• Similarly, should I remove or change any of my rules?
• This is a code-golf version of this previous edit. Should I keep it as code-golf or change it back?
• "replacing ASCII characters with nearly-identical Unicode" doesn't really express what that old chestnut does. "Exploiting visual similarity between characters with different code-points" is more accurate. Although it's arguable whether that covers e.g. switching space for non-breaking space, and I don't think it covers using non-whitespace non-printable characters (which with the right font are invisible). – Peter Taylor Dec 16 '15 at 16:44
• I think there is something interesting here in making seemingly equivalent programs behave very differently. But I'm generally sceptical of underhanded pop-cons, because they're usually way too broad and this one doesn't seem to be an exception. The primary cause is probably that there's no actual task that the program should accomplish. That means you can literally write any code that leads to failure from a small change (which is probably most code although the failure will not be surprising for most of those changes). I'd recommend giving a task for at least one of the two programs. – Martin Ender Dec 16 '15 at 16:49
• @PeterTaylor Maybe something like "Your program's change must work with all fonts, any may not exploit visual similarity between characters with different code-points"? – ASCIIThenANSI Dec 16 '15 at 16:53
• @MartinBüttner I've changed it to two programs that should print "Hello, world!" (only the correct program will work). How does this look? – ASCIIThenANSI Dec 16 '15 at 16:57
• There are some very closely related underhanded challenges: codegolf.stackexchange.com/q/31647/8478 codegolf.stackexchange.com/questions/23250/what-no-error codegolf.stackexchange.com/questions/19379/… – Martin Ender Dec 18 '15 at 16:37
• @MartinBüttner I've added them in. Do you think they're close enough to be duplicates? – ASCIIThenANSI Dec 18 '15 at 16:42
• @ASCIIThenANSI I can't predict how the community will vote, but I wouldn't mod hammer it. – Martin Ender Dec 18 '15 at 16:45

# Golf A Wiki

## The Challenge

Golf a wiki. A wiki, for the purposes of this contest, is defined as a website with:

• Content editable by all
• Easy CamelCase (defined as a word with two capitals) linking
• Different pages or articles that are the targets of the links

Your wiki can be a self-contained HTML file (e.g. TiddlyWiki), or a cgi-bin script (e.g. SigWik).

## Scoring

Your score is the size of your program in bytes, divided by the number of extra features implemented plus one.

The possible extra features are:

• Page history
• Syntax for "nowiki", that is, something like <\noscript> in HTML that makes the text inside it not be wiki syntax.
• A page list
• A find page facility
• Delete pages
• Change page titles
• Redirects
• Random page
• Non-HTML formatting that is not just links [Should I remove this? I doubt it will be done.]

Lowest score wins, as this is code golf.

# DISCLAIMER

ANSWERS WILL PROBABLY CONTAIN MAJOR SECURITY FLAWS. ONLY USE ON PRIVATE PORTS, UNLESS YOU WANT YOUR COMPUTER AND VERY POSSIBLY YOUR WHOLE NETWORK TO GET DESTROYED (FIGURATIVELY). [Is this too forceful?]

• I would vote to close this as too broad. Among the problems I see: 1. The two given examples don't seem to be the same thing as each other 2. The complete lack of constraints mean that I could just automatically make every word a link. (This could be fixed by specifying one link syntax: for golfing I quite like the UseModWiki use of CamelCase for links). 3. I think I can get the "text formatting" feature for free by not escaping HTML characters. 4. Needs a big warning "Answers will likely contain major security flaws and should not be used on ports which are publicly visible" – Peter Taylor Dec 30 '15 at 10:49
• Ok, thanks, I'll edit when I have time today. – Hipe99 Dec 30 '15 at 21:27

## Progress 100%

For that I created an event mechanism that reports on the progress of each individual file. It sends me the information on how many bytes B have been downloaded of file T total.

## Input

Integer C between 1 to 100, followed by new line, followed by C progresses separated by new line. Each progress is constructed of two numbers with the maximum size of 64 bits: B T, separated by space.

Input options

The input is a String available from the following options

• file
• stdin
• method parameter

## Output

Floating number between 0 to 1, the average of all the progresses. It must be displayed to 11 decimal places, floored.

## Criterial

Shortest code wins

## Example

Input file:

3
5 10
1024 1024
20 100


Output

0.56666666666


Explanation

((5/10) + (1024/1024) + (20/100)) / 3 = 17/30


## Example2

Input file:

1
2 10


Output

0.2


## Example3

2
Long.MAX_VALUE Long.MAX_VALUE
5 10


Explanation In this example Long.MAX_VALUE represent the maximum 64 bit value, so if you use 64 bit value for storing the sum of the averages it will not work in this case.

Output

0.66666666666

• 1. It's not clear from your specification how the result should be computed. The "total progress" implies to me that I should figure out how many bytes have been downloaded of the total, i.e. sum(B)/sum(T)`. However, your first example suggests, that we should actually compute the arithmetic mean/average of the individual progresses. If so, please state this clearly. 2. By requiring 11 digits of accuracy, you require 64-bit floats (double precision), because 32-bit floats only have 7.something decimal digits. Is this intentional? (seeing your input is only 32 bits) – Martin Ender Apr 1 '15 at 20:39
• @MartinBüttner how about now? I do want the high precision – Ilya Gazman Apr 1 '15 at 21:24
• My first point still stands. It's not clear from the specification how the result should be computed. – Martin Ender Apr 1 '15 at 21:27
• @MartinBüttner I expect you to process all the progresses and find the average one, not sure how to say it right. – Ilya Gazman Apr 1 '15 at 21:28
• Just like that, but as far as I can see your challenge currently doesn't mention "average" or "arithmetic mean" anywhere. – Martin Ender Apr 1 '15 at 21:32
• @MartinBüttner Anything else? – Ilya Gazman Apr 1 '15 at 21:40
• Why did you remove it again? And what's the purpose of the hint? – Martin Ender Apr 1 '15 at 21:43
• @MartinBüttner sorry had 2 windows opened. The hint helps you to understand that you cannot store the sum of all the progresses in 64 bit value. – Ilya Gazman Apr 1 '15 at 21:45
• What does "up to 11 digits of accuracy mean"? That I can supply only 3 digits, but I may not supply 12? And what counts as a "digit of accuracy", anyway: are you talking decimal places or significant figures? And if significant figures, what is the correct output if the average progress is exactly 0? – Peter Taylor Apr 1 '15 at 22:37
• @PeterTaylor I want an 11 digits after the dot of accuracy in the output. So 3/10 will produce 0.33333333333 and 0/10 will produce 0. Maybe you can suggest a better way of writing it down. – Ilya Gazman Apr 1 '15 at 22:40
• I've edited in some changes. I would suggest also deleting the hint and replacing it with a test case. It would also be good to describe a test case (it will probably be too long to post) which demonstrates that it's not sufficient to use IEEE754 double-precision. – Peter Taylor Apr 2 '15 at 7:35
• @PeterTaylor is it ready now? – Ilya Gazman Apr 2 '15 at 14:09
• It would also be good to describe a test case (it will probably be too long to post) which demonstrates that it's not sufficient to use IEEE754 double-precision. – Peter Taylor Apr 2 '15 at 19:28
• @PeterTaylor I don't understand what you are saying, can you please explain it a little bit more – Ilya Gazman Apr 2 '15 at 20:15
• Since you're requiring programs to support averaging 2^31 numbers and you want output to a precision of about 35 bits, a naïve solution with 64-bit floating point will be incorrect, but that might not be obvious to everyone who would attempt an answer. – Peter Taylor Apr 2 '15 at 20:23

# There's an App SE Site for that

Oftentimes, when searching through StackExchange, I find myself seeking to post a question about something or another, but not knowing where to post it. That's where you come in.

## The Challenge

Write a full-functioning program that does the following:

1. Takes an input string
2. Attempts to find suitable SE sites relevant to the input string (this is very flexible, but should not be returning English.SE for questions about Coffee, for example)
3. Attempts to find 3 questions on each suitable site that may relate to the input string (should match the list of questions if I searched in the search bar of each site, sorted by number of votes)
4. "Output" is a folder tree written to disk with the following qualities:
• The highest folder of the tree should be named the input string.
• The second-highest layer should consist of folders named the same as the sites on which the input string was found suitable.
• The third layer should be <=3 .md files that are named the same as the questions found when searching through the suitable sites, the contents of which are the question's markup content.

# Rules

• You MUST query for this information. I don't want 50EB solutions.
• "Suitable sites" are defined as the keyword appearing in the site description.
• Run time should be <5 minutes for >3 MB internet speed.

# Bonuses

There are no bonuses.

Remember - SE is a big place now, and, as of such, we must compensate with short code. This is , everybody, so the shortest solution wins!

• "Whatever defines "suitable" for your code is up to you" is too broad IMO. – Peter Taylor Jan 25 '16 at 14:35
• @PeterTaylor Refined. Please see edit. – Addison Crump Jan 29 '16 at 17:50
• @RikerW I don't know what you're saying. – Addison Crump Jan 29 '16 at 17:57
• Me neither. lol – Rɪᴋᴇʀ Jan 29 '16 at 17:58
• What's the yardstick for whether two words are synonyms? If that's up to answers to decide, no-one will waste any bytes on it, so you should simplify the question by removing the mention of synonyms. Otherwise you need to add a source (and risk the question being largely a kolmogorov-complexity for that list). – Peter Taylor Jan 29 '16 at 19:48
• @PeterTaylor Fixed. – Addison Crump Jan 29 '16 at 20:45