text:
Is it L-convex?
Background
A polyomino is called L-convex, if it's possible to travel from any tile to any other tile by an L-shaped path, that is, a path that goes in the cardinal directions and changes direction at most once.
For example, the polyomino of 1s in the figure
0 0 1 1 1 0

1 1 1 1 0 0

1 1 0 0 0 0

is not L-convex, since both L-shaped paths from the bottom left 1 to the top right 1 contain a 0:
0>0>1>1>1 0
^       ^
1 1 1 1 0 0
^       ^
1>1>0>0>0 0

However, the polyomino of 1s in this figure is L-convex:
0 1 1 1 0 0

1 1 1 1 1 1

0 1 1 0 0 0

Input
Your input is a 2D array of bits in the native format of your language, or as a newline-delimited string if our language lacks arrays.
It is guaranteed to contain at least one 1.
Output
Your output shall be a truthy value if the set of 1s is an L-convex polyomino, and a falsy value if not.
These outputs must be consistent: you must output the same truthy value for all L-convex inputs, and the same falsy value for others.
Note that a disconnected set of 1s (which is not a polyomino) results in a falsy output.
Rules and Scoring
You can write either a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Test Cases
These test cases should work also if you rotate or reflect the arrays, or add rows of 0s to any borders.
False instances
01
10

111
101
111

1101
1111
1110

1100
1000
0011

01100
11110
01110
00110

011000
011110
001111

True instances
1

01
11

010
111
010

001
011
111

11100
11110
01100
01000

011000
011000
111100
111111
001000

Very nice challenge, I enjoyed it=)

About input: it a newline-delimited string allowed, if our language does not lack arrays ?

@edc65 (Sorry, been off the grid for a couple of days.) Sure, that's allowed too, it's just badly worded on my part.

Snails, 45 24
&
!{\1t\1!{o\1,nf\1,!.!~

Right after posting my initial solution, I realized there was a much better way. The original program traveled around the square formed by the paths between two 1s, testing for the presence of a 0 in each pair of sides. It also had to have a special case for straight line paths. The new version starts by teleporting from one 1 to the other, and testing for the absence of a straight or L-shaped path of 1s back to the start.

OMG!! Is there an online interpreter where we could play around with this?

@flawr You can build it from source with the source code here.

Matlab, 182 bytes
Idea: Repeat for every 1 in the polyomino matrix:

Create new matrix with only the given 1 but the rest zero.
for every 1 in this new matrix (repeat until nothing changes anymore)

add 1 as neighbours in x direction if there are 1 as neighbours in the polynomio

for every 1 in this new matrix (repeat until nothing changes anymore)

add 1 as neighbours in x direction if there are 1 as neighbours in the polynomio

Now 1 in the new matrix should cover all 1 in the polynomio-matrix that are reachable from the given starting point by first going in x-direction and then in y-direction. Now we can repeat the same process but with first going into y-direction and then in x-direction. Now every 1 of the polyomino matrix should be reached at once or both times. If not, then we have found a position in the polynomio matrix that cannot be reached from every other position by an L-path.
Golfed:
function r=f(a);[i,j,b]=find(a);N=nnz(i);r=1;for k=1:N;K=1:3;for l=1:2;c=b;b=a*0;b(i(k),j(k))=1;for z=1:2*N; b=conv2(b+0,K,'s')&a;if z==N;K=K';end;end;end;r=r*all(b(:)|c(:)>=a(:));end

With comments:
function r=codegolf_L_convex(a);
%a=[0,1;1,1];
[i,j,b]=find(a);%b just needs to be initialized, does not really mattter
N=nnz(i);%number of ones in the matrix
r=1;%return value
for k=1:N;%go throu all '1' in the matrix
    %expand that pixel in x dir:
    K=1:3;%convolution kernel (just three positive values needed)
    for l=1:2;%first horizontal->vertical then vertical->horizontal
        c=b;%backup for considering both runs
        b=a*0;
        b(i(k),j(k))=1; %set the seed
        for z=1:2*N;
            b=conv2(b+0,K,'s')&a; %expand the seed horizontally (or vertically for the second half) but only within the polyomino
            if z==N;
                K=K'; %change horizontal/vertical
            end;
        end;
    end;
    r=r*all(b(:)|c(:)>=a(:));%check whether we can really reach every point
end

Test cases script:
disp('all false -------------');
a=[0,1;1,0];
f(a)
a=[1,1,1;1,0,1;1,1,1];
f(a)
a=[1,1,0,1;1,1,1,1;1,1,1,0];
f(a)
a=[1,1,0,0;1,0,0,0;0,0,1,1];
f(a)
a=[0,1,1,0,0;1,1,1,1,0;0,1,1,1,0;0,0,1,1,0];
f(a)
a=[0,1,1,0,0,0;0,1,1,1,1,0;0,0,1,1,1,1];
f(a)
 disp('all true +++++++++++++');
a=[1];
f(a)
a=[0,1;1,1];
f(a)
a=[0,1,0;1,1,1;0,1,0];
f(a)
a=[0,0,1;0,1,1;1,1,1];
f(a)
a=[1,1,1,0,0;1,1,1,1,0;0,1,1,0,0;0,1,0,0,0];
f(a)
a=[0,1,1,0,0,0;0,1,1,0,0,0;1,1,1,1,0,0;1,1,1,1,1,1;0,0,1,0,0,0];
f(a)

Mathematica, 129 127 bytes
3>GraphDiameter@Graph[#,#<->#2&@@@Select[#~Tuples~2,!FreeQ[#-#2&@@#,0]&]]&@Position[#,1]&&{#,Thread@#}~FreeQ~{___,1,0..,1,___}&

Explanation:
First, if there is a 0 between two 1s on the same row or column, the array is not L-convex, because we can't connect the two 1s.
After excluding this case, every two 1s on the same row or column can be connected by a straight path. We can generate a graph, whose vertices are the positions of 1s in the array, and edges are pairs of 1s on the same row or column. Then the array is L-convex if and only if the diameter of the graph is less than 3.

Can you give an explanation how this works? I am not gonna upvote gibberish nobody could possibly understand=)

How does this recognize the first and fourth false instances (the disconnected ones)?

@Zgarb If the graph is disconnected, its diameter is infinity.

Javascript ES6, 290 bytes
Ok, maybe it won't win any awards for brevity, but it does use a novel approach. See the ungolfed version for how it works.
Proof for this method can be found in: Cellular Automata and Discrete Complex Systems.
L=a=>[1,0,1].every($=>(a=a[0].map((_,col)=>a.map(row=>row[col]))).map(r=>($?r.reverse():r).join``).every((r,i,b)=>r.replace(/^(0*)(1*)(0*)$|(.+)/,(_,s,m,o,e)=>(c=e)?'':!m||b[i-1]&&+b[i-1][s.length]?1:b.every((r,j)=>j<i||(c=c||!+r[l=s.length])?r.search(`0{${l}}.*0{${o.length}}`)+1:1)||'')))

Ungolfed:
function L(a) {
  /* Runs three times and ensure all pass validation
   * 1: horizontally reversed
   * 2: 90 degrees rotated
   * 3: original
   *
   *     | 1:  | 2:  | 3:
   * =====================
   * 001 | 100 | 111 | 001
   * 011 | 110 | 011 | 011
   * 111 | 111 | 001 | 111
   *
   * By finding maximal rectangles with corners on all NW and NE corners
   * (separately) of a HV-convex polyomino and ensuring it doesn't enter the
   * boundaries labelled ABCD for the rectangle X below:
   *
   *   A  |         |  B
   * -----===========-----
   *      |    X    |
   * -----===========-----
   *   C  |         |  D
   *
   * The first iteration tests the NE corners and horizontal convexity.
   * The second iteration test vertical convexity.
   * The third iteration tests the NW corners.
   *
   * If all pass then the polyomino is L-convex.
   */
  return [1,0,1].every(function($){
    return (a=a[0].map((_,col)=>{
      // Transpose rows with columns
      return a.map(row=>row[col])
    })).map(row=>{
      // Join rows as strings and on odd iterations reverse them
      return ($ ? row.reverse() : row).join``
    }).every(function(row, i, b) {
      if (i == 0) console.log(b.join('\n'));
      return row.replace(/^(0*)(1*)(0*)$|(.+)/, function(_, start, middle, end, invalid) {
        // Non H-convex polyomino (0 between 1s)
        if (invalid) return '';
        // Is not a NW corner (character above is 1)
        if (!middle || b[i-1] && +b[i-1][start.length]) return 1;
        c=1;
        return b.every(function(row, j) {
          // Above or below maximal rectangle from corner
          if (j < i || !(c=c&&+row[l=start.length])) {
            // Area before and after maximal rectangle doesn't contain 1
            return row.search(`0{${l}}.*0{${end.length}}`)+1
          }
          return 1;
        }) || '';
      });
    });
  });
}

Ha, that article is where I got the inspiration for this challenge!

@Zgarb The article was great and one of the few I could find that made sense to someone who isn't mathematically orientated.

JavaScript (ES6) 174
Looking at the grid of empty or filled cells, for any pair of filled cells I check the horizontal paths to the other cell column (there can be 1 if the cells are on the same row, else or 2) and the vertical paths to the other cell row (there can be 1 or 2 too). If I find an empty cell in both vertical paths or both horizontal paths, then there can not be an L shaped path between the cells.
(I had a hard time trying to put up this explanation - I hope to have been clear)
Test running the snippet below in any EcmaScript 6 compliant browser

F=p=>!p.some((n,y)=>n.some((q,x)=>q&&p.some((o,u)=>o.some((q,t)=>{for(f=0,i=y;q&i<=u;i++)f|=!p[i][x]|2*!p[i][t];if(f<3)for(f=0,j=x;q&j<=t;j++)f|=!n[j]|2*!o[j];return f>2}))))

// TEST
console.log=(...x)=>O.innerHTML+=x+'\n'

tko = [
 [[0,1],[1,0]]
,[[1,1,1],[1,0,1],[1,1,1]]
,[[1,1,0,1],[1,1,1,1],[1,1,1,0]]
,[[1,1,0,0],[1,0,0,0],[0,0,1,1]]
,[[0,1,1,0,0],[1,1,1,1,0],[0,1,1,1,0],[0,0,1,1,0]]
,[[0,1,1,0,0,0],[0,1,1,1,1,0],[0,0,1,1,1,1]]
]
tko.forEach(t=>(console.log(t.join`\n`+`\nFalse? ${F(t)}\n`)));
tok = [
 [[1]]
,[[0,1],[1,1]]
,[[0,1,0],[1,1,1],[0,1,0]]
,[[0,0,1],[0,1,1],[1,1,1]]
,[[1,1,1,0,0],[1,1,1,1,0],[0,1,1,0,0],[0,1,0,0,0]]
,[[0,1,1,0,0,0],[0,1,1,0,0,0],[1,1,1,1,0,0],[1,1,1,1,1,1],[0,0,1,0,0,0]]
]
tok.forEach(t=>(console.log(t.join`\n`+`\nTrue? ${F(t)}\n`)));

// LESS GOLFED

U=p=>
  !p.some((n,y)=>
    n.some((q,x)=>
      q && p.some((o,u)=>
        o.some((q,t)=>{
          for(f=0,i=y; q&i<=u; i++)f|=!p[i][x]|2*!p[i][t]
          if (f<3)
            for(f=0,j=x; q&j<=t; j++)f|=!n[j]|2*!o[j]
          return f>2
        })
      )
    )
  )


text:
How can Pyth be improved?
Pyth is in ongoing development, meaning that new features are being added all the time.
I want to make Pyth a better langauge, so I'd like to know what features people are looking for.
This is the place the post ideas you have for making Pyth better.
In your answer, please state:

What you'd like to see changed/added.
An example usage of the change.

I'll comment if I'm planning to implement the suggestion.
Please check if the idea you want to suggest has already been suggested. Upvote ideas you'd like implemented.

Implemented suggestions:

Eval string in Pyth, as .v
More Regex operations
Apply While as .W
Nested Loops and More Lambdas (They use the same mechanism underneath)
Flatten nested lists as .n

This was on topic as per this meta question when I posted the question, it is no longer clear.

Why is this a community wiki?

It's more of a discussion and collection of suggestions. Nobody should gain or lose rep for suggesting a Pyth feature. Also, implemented suggestions should probably be deleted. This related question is also community wiki.

I'm not sure how I feel about questions like this. I can see that it sort of makes sense here, because PPCG probably covers most (if not all) of Pyth's user base, but I'm not sure we should use it as an issue tracker. I have added an answer to the meta post.

Shouldn't this been meta? Seriously guys

@AlecTeal "Meta Programming Puzzles & Code Golf Stack Exchange is the part of the site where users discuss the workings and policies of Code Golf Stack Exchange rather than discussing programming puzzles or code golf itself." Meta is specifically about this community. It really doesn't belong on meta. Whether it belongs here or not on PPCG at all is currently being discussed in the meta post I linked.

@MartinBüttner So, should I close the question?

@isaacg I'd say give it some time to see if the new answer actually pulls ahead on meta.

If it's relevant either way to people voting on meta, this type of question will almost invariably reach HNQ. (Being community wiki does not prevent it showing on HNQ.)

All of the good suggestions here will end up on the Github issue tracker, won't they? I'd say this isn't an appropriate use of SE.

I think at 27 vs 17 (+/- the votes Alex and I couldn't cast on our own answers), the consensus is fairly clear now. Therefore, I'm closing this question now.

Nested loops
If you want to nest for loops, you currently have to waste a byte for using F<var><seq> inside a V<seq> or vice versa. I'd love to have the same thing as with lambdas, where the variable used for the loop would change when nesting loops.

This might even be extensible to other things like L, which could redefine, say, C the second time it were called.

Turt
Pyth equivalent of turtle graphics, as per import turtle.

Sleeping
This caused trouble here, and @mbomb007 suggested to put it as an improvement to Pyth. Basically, right now, in order to sleep for the given number of seconds, I need to do something like:
Q$__import__('time').sleep(Q)$

Which is annoying and long as heck.

You can simulate the sleeping behaviour with the date-function. f>.d1Q0 for instance sleeps Q seconds.

@Jakube That doesn't always work. According to the docs, on Unix, it returns how long the program has been running for. Which is bad when the user is entering input.

How about this one than: J.d0f>-.d0JQ0. It's quite long though... I agree, a sleep function would be nice.

Easier Module Importing
So far, every time I have used $ it has been something like:
$from <module> import <function> as <pyth-function-with-same-arity>$
for example:
$from unicodedata import name as neg$

There could be a new function that summarized this for example .$:
.$"unicodedata""name""neg"
.$"unicodedata name neg"

Or using the newer syntax like _M which may not be easy/possible to do:
_$unicodedata name$

In addition, one function with each arity could be given a single letter macro name so that these calls could be shorter (except for the _$ option).

More lambdas
This is really FryAmTheEggman's idea, but I'm posting it to get it out there.
Sometimes I find that using two different one-argument lambdas would shorten the code, while having to use a two-argument lambda for one wouldn't.
It would be nice to have L, M and friends redefine a different function every time used; for example, this code:
L*b2L*b3y5'5

could compile to:
@memoized
def subsets(b):
 return times(b,2)
@memoized
def read_file(b):
 return times(b,3)
imp_print(subsets(5))
imp_print(read_file(5))

The exact choice of functions could be changed, of course.

Improved multi-dimensional arrays
Using multi-dimensional arrays is rather hard to do currently. For example, the C code A[B][C][D] would translate to @@@ABCD in Pyth. Something like @A[BCD) would be much nicer (albeit not any shorter here). The same also goes for X; A[B][C][D] = E is currently X@@ABCDE, when it could be XA[BCD)E.

Some minor ideas

Absolute difference, i.e. abs(val1 - val2). Currently it's .a-<val1><val2>.
min/max for values. Currently it's hS,<val1><val2>/eS,<val1><val2> or the same thing with more values. (hS<seq>/eS<seq> for sequences is short enough.)

Not a Pyth feature, but nevertheless...
Modularize the Pyth code
This only affects Pyth under the hood. Some parts of the Pyth implementation are quite messy. Lots of global variables and other hacky things.
I really got frustrated a few days ago, when I tried using a few functions of the Pyth implementation (like executing a string of Pyth commands) from another Python script.
Something like the following would be nice:
from pyth import execute_pyth
print(execute_pyth(code='sQ', input='[1, 2, 3]'))

Well, I guess this is just a help call for Pyth5.

https://github.com/isaacg1/pyth/issues/111?

Unique elements
Pyth currently has no short way of getting unique elements of a sequence. You can test if it's unique, but you can't get the items that are actually unique. Currently, the shortest way is:
{.-Q{Q

6 bytes! Compare that to K, where getting the unique elements is a one-byte operation: =x.
Maybe .} would work here?

What use cases (other than tat one challenge) are you thinking of?

@isaacg I can't quite recall, but I've had to try and get the unique elements of a list before and had to use something else (which was always longer).

I'm not a Pyth programmer, but I run into this all the time in GolfScript/CJam: .& resp. _& appears in a lot of answers. It's very useful.

How is this different from {Q?

@isaacg It's sorted

@kirbyfan64sos =x looks like a 2 byte operation to me! Maybe I'm missing something...

@wizzwizz4 I was referring to the =; the x was just an example.

source: Stack Exchange

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

sort: votes


text:
Self-Mutilating Program
Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as.
Please include the beginning source as well as the ending source in your post, as well as a description. E.g. Describe what (else) your program does, the language you used, your strategy, etc.
Rules

Your program must halt sometime after the modification is complete.

It must actually modify its own, currently running source code (not necessarily the file you passed to the interpreter, it modifies its instructions), not print a new program or write a new file.

Standard loopholes are disallowed.

Shortest program wins.

If your language can modify its own file and execute a new compiler process, but cannot modify its own (currently running) source code, you may write such a program instead at a +20% bytes penalty, rounded up. Real self-modifying languages should have an advantage.

Edit: If your program halts with errors, please specify it as such (and maybe say what the errors are.)

Do I understand correctly that the program should modify its own source while it is running, in a way that potentially affects its behavior? This would rule out most non-esoteric languages. Or is it allowed to modify the source and launch a new interpreter/compiler process on it?

@Zgarb It must actually modify its own, currently running source code. Yes, that rules out most languages.

@mbomb007 That's bad.

@mbomb007 It's says nowhere in you challenge that it has to run the modified source code.

Also, no it doesn't make this challenge trivial, it'll still good scoped. You ruled out too many languages with this.

Let us continue this discussion in chat.

I take it there is no requirement for the final source code to be the same length as the initial source code?

@trichoplax Correct. Only the area of the source code needs to be different. Any memory locations that are outside the initial area do not matter.

@mbomb007 I was thinking of answers that reduce the source code rather than expanding it. If the source code is reduced to zero does that still count since the memory no longer occupied by source code will then be occupied by something different?

@trichoplax Ah, yes. I think that's reasonable.

Must the end result have the same amount of characters as the original source?

No. My program in Self-modifying BF is an example of one that doesn't.

///, 1 byte
/

The program finds a / (the start of a pattern-replacement group), and removes it in preparation to make the replacement. Then it reaches EOF, so it gives up and halts.

The is the earliest answer with 1 byte, so it's the winner.

Labyrinth, 2 bytes
>@

The > rotates the source so that it becomes
@>

The instruction pointer is now in a dead end and turns around to hit the @ which terminates the program.
Of course, <@ would also work.

Python 2, 225 bytes
import sys
from ctypes import*
c=sys._getframe().f_code.co_code
i=c_int
p=POINTER
class S(Structure):_fields_=zip("r"*9+"v",(i,c_void_p,i,c_char_p,i,p(i),i,c_long,i,c_char*len(c)))
cast(id(c),p(S)).contents.v=`len([])`*len(c)

The ending source code is a string of "0"s whose length is equal to the number of bytes in the original compiled code object.
The code finds the running code object, sys._getframe().f_code.co_code, and creates a structure which represents python string objects. It then gets the memory that the code actually takes and replaces it with "0"*len(c).
When ran, the program exits with the following traceback:
XXX lineno: 7, opcode: 49
Traceback (most recent call last):
  File "main.py", line 7, in <module>
    cast(id(c),p(S)).contents.v=`1+1`*len(c)
SystemError: unknown opcode

This shows that the overwrite was successful and the program dies because 0 isn't a valid opcode.
I'm surprised that this is even possible in python, frame objects are read-only, I can't create new ones. The only complicated thing this does is change an immutable object (a string).

Not sure if this quite meets the requirements that EVERY character must be different.  The "1" in the original source code would still be a "1" in the mangled code...

Well actually, the "1" string in the code isn't actually part of the 'code', its just a constant that's referred to in the bytecode. What I'm actually changing is the compiled python virtual machine opcodes, not the constants or variables. So what I'm changing isn't the source code per say, just the compiled code. I could change the source code as stored but that wouldn't actually affect the code at runtime because it would have already been compiled. If you wanted, I could post this in a 'compiled Python 2.7 opcodes with constants', but that would be silly IMO.

And also, I can't look at the compiled code because by changing it to see inside, I'm actually changing the code, meaning I don't actually see the code. So really, I have no idea if the code really replaces every character, just that it changes most(?) of them

To get around the issue of the 1 not being changed in the compiled code, you could change the "1" to <backtick>1+1<backtick> for only 2 more bytes

Not that I see (compiled with 2.7.10). Unfortunately, the 1+1 from my suggestion gets turned into a 2 in the compiled version... The compiler is too smart for its own good!

I always forget you can compile using a library at runtime

Unfortunately, the 1+1 trick doesn't work, because the compiled code contains a 2, thanks to optimizing the addition. Another way I've found is using len([]), which will replace everything with a 0 (also an invalid opcode), with no 0s to be found in the compiled code.

You should post this to https://codegolf.stackexchange.com/questions/119346/a-program-that-forgets-itself (if it doesn't get closed as duplicate)

evil, 1 byte
q

evil has several memory stores - one is the source code itself and one is the wheel which is a circular queue which is initialised to a single zero. q swaps the source code and the wheel, so it replaces the source with a null-byte. However, only lower-case letters are actual operators in evil, so that character is simply a no-op and the program terminates.

MSM, 8 bytes
'.qp.;.;

Transforms the source code to pqpqpqpq
MSM operates on a list of strings. Commands are taken from the left and they treat the right side as a stack. MSM always works on it's own source.
Execution trace:
'.qp.;.;                       upon start the source is implicitly split into a
                               list of single char strings

' . q p . ; . ;                ' takes the next element and pushes it on the stack
    q p . ; . ; .              q is not a command so it's pushed
      p . ; . ; . q            same for p
        . ; . ; . q p          . concats the top and next to top element
          ; . ; . pq           ; duplicates the top element
            . ; . pq pq        concat
              ; . pqpq         dup
                . pqpq pqpq    concat
                  pqpqpqpq     MSM stops when there's only one element left

Malbolge, 1 or 2 bytes.
D

The Malbolge language "encrypts" each instruction after executing it, so this letter (Malbolge NOP) will become an ! (which is also a nop), and then terminate. For some reason, the Malbolge interpreter I use requires two bytes to run, giving DC (both of which are nops) becoming !U (both of which are also nops)
Edit: The initial state of Malbolge memory depends on the last two characters in the code, so it is not well defined for one character programs. (Though this code doesn't care about the initial state of memory)

x86 asm - 6 bytes
not sure if "until every character of the source is different than what it started as" refers to each byte, each nemonic, or general modification. if I'm invalid I can change the xor to a rep xor so each bit changes values but was hoping not to do that to save 6 more bytes to stay at least a little bit comparable to these specialty golf languages.
All this does is change a c2 to a c3 retn by getting live address of eip and xoring 5 bytes in front.
58          | pop eax                        ; store addr of eip in eax
83 70 05 01 | xor dword ptr ds:[eax + 5], 1  ; c2 ^ 1 = c3 = RETN
c2          | retn                           ; leave

SMBF, 92 bytes
Can be golfed, and I'll probably work more on it later.
>>+>>+>>+>>+>>+>>+[<-[>+<---]>+++++<<]>>>>>--[>-<++++++]>--->>++>+++++[>------<-]>->>++[<<]<

Explanation
The program generates the following commands at the end of its tape to erase itself, so it has to generate the following values on the tape:
[[-]<]          ASCII: 91 91 45 93 60 93

Make a bunch of 91s, with nulls (shown as _) between to use for temp values.
>>+>>+>>+>>+>>+>>+[<-[>+<---]>+++++<<]

code__91_91_91_91_91_91_
   ^

Adjust the values by the differences
>>>>>--[>-<++++++]>---  Sub 46
>>++                    Add 2
>+++++[>------<-]>-     Sub 31
>>++                    Add 2
[<<]<                   Shift left to the code
code__[_[_-_]_<_]_      Zero out the code
   ^

The tape following execution will be all zeros, with the exception of the generated code [_[_-_]_<_].
Note:
This program made me realize that my Python interpreter for SMBF has a bug or two, and I haven't figured out a fix yet. It's fixed now.

Redcode, 7 bytes, 1 instruction (Just an example. Not competing)
This is a trivial example.
Moves the next memory location onto itself, then halts (because the entire memory is initialized to DAT 0 0, which halts the program when executed.)
MOV 1 0

Why are you counting this as instructions instead of bytes?

Because I don't know how many bytes it is. I think that's dependent on memory size, or implementation?...

I'd count by ASCII characters if you don't know how it's implemented.

From the Wikipedia page: Each Redcode instruction occupies exactly one memory slot and takes exactly one cycle to execute. ... The memory is addressed in units of one instruction.

All [tag:code-golf] posts are scored in bytes. Since there is no Redcode machine code, we must use the characters in the "assembly source", not what it assembles to.

In ICWS-86 standard Redcode, each instruction is 4 bytes at coresize 8192, so 4 bytes.

Don't forget to indicate ICWS-86 Redcode in the title.

@CatsAreFluffy Do you have a citation? I don't see how that fits in 4 bytes. 8192 = 2^15, so A and B each need 2 bytes, right? The instruction and addressing modes probably also each need a byte, or possibly they could both fit into the same byte. That's 5 at minimum. Or are A and B stuck into the same byte?

No, can't find it.

To keep the language simple and abstract no numerical equivalents have been defined for the OpCodes, so using mathematical operations on them wouldn't make any sense at all. - The beginners' guide to Redcode

Emacs Lisp 22 bytes
(defun a()(defun a()))

Run from REPL:
ELISP> (defun a()(defun a()))
a
ELISP> (symbol-function 'a)
(lambda nil
  (defun a nil))

ELISP> (a)
a
ELISP> (symbol-function 'a)
(lambda nil nil)

Function now evaluates to nil.
Alternately (unbind itself) 30 bytes
(defun a()(fmakunbound 'a)(a))

Evaluate and errors as void-function.  Function existed prior to being run.

MIXAL, 6 bytes (counting 2 tabs)
    STZ    0

The program starts at memory location 0 and then writes 0 to memory location 0, thus erasing itself. The machine halts automatically.
This is the assembly language for Donald Knuth's hypothetical MIX computer, which may be assembled and run using GNU MIX development kit (https://www.gnu.org/software/mdk/).

Powershell 65 bytes
function a{si -pat:function:a -va:([scriptblock]::create($null))}

Define a function that rewrites itself to null.
Evaluate it once and it eliminates itself.
Alternately (deletes itself from memory) 36 bytes
function a{remove-item function:a;a}

Calling it first removes it then attempts to evaluate recursively.  Erroring out as an unknown command.

><>, 40 34 30 bytes
0&00a6*0&1+:&060"c"l=?!.~~r >p

Try it here!
Explanation:
0&          Adds 0 to the registry
00a6*       Adds "0,0,<" to the stack; coords followed by a character
------------loop start (for clarity)
0           0 added to stack
&1+:&       Registry retrieved, increased by 1, duplicated, one put back in registry
0           ASCII character 0 added to stack (just a 0 but will be converted to that character when inserted in the code)
60          6 and 0 added to stack
"c"         The number 99 added to stack (length of code + 1 * 3)
l=?         Code length added to stack, checks if it is equal to 111

!.          If false, pointer jumps back to character (9,0) (loop start position)
~~r >p      If true, removes the 0 and 9, reverses stack, then loops the p command setting
all the characters to a "<" character and the 2nd character to a " "

Basically this puts a bunch of 3 character blocks in the stack like so: (ypos, xpos, ASCII character) which gets reversed at the end so the final 'p' command reads (character, xpos, ypos) and sets that position in the code to that character. The first character is manually set as '<', so that the code ends up being '>p<' at the end to loop the command. Then every other character is overwritten as a ' ' including the p character. The ' ' is actually "ASCII CHAR 0" which is NOT a NOP and will give an error when read.
Also there have to be an odd(?) number of characters before the 'p' command or else it wont be looped back into a last time and overwritten.

Batch, 11 bytes
@echo>%0&&*

Modifies source code to ECHO is on.
@           - don't echo the command.
 echo       - print ECHO is on.
     >%0    - write to own file.
        &&* - execute * command after the above is done, * doesn't exist so program halts.

The @ is there so the command isn't echoed, but mostly so the two echos don't line up.

the @ can be removed, because ECHO (uppercase) != echo (lowercase)

@ppperry The two echos can't line up.

But they're different cases.

Jolf, 4 bytes, noncompeting
₯S₯C

This ₯Sets the ₯Code element's value to the input, undefined as none is given. Try it here!

(Filesystem) Befunge 98, 46 bytes
ff*:1100'aof0'ai
               21f0'ai@

Note that this program creates and manipulates a file named a.
How it works:

The code creates a file named a containing the entire code (out to 256 characters in each dimension) shifted one space upward and two the left.
This program then reads the file named a as one line, replacing the entire first line with the contents of the a file.
The second line, which has been copied in front of the IP, is executed
Which reads the a file into the second line shifted two places to the right.

As a side effect, the ending source code isn't even valid Befunge! (because it contains newlines as data in a single line)

Python 2, 238 bytes + 20% = 285.6
# coding: utf-8
import codecs
with codecs.open(__file__,'r') as f:
    t = f.read()
n="utf-8" if t.startswith("# coding: ascii") else "ascii"
with codecs.open(__file__,'w', encoding=n) as f:
    f.write(t[0]+" coding: "+n+t[t.find("\n"):])

Basically, this toggles the current file encoding of the python source between ascii and utf-8, thus essentially changing every character of the source!

There are some extra spaces that can be removed. ) as -> )as, ) else -> )else, "utf-8"if, 'w',encoding.

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:
Source Code Metamorphosis
mbomb007 asked us to make a self mutilating program.  Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating.  I like to think that, at the heart of every program is a beautiful butterfly waiting to break out.
As such, for my first ever Code Golf challenge, I challenge Stack Exchange to metamorph a butterfly.  Your program should accept its own code as input and output I am a caterpillar! followed by the code for another program in the same language (you may put a divider between the outputs or not... but we're talking butterflies, so prettiness counts!). This second program should output I am a beautiful butterfly!
Metamorphosis: This program should modify itself, which is why it is being passed itself as input.  I don't want a boring nested program that is nothing but a print statement I am a caterpillar! followed by printing source code.  You have to metamorph the code itself, so the most boring acceptable answer is one which prints I am a caterpillar, then rips a string out of the input (which happens to be code) and prints that.  Of course, this is a very tricky little requirement to write, so it should be thought of as a "spirit of the challenge."  The formal requirement is going to be set at "If your program is given a random string of the same length as your program, there should be less than a 5% chance of printing I am a butterfly when the second program is run."
Summary:

Write a program which, when provided its own code as input, prints I am a caterpillar! followed by a block of source code (with a delimiter between them or not).
This second block of source code, when compiled/interpreted as the same language, prints I am a beautiful butterfly!
If your program is not fed its own source code as input, and is instead given a random string of characters that does not match its own code, the result must either fail to compile/interpret, or not print I am a butterfly! for at least 95% of random strings (spirit: you are expected to read your own source code from the input, and stitch it together into a butterfly).

I'm comfortable with you not proving this, so long as you're holding to the spirit of the metamorphosis idea, modifying your own code, but if you're trying to play loophole games to work around using your inputs, expect to have to prove it.

Standard loopholes apply

I'd like these to be judged by their beauty, but that's a decidedly non-quantitative approach, so the usual "number of bytes" route can be used to judge
Bonus: -20% - pick any 3 letter string that doesn't match the first 3 letters of your program.  If I run the caterpillar program, but modify the input so that the first 3 character are changed to the specified ones, print I am Batman! instead.   Always be Batman.  (Same random string rules apply for this... metamorphosis!)
Trivial example (python):
"""
    print "I am a beautiful butterfly!"
    #print "I am Batman!"
"""
import sys
code = sys.stdin.read()
if code.startswith("YYZ"):
   # swap the comments between the print statements
   code = code.replace("#print", "_a").replace("print", "#print").replace("_a", "print")
code = [3:] # remove """ or XYZ
code = code.split('"""')[0]
print "I am a caterpillar!"
print code

As a note: I'd love to see ascii art programs where it looks like a caterpillar the first time, and turns into an ascii butterfly the next phase, but that's quite a bit more advanced than the challenge needs to be.

What should we do if a program has multiple files?

@TheNumberOne I'm curious what you have planned there!  I don't know if I want to beat down the rules for that right away, without seeing the consequences, but it seems to me that, if you were to accept a multi-part set of files as input (rather than a single file's contents), and you were to output a multi-part set of outputs (rather than a single output), with a half-reasonable deliniator between the files, I think that should be a reasonable solution.  If that doesn't work for you, I may need more insight into your proposed solution to better craft a rule.

@TheNumberOne And thank you for the typo catch.  That typo was very clearly not a beautiful butterfly!

Befunge-98, 602 bytes
                                        "^@<"v@@
                                     "'I'"00v>00g::
                                   "@v"0v@@@>g::a">#"
                                 "a">v@@>      0g::'"1>                                 /
                             ":\"'"v@>            'm'"00g:a                       >"@v$"
 "lufituaeb"'"'v00ga"@v\"'":'b\00v@>                :'a\":*84>"00ga"\>@@@@_,#:>"00g:a'<'"
"et"'"'va'v'":'l\00g5k:'""y!">>v@>                    g::'''""ut"'"'>a'<'""fr"'"00g3k:'">
 "ma"00g>'I~48*-~48*-+#@_>:#,_@>                        '"aa"---"aa"!rallipretac"00g:'a\

Tested in PyFunge.
When run with a string not starting with 2 spaces (probability well over 95% when random) outputs nothing. This isn't exactly what the OP is looking for, but fits the specification.
When passed a string starting with 2 spaces (like itself) outputs this:
I am a caterpillar!

---

"!y"       "l"v
v"te"     "rf"<
>"tu"'   "b"\v@
 v"beautiful"<
  >:#,_@@@@>\
 >48*:"a"\:$v@
  "ma"   v@#>
   'I'   <@^

The lower part of that, in turn, outputs:
I am a beautiful butterfly!

Wow. This is amazing.

I knew someone would want to push the rules just like you did; I'm glad something beautiful came out of it =)

Both caterpillar and butterfly look like they are stuck in the Matrix. Beautiful!

where can I run this?

I will never understand how you good folks at Code Golf manage to create such beautiful monstrosities.

PHP, 74 Bytes
<?=~¶ßž’ßžß,$s="caterpillar!",strtr($argv[1],[$s=>~šžŠ‹–™Š“ßŠ‹‹š™“†Þ]);

<?= is equivalent to <?php echo and can take several comma separated values to output
¶ßž’ßžß and šžŠ‹–™Š“ßŠ‹‹š™“†Þ are valid constant names in PHP, but because the constants do not exist are treated as string literal. ~ inverts them to "I am a " and "beautiful butterfly!" (saving a byte for one quotation mark each)
strtr replaces "caterpillar!" with "a beautiful butterfly!" in the argument

Care to provide an explanation?

@Timwi no problem, explanation added

I fully expected someone to encode "beautiful butterfly" with something like ROT13, but the idea of matching it with PHP's string literal technique is, in the words of Kaylee, shiny!

Pyth, 50 46 bytes
"I am a caterpillar!"+<z8"beautiful butterfly!

Explanation
"I am a caterpillar!"        print "I am a caterpillar!"
 z<8                         first 8 chars of input
+   "beautiful butterfly!    add "beautiful butterfly!" to that and print

The resulting source code is
"I am a beautiful butterfly!

Which basically prints the text.

Perl 6, 60 56 bytes
say "I am a caterpillar!"; s/\S+\!/beautiful butterfly!/

Requires -p to run properly; I have accounted for this in the byte count.
Sadly one of the downsides to Perl 6 is that the syntax is much more strict now...

Caterpillars are vulnerable during metamorphosis. That's why they like to wrap themselves in c̶o̶c̶o̶o̶n̶s̶ variables: $a=caterpillar;say"I am a $a!";s/$a/beautiful butterfly/ (I'm assuming that Perl 6 allows barewords like Perl 5 with no strict 'subs' and s/// interpolates variables on the LHS.)

Huh, that's funny. I tried that and for some reason when I did wc it gave me the same amount of bytes. But upon typing it out again it gave me less bytes. Strange.

Oh wait nevermind I remember why I didn't do it. When run the new code it throws an error because of the space between beautiful and butterfly.

Ah, I've never used Perl 6 so can't help you there. I really just wanted an excuse to make a witty remark. ;) say"I am a caterpillar!";s/\S+!/beautiful butterfly!/ is shorter and will certainly work in Perl 6.

It throws the error in Perl 5 too. I think it needs quotes around it. And as for the other one, that works but I think it kinda defeats the purpose of the challenge since it replaces anything followed by ! with beautiful butterfly. The challenge says that it should only really replace your source code (Random strings should not work most of the time.)

Ah, I see what you're saying. Yes, it does need to be quoted. As for the second approach, I really doubt that more than 5% of random 53-character strings will generate compiling Perl code that also prints I am a beautiful butterfly! (say"I am a + space + 40 non-spaces + !" hardly counts as random). The code reads and modifies itself, so I don't see why it would be against the spirit of the challenge.

@ThisSuitIsBlackNot It does fit the challenge.  The rules were just there to make sure you actually read and modify your code.  In the end, the real spirit is trying to let the beautiful butterfly in the heart of the code break free.  Beauty, of course, is in the eye of the beholder.  We will each find different solutions more or less beautiful than others.  As for solutions in PERL, well... let's just say PERL has its own peculiar definition of beautiful, and it suits its purposes just fine ;-)

Retina, 53 bytes
caterpillar
beautiful butterfly
^
I am a caterpillar!

Prints out:
I am a caterpillar!beautiful butterfly
beautiful butterfly
^
I am a beautiful butterfly!

Notice that there is no separator between I am a caterpillar!  and the new program. The new program expects no input.

bash / awk / cksum - 179.2 169.6 168 bytes
awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'

Demo:
$ awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'<<'E'
> awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'
> E
I am a caterpillar!
echo|awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."10"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'
$ echo|awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."10"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'
I am a beautiful butterfly!

# Batman!
$ awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'<<'E'
> xyzawk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'
> E
I am Batman!

# Invalid input
$ awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0}'<<'E'
> awk '/^xyz/{print"I am Batman!";exit}NF{("cksum<<<'"'"'"substr($0,100))|getline r;if(r!~/^6689751/)exit}{printf"I am a %s%."!NF"s!\n",NF?"caterpillar":"beautiful"," butterfly"}NF&&sub(/!NF/,10){print"echo|"$0{'
> E

I hope the 20% applies for any string starting with xyz, otherwise the original count is 224 212 210 bytes (fixed the "I am Batman!" part).
Transformation done: replaces the only occurrence of the literal !NF with 10, so that " butterfly" is also printed using the printf.
Performs a simple cksum on a portion (i.e. the remainder) of the source code, hence its requirement as well.
Caveat: first input must end with '. Not so much a caveat as to suppress wrong input...
No second input is expected.

WHOA. I was waiting for the awk person, and that's it. That's pretty cool.

@jrg thanks for the encouragement. :)

Python - 184 bytes -20% for bonus = 147.2
""""""
import sys;c=sys.stdin.read();print"I am a caterpillar!";x=c[3:] if"\'''"!=c[:3] else c
print x+c[:3]
""";print"I am a beautiful butterfly!" """
''';print"I am Batman";'''

To print I am batman, replace the first three double quotes with single quotes in the input.(First line is '''""")

FMSLogo, 169.6 bytes
from 212 * 0.8
to f[:b]1
type[I am]type char 32 ifelse name? "b[make "b last :b
print[a caterpillar!;beautiful butterfly
](foreach[23 8 19 2][10 32 13 97][repeat ?2[ignore pop "b]repeat ?1[type pop "b]])][print[Batman!]]print "

The online logo interpreters I know of do not support every logo feature this program is using. calormen.com, for example, does not support anonymous functions. The program works on FMSLogo 8.3.2.
Luckily for readability, the newlines are either necessary or have no cost. The program, in caterpillar form, is a variadic function which defaults to 1 argument. Pass the program code to it by pasting it between the bars in f "||.
It will print "I am a caterpillar!", then splice together the output program from its own parts character by character by popping from the string. It will output this:
type[I am]type char 32 print[a beautiful butterfly!]

I should change the type char 32 part, but then the splicing code will look less epic.
In Batman form, achieved by replacing to  with ;  , thereby commenting out the function header, the Program will run when you load the file, and obviously not take input. For me, non-declarative code pasted into the edit window runs twice, but loading it as a file will still make it run once. To decide whether it is Batman, the program checks whether the input variable exists.

morsecco:  190  193 bytes
Morsecco itself ignores those boring strings without any dots or dashes, but if you provide it as input, why not use it and modify it?
I am a caterpillar!beautiful butterfly!.    .-. - - . - .-. -... -.. --.. --.- --.- -.-. -..-- - - --- -.-. --- - .. -.-. -.-.. - .-. -.-. . . . - . -.- .- -.-. .... .   -.- - ---  -.-. ... ---

.    .-. - - . - .-. to Read the own source code and stdin
-... -.. --.. --.- --.- for a Binary Diff and to Zeroskip the Quit if it's identical
-.-. -..-- - - --- Cuts the caterpillar string, keeps a copy and Outputs it
-.-. --- - .. -.-. -.-.. - .-. -.-. . gets rid of the caterpillar and sets in the butterfly
. . - . -.- .- -.-. .... Konverts from ·Text to hide the butterfly in the caterpillar
.   -.- - ---  -.-. ... --- finally Concatenates the code for butterfly Output and put this code Out.

Other languages may need to do some ASCII art now, but the output of the code (if given the correct source, otherwise silently quit) will be:
I am a caterpillar!
.   -..-..- -..... --....- --.--.- -..... --....- -..... --...-. --..-.- --....- ---.-.- ---.-.. --.-..- --..--. ---.-.- --.--.. -..... --...-. ---.-.- ---.-.. ---.-.. --..-.- ---..-. --..--. --.--.. ----..- -....-  -.- - ---

and honestly: It looks a little like crawling caterpillars anyhow! Maybe like a millipede, but you wouldn't expect this to turn into a butterfly, wouldn't you? But execute it with morsecco and be surprised about the metamorphosis!


text:
How many languages can you use simultaneously in ONE functioning program in under 500 bytes
Intro
In Objective-C (a superset of C and an object-oriented language), I can create an object called a UIWebView. There is a method for this object called loadHTMLString: in which I can load actual HTML into the UIWebView object itself. I can also inject Javascript into it using the method stringByEvaluatingJavaScriptFromString:.
If I were to write a program that created a UIWebView, loaded in my string (which happens to be HTML "code") and then injected a second string (which is Javascript code) I would be using 3 languages at once, in a functional program. (Not sure that html is really a programming language... so that's debatable haha)
You can also do things like embed Python into C (and other languages): https://docs.python.org/2/extending/embedding.html

This isn't too difficult, with any language you can use other languages inside it if you try hard enough.

Challenge
The challenge here is to see how many languages you can cram into 1 functioning program in under 500 bytes. https://mothereff.in/byte-counter
The program can do literally any task, it just has to work. The languages all have to work together, so you can't have 2 languages running one task, and 3 other languages running a completely different task. So whatever your "task" may be (you decide), there should only be 1 task, and all n languages should work on just that 1 task in your 1 program.

Objective
Your score is the number of languages you used. Whoever uses the most languages at once gets a cookie.
Since this is a popularity contest I will be accepting the answer with the most up-votes.

Q&A
•Ray asked, "Just to clarify, you're looking for a program that uses multiple languages to accomplish different parts of a single task, as opposed to a polyglot that is a valid program in multiple languages?"
Answer, "Yes".
•DanielM. asked, "does Regex count?" Answer, "Yes, I personally WOULD count it. Again, this is a popularity contest, so it really is up to the voters to determine. HTML is not considered a programming language by some, but it has been successfully used in an answer already that has seen quite a few upvotes. (Also, Stack-overflow does define Regex as a programming language if that helps you make your decision to use it or not: https://stackoverflow.com/tags/regex/info)

Just checking: I'm guessing 0 bytes isn't a valid answer? (Task: Does nothing)

I think the goal is to use a language, inside another language, etc.

Correct SuperJedi, this is not a contest for shortest task, this is a contest for most languages nested inside each other, all working to preform a single task (in under 500 bytes)

Can the task be "do nothing"? If we're trying to cram as many in as possible, it seems like any work or output would detract from the "purity" of that goal ;)

@Geobits Hahaha, I suppose that will be up to the voters, I have no problem with it ;) As long as your program doesn't crash I'll be selecting the answer with the most languages used. (Or highest score)

If you're accepting the answer with the most languages used, this is no longer a popularity contest since the winner is not determined by votes.

@AlexA. In the case I will not be selecting an answer, thank you for pointing that out, I'll add it into my post.

The point of a popularity contest is that the answer with the most votes gets accepted. Challenges here need an objective winning criterion to be on topic.

Just to clarify, you're looking for a program that uses multiple languages to accomplish different parts of a single task, as opposed to a polyglot that is a valid program in multiple languages?

@Ray Exactly!!!

@AlexA. Edited it in, thank you!

How would a Sacred {lang} do here? Sacred. Can I just have a Sacred ... Sacred?

I've got a cool answer in the works, but I may have a hard time getting it down to 500 bytes...

Does regex count?

@DanielM. According to S/O Regex is a type of programming language. http://stackoverflow.com/tags/regex/info — I would personally count it, but again, it will most likely be up to the voters to decide ;) Regex def. qualifies more than HTML and HTML has already been successfully used and counted in an answer.

make, sh, awk, sed, regex, yacc, lex, C; 8 languages.
Including the input and output languages: brainfuck and D; 10 languages
This is a brainfuck to D compiler.  It takes the brainfuck program over standard input and prints the D code to standard output.
Make uses awk, sed, and sh to generate a yacc program, which in conjunction
with a lex program is used to generate a C program that takes a brainfuck
program as input and outputs an equivalent D program.  I tried to only use languages in ways that were actually useful, instead of just throwing in a bunch of no-ops.  The lex/yacc/C combination is fairly standard for simple compilers, the make/sh combination is useful for building, and the awk/sed line was the only way I could get the whole thing under 500 bytes. (It's at 498 bytes currently.)
Code
define L
%%
[][+-<>.,] return *yytext;
. ;
%%
endef
define Y
%{
#include <stdio.h>
%}
%left '+' '-' '.' ',' '>' '<' '[' ']'
%%
q: q q {}
+ p[i]++
- p[i]--
> i++
y;lex y;echo "$$Y"|awk '/^[+-^]/{printf("q: X%sX {puts(\"%s;\");}\n",$$1,$$2)} /^[^+-^]/'|sed "y/X/'/">y;yacc y;cc *.c;./a.out;:

Example of use
$ cat helloworld.bf
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
$ make < helloworld.bf > tmp.d
y: warning: 8 shift/reduce conflicts [-Wconflicts-sr]
$ dmd tmp.d && ./tmp
Hello World!

Wow haha! I'd count the input language if I were you haha! Processing it is really neat, creative solution to sneak an extra language in

Well, I think this answer is easily the best answer, but my question was put on hold and activity dropped, and since it's a "popularity contest" I have to chose the answer with the most votes, even though I think if it wasn't put [on hold] this would have easily been the first place answer. Sorry /:

make, awk and sed can all be easily executed by sh, regex can be easily parsed by sed. So, -1.

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I agree with you on the regex, but the OP explicitly stated that regex should be counted, so I did.  I'm not sure I understand what you mean about make, awk, and sed being easily executed by sh.  I do call sed and awk from sh, although it's make that calls sh, not the other way around.  That said, sh was mainly needed for the I/O redirection and echo command. awk was needed for the input tokenization and regex, and sed was needed for the transliteration.  There were other ways to do all that, but not easily under 500 characters. (Besides, the point was to use many languages)

@Ray But you listed "sed" and "regex" separately, so I count them as one. Yet, you can say "make, dash, coreutils, yacc, lex".

Realized I could just remove my vote from the other answer thus making it a tie and I can select this as tie breaker since it's clearly the best answer. Loophole!

@AlbertRenshaw wow ok....

HTML, CSS, PHP, JavaScript, CoffeeScript, RegEx, sed, bash; 8 languages
Displays colors of the rainbow.
(Only 396 bytes) will try to add more languages
HTML + CSS is turning complete and counts as a valid language on PPCG. I've been told CoffeeScript is different enough as JavaScript to be counted as a separate language. And RegEx has been specifically allowed also.
PHP allows for addition of many languages especially with exec and shell_exec functions.
Golfed to fit inside byte limit (ES6)

Uses:

PHP to generate CSS
PHP, uses exec to run bash
sed to split color items for bash
CSS to specify text colors
JavaScript to generate elements
RegEx to split color items for JS
CoffeScript to print elements
HTML as a wrapper / output

Faster & Ungolfed (All modern browsers)

Very nice seamless combination of the languages at hand

I sense a serious lack of XSLT. And the XPath that comes with it.

@Édouard I've tried to implement that but it's difficult implementing that in under 100 bytes. JavaScript doesn't have very consise XSLT but I'm working on it

What do you mean “JS doesn’t have concise XSLT”? Are you trying to use JS to apply your transformation?


text:
Graph Florets of a Flower
Take a look at this chamomile flower:

Pretty, isn't it? Well, what if I told you that this wasn't actually one flower?
A lot of flowers (including sunflowers, chamomiles, daisies and others) actually consist of many very small flowers (the black dots on sunflowers) on a flower head. These miniature flowers are called florets, and they are arranged in a very special way.
Basically, the nth floret's position on a flower head is (in polar coordinates):

where c = 1 (Note that 137.508 degrees = golden angle. You don't have to use this exact precision.)
This causes the florets to be formed in a spiral called Fermat's Spiral. The positioning of the florets also is connected with Fibonnaci numbers, but that's a tale for another time.
So, here's the challenge. Given an integer n as input, calculate the positions of the first n florets and plot them. This is graphical-output, so I do actually want you to display the points in either a window of some sort or outputted as data in some common image format to STDOUT or a file. Other than that, this challenge should be fairly straightforward. It's code-golf, so shortest code wins. GLHF!
Here is a sample picture of what an output might look like:

Are we allowed to draw the spiral upside down?

FWIW many fruits display this pattern, such as the pineapple, agauje, and pinecone. This should not be surprising since fruits develop from flowers. Interestingly some cactus bodies also display this pattern. My favorite is the fractal Romanesco broccoli: https://en.wikipedia.org/wiki/Romanesco_broccoli#/media/File:Romanesco_broccoli_%283%29.jpg

That's cool! I've seen Romanesco broccoli before; I think it's really cool how they have that fractal pattern. Maybe I could make a challenge about that...

TI-BASIC, 34 bytes
For the TI-83+/84+ series of calculators.
Input N
2πe^(-2sinh⁻¹(.5→θstep
AnsN→θmax
"√(θ→r₁
Polar                      ;Displays polar mode graphs to graph screen
Dot                        ;Prevents lines from connecting points
DispGraph                  ;Displays graph screen

This considers the dot at the origin to be the 0th dot.
Thanks to the one-byte sinh⁻¹( token, 2πe^(-2sinh⁻¹(.5 is a short way of getting the golden angle in radians. This is derived from the fact that e^(sinh⁻¹(.5 is the golden ratio.
Here are screenshots for N=50.
(Yes, that's a 96x64 monochrome display on a TI-84+. The newer color calculators have a resolution upgrade, but still have only 3.7% the pixels of an iPhone.)

Press TRACE to step through each point.

TI-BASIC is a natural choice for polar coordinates.

How did you determine the number of bytes? Looks like a lot more than 34.  A pre-programmed key, as sinh⁻¹ appears to be (if I understood your explanation), would count as more than one byte.

@DavidCarraher TI-BASIC is tokenized; all of these tokens are one byte each in the calculator's memory.

You can determine the number of bytes in a program by going to Mem (2nd->+)->7. You will then see a list of all programs on your calculator and the number of bytes they take up. Note that all TI-BASIC programs have a 9 byte header + the number of bytes in the name, so be sure to subtract those to get the proper byte count.

Syntax error on -2sinh^-1

Python 2, 85 82 81 bytes
from pylab import*
for i in arange(0,input(),2.39996):polar(i,sqrt(i),'o')
show()

Shortened by one byte by marinus.
Using the golden angle in radians. Byte length is the same if I used 137.508 instead, but somehow doesn't look as good. Generates a polar plot using pylab. Below is when 300 (for the older version) is the input and 7000 (for the newer version) is the input. Could round the angle up to 2.4 to lower the number of bytes to 77.

Here's a longer version that produces a cleaner look by removing the grid and axis:
from pylab import *
def florets(n):
    for i in arange(0, n, 2.39996):polar(i, sqrt(i), 'o')
    grid(0)#turn off grid
    xticks([])#turn off angle axis
    yticks([])#turn off radius axis
    show()

The reason for the different colors is because each point is plotted separately and treated as its own set of data. If the angles and radii were passed as lists, then they would be treated as one set and be of one color.

I think this is the prettiest answer by far. It's very cool to see the clear spiral patterns in the center.

You could save a byte by using a normal for loop instead of a list comprehension. It'd have to be on its own line, but ; and \n are the same length, so that doesn't matter. I.e.: from pylab import* - for i in arange(0,input(),2.39996):polar(i,sqrt(i),'o') - show()

@marinus but then its no longer a supercool one liner! But thanks, I've added it in.

Blitz 2D/3D, 102 bytes
(The very FIRST EVER Blitz 2D/3D answer on this site!)
Graphics 180,180
Origin 90,90
n=Input()
For i=1To n
t#=i*137.508
r#=Sqr(t)
Plot r*Cos(t),r*Sin(t)
Next

An input of 50 fills the window. (Yes, I could shave off two bytes by doing Graphics 99,99, but that's not nearly so visually interesting or useful.)

Prettier version (and exits more nicely):
Graphics 400,400
Origin 200,200

n=Input("How many florets? ")

For i = 1 To n
    t# = i * 137.508
    r# = Sqr(t)

    Oval r*Cos(t)-3,r*Sin(t)-3,7,7,1
Next

WaitKey
End

hey, neat! i didn't know about blitz before reading this.

Wow, Blitz3D was my first language some 15 years ago :D... sigh.. :'(

Degrees as the default? "Interesting"...

@ThomasKwa: I know! And sin and cos assume that the argument is in degrees. Definitely gave me trouble in the (distant) past, but I've gotten pretty used to it.

@noncom: It was the first language that I really made significant programs in. Eight years ago. It's still one of my top two best languages today (the other being Python).

@noncom, It was my first language too. I wonder how I'd feel using it professionally now.

@JamesWebster: Using it professionally would be hard because it's lacking multiple features (like local arrays) that make it significantly less powerful. Despite this, one of my largest projects yet (ArbyChess, a chess engine) is written in Blitz 2D because graphics and interactivity is hard with Python. Go figure.

Mathematica, 43 42 bytes
ListPolarPlot@Array[(2.39996#)^{1,.5}&,#]&

This is an unnamed function taking an integer argument, e.g.

The screenshot uses an older version, but the output looks the same.
Mathematica actually has a built-in GoldenAngle for even more accurate results, but that's longer than 2.39996.

GoldenAngle! Is it a new function in Mathematica 10.2?

@alephalpha Yep.

MATLAB, 42 bytes
t=2.39996*(1:input(''));polar(t,t.^.5,'.')

Gets the input number, creates a range from 1 to that number.
Multiplies the range by the golden angle in radians (the value used is closer to the true value than 137.508 degrees to 6 s.f.).
Then simply plots theta vs. r on a polar coordinates chart using dots. Here shown with 2000 points

A slightly prettier looking graph (no grid lines) would be this code:
t=2.39996*(1:input(''));[x,y]=pol2cart(t,t.^.5);plot(x,y,'.');axis equal

Though that is at the expense of 31 bytes. Again here is it shown with 2000 points

I like the polar solution, I've never used that one before. I think you can save two bytes by using t.^.5 instad of sqrt(t)!

@flawr Thanks. Two bytes indeed saved.

R, 58 55 54 bytes
x=2.39996*1:scan();plotrix::radial.plot(x^.5,x,rp="s")

This requires the plotrix package to be installed, but the package doesn't have to be imported because we're referencing the namespace explicitly.
Ungolfed:
# Read a number of STDIN
n <- scan()

x <- 2.39996*(1:n)

# The rp.type = "s" option specifies that we want to plot points rather
# than lines (the default)
plotrix::radial.plot(lengths = sqrt(x), radial.pos = x, rp.type = "s")

Example output for n = 1500:

Saved 3 bytes thanks to plannapus!

R, 55 54 bytes
t=1:scan()*2.39996;r=t^.5;plot(r*cos(t),r*sin(t),as=1)

Here is the result for n=1000:

Edit: Saved 1 byte using partial matching of arguments (as instead of asp) thanks to @AlexA.!

R, 48 47 bytes
I think this is sufficiently different from the other R solutions so far.  This one uses complex vectors to construct the coordinates.  the sqrt of t and t are put into the modulus and argument parameters and the x, y are taking from the real and imaginary.
Thanks to @AlexA. for the byte.
plot(complex(,,,t^.5,t<-1:scan()*2.39996),as=1)

Not only is it different, it's shorter! +1.

You can save a byte using partial matching of function parameters: as can be used in place of asp.

@AlexA.  Thanks Alex, I keep forgetting to test those ones :)

Html+JavaScript 179

<canvas id=C></canvas><script>n=1500,C.width=C.height=400,T=C.getContext('2d');for(n=prompt(M=Math);n--;)r=M.sqrt(t=n*2.4)*9,T.fillRect(M.cos(t)*r+200,M.sin(t)*r+200,2,2)</script>

Jolf, 25 bytes
yG@@KyoΜzXDyOUH*Hm°yT'.}

(output for n = 5000)
Try it online. (note that the resulting spiral is small)
Non-competing since Jolf was created after this challenge. This is 25 bytes when encoded with ISO-8859-7, and it contains one unprintable (here's a hexdump):
0000000: 7947 4096 404b 796f cc7a 5844 794f 5548  yG@.@Kyo.zXDyOUH
0000010: 2a48 6db0 7954 272e 7d                   *Hm.yT'.}

Explanation
yG@@KyoΜzXDyOUH*Hm°yT'.}
yG@@K                      goto (150,75) (center of the canvas)
     yo                    set current location as the origin
       MzX                 map over range 1...input
          D                start of function
           yO              goto polar coordinates ....
             UH            radius: square root of argument
               *Hm°        angle: argument times golden angle
                   yT'.    draw a dot there
                       }

Well. I think I'll have to look into Jolf now, despite the strange encoding.

K (oK) + iKe, 37 bytes
{(80+(%t)*(cos;sin)@\:t:x*2.4;;1)}'!:

Try it online!
a function which takes n on the right. Uses the approximate 2.4 radian measure.
-8 bytes from JohnE.
Explanation
{draw::{(80+(%t)*(cos;sin)@\:t:x*2.4;;1)}'!x}
 draw::                                       globally set draw to:
       {                                }     the following function
                                         '!x  run on range 0..input-1
        (                              )      create an array:
                             t:x*2.4          multiply right arg by 2.4, set to t
                 (cos;sin)@\:                 apply cos and sin on each
            (%t)*                             multiply by sqrt(t)
         80+                                  add 80 (for compatibility with any size, change to ((w;h)%2)+)

Python 2, 74 bytes
from pylab import*
i=arange(1,input(),2.39996)
polar(i,sqrt(i),'o')
show()

MATL, 20 bytes
:2.4*tX^wJ*Ze*'.'&XG

Try it at MATL Online!
The golden angle, 137.708deg = pi*(3-sqrt(5))rad = 2.39996...rad is approximated as 2.4rad.
The following version (25 bytes) uses the exact value, up to double floating-point precision:
:YPI5X^-**tX^wJ*Ze*'.'&XG

Try it at MATL Online!

Tcl/Tk, 114
grid [canvas .c]
proc P n {time {incr i
.c cr o [lmap h {cos sin cos sin} {expr sqrt($i*2.4)*$h\($i*2.4)+99}]} $n}

Example of usage:
P 1024

and outputs the window


text:
QWERTY keyboard string length
QWERTY keyboard distance (QKD) is, in short, the distance between two letters/numbers/punctuation keys on a standard QWERTY keyboard (if you don't have one around, you can check this Wikipedia picture). Note that only characters without modifiers be considered for this challenge  (so ; is valid, but ) is not).
Some examples:
>> QKD("a","s")
 1
>> QKD("e","f")
 2
>> QKD("g",".")
 5

In this code-golf challenge you will have to compute the QWERTY string length (QSL), which is the sum of the QWERTY keyboard distances between every two consecutive characters of a given string. E.g. QSL("abcd") = QKD("a", "b") + QKD("b", "c") + QKD("c", "d")
Examples:
>> QSL("code-golf")
 37 // QKD(c,o) + QKD(o,d) + QKD(d,e) + .. = 6  +  6 + 1 + 8 + 6 + 4 + 1 + 5 = 37
>> QSL("puzzles")
 25 // 3 + 6 + 0 + 8 + 7 + 1
>> QSL("stackexchange")
 43 // 3 + 4 + 3 + 5 + 6 + 2 + 1 + 3 + 5 + 6 + 2 + 3

Some notes:

You have to support at least a-z, 0-9, =[];'\,./ ` and Space.
When you aren't sure about the distance between two characters, refer to the Wikipedia picture.
Standard loopholes are disallowed, as usual (you knew that, didn't you?).
This is code-golf, thus shortest code wins.

@TimmyD Hm... looks similar, but the distance metric is different :)

This may not be exactly the same, but it is very similar to the duplicate. This question doesn't really add much that the other one doesn't have.

Ok, no problem...

You may not have been aware of this, but on Meta there is a Sandbox where you can post challenges that you'd like to post on the main site and get feedback, including any [almost]-duplicates or requests for clarification, perceived problems pointed out, that sort of thing. It really helps to sandbox your challenges first.

@El'endiaStarman I'm aware of it.... Just didn't think about it before posting :D


text:
Sums of digits 1 through 7
Challenge
Given a positive integer N that is 28 or above, output a list of numbers summing to N that uses each digit 1 through 7 exactly once. You can give as a program or function.
The digits can appear by themselves or concatenated, as long as you use each of them once without repeats. For example,[12, 34, 56, 7] is valid, as is [1, 27, 6, 4, 35] and [1234, 567], but not [123, 34567] or [3, 2, 1476]. The order that the numbers are listed does not matter.
If N cannot be made with 1-7, return or output nothing.
Other information

This is code golf, so the shortest code in bytes by Thursday the 15th of October wins.

Ask any questions in the comments.

Anything I do not specify in the challenge is up to you.

Standard loopholes are disallowed.

Examples
These may clear any confusion up:
Input
28

Output
[1, 2, 3, 4, 5, 6, 7]

Input
100

Output
[56, 7, 4, 31, 2]

Input
1234567

Output
[1234567]

Input
29

Output
Nothing, 29 is invalid.
Input
1891

Output
[1234, 657]

Input
370

Output
[15, 342, 7, 6]

I'll make more if needed.
Here's a pastebin of all of the possible numbers created with these seven numbers, courtesy of FryAmTheEggman.

What's the output for 29?

@Geobits That's impossible, so nothing.

If you want the output to be nothing, don't put (N/A) as the output.

@mbomb007 Fixed.

why would 1234567 result in [1234567] ? You can have less than 7 numbers like f.e. [1234566, 1] ?

@LukStorms The object is to use each digit 1-7 exactly once.

@LukStorms [1234566, 1] is not a valid output, because 6 is repeated. You may not repeat numbers in the output.

Ok, I'm guessing most solutions will have to resort to a brute force method for this one.

Maybe »... a list of numbers made from the decimal digits 1 to 7 which sum up to N« is a clearer wording than the one currently in the question.

For a slightly less brute force solution: This is equivalent to assigning a power-of-10 coefficient to each of 1, ..,, 7 so that there's at least as many 1's as 10's, at least as many 10's as 100's, and so on.

Pyth, 18 14 bytes
hfqSjkTjkS7./Q

Thanks to @isaacg for golfing off 2 bytes and paving the way for 2 more.
The code will crash if it should produce no output, which causes no output to be produced.
This will work for small-ish inputs if you're patient enough, and for larger ones if given enough time and memory.
To verify that the code works as intended, you can replace the 7 with a 3 for sums of digits 1 through 3. Click here for a test suite.
Example runs
$ time pyth/pyth.py -c 'hfqSjkTjkS7./Q' <<< 28
(1, 2, 3, 4, 5, 6, 7)

real    4m34.634s
user    4m34.751s
sys     0m0.101s
$ time pyth/pyth.py -c 'hfqSjkTjkS7./Q' <<< 29 2>/dev/null

real    9m5.819s
user    9m6.069s
sys     0m0.093s

How it works
           ./Q    Compute all integer partitions of the input.
 f                Filter the integer partitions:
    jkT             Join the integers with empty separator.
   S                Sort the characters of the resulting string.
      jkS7          Join [1, ..., 7] with empty separator.
  q                 Check both results for equality.
                  Keep the partition of `q' returned True.
h                 Retrieve the first element of the filtered list.
                  For a non-empty list, this retrieves the solution.
                  For the empty list, it causes an error and produces no output.

Well done! Quite an innovative approach. ```MS7`` is shorter than r\1\8. Also @ .. 0 is the same as h.

@isaacg Thanks! I'm not sure how I missed h, but I had no idea you could use S that way. (The char reference in the online interpreter doesn't mention it.) jkS7 seems to be even shorter, since I don't need s anymore.

Python 3, 109
def f(n,s=set('1234567'),l='0,'):[f(n,s-{x},l+x+c)for c in(',','')for x in s]or n-sum(eval(l))or~print(l[2:])

A function that takes a number and outputs a tuple in the like 123,4567,. Yes, this is a valid tuple.
The idea is to generate all possible strings like 43,126,7,5, that have the digits 1 through 7 separated by commas, with no two commas consecutive. Evaluate this expression as a tuple, and its sum equals n, print it and terminate with error.
To build all such strings, we track the set s of chars to use, and try appenping each one either with a comma, which makes the digit end the entry, or without, in which case future digits will concatenate onto it.
Short-circuiting is used to check that s is empty because the list-comp is empty, and that n==sum(eval(l)), in which case we print l and terminate with an error by taking ~ of the None returned by printing (thanks to Sp3000 for this.).
I believe that in Python 3.5, two chars can be saved by writing s={*'1234567'} (thanks Sp3000).
There's some small annoyances that eat up chars. One is that in the case that l looking like 1234567 with no commas, it is parsed as a single number and calling sum gives an error. This is handled with the hack of starting l with the element 0 and stripping it when printing. This costs 6 chars.
Iterating c over the comma and the empty string is annoyingly wordy for c in(',',''), since Python 3 doesn't allow this tuple to be naked. I'd like there to be some char ? that is ignored in numbers to do ',?' for 4 chars less, but there doesn't seem to be such a char.

Old method:
Python 2, 117
def f(n,s={1,2,3,4,5,6,7},l=[],p=0):
 if{n,p}|s=={0}:print l;1/0
 if p:f(n-p,s,l+[p])
 for x in s:f(n,s-{x},l,p*10+x)

Defines a function that takes a number and prints a list.
The idea is to use recursion to try every branch. The variables track are

The remaining sum n needed
The set of digits s remaining to use
The list l of numbers made so far
The current partially-formed number p

When n==0 and s is empty, print l and terminate by error.
If the current partially-formed number p is non-zero, try adding it to the list and removing it from the remaining sum.
For each digit x we can use from s, try appending it to p and removing it from s.

Pyth, 23
#iRThfqQsiR10Ts./M.pS7q

Naive brute force, too slow online, takes about a minute on my computer. Uses the common "loop forever until exception" pattern of pyth golfs where accessing the resulted filtered list of combinations causes an error for impossible numbers, like 29.
Outputs like a pythonic list, e.g.
1891
[1234, 657]
100
[1, 2, 34, 56, 7]
370
[12, 345, 6, 7]

Here is a paste of all of the 10136 numbers that can be made this way.

May I use the pastebin link for examples?

@The_Basset_Hound Of course, go ahead.

JavaScript (ES6), 165 196
Edit Shortened a little. Could be shorter using eval, but I like it being fast
Brute force, shamefully longer than Pith version, but faster. Test running the snippet below in an EcmaScript 6 compliant browser.

f=z=>{for(r=i=1e6;r&&++i<8e6;)for(m=/(.).*\1|[089]/.test(w=i+'')?0:64;r&&m--;t.split`+`.map(v=>r-=v,r=z))for(t=w[j=0],l=1;d=w[++j];l+=l)t+=l&m?'+'+d:d;return r?'':t}

function test() { O.innerHTML=f(+I.value) }

test()

// Less golfed

f=z=>{
  for(r=i=1e6; r&&++i<8e6;)
    for(m=/(.).*\1|[089]/.test(w=i+'')?0:64; r&&m--; t.split`+`.map(v=>r-=v,r=z))
      for(t=w[j=0],l=1;d=w[++j];l+=l)
        t+=l&m?'+'+d:d;
  return r?'':t
}
<input id=I value=28><button onclick=test()>-></button>

No shame to be longer because of language, I really enjoy your JS answers, +1

Python 2.7, 178 172 169 bytes
n=input()
for i in range(8**7):
 for j in len(set('%o0'%i))/8*range(128):
    s=''
    for c in'%o'%i:s+='+'[:j%2*len(s)]+c;j/=2
    if eval(s)==n:print map(int,s.split('+'));1/0

Note that the last three lines are supposed to be indented with tabs but I
can't figure out how to do so in this editor.
Edit: Flattened one layer of nesting with the help of Sp3000

SE strips out tabs unfortunately, so just saying how it's meant to be indented is fine :)

Ah okay, still figuring my way around this site.

Python 2, 270 268 bytes
from itertools import*;P=permutations
x,d,f=range(1,8),[],input()
r=sum([[int(''.join(str(n)for n in i))for i in list(P(x,j))]for j in x],[])
z=1
while z:
 t=sum([[list(j)for j in P(r,z)]for i in x],[])
 v=filter(lambda i:sum(i)==f,t)
 if v:print v[0];break
 else:z+=1

Still working on golfing.
This loops until a match is found.

import as is rarely necessary - you can do from itertools import*;P=permutations

It's shorter to use map(str,i) than the list comprehension, and you can construct the list r directly rather than by flattening a nested list: r=[int(''.join(map(str,i)))for j in x for i in P(x,j)], and a similar thing for t.

You can use \n`instead ofstr(n), since n` will never be above the maximum integer.

Haskell (145 bytes)
main=getLine>>=print.head.f[1..7].read
f[]0=[[]]
f b s=[n:j|(n,g)<-m b,j<-f g$s-n]
m b=[(d+10*z,g)|d<-b,(z,g)<-(0,filter(/=d)b):m(filter(/=d)b)]

Uses recursion.
Ungolfed (337 bytes):
delete d = filter (/= d)
main = getLine >>= print . (`form` [1..7]) . read

form s [] | s == 0    = [[]]
form s ds | s <= 0    = []
form s ds | otherwise = [n:ns | (n, ds') <- makeNumbers ds, ns <- form (s-n) ds']

makeNumbers [] = []
makeNumbers ds  = [(d + 10 * n',ds') | d <- ds, (n',ds') <- (0,delete d ds):makeNumbers (delete d ds)]

Jelly, 12 bytes
ŒṗDẎṢ⁼ʋƇ7R¤Ḣ

Try it online!
Times out for pretty much all inputs. Outputs 0 if no such list exists. Requiring empty output adds 3 bytes.
This is a 14 byte (17 for empty output) answer which has a more or less constant runtime (~40 seconds).
How they work
ŒṗDẎṢ⁼ʋƇ7R¤Ḣ - Main link. Takes n on the left
Œṗ           - Integer partitions of n
      ʋƇ     - Keep those for which the following is true:
  D          -   Convert to digits
   Ẏ         -   Flatten
    Ṣ        -   Sorted
     ⁼  7R¤  -   Equals [1, 2, 3, 4, 5, 6, 7]
           Ḣ - Take the first list

The 14 byte version:
7Œ!ŒṖ€ẎḌS=¥Ƈ⁸Ḣ - Main link. Takes n on the left
7              - Yield 7
 Œ!            - Get all permutations of [1, 2, 3, 4, 5, 6, 7]
     €         - Over each:
   ŒṖ          - Yield it's partitions
      Ẏ        - Flatten to a single list of all partitions
       Ḍ       - Convert from digits
          ¥Ƈ   - Keep those for which the following is true:
        S      -   Sum
         =  ⁸  -   Equals n
             Ḣ - Take the first list

Scala, 195 bytes
This isn't the most efficient and it took over 15 minutes to get the output for 29 but it works
def g(s: Seq[Int]): Iterator[Seq[Int]]=s.combinations(2).map(c=>g(c.mkString.toInt +: s.filterNot(c.contains))).flatten ++ Seq(s)
def f(i: Int)=(1 to 7).permutations.map(g).flatten.find(_.sum==i)

Here is some output
scala> f(100)
res2: Option[Seq[Int]] = Some(Vector(46, 35, 12, 7))

scala> f(1891)
res3: Option[Seq[Int]] = Some(Vector(567, 1324))

scala> f(370)
res4: Option[Seq[Int]] = Some(Vector(345, 12, 6, 7))

scala> f(29)
res5: Option[Seq[Int]] = None

Ruby, 105 bytes
Brute force! Checks every subset of lengths between 0 and 7 of the integers between 1 and 7654321 and sees if any of them matches our criteria. You probably don't want to wait for this to terminate.
->n{8.times{|i|[*1..7654321].permutation(i){|x|return x if
x.join.chars.sort==[*?1..?7]&&eval(x*?+)==n}}}

To run and verify the algorithm you can narrow down the search space by replacing 7654321 with the largest number you know will be in the answer. For instance, 56 for n=100, or 1234 for n=1891. Here's a trial run of the latter:
$ ruby -e "p ->n{8.times{|i|[*1..1234].permutation(i){|x|return x if x.join.chars.sort==[*?1..?7]&&eval(x*?+)==n}}}[gets.to_i]" <<< 1891
[657, 1234]

0 to 7 integers? You should use exaclty 7 integers: 1,2,3,4,5,6,7

@edc65 You mean exactly 7 digits. The result is a set of integers, and the size of the set depends on the input.

I don't speak Ruby, I presume the program works, but I don't get the explanation. If your integers are less than 1234567, how do you get 7654321?

@edc65 You're right, I'll have to change that number. I'll try to explain it better too.

Husk, 15 bytes
ḟȯ=ḣ7Oṁdfo=¹ΣṖḣ

Try it online!