# Shortest code to write longest code

Your challenge is to create a shortest code in your language of choice which writes on a .txt file the longest code to multiply two numbers by taking two numbers as input and output the answer.

NO INPUT NEEDED TO YOUR CODE WHICH IS DOING THE WRITING JOB!

The generator code and generated code can be in any languages

Do NOT use unlimited series or progression to make text file big.
Do NOT use unnecessary statements to increase the score.

### SCORING

( size of text file generated in bytes )  (without any unnecessary white spaces, tabs or newlines)
-----------------------------------------
( size of your code in bytes )


# Winner

Winner will be chosen after 1 week from now with the highest score.

EDIT : range of input in code multiplying two numbers should be in between -32768 to 32767

• I eventually figured out, but the fact that you use code formatting for the output made it seem like you were looking for the literal string "the longest code to...". – undergroundmonorail Apr 4 '14 at 18:09
• I think you can just use this answer by Comintern, changing the + to * in the generator program he provides, and you probably already know this, since you answered that question as well. – Geobits Apr 4 '14 at 18:21
• @Geobits I tried to keep my question away from that answer, but I think the effort is not enough, what should I ask to generate then, so that The question has nothing to relate from other question-answers? – Mukul Kumar Apr 4 '14 at 18:29
• I don't know what you should ask, it just seems like any winner here is going to be eerily similar to the answers there. – Geobits Apr 4 '14 at 18:30
• @MukulKumar maybe the long code should generate the short code? But don't change this question to that, the change is way too substantial. But it might be an idea for another quine-related challenge (if it hasn't been asked before). – Martin Ender Apr 4 '14 at 18:31

# perl/perl, unlimited score under original rule with unlimited range

Here's some code which doesn't win:

$l=-2**5-1;$h=2**5;
sub p{print@_}
p"sub add {($i,$j)=\@_;\n";
for($i=$l;$i<=$h;++$i){ for ($j=$l;$j<=$h;++$j){
p" return ".($i*$j)." if ($i == i) && ($j == $j);\n"; } } p"}print add(<>,<>)\n";  The output has this form: sub add {($i,$j)=@_; return 1089 if ($i == -33) && ($j == -33); return 1056 if ($i == -33) && ($j == -32); return 1023 if ($i == -33) && ($j == -31); return 990 if ($i == -33) && ($j == -30); ... return 928 if ($i == 32) && ($j == 29); return 960 if ($i == 32) && ($j == 30); return 992 if ($i == 32) && ($j == 31); return 1024 if ($i == 32) && ($j == 32); }print add(<>,<>)  the output file is 181030 bytes long, but after stripping spaces and newlines, it is only 133109 bytes long. so, the score is 133109/248 = 536.7289... Here's some other code that doesn't win - it is the same program except the first 2 lines: $l=-2**6-1;
$h=2**6;  the output file is 718138 bytes long, but after stripping spaces and newlines, it is only 532233 bytes long. so, the score is 532233/248 = ~2146. better! using 7 yields a score of ~8750, 8 yields ~35347, 9 yields ~149129, 10 yields 151100000 non-space / 250 = 604,400 .... of course we can do this as long as we want. the size of the source program, n, will increase as O(log(n)). the size of the output program is O(2*n). The limit of 2*n/log(n) as n goes to infinity is clearly infinity, so if I just substitute in my favorite large number, a googolplex, I win (until someone suggests googolplex+1). • What is the kind of output ? like you may give first non-repetitive lines. – Mukul Kumar Apr 5 '14 at 2:09 • First time I could actually read Perl. It generates a function named add which takes two parameters. It then populates that function with return statements looking like return 39 if ($i == 13) && ($j == 3);, using all values from $l to $h for $i and $j. Smartass bending of the "only unnecessary statements" rule. – tomsmeding Apr 5 '14 at 5:50 • Mukul, I edited the answer to include some sample output. – skibrianski Apr 7 '14 at 17:51 • @skibrianski well that's finite then, because the value the variables i,j can hold are finite. But, quite large. – Mukul Kumar Apr 7 '14 at 19:09 • Mujul. Finite, but unlimited. Give me any number and I can choose a larger size output (or score) by simply adjusting those variables. – skibrianski Apr 7 '14 at 20:08 # C, 27297/245 = 111.4 ### Source code (245 bytes) #include<stdio.h> main(int c,char**v){char*s;FILE*f=fopen("/tmp/x.c","w");fprintf(f,"#include<stdio.h>\n#include<stdlib.h>\nmain(){int a=%s,b=%s;printf(\"%s * %s = %%d\\n\",a*b);}",v[1],v[2],v[1],v[2]);fclose(f);system("cc -E /tmp/x.c >add.c");}  When compiled and run with two integer arguments on the command line, this generates another C file containing the necessary code to calculate their product, and compiles it with the -E flag. This flag specifies that the compiler should stop after the preprocessing stage and output the processed source code (which will include the entire contents of stdio.h and stdlib.h). ### Output file (27297 bytes) # 1 "/tmp/x.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "/tmp/x.c" # 1 "/usr/include/stdio.h" 1 3 4 # 64 "/usr/include/stdio.h" 3 4 # 1 "/usr/include/_types.h" 1 3 4 # 27 "/usr/include/_types.h" 3 4 # 1 "/usr/include/sys/_types.h" 1 3 4 # 32 "/usr/include/sys/_types.h" 3 4 # 1 "/usr/include/sys/cdefs.h" 1 3 4 # 33 "/usr/include/sys/_types.h" 2 3 4  ********* LINES 13-1273 OMITTED ********* long long strtoq(const char *, char **, int); unsigned long long strtouq(const char *, char **, int); extern char *suboptarg; void *valloc(size_t); # 3 "/tmp/x.c" 2 main(){int a=6,b=7;printf("6 * 7 = %d\n",a*b);}  ### Result of running the output code The output file is saved as add.c, which can be compiled and run normally: $ ./a.out 6 7
$cc add.c -o add$ ./add
6 * 7 = 42
$ # perl, 125 chars, score 1,630,326,497.312 Same basic approach as my other answer, but this time bounded between -32768 and 32767 per the updated rules, and all unnecessary whitespace stripped completely: $l=-($h=32767)-1;print"sub a{";for$i($l..$h){print"return ".$i*$_." if$_[0]==i&&$_[1]==$_;"for$l..$h;}print"}print a<>,<>"  The output program begins like so: sub a{return 1073741824 if$_[0]==-32768&&$_[1]==-32768;return 1073709056 if$_[0]==-32768&&$_[1]==-32767;  and ends: return 1073643522 if$_[0]==32767&&$_[1]==32766;return 1073676289 if$_[0]==32767&&\$_[1]==32767;}print a<>,<>


The output program is 190GB long. More precisely, 203790812164 bytes. Score = 203790812164 / 125 = 1630326497.312

## Windows Command Script: ~1,000,000,000 pts

Code: 158 bytes

Output: ~158000000000 bytes

echo>.txt @goto :%%1_%%2
set,=for /l %%a in (-32768 1 32767) do call :
%,%1 %%a
:1
%,%2 %1 %%a
:2
set/a]=%1*%2
echo :%1_%2>>.txt
echo @echo.%]%^&exit/b0>>.txt


The output pretty much consists of:

@goto :%1_%2
:-32768_-32768
@echo.1073741824&exit/b0
:-32768_-32767
@echo.1073709056&exit/b0
...
:32767_32767
@echo.1073676289&exit/b0