text:
Make a quine writer!
Writing quines is hard. Why not have your computer write them for you!
Your program will take as input an interpreter (in a Turing complete language of your choosing) for a language X, and you will output a quine in language X.
Notes:

Language X is guaranteed to be Turing complete (you do not need to check this (it would be impossible to do so anyways)).
Due to some issues that jimmy23013 raised in the comments, I'll also guarantee that the language has a quine.
A quine for the purposes of this challenge is a program that outputs its own source code when given no input.
The interpreter might throw errors if the program it is running has errors, so be prepared! (A quine shouldn't throw errors.)

Here is an example algorithm you can use. I am only putting it here so people don't claim this challenge is impossible:

 Go through every possible program, running them all in parallel or via Dovetailing. Throw out programs that cause errors. Whenever a program outputs its own source code, you are done. Since every Turing complete language has at least one quine, this is guaranteed to eventually return a result.

This is code golf, so the shortest answer wins!

This seems like a fun one. But to be clear the program should take the interpreter as input? How on earth are we going to parse that??

eval might help :P Or maybe just use system commands to run the interpreter.

@MDXF You could use a universal turing machine. Javascript would also work, but that sounds like it would be more trouble than its worth.

It's possible to write quines in some languages that is not Turing complete. And someone can design a Turing complete language that a quine is impossible.

Go through every possible program, running them all - I'm not convinced this is possible in general.  It is quite likely you'll get rm -rf / or shutdown -h now (or equivalents in the given language) before you get to a valid quine.  Oh and there is also the thing with the halting problem - while(true) may well be generated before a quine.

@DigitalTrauma The while(True) can be evaded by using dovetailing as suggested in the post, as for the others, you might have trouble with that.

Can we create our own TC language in which to take input interpreters?

"Since every Turing complete language has at least one quine, this is guaranteed to eventually return a result." There are some caveats to this. I can easily design a Turing-complete language that cannot output its own source code (consider a language whose source code is written entirely with letters, but which can only output 0s and 1s). Some TC languages don't have traditional output at all. The statement is only true if you define some encoding for arbitrary strings on whatever the language's output is. Then you can always find a program which produces output that encodes the source.

However, you can't let people choose an arbitrary encoding, because then they could always choose a suitable encoding to trivialise the challenge. So I'd suggest guaranteeing that the language is capable of producing arbitrary strings as output to begin with, so that the source code can always be matched exactly.

I'm also not sure how dovetailing would be an option if we're only given a black box interpreter. Spawning separate threads and suspending them each in turn to ensure each thread gets arbitrary amounts of computation time should work though, I think.

@MartinEnder Just found the problem. The proof on Wikipedia requires the programming language to be an admissible numbering. Someone can design a language that prints some extra characters if the input is empty, and the output is the same as the source code when it ends. It is still possible to write every computable function in it. Just write the program normally, and add a nop if it happens to print itself when the input is empty. But we may not know if it doesn't halt. It is still Turing-complete as how I understand the definition. But it is not an admissible numbering and the proof fails.

@MartinEnder Sorry I forgot to say what is "the problem". I mean I can design a language that is impossible to quine, even if it uses the complete character set and can compute every computable function mapping any input to any output. It's just the case we don't know how to translate arbitrary programs into it without solving the halting problem.

Wait if you get to the program that does rm -rf / before the quine?

@jimmy23013 I'll just add that it has a quine.

@EriktheOutgolfer Side effects are okay, but you are not required to execute anything, just find a quine. The hint box is just a suggestion.

But ANY interpreter?

@Christopher Only ones for Turing complete languages (with quines).

@PyRulez that is crazy. Assume ASCII only codebase?

@Christopher Sure

Unless I'm reading this wrong, wouldn't this require solving the halting problem? while(true) would break stuff, I think

@StephenS The hint describes a way around this.

Does the desired quine program have to halt after printing its source code?

@ppperry yes, it does

Can the program take longer than the age of the universe to execute? (This question applies to both the quine-maker and its produced quine)

@ppperry sure thing

@ppperry yep, no runtime requirements

From the challenge description, couldn't someone just hardcode the output for the quine in language X, not using the input?

@mbomb007 Your program must work for every language. You don't pick language X, language X is determined by the interpreter given.

"take as input an interpreter (in a Turing complete language of your choosing)"

Is outputting a trailing newline acceptable?

@mbomb007 if it's only one

Well, I'm trying, but I may not know enough about how shell commands work. It's not easy to test this on TIO.

@mbomb007 why not just require the interpreters to be given in BF or something?

I'm voting to close this question as off-topic because any answer would be simply outdated too quickly. new languages pop up every month, and there is no way to future proof it without first solving the halting problem. Aditionally, an 'interpreter' is not defined well enough to mean much. Is it the path to the intepreter, the command to interpret the program, a link to download the interpreter?

It is possible to make a turing complete language not have a quine. It's as simple as going to the interpreter and typing something like "if(print.msg == src){print.cancel();}". What should happen if such a language were to be made, and handed to a 'Valid' entry?

@tuskiomi I took it to mean that you take the command to execute the code. For Python on TIO, I was using python -c, and then using each possible code string as the following argument. You don't have to update for languages, you simply run the interpreter executable with the code as an argument, then poll for output.

I don't think this is off-topic. It might be "unclear" though.

Here's a simplified Python example, from what I'm working on.

@tuskiomi I gave the algorithm as a hint.


text:
The most unreliable gun ever
You are given a very special gun with a full magazine.
Let n be the initial number of bullets in the magazine and i the number of bullets left.
That gun is really unreliable, hence each time you shoot, you have a i/n chance to successfully shoot. The fewer bullets you have left, the more tries it requires to shoot.
The goal is to find the average number of attempts to shoot before running out of ammo.
Example
You start with 3 bullets (n=3). Your first shot is always successful. You have now 2 bullets left. You will shoot first with a probability of 2/3 and misfire with 1/3. The probability of emptying your magazine in just 3 tries (no misfires) is (3/3) * (2/3) * (1/3).
The average number of tries before emptying your magazine for this example is 5.5.
Test Cases
f(2) = 3.000
f(3) = 5.500
f(4) = 8.330
f(10) ~= 29.290

Can you give a few more input/output examples? I suspect that this is a very simple equation.

Related

Now I'm picturing a revolver with a small motor attached to the cylinder to keep it spinning.

Aside from being a trivial variation on a question which was posted three days ago, this a) is underspecified, making no mention of the required precision; b) gives an incorrect test case: f(4) = 25/3 exactly, which under no circumstances rounds to 8.330.

05AB1E, 3 bytes
L/O

Try it online!
or as a Test suite
Explanation
L     # range [1 ... n]
 /    # divide n by each in above list
  O   # sum

Explanation is needed

@sagiksp: Explanation provided :)

This is pure magic, I'm moving to 05AB1E now, nothing can stop me.

Haskell, 22 21 bytes
f n=sum$(n/)<$>[1..n]

Try it online (TIO)!

Previous, more self-explanatory version:
f n=sum[n/i|i<-[1..n]]

Japt, 6 4+1= 5 bytes
Inspired by Emigna's 05AB1E solution.
+1 byte for the -x flag.
õ@/X

Try it online

Are flags worth 1 byte again?

No, @Oliver, this was posted before they cost 2 bytes (or before I knew they did, at least).

Oh, sorry. I should have looked at the date.

Ohm, 4 bytes
D@/Σ

Try it online!
Inspired by Emigna's answer

Aceto, 41 34 bytes
Based on Emigna's insight
Could almost definitely be golfed more.
  9jpX
 {:s_=1(
 &_L+&l@
iM!l
rLz@

Rough explanation
Part 1: Making a range and dividing by each of the numbers:
 {:s
 &_L
iM!l
rLz@

Part 2: Summing them up
    _=1(
    +&l@

Part 3: Printing, exiting, and making sure we don't visit this earlier
  9jpX

PHP, 37 Bytes
for(;$i++<$argn;)$s+=$argn/$i;echo$s;

Try it online!

JavaScript (ES6), 44 34 27 26 bytes
Also inspired by Emigna's 05AB1E solution.
f=(n,i=n)=>i&&n/i+f(n,--i)

(Look at me , going for recursion over array mapping for once!)

Try it

f=(n,i=n)=>i&&n/i+f(n,--i)
oninput=_=>o.innerText=f(+i.value)
o.innerText=f(i.value=1)
<input id=i type=number><pre id=o>

CJam, 11 bytes
rid_,:)f/:+

Try it online!
Inspired by Emigna's answer

jq, 30 characters
. as$n|[range(1;.+1)|$n/.]|add

Sample run:
bash-4.4$ jq '. as$n|[range(1;.+1)|$n/.]|add' <<< 10
29.289682539682538

Try in jq‣play

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
The Curious Case of Steve Ballmer
Steve Ballmer is the ex-CEO of Microsoft, and in a recent article, claimed that he "still does not know what he did wrong with mobile".
As CodeProject's newsletter pointed out, "That article's title could be ended at so many spots and still be accurate".
Given no input, output the following:
Steve Ballmer still does not know.
Steve Ballmer still does not know what he did.
Steve Ballmer still does not know what he did wrong.
Steve Ballmer still does not know what he did wrong with mobile.

This must be outputted exactly as shown, and must be the only output of your program. You may include a single trailing newline.
This is code-golf so fewest bytes in each language wins

When I saw the title / tags I thought that the output would be developers developers ...

tcl, 25 — while 1 {puts developers} — demo

braingolf, 23 - 1"developers "[!@11 1>] :P

And I thought of xkcd's Ballmer Peak

Can we output a multiline string containing that? i.e. the actual output of our program is "Steve Ballmer still does not know.\n...Steve Ballmer still does not know what he did wrong with mobile.\n"

I don't suppose you'd allow a leading space on each line?

@Riker sure you can

@Shaggy nope, no trailing whitespace

But what about leading, Mayube?! ;)

@Shaggy I was already going to say no, but now you get a triple no for that godaweful pun.

@Mayube Is there an optional trailing new-line, or is it required?

@wizzwizz4 optional

I'm surprised there's no MS powershell attempt.

yes, 14 — yes developers

pyth, 13 -- #"developers

actually you need p to print sans trailing newlines #p"developers so 14 bytes

@tfbninja it wasn't a codeproject article, just a general tech news article they sent out in their daily newsletter a few months back. They always add a witty little subtitle beneath the titles of all the articles in the newsletter, that's the source of the challenge

Python 3, 100 99 99 97 bytes
-1 byte thanks to ovs
-1 byte thanks to Jonathan Allan
-1 byte thanks to Dennis
for i in b'!-3?':print('Steve Ballmer still does not know what he did wrong with mobile'[:i]+'.')

Try it online!

05AB1E, 50 49 45 44 bytes
4 bytes saved with inspiration from Kevin's Java answer
„€Ž†©'–Ñ…€À€½ƒ§“mer„â‚à€–ƒ€“”™¸ïß”[Žì'.«=¨ð«

Try it online!
Explanation
„€Ž†©                                         # push "with mobile"
     '–Ñ                                      # push "wrong"
        …€À€½ƒ§                               # push "what he did"
               “mer„â‚à€–ƒ€“                  # push "mer still does not know"
                            ”™¸ïß”            # push "Steve Ball"
                                  [Ž          # loop until stack is empty
                                    ì         # prepend the top string to the 2nd top string
                                     '.«      # append a dot
                                        =     # print without popping
                                         ¨    # remove the dot
                                          ð«  # append a space

Oh nice, managed to use dictionary compression for everything but Ballmer?

@Mayube: Yeah. I got it partially now (ball) to save a byte by restructuring the original string :)

looks much better now, if only you could compress that mer

@Mayube: I could hide it by compressing me but unfortunately that wouldn't save any bytes :/

This is 97 bytes by my count.

@StigHemmer: It is 44 bytes in the 05AB1E code page

what about compressing mermaid and then subtracting maid?

Haskell, 96 bytes
(++".\n")=<<scanl(++)"Steve Ballmer still does not know"[" what he did"," wrong"," with mobile"]

Try it online!
scanl is like foldl (or reduce as it is called in other languages) except it returns a list of all intermediate results instead of just the final one. Each intermediate result is appended with ".\n" and all of them are concatenated into a single string.

Retina, 82 75 bytes
Thanks to Neil for saving 7 bytes.
Byte count assumes ISO 8859-1 encoding.

Steve Ballmer still does not know what he did wrong with mobile.
 w
.¶$`$&

Try it online!
Explanation

Steve Ballmer still does not know what he did wrong with mobile.

Initialise the working string to the full headline.
 w
.¶$`$&

As pointed out by Neil, all three truncations are made before a word starting with w, and there are no other words starting with w. So we match a space followed by a w to find the truncation points. At these points, we insert the following:

.¶, a period and a linefeed to truncate the sentence and begin a new one.
$`, the entire string in front of the match, so that the next sentence starts over from the beginning.
$&, the space and w again, so that they're also part of the next sentence.

We don't need to match the mobile explicitly, because that will simply be what's left over on the third match.

You only need to match on w and replace with .¶$`$&.

@Neil Oh, that's really neat, thank you. :)

///, 88 bytes
8 bytes saved by @MartinEnder!
/1/Steve Ballmer still does not know//2/1 what he did//3/2 wrong/1.
2.
3.
3 with mobile.

Try it online!

You can save a bit more by moving the previous prefix into each substitution: https://tio.run/##BcHBDcMgEATAP1VsBawAV5AWUgEWp4B8BsmHTPlkxjRbFdubgd8pr@CTVW95YLOpogwx9DFx9bHIyIBV80QVlFbIxIj1jP4jDyasNivucTYVBu@id8m7w@/9Bw

@MartinEnder That's particularly clever. Thanks!

Oh, and another 5 by dropping 4 altogether: https://tio.run/##DcLRDcMgDAXA/0zxJuAJskFX6ARUWAXVwVJslfFpT@davYvvzcxnyFfwqKqX3PAYqmgmjmmBz7RFFmasXgNd0EYjTxas2@abOR0lHec/1oiOy15DJe39Aw

@MartinEnder "Yes, I'll have a nr. 3 with mobile, please."

PHP, 104 95 94 bytes
<?=$a="Steve Ballmer still does not know",$a=".
$a what he did",$a.=" wrong",$a?> with mobile.

Missing "what"?

C (gcc), 112 bytes
f(){printf("%.33s.\n%1$.45s.\n%1$s.\n%1$s with mobile.","Steve Ballmer still does not know what he did wrong");}

Try it online!

Java 8, 127 126 bytes
()->{String t="Steve Ballmer still does not know",d=".\n";return t+d+(t+=" what he did")+d+(t+=" wrong")+d+t+" with mobile.";}

-1 byte thanks to @KonstantinCh.
Try it here.

Hope you don't mind that I stole your idea, it's much better than my looping approach.

@TheLethalCoder No problem at all, since I see you've credited me. :) Btw, string can't be var in your C# lambda?

No because I'm declaring multiple at once.

@TheLethalCoder Ah of course, my bad.. And ()=>{var t="Steve Ballmer still does not know";return t+".\n"+(t+=" what he did")+".\n"+(t+=" wrong")+".\n"+t+" with mobile"+".";}; is unfortunately three bytes longer.

True but see my new version, you can probably make use of it too to save some bytes.

Can you use verbatim strings like @Shaggy's answer to save bytes?

@TheLethalCoder Nope, verbatism-Strings aren't not possible in Java without String.format. As for your previous comment, I could do (124 bytes): ()->m.c(33)+m.c(45)+m.c(51)+m.c(63)n->"Steve Ballmer still does not know what he did wrong with mobile".substring(0,n)+".\n" (where m is the anonymous function's interface), but if I'm not mistaken I've read in Meta that you aren't allowed to have > 1 anonymous function. So it would be ()->c(33)+c(45)+c(51)+c(63)String c(int n){"Steve Ballmer still does not know what he did wrong with mobile".substring(0,n)+".\n";} instead, which is 131 bytes.

Have you got a link to that meta post? I've used multiple anonymous methods in answers a few times.

Let us continue this discussion in chat.

Konstantin Ch suggests changing the "+d at the end to ." to save a byte as the final linefeed is optional.

05AB1E, 46 bytes
”™¸ïßme”“r„â‚à€–ƒ€“«…€À€½ƒ§'–Ñ„€Ž†©).pvyðý'.«»

Try it online!

This is 98 bytes by my count.

@StigHemmer 05AB1E uses its own code-page with 256 bytes, which encodes each character to a single byte. Hence the 46 bytes, even though it's a lot more bytes in basic UTF-8 encoding.

Jelly, 52 46 bytes
“ṬċḌ)⁹œḃṣ⁷Ṅḋ%W3Œƭ;ḷẓ“£Ṿ⁴'Þḣ~ẉ“¥Ị)“Ṡ8gÐ/»;\p”.Y

Credits for ṬċḌ)⁹œḃṣ⁷Ṅḋ%W3Œƭ;ḷẓ go to @EriktheOutgolfer, who used it in his answer.
Try it online!
How it works
The lion share of the work is done by Jelly's dictionary compression here.
ṬċḌ)⁹œḃṣ⁷Ṅḋ%W3Œƭ;ḷẓ

encodes
Steve| Ball|mer| still| do|es| no|t| know

there | indicates boundaries between words that where fetched from the dictionary and strings that were encoded character by character (mer, es, and t).
Similarly, £Ṿ⁴'Þḣ~ẉ encodes  what| he| did (surprisingly, he does not come from the dictionary), ¥Ị) encodes  wrong, and Ṡ8gÐ/ encodes  with| mobile.
“ṬċḌ)⁹œḃṣ⁷Ṅḋ%W3Œƭ;ḷẓ“£Ṿ⁴'Þḣ~ẉ“¥Ị)“Ṡ8gÐ/»

thus yields the string array
“Steve Ballmer still does not know“ what he did“ wrong“ with mobile”

;\ cumulatively reduces by concatenation, building the phrases on each line.
Finally, p”. computes the Cartesian product of these phrases and the dot character, and Y separates the resulting sentences by linefeeds.

By my count this is 97 bytes.

@StigHemmer In UTF-8, it would be. However, Jelly also supports this single-byte character set.

JavaScript (ES6), 102 bytes
_=>(s="Steve Ballmer still does not know")+`.
${s+=" what he did"}.
${s+=" wrong"}.
${s} with mobile.`

Try it

o.innerText=(
_=>(s="Steve Ballmer still does not know")+`.
${s+=" what he did"}.
${s+=" wrong"}.
${s} with mobile.`
)()
<pre id=o>

Nice approach I have "borrowed" it for my C# answer.

Maybe I don't understand the rules of the game, but this function only works correctly if you're in a browser and using the pre tag innertext like you did. So isn't that more than 102 bytes, since it depends on the o.innerText= and the  and actually getting ahold of the element?

@Paul I know this is old but, an anonymous function is acceptable form of I/O as an entry, so as long as it returns the expected data, it doesn't need to display it directly.

Retina, 95 86 bytes
:`
Steve Ballmer still does not know.
:`.$
 what he did.
:`.$
 wrong.
.$
 with mobile.

Try it online! Edit: Saved 9 bytes by switching from outputting parts of the whole string to building up the string in pieces. The :` is needed on the first three stages to make them output.

ooh that's clever, deleting everything between the w and e, then deleting everything between the wr and e, then wi and e. Not super golfy due to Retina's newline-iness, but definitely cool nontheless

@Mayube Turned out to be not very golfy at all, so I've switched methods. (Still not as cool as Martin Ender's answer though.)

Ugh, this is still worse than @Leo's Retina Kolmogorov golfer, which finds an 82-byte answer.

C (gcc), 124 122 bytes
#define A"Steve Ballmer still does not know"
#define B".\n"A" what he did"
f(){puts(A B B" wrong"B" wrong with mobile.");}

Try it online!

You can remove the spaces between A and B, and the strings that define them.

C#, 158 128 120 114 bytes
()=>{var s="Steve Ballmer still does not know";return s+$@".
{s+=" what he did"}.
{s+=" wrong"}.
 with mobile.";};

Saved 30 bytes thanks to @KevinCruijssen.
Saved 6 bytes thanks to @Shaggy.

Version using sub-stringing for 120 bytes:
s=n=>"Steve Ballmer still does not know what he did wrong with mobile".Substring(0,n)+".\n";()=>s(33)+s(45)+s(51)+s(63);

Version borrowed from @KevinCruijssen for 128 bytes:
()=>{string t="Steve Ballmer still does not know",d=".\n";return t+d+(t+=" what he did")+d+(t+=" wrong")+d+t+" with mobile"+d;};

Version using looping for 158 bytes:
()=>{var r="";for(int i=0;++i<5;)r+=$"Steve Ballmer still does not know{(i>1?$" what he did{(i>2?$" wrong{(i>3?" with mobile":"")}":"")}":"")}.\n";return r;};

Simple approach using ternary statements to in a loop to append the new parts onto the string each time.

As an aside, it's worth noting that this only works for C# >= 6 as earlier versions don't have interpolated strings

@Mayube True, but I'm golfing this to use Kevin's approach at the moment as that is a lot better than mine haha

Gotta golf 2 more bytes so you can beat the java answer D:

@Mayube The Java answers usually beat C# because they don't include a trailing semi-colon. Is always annoying!

@Mayube Done it, for the time being at least...

@TheLethalCoder Nice approach +1. I don't think I can outgolf this in Java, because you can do ()=> as inner method, and I have to define the entire lambda as well which raises the byte-count by a lot.

@KevinCruijssen Well I'm compiling to two separate anonymous functions where one just calls the other, I'd assume you could use that idea too.

CJam, 79 bytes
4{)"Steve Ballmer still does not know
hat he did
rong
ith mobile"N/<" w"*'.+N}%

Try it online!

wow, interesting pattern find

Ruby, 94 bytes
"!-3Z".bytes{|i|puts"Steve Ballmer still does not know what he did wrong with mobile"[0,i]+?.}

Iterates through the 4 characters in the first string, converting each to its ascii value n and outputting the first n characters of the second string each time. It really does not matter what the last character of the first string is, so long as its ascii value is equal or greater than the length of the second string.

Bash, 111 109 107 bytes
a=(Steve Ballmer still does not know "what he did" wrong with\ mobile)
for i in {6..9};{ echo ${a[@]::i}.;}

Try it online!

Japt, 70 68 65 61 60 59 bytes
Contains a few characters that won't display here; follow the link below to see the full code.
`Sve Ba¥´r Ð]l º not know
 Ø  ¹d
 Ùg
 ØP ¶ßè`£'.iP±X}R

Try it online

3 4 bytes saved thanks to ETH, plus another 4 with some prompting.

Explanation
Everything between the 2 backticks is a compressed string of the following:
Steve Ballmer still does not know
 what he did
 wrong
 with mobile

`...`             :Decompress the string.
     £       }R   :Map over the each line X in the string
         P±X      :   Append X to P (initially the empty string)
      '.i         :   Prepend that to the string "."

Nice. You can save some bytes by doing [`Sve Ba¥´r Ð]l º not know`` Ø  ¹d`` Ùg`` ØP ¶ßè.`]m@P+=X}, then a couple more bytes that involves removing the [ and ] (I'll let you figure that one out).

Nice one, @ETHproductions. Took me a couple of minutes to decipher that between the compression and characters SE doesn't display but I got there and now I think I see the other saving you're hinting at too.

You may be better off if you remove the splitting and joining, and instead do £P±X +'.}R at the end

@ETHproductions, it still comes in at 61 bytes, but it's definitely neater; gets rid of the need for the trailing newline. EDIT: Oh, wait, no, I can save 1 byte with that approach :)

Fission, 299 291 269 bytes
MN"."                             ]              ]        ]
                                  W$]            W$$]     W$$$]
R"Steve Ballmer still does not know"%[" what he did"%[" wrong"%[" with mobile.";
                                    [W              [W        [W

Try it online!
Finally a 2D language I understand!
Explanation
Program spawns an atom with 1 mass and 0 energy (a 1:0 atom)at the R on line 3, and begins moving to the right.
"Steve Ballmer still does not know" prints each character.
% moves the atom up if it has 0 energy, or decrements it's energy and moves it down.
] moves the atom to the left, $ increments the atom's energy, W moves the atom up.
Once the atom is on the top row, it moves to the left, until it reaches ".", which prints a period, N, which prints a newline, and finally M, which moves the atom down to the R again, which subsequently moves the atom to the right.
Each loop the atom's energy is one higher, meaning it will pass through one more %. After the 4th loop it reaches the ; at the end of the third line, which destroys the atom. The program terminates once all atoms are destroyed.

Could you add an explanation?

@Shaggy will do

You can compress the top a lot more: 209 bytes.

Vim, 79 keystrokes
iSteve Ballmer still does not know.<CR><C-x><C-l><Backspace> what he did.<CR><C-x><C-l><Backspace> wrong.<CR><C-x><C-l><Left> with mobile

<C-x><C-l> auto-completes with the previous line. Alternatively you can replace every occurrence of <CR><C-x><C-l> with <Esc>o<C-a>

Nim, 100 bytes
for i in " ,2>":echo "Steve Ballmer still does not know what he did wrong with mobile"[0..i.int],"."

here the same in more readable code:
const str = "Steve Ballmer still does not know what he did wrong with mobile"

for i in [32, 44, 50, 62]:
  echo(str[0..i], ".")

The language has string slicing and inclusive upper bounds. The rest should explain itself if you know programming.

99 bytes: for i in " ,2>":"Steve Ballmer still does not know what he did wrong with mobile"[0..i.int].echo"."

Bash, 92 91 bytes
printf 'Steve Ballmer still does not %s.
' know{,' what he did'{,\ wrong{,\ with\ mobile}}}

Try it online!

PHP, 116 Bytes
for(;$i<4;)echo"Steve Ballmer still does not know",["",$t=" what he did",$t.=" wrong","$t with mobile"][+$i++],".

";
Try it online!

SOGL, 42 bytes
⁹⁴<>‘υG‘Γω/w¹‘O‛Æw▓½0H(æ█◄K∆2Ξgh‘4{Tļ.@+;+

Explanation:
..‘                    push "with mobile"
   ..‘                 push "wrong"
      ..‘              push "what he did"
         ..‘           push "Steve Ballmer still does not know"
            4{         4 times do
              T          output, not popping the top of stack
               ļ.        output "."
                 @+      append a space to the top thing in stack
                   ;+    reverse add (adding the next part to the top thing in stack)

How do you use SOGL? I have installed Processing and all of the versions, although I can't figure out how you would run it.

open up the "P5Parser" with no version labels, and in it's folder in data/p.sogl paste the code. Then running the processing code should run it and the output should be in the console

Tried to run your code, but it doesn't have any output... ./processing-java --sketch=../SOGL/P5Parser --run p.sogl ""

It works for me. Try giving it the full path instead of p.sogl. if there's nothing in STDOUT or P5Parser/output.txt, I don't know.

This is the output for me, separated into STDOUT and STDERR.

Content of file /home/erik/Desktop.bak/Desktop/SOGL/P5Parser/data/p.sogl is ⁹⁴<>‘υG‘Γω/w¹‘O‛Æw▓½0H(æ█◄K∆2Ξgh‘4{Tļ.@+;+. /home/erik/Desktop is symlink to /home/erik/Desktop.bak/Desktop. Oh and preprocessor actually contains the code, output is different from that of an empty file.

Let us continue this discussion in chat.

What encoding do you save the file in? I did store it in UTF8 and it is 73 Bytes. Therefore I have to count your claim to have only 73 bytes as wrong.

@Arne You'd have to save it in SOGLs encoding. With it there is a 1-to-1 from a byte to a character. Trough right now there isn't a converter

Jelly, 49 bytes
“ṬċḌ)⁹œḃṣ⁷Ṅḋ%W3Œƭ;ḷẓ“¡=~Ṃ©N|ȯ“¡ṭṂ“CṬṀWỌ»ḣJK;¥€”.Y

Try it online!

Go, 140 127 bytes
import."fmt"
func f(){for _,i:=range"!-3?"{Println("Steve Ballmer still does not know what he did wrong with mobile"[:i]+".")}}

Try it online!

Sed, 96
s/^/Steve Ballmer still does not know./p
s/\./ what he did./p
s/\./ wrong./p
s/\./ with mobile./

Try it online.
Implicit newline input given, as per this meta-question.

You can get 92 bytes by removing the second two \.s

JavaScript (ES6, no browser dependencies) 154 Bytes
(s='Steve Ballmer still does not know what he did wrong with mobile.')=>{
  let l=s.slice.bind(s)
  return `${l(0,33).\n${l(0,45)}.\n${l(0,51)}.\n${s}`
}

The other ES6 solution requires (and doesn't account for) the use of html and html element APIs.

C (gcc), 113 112 bytes
-1 bytes thanks to ceilingcat.
f(c){for(c=0;write(1,"Steve Ballmer still does not know what he did wrong with mobile","!-3?"[c++]);puts("."));}

Try it online!

APL (Dyalog Unicode), 81 bytesSBCS
↑1⌽¨,\'.Steve Ballmer still does not know' ' what he did' ' wrong' ' with mobile'

Try it online!
One the very right, we have a list of strings.
,\ cumulative concatenation
1⌽¨ cyclically rotate each one step left (puts the periods at the ends)
↑ mix the list of strings into a character matrix

MATLAB / Octave - 120 bytes
a=[];s={'Steve Ballmer still does not know',' what he did',' wrong',' with mobile'};for i=s,a=[a i{1}];disp([a '.']);end

Logic is to start off with an empty string, then we have a cell array that contains the base string as the first element followed by the additions for the other elements.  Note that each additional component has a space prepended.  We then iterate through the cell array, and at each iteration we concatenate with a component and display the string to the user adding a period at the end.
We get:
>> a=[];s={'Steve Ballmer still does not know',' what he did',' wrong',' with mobile'};for i=s,a=[a i{1}];disp([a '.']);end
Steve Ballmer still does not know.
Steve Ballmer still does not know what he did.
Steve Ballmer still does not know what he did wrong.
Steve Ballmer still does not know what he did wrong with mobile.

Try it online!
http://www.tutorialspoint.com/execute_octave_online.php?PID=0Bw_CjBb95KQMRGZoWFJ1Z3NaNTQ

Perl 6, 90 bytes
"$_.".say for [\,] 'Steve Ballmer still does not know','what he did','wrong','with mobile'

Charcoal, 71 69 bytes
Ａ⟦⟧βＦ⪪”↓/‘ZQ≔'Ｗε}÷＆’/↗∧μ~⎇²~ηρπ‖¢β\`σuσＩ⌀δ#″:§▶¬QγγＱＺ–” w⁺⪫⊞Ｏβι w¦.¶

Try it online! Link is to verbose version of code, with some separators omitted because deverbosifier can't do it automatically. This is basically a port of @KevinCruijssen's answer.

Mathematica, 108 104 bytes
"Steve Ballmer still does not know what he did wrong with mobile"~StringTake~#~Print~"."&/@{33,45,51,63}

Try it online!
-4 bytes from Martin

><>, 135 bytes
".wonk ton seod llits remllaB evetS"\
l?!\o99+2*1./"h tahw  "32p10pao     \
52p\".did e"/"   "53p33p
  /\".gnorw"/
1p/\".elibom htiw;"3

This basically goes through the string, prints then replaces the fullstop and conditionals with spaces to keep moving along the code.
It may be best to visualise it using the below ><> pond link;
><> pond!
Try it online!

It never occurred to me that know spelled backwards is wonk.

@DigitalTrauma Well, now you wonk

Powershell, 101 bytes
0..3|%{-join("Steve Ballmer still does not know"," what he did"," wrong"," with mobile")[0..$_]+"."}

99 bytes, 5 years later :)

I meant 97, but I missed the edit window

><>, 126 bytes
 \"elibom htiw \"10p";"15p
  "gnorw  "10p
  "did eh tahw \"11p
 \"wonk ton seod llits remllaB evetS\"12p04.
  l?!vo
oo00.>a"."

Octave, 126 bytes
Two approaches, same length:
printf('%s.\n',(s={'Steve Ballmer still does not know',' what he did',' wrong',' with mobile'}){1},[s{1:2}],[s{1:3}],[s{1:4}])

Try it online!
s={'Steve Ballmer still does not know',' what he did',' wrong',' with mobile'};printf('%s.\n',s{1},[s{1:2}],[s{1:3}],[s{1:4}])

Try it online!
I could make it 21 bytes shorter, if I steal Rod's approach, but that's no fun.
for i=[33,45,51,63],disp(['Steve Ballmer still does not know what he did wrong with mobile'(1:i),46]),end

Perl, 98 bytes
for('Steve Ballmer still does not know',' what he did',' wrong',' with mobile'){$s.=$_;say "$s."}

(Run via perl -M5.10.1 ... so that "say" will be recognized)

According to J B's tip, you can rewrite it as say$s.="$_."for'Steve Ballmer ….

You can shrink to 89 bytes with this, but can't think of much more to do to shrink it!

Down to 85! Try it online!

Retina, 82 bytes

ABCC with mobile.
C
B wrong
B
.¶A what he did
A
Steve Ballmer still does not know

Try it online!

Rust, 145 bytes
||{for i in b"!-3?"{println!("{}.",&"Steve Ballmer still does not know what he did wrong with mobile".to_owned().get(..*i as usize).unwrap());}};

Inspired by this solution.
Try it online!

Julia 0.6, 99 bytes
Generate the 4 desired strings with cumprod (* is string concatenation). Tack on a period with a broadcasted string concatenation .* and print all elements in the list with a broadcasted call println..

println.(cumprod(["Steve Balmer still does not know"," what he did"," wrong"," with mobile"]).*".")

Try it online!

Unix TMG, 145 bytes
p:parse(b)b:=(1){<Steve Ballmer still does not know>$1<.>*}=(1){1({< what he did>$1})}=(1){1({< wrong>$1})}={3({})2({})1({})1({< with mobile>})};

With some white spaces:
p:parse(b)
b:=(1){<Steve Ballmer still does not know>$1<.>*}
  =(1){1({< what he did>$1})}
  =(1){1({< wrong>$1})}
  ={3({}) 2({}) 1({}) 1({< with mobile>})};

05AB1E, 43 bytes
”™¸ïßmer”“„â‚à€–ƒ€“…€À€½ƒ§'–Ñ„€Ž†©)η¦ðý'.«»

Try it online!

Deadfish~, 1507 bytes
{{i}dd}iiic{iii}iiic{d}dddddc{ii}dddc{dd}iiic{{d}iii}ic{iii}iiiic{iii}ic{i}iccic{d}iic{i}iiic{{d}ii}ddc{{i}dd}iiicic{d}dciiicc{{d}iii}ddddddc{{i}ddd}ddc{i}ic{d}c{i}iiiic{{d}ii}dddc{{i}dd}ddciciiiiic{{d}ii}ddddc{{i}ddd}iiiiiciiicic{i}ddc{{d}iii}dddc{ddd}ddddddc{{i}ddd}iiic{iii}iiic{d}dddddc{ii}dddc{dd}iiic{{d}iii}ic{iii}iiiic{iii}ic{i}iccic{d}iic{i}iiic{{d}ii}ddc{{i}dd}iiicic{d}dciiicc{{d}iii}ddddddc{{i}ddd}ddc{i}ic{d}c{i}iiiic{{d}ii}dddc{{i}dd}ddciciiiiic{{d}ii}ddddc{{i}ddd}iiiiiciiicic{i}ddc{{d}i}iiic{{i}d}dddc{d}dddddc{d}iiic{ii}dc{{d}ii}ddddc{{i}ddd}iicdddc{{d}iii}ic{{i}ddd}ddciiiiicdddddc{ddddd}ddddc{ddd}ddddddc{{i}ddd}iiic{iii}iiic{d}dddddc{ii}dddc{dd}iiic{{d}iii}ic{iii}iiiic{iii}ic{i}iccic{d}iic{i}iiic{{d}ii}ddc{{i}dd}iiicic{d}dciiicc{{d}iii}ddddddc{{i}ddd}ddc{i}ic{d}c{i}iiiic{{d}ii}dddc{{i}dd}ddciciiiiic{{d}ii}ddddc{{i}ddd}iiiiiciiicic{i}ddc{{d}i}iiic{{i}d}dddc{d}dddddc{d}iiic{ii}dc{{d}ii}ddddc{{i}ddd}iicdddc{{d}iii}ic{{i}ddd}ddciiiiicdddddc{{d}iii}iic{{i}d}dddcdddddcdddcdc{d}iiic{dddddd}iiic{ddd}ddddddc{{i}ddd}iiic{iii}iiic{d}dddddc{ii}dddc{dd}iiic{{d}iii}ic{iii}iiiic{iii}ic{i}iccic{d}iic{i}iiic{{d}ii}ddc{{i}dd}iiicic{d}dciiicc{{d}iii}ddddddc{{i}ddd}ddc{i}ic{d}c{i}iiiic{{d}ii}dddc{{i}dd}ddciciiiiic{{d}ii}ddddc{{i}ddd}iiiiiciiicic{i}ddc{{d}i}iiic{{i}d}dddc{d}dddddc{d}iiic{ii}dc{{d}ii}ddddc{{i}ddd}iicdddc{{d}iii}ic{{i}ddd}ddciiiiicdddddc{{d}iii}iic{{i}d}dddcdddddcdddcdc{d}iiic{{d}iii}dc{{i}d}dddc{d}ddddc{i}ic{d}ddc{{d}iii}ddc{{i}dd}dddciic{d}dddc{i}dddciiic{d}iiic{ddddd}dddddc

Try it online!

Stax, 38 37 bytes
¥úσÆ}≡ër↑←â .M)↨\7╒°1╕J°Y¥₧iC+F.ifd┼$

Run and debug it

should be 37 removing the swap s

Quite right.  Thanks.

MSX-BASIC, 123 bytes
1s$="Steve Ballmer still does not know what he did wrong with mobile":forx=1to4:readl:?left$(s$,l);".":next:data33,45,51,64

Braingolf, 139 108 bytes
"Steve Ballmer still does not know
."VRMM!&@v!&@R" what he did"!&@v!&@R" wrong"!&@v!&@R " with mobile"&@v&@R

QBIC, 95 bytes
?@Steve Ballmer still does not know`+@.`?A+@ what he did`+B?A+C+@ wrong`+B?A+C+D+@ with mobile.

This makes every part of the output into a separate string literal, where 'A$' holds Steve Ballmer still does not know, and then repeatedly prints 'A$', followed by 'B$' (a period) or the next literal.
Chopping the original string into substrings takes just a byte more (96 bytes):
?B,34|+@.`?_sB,46|+A?_sB,52|+A?@Steve Ballmer still does not know what he did wrong with mobile.

Here, 'B$' holds the entire thing, and parts of it are subsequently shown using substring ('_s...|`). Note that 'A$' now holds the period. This allows the full sentence to be moved to the end of the program, so we can drop the closing backtick.

Tcl, 115 bytes
puts [set S "Steve Ballmer still does not know"].\n[set h "$S what he did"].\n[set w $h\ wrong].\n$w\ with\ mobile.

Try it online!

REXX, 123 bytes
s='Steve Ballmer still does not know what he did wrong with mobile'
w=6 9 10 12
do i=1 to 4
say subword(s,1,word(w,i)).
end

Clojure(script), 122 bytes
(print(apply str(interpose"\n"(reductions str"Steve Ballmer still does not know"[" what he did"" wrong"" with mobile"]))))

Pyth - 98
K." w!ZÑ`±§ÑÔæý^àV;KæM×ü1A_4ÿ"J" what he did"A," wrong"" with mobile"=N\.+KN++KJNs[KJGN)s[KJGHN

The first string is a packed string

Fission 2, 109 107 bytes
R"Steve Ballmer still does not know"J2~~$$" what he did"J1~$" wrong"J0" with mobile."*
/0C+$$J1C+$$J2C@"."N

Try it online!
I was a little annoyed at the amount of whitespace in the previous Fission answer, so I decided to see if I could make it smaller.

GolfScript, 82 bytes
4,{"Steve Ballmer still does not know
 what he did
 wrong
 with mobile"n/\)<"."n}/

This can be considered "19 bytes" since that's the actual code.
4,{"nnn"s/\)<"."n}/ are all the excess characters that actually make the code itself.
Try it online!
Very happy with this. Splits along newlines, then adds the next element one at a time with a period until everything is printed. Lovely.
Explanation!
First of all, we have to acknowledge the string.
It's split along newlines right where we want the breaks to be.
This will be important.

For the explanation, our string is S.

4,{Sn/\)<"."n}/
4,              #Make an array [0 1 2 3]
  {          }/ #For each of those elements...
   Sn/          #Take our string and split it along newlines
      \         #Move our number-element to the front of the stack
       )        #Increase it by 1
        <       #Look at a number of parts of the split string eq. to that num
         "."    #Put a period after
            n   #Newline
                #Implicit "print the stack" at the end of creation. No quotes.

Python 3, 97 bytes
["Steve Ballmer still does not know what he did wrong with mobile"[:i]+"."for i in [33,45,51,63]]

Try it online!

Vyxal oj, 124 58 50 bytes
`æ⁽ æ∴Ǐ₇ ⟑∵ ƛ∪ λ† ¬λ λ⟨ he ¬ṙ ↔Ẏ λ» ∨⁺`»→⇩d»₆τẎ\.+

Try it Online!

50 bytes: Try it Online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
T minus time to ransom!
The WannaCrypt ransomware has struck and it is attacking networks right, left and center. A network is defined by an m*n binary matrix (a),  which has a a[i][j] = 1 if a computer is infected and a[i][j] = 0 if it is not. At the end of each hour, all computers that are a neighbour (which shares a side or a corner with) of an infected computer are infected by the ransomware..
Your job is to calculate the time after which all computers in the network will be infected by the virus.
Also, do keep in mind that the shortest code wins.
Input
The first 2 lines contains the values of m and n respectively.
The next m lines contain a binary string of length n corresponding to the computers of the network.
Output
An integer which is equal to the mumber of hours after which the whole network will be infected by the ransomware.
Input Constraints
1 <= m,n <= 1000
Sample Test Cases
Test Case 1
Sample Input
2
2
11
11

Sample Output
0

Test Case 2
Sample Input
3
4
0101
0001
0001

Sample Output
2

Test Case 3
Sample Input
2
2
10
00

Sample Output
1

P.S: Take input in any format that doesn't violate the ordering of [m,n,matrix]
P.P.S: m and n are optional inputs. The only compulsory input is the matrix.

Can we take it as an array instead? i.e. [2, 2, "11", "11"] for JavaScript. People don't like having to spend bytes parsing input, usually

yes. that works.

Can we take the matrix as a matrix, instead of row by row?

I've incorporated an additional condition. As long as it doesn't affect the variables, m,n and matrix can be taken in any reasonable format.

Do we have to take the dimensions? Most languages will be able to handle input without that information, and not using it might be even shorter.. Also, do sides/corners wrap around?

It makes it computationally easier if the dimensions are there. But do you think the challenge will be better if that part is removed?

The challenge would be better with that part optional.

@Rod the sandpile problem is a state calculation problem. Plus, there the origin point can change and at every second may affect multiple points which may not even be its neighbour. This is a time calculation problem, plus once a ripple has passed through it's neighbours, that state is fixed and cannot be changed. I don't see how they are related. Could you please explain?

So this is a maximum filter (with a 3x3 kernel) iteration counter?

@KoishoreRoy fair enough

@GáborFekete It's more like a longest path calculator. If you want to approach the problem from a different perspective i.e.

Octave, 26 bytes
@(a)max(bwdist(a,"ch")(:))

Try it online!
Explanation:
Computes maximum of the chessboard distance transform of the binary matrix.

Python 2, 90 bytes
g=lambda a:min(min(a))or-~g(map(lambda*c:map(max,(0,)+c[:-1],c,c[1:]),*a))
lambda a:g(a)/2

Try it online!
Accepts a matrix as a list of lists of 0 and 1.
How it works
g=lambda a:min(min(a))or…

If the smallest element of the matrix is 1 (it is completely infected), return 1; otherwise…
                        -~g(…                                            )

return 1 plus the recursive result on the following modified matrix…
                            map(lambda*c:…                           ,*a)

for each old column c…
                                         map(max,(0,)+c[:-1],c,c[1:])

produce a new row by zipping max over the down-shifted, original, and up-shifted versions of c.  (map fills in the gap at the end of c[1:] with None, which is falsy and smaller than both 0 and 1.)
Each iteration of g computes all vertical infections, then transposes the matrix.  This way, every 2 iterations of g compute all horizontal, vertical, and diagonal infections.
lambda a:g(a)/2

Because the base case of g with a fully infected matrix gave 1 rather than 0, the parity works out such that floored division by 2 always gives the correct result.

R, 127 bytes
function(x,y,m){a=which(m);b=cbind(a%/%x+1,(a-1)%%x+1);for(i in 1:x)for(j in 1:y)m[i,j]=min(apply(abs(b-c(i,j)),1,max));max(m)}

For each clean computer (0), checks what the closest infected computer is. Outputs the maximum value, because that is how long it would take for the infection to reach it.
It is a function that takes the number of rows x, the number of columns y and the matrix m as input. More explanation follows when I get home.
function(x,y,m){                     A function taking 3 arguments
  a=which(m)                         Take the indices of matrix m containing 1 (TRUE). This
                                     implicitly turns m into a vector, so a contains all
                                     the wrapped indices.
  b=cbind(a%/%x+1,(a-1)%%x+1)        Turn a back into i and j indices for 1s in m.
  for(i in 1:x)                      Loop over all rows
    for(j in 1:y)                    Loop over all columns
      m[i,j]=                        Assign in m[i,j] the following:
      min(                           Take the lowest value of the vector created below v
      apply(abs(b-c(i,j)),1,max));   Take the absolute difference between (i,j) and all
                                     (x,y) where m[x,y] == 1. Take the rowwise maximum
                                     to find the distance between (i,j) and all the 1s in m
  max(m)}                            Return the maximum distance.

Python 2, 181 bytes
import numpy as n,scipy.ndimage.filters as s
g=lambda m=n.asarray(list(map(int,list(i))for i in input().split())),i=0:g(s.maximum_filter(m,3),i+1)if n.count_nonzero(m)<m.size else i

Recursively calls itself until each element is 1 and returns the iteration count. Accepts input as a string: "0101\n0001\n0001"


text:
Minecraft Pumpkin / Melon overload
DONT EVALUATE YET, ALMOST FINISHED, NEED A CLEAR WINNING CRITERION
Make me rich in minecraft
Minecraft is a 3D game made of blocks that you can destroy and place. There are some interesting farms you can build to provide you with game resources. In this problem, we will only have a look at pumpkin and melons farms. Here's a melon stem on the right that produced a melon block on the left.

When the melon block grows, you can break it and the stem will produce another one later. Pumpkins farms have exactly the same behavior.
On some servers there's an economy going on where you can sell your items such as melons and pumpkins. The motivation behind this problem is to get rich selling pumpkins and melons.

Types of blocks
Since we're only gonna farm melons and pumpkins, we are not gonna take a look at the couple hundreds of blocks in the game. We will just focus on:

Dirt : Basic block, does not impact growth rate but provides a place when pumpkins/melons can grow
Farmland: Tiled dirt where you can plant stems
Hydrated farmland: Basically farmland but with water nearby. See irrigation section just below.
Stem: Money making magic plant.
Melon or pumpkin: Things your stems grow and you sell. They will appear around the stem.

Irrigation
Water can irragate farmland to hydrated farmlands if it's close enough. The water irrigates all blocks in a 9x9 grid centered on the source.

Note that the water will irrigate that grid no matter what is composing it. If there is a wall all around the water, it will still irrigate a 9x9 grid.

Stem behavior
A stem can only grow a fruit above dirt or farmland if the space is innocupied. To grow a fruit, the stem follows a complex game mechanic. Hang out for the next part, it's getting complicated.
Game mechanic
Each second, 400 blocks are choosen at random in a 16x16x128 area, they will receive an update. When a fully grown stem is choosen, it will have a chance to grow a fruit.
In the first time, the game select at random a block next to the stem (on his 4 sides, diagonals excluded). If the block choosen is dirt or farmland AND there is nothing above, it will then try to grow a fruit on this block. (Please note that if a fruit grows on a farmland, it turns it into dirt.)
The chance of a fruit growing depends on the score s of the stem. The score is calculated as following:

If the stem is planted in an hydrated farmland, the initial value of s is 4. If it is not hydrated, it is 2.
For each farmland in a 3x3 grid centered on the stem, the score gains 0.75. This also applies if the farmland has a stem growing in. If it's not hydrated farmland, the score gains 0.25.

The chance of trying to grow a fruit is then 1/(floor(25/s)+1)
Overfarming penalties:
Stems don't like having neighboors. If there is another stem, of the same type only, in the 3x3 grid around it, the score s is halved. There is only one exception, if the stems are in a row, it's not halved. Note that if there are 8 stems around, the score is only halved once. Here's a pic to illustrate that rule, green stems have normal growth, orange ones are halved.

An example to determine the income from a given layout

For this case, the stem is planted in an hydrated farmland (consider a water source nearby not represented). It is surrounded by 4 hydrated farmlands. The four others blocks are just dirt. There are 3 dirt blocks available for the fruit to grow on (the 3 on its sides), so the stem has a 3/4 chance to choose a valid spot.
The stem is planted on an hydrated farmland so the score is 4. There are 4 others farmlands in a 3x3 grid around the stem so the total score is s = 4 + 0.75*4 = 7. The chance to succeed the attempt is P = 1/(floor(25/s)+1) = 1/4.
So the chance for the fruit to grow is then 3/4 * 1/4 = 3/16
Now let's calculate the average number of fruit per hour this single stem can provide. Each second the stem has a 400 /(16x16x128) chance of being choosen. So in an hour, the block is choosen 3600x400 /(16x16x128) = 43.945 times on average. Each time it is choosen, the plant grows with a probability of 3/16. In an hour, the stem will then provide 43.945x3/16 = 8.24 fruits on average.

Rules
Money making
Each melon that grows is sold 5$.
For the minecraft fans out there, a melon block drops on average 5 melon slices each one worth 1$.
Each pumpkin that grow is sold 8$.
Specifications

Stems can produce an infinite amount of fruits without ever breaking.
The fruit is always produced next to the stem (sides, not diagonals) on a dirt block.
The fruit is harvested instantly. Usually when the block grow, you are supposed to break it before the stem can produce another one. Here we will consider that all the fruits are harvested whenever they grow.
Since fruit production is random, we will only work with the average production.
Stems grow on farmland only but no fruit can grow above farmland (with ou without stem), since after a fruit grows it will turn farmland into dirt! Dirt is then the only valid spot for a fruit to grow on.
If a stem has another stem in a 3x3 grid, it is counted as a farmland for the score calculation. If the stem is not of the same type (like one melon and one pumpkin stem), there is no score penalties.
All stems are already in their final stage. In the game, to have a stem you need to plant a seed that will grow to its final stage and that will then stay this way and start producing fruits. We assume that when seeds are planted, they are already fully grown stems.
Water irrigates a 9x9 grid no matter what's around. So water can irrigate farms through walls.

Goal
In a given space, you need to design the best layout to produce the maximum amount of money per hour.
Input
You are given a grid containing 0 and # that represent the space allowed for your layout. # for occupied blocks where you can't place anything, 0 for the spot where you can place dirt/farmland/stem.
Output
Your program should return the maximum amount of money per hour you can make with this space allowed, and the layout that yields this result. The layout is composed of numbers that follow this code:

0: Dirt block
1: Farmland (blocked, no fruit can grow on it)
2: Pumpkin stem
3: Melon stem
9: Water source

Test cases
Input
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Outputs
325.927734375
2 0 2 0
0 3 0 3
2 0 2 0
0 3 0 9

Here 0 means dirt, 1 blocked farmland, 2 pumpkin stem, 3 melon stem, 9 water.

Winning criterion
Your are given txt files that corresponds to inputs. There are labelled Level-3 to Level-20, where the number represent the size of the input. The level 6 for instance is a 6x6 input grid.
The goal is to find the best solutions for each layout. Since I don't have the solution to all the layouts (I could just compute the first ones in bruteforce), the goal is not to find THE OPTIMAL solution, but a better solutions than all the ones already found. Hence, metaheuristics and original solutions are greatly appreciated.
Then, you should provide along with your solution all the results you get for each level. If any of them is above the best solution we found, it will be verified in the snippet and updated in the post.
Here is the snippet that will help you building your fitness function and that will be used to verify your layouts.

<!DOCTYPE html>

Input your layout and select your size:

<textarea rows="10" cols="40" id="myTextarea">2 0 2 0
0 3 0 3
2 0 2 0
0 3 0 9</textarea>

<select id="mySelect">
  <option value="16">16</option>
  <option value="32">32</option>
  <option value="64">64</option>
</select>
<button onclick="DrawCanvas()">Test it</button>

The income is: None.
Scroll down to see a graphical representation of your layout.

Levels and highscores
It starts from this zip: https://file.io/IvA6rf
Level 3:  6.223 by ME
Level 4:  0
Level 5:  0
Level 6:  0
Level 7:  0
Level 8:  0
Level 9:  0
Level 10: 0
Level 11: 0
Level 12: 0
Level 13: 0
Level 14: 0
Level 15: 0
Level 16: 0
Level 17: 0
Level 18: 0
Level 19: 0
Level 20: 0

Does water actually irrigate that far away from the source now?

It always did bro, but no one paid attention to that at the time ;)

This looks like an interesting challenge but is currently missing an objective winning criterion. How should it be determined which of two answers score higher?

Oh I see, I guess I'll throw a really huge layout like 1000x1000 and the winner is gonna be the one with the highest money / h :)

@Philippe I would suggest having multiple inputs. With one input, a valid program just prints the best score. You should also make this based on something other than following an algorithm - I would suggest considering [tag:code-golf]

I like this. I think that you should explain the mechanics a bit better, but otherwise Well thought out. You should note that having one output is not that great, and it's better to say for any given layout.

I'm voting to close this question as off-topic because I think it would be better suited for puzzling.SE or generalised with an objective winning criteria

Regarding the title of the new edit, you should use the Sandbox for developing challenges.

@Philippe there is still no winning criterion. If there are two answers, how does everyone know which one wins? Or are you looking for the current best solution for each level separately?

I look at the score provided by each layout and I keep the best ones. If two solutions gives the same results, I only quote the first one that has been posted. The idea is that for the harder levels, you will never get the optimal answer so there will always be competition to find the best approximation.

@Philippe What I mean by "winning criterion" is that when people post answers, you have to chose a "best answer". [tag:code-challenge] wants you to create your own winning criterion that is not covered by other types. My suggestion is that the winner is the either the individual or the program that creates the most optimal solutions. That way, anyone can determine who the winner is at a glance - that will solve the reason your challenge was closed. We need to be able to "indisputably decide which entry should win."

Oh I understand better now. I'll figure out a way to find a single winner tomorrow, i'll add the [not evaluate] tag during this time


text:
The sum of some parts
Challenge
Given a list of keys and values, and a target n, return all sets of keys where the sum of their values equals or exceeds n.
Input
Input will be like this:
[["Part 1", 20], ["Part 2", 15], ["Part 3", 14.75], ["Part 4", 3]], 30

Input consists of a list with keys (which can be any kind of string) and values (which can be any kind of decimal). Also, a number n is supplied as the target.
You may take these inputs in any format you like, in any order etc. It needs to support strings, numbers (with decimal precision and possibly negative).
The target might be positive, negative or zero. The list will always contain at least 1 KV-pair.
Each key is guaranteed to be unique. Each value <> 0. Different keys can have the same value. It is not guaranteed that a list holds a satisfactory combination.
Output
The expected output is a list of lists with all keys that have a combined value >=n. Each set that manages to satisfy this condition needs to be shown in a clearly distinguishable group, for example by separating them with brackets or newlines.
Sample output for the above input:
Part 1, Part2
Part 1, Part 3
Part 1, Part2, Part 3
Part 1, Part2, Part 4
Part 1, Part3, Part 4
Part 1, Part2, Part 3, Part 4
Part2, Part 3, Part 4

Note that each combination needs to be unique. The output doesn't need to be sorted, but part 1, part 2 is considered a duplicate of part 2, part 1 and should not be shown twice.
Additional rules

Standard loopholes are forbidden
Answer must be a full program or a function, not a snippet or a REPL-entry.
code-golf, shortest answer in bytes wins.

Sandbox.

05AB1E, 10 bytes
æʒø`O²‹_i,

Try it online!
Explanation
æ           # compute powerset of input
 ʒ          # filter out falsy values (we don't actually filter, it just saves a byte)
  ø         # zip into a list of keys and a list of values
   `        # push separately to the stack
    O       # sum values
     ²‹_i   # if not less than input_2
         ,  # print list of keys

ʒ vs. vy...this is clever.

Mathematica, 45 43 bytes
Saved 2 bytes due to alephalpha.
Keys/@Cases[Subsets@#,a_/;Tr@Values@a>=#2]&

Anonymous function. Takes a list of rules (e.g., {"Part 1"->20,"Part 2"->15}) and a number as input and returns a list of lists of strings as output.

@alephalpha Implemented.

JavaScript (ES6), 127 123 bytes
Takes the list l and the target n in currying syntax (l)(n). Returns an array of arrays.
l=>n=>l.reduceRight((p,c)=>[...p,...p.map(x=>[c,...x])],[[]]).filter(x=>x.map(x=>s+=x[1],s=0)&&s>=n).map(x=>x.map(x=>x[0]))

Demo

let f =

l=>n=>l.reduceRight((p,c)=>[...p,...p.map(x=>[c,...x])],[[]]).filter(x=>x.map(x=>s+=x[1],s=0)&&s>=n).map(x=>x.map(x=>x[0]))

console.log(
  f([["Part 1", 20], ["Part 2", 15], ["Part 3", 14.75], ["Part 4", 3]])(30)
)

Haskell, 60 bytes
n#l=[map fst=<<e|e<-mapM(\p->[[],[p]])l,sum(map snd=<<e)>=n]

Usage example: 3 # [("Part 1",1), ("Part 2",1.5),("Part 3",2)] -> [["Part 2","Part 3"],["Part 1","Part 3"],["Part 1","Part 2","Part 3"]].
Try it online!
How it works:
      mapM(\p->[[],[p]])l         -- turn every element p from the input list l
                                  -- into a list [[],[p]], i.e. [<empty list>, <singleton list p>]
                                  -- and make a list of all combinations there by
                                  -- picking either [] or [p]
                                  -- e.g. [1,2] -> [[[],[]], [[],[2]], [[1],[]], [[1],[2]]]
    e<-                           -- keep all elements e from this list where
          sum(map snd=<<e)>=n     -- the second elements of the pairs are >= n
[map fst=<<e |         ]          -- and extract the first elements of the pairs from it

Japt, 15 14 12 bytes
Saved 2 bytes thanks to @obarakon
à f_xÅ¨VÃm®g

Test it online! Output is a nested array, but it's rather hard to tell so the -R flag has been added to put each item on its own line.
Explanation
 à f_  xÅ  ¨ VÃ m®   g
Uà fZ{Zxs1 >=V} mmZ{Zg}
                         // Implicit: U = input array, V = input number
Uà                       // Take all combinations of U.
   fZ{        }          // Filter to only the combinations Z where this is true:
      Zxs1               //   The sum of each [item of Z]'s item at index 1
           >=V           //   is greater than or equal to V.
                m        // Map each combination in the result by
                 mZ{  }  //   mapping each array Z in that to
                    Zg   //     the first item in Z.
                         // This replaces each key-value pair with its key.
                         // Implicit: output result of last expression

An interesting thing to note is the use of Å (or s1 ) instead of g1 . s1  on an array simply returns everything but the first item. Since each array only has two items (a key and a value), this returns an array containing the value. x then uses JS's native coercion to convert this into a number, and on an array containing one number, this happens to return that number.

Can you replace g1  with Å?

@obarakon Oh my gosh, that is genius...

R, 97 bytes
function(l,v){z=c()
k=combn
for(i in 1:length(l))z=c(z,lapply(k(l,i,,F)[k(l,i,sum)>=v],names))
z}

This is an anonymous function which takes the input in as a named list of values l (where the names are the parts) and a value v, and returns a list of vectors of names. Returns a list with value NULL if no matches are found.
The function combn(x,m)generates all elements of x taken m at a time with some options to simplify and aggregate. Hence the code iteratively generates the subsets of size i, k(l,i,,F), subsets those whose sum k(l,i,sum) is at least v, and then applies the names function to to each of those to extract the part names.
A different input scheme might lead to golfier code.
Try it online!

PHP, 134 bytes
function f($a,$n){$r=$n>0?[]:[[]];if([$k,$v]=each($a)){unset($a[$k]);$r=f($a,$n);foreach(f($a,$n-$v)as$t){$t[]=$k;$r[]=$t;}}return$r;}

Test it online.