text:
Simple Tag Parser
This is a model of a forgiving HTML parser. Instead of parsing HTML and extracting attributes, in this code golf, the tag parser will be simple.
Write a function that parses a tag structure and returns its parenthized form.
An opening tag consists of one lowercase letter, and a closing tag consists of one uppercase letter. For example, aAbaAB parses into (a)(b(a)), or in HTML, .
Of course, tags can be in juxtaposition and nest.
"Prematurely" closed tags must be handled. For example, in abcA, the A closes the outermost a, so it parses into (a(b(c))).
Extra closing tags are simply ignored: aAB parses into (a).
Overlapping tags are NOT handled. For example, abAB parses into (a(b)), not (a(b))(b), by the previous rule of extra closing tags (abAB -> abA ((a(b))) + B (extra)).
Assuming no whitespaces and other illegal characters in the input.
You are not allowed to use any library.
Here is a reference implementation and a list of test cases:
#!/usr/bin/python

def pars(inpu):
  outp = ""
  stac = []
  i = 0
  for x in inpu:
    lowr = x.lower()
    if x == lowr:
      stac.append(x)
      outp += "(" + x
      i = i + 1
    else:
      while len(stac) > 1 and stac[len(stac) - 1] != lowr:
        outp += ")"
        stac.pop()
        i = i - 1
      if len(stac) > 0:
        outp += ")"
        stac.pop()
        i = i - 1
  outp += ")" * i
  return outp

tests = [
  ("aAaAbB", "(a)(a)(b)"),
  ("abBcdDCA", "(a(b)(c(d)))"),
  ("bisSsIB", "(b(i(s)(s)))"),
  ("aAabc", "(a)(a(b(c)))"),
  ("abcdDA", "(a(b(c(d))))"),
  ("abcAaA", "(a(b(c)))(a)"),
  ("acAC", "(a(c))"),
  ("ABCDEFG", ""),
  ("AbcBCabA", "(b(c))(a(b))")
]

for case, expe in tests:
  actu = pars(case)
  print "%s: C: [%s] E: [%s] A: [%s]" % (["FAIL", "PASS"][expe == actu], case, expe, actu)

Shortest code wins.

like any other code golfs, standard library allowed

no limit on length nor nesting level

You should add a test case for input that leads with a closing tag, such as AbcBCabA (should parse as (b(c))(a(b)). My code could have been shorter except for this case.

Golfscript, 54 chars
{[]:|\{.96>{.|+:|;40\}{32+|?).')'*\|>:|;}if}%|,')'*}:$

Tests
;["aAaAbB" "abBcdDCA" "bisSsIB" "aAabc" "abcdDA" "abcAaA" "acAC" "aAB" "abAB" "AbcBCabA"]{.' '\$n}%

aAaAbBaAaAbB (a)(a)(b)
abBcdDCA (a(b)(c(d)))
bisSsIB (b(i(s)(s)))
aAabc (a)(a(b(c)))
abcdDA (a(b(c(d))))
abcAaA (a(b(c)))(a)
acAC (a(c))
aAB (a)
abAB (a(b))
AbcBCabA (b(c))(a(b))

Haskell, 111 characters
s@(d:z)§c|c>'^'=toEnum(fromEnum c-32):s++'(':[c]|d<'='=s|d==c=z++")"|1<3=(z++")")§c
p=tail.foldl(§)"$".(++"$")

This one's pretty golf'd for Haskell. Fun feature: The stack and the accumulating output are kept in the same string!
Test cases:
> runTests
Pass: aAbaAB parsed correctly as (a)(b(a))
Pass: abcA parsed correctly as (a(b(c)))
Pass: aAB parsed correctly as (a)
Pass: abAB parsed correctly as (a(b))
Pass: aAaAbB parsed correctly as (a)(a)(b)
Pass: abBcdDCA parsed correctly as (a(b)(c(d)))
Pass: bisSsIB parsed correctly as (b(i(s)(s)))
Pass: aAabc parsed correctly as (a)(a(b(c)))
Pass: abcdDA parsed correctly as (a(b(c(d))))
Pass: abcAaA parsed correctly as (a(b(c)))(a)
Pass: acAC parsed correctly as (a(c))
Pass: AbcBCabA parsed correctly as (b(c))(a(b))

Edit: (113 → 111) used an @ pattern as suggested by FUZxxl

Using an @-pattern for d:z might save two chars.

Z80 Machine Code for TI-83+, 41 bytes
This is an implementation in hexadecimal machine code for a z80 cpu running on a TI-83+.
11XXXX131AFE61380F6FE53E28CD9DB47DCD9DB4188EE1BDC03E29CD9DB4189BEF4504E5214CE1C9
The XXXX (3 - 6 inclusive) is the 16-bit address of the string you are parsing, minus 1 byte.
Encoded in Z80-ASCII:
¹XX≤¯•⟙8o↥>(ˣïÑ}ˣïÑ≠á↑γ∊>)ˣïÑ≠Ì⬆E↥!₄L↑Φ
(Approximate, because TI calculators have their own character set.)
NOTE THAT THE AsmPrgm IS NOT INCLUDED IN THE ABOVE

Windows PowerShell, 142 146 147 152 156 169
{$s=''
-join([char[]]"$args "|%{if(90-ge$_){')'*(($x=$s.indexOf("$_".ToLower())+1)+$s.Length*!$x)
$s=$s.substring($x)}else{"($_"
$s="$_$s"}})}

Some things to note: This is just a script block. It can be assigned to a variable or given a function name, if necessary. You can also run it by putting . or & in front of it and the arguments at the end. Uses a final space to terminate unclosed tags.
Passes all tests. Test script:
$tests = ("aAaAbB","(a)(a)(b)"),("abBcdDCA","(a(b)(c(d)))"),("bisSsIB","(b(i(s)(s)))"),("aAabc","(a)(a(b(c)))"),("abcdDA","(a(b(c(d))))"),("abcAaA", "(a(b(c)))(a)"),("acAC","(a(c))")
"function f " + ((gc ./tags.ps1)-join"`n") | iex
$tests | %{
    $result = f $_[0]
    ("FAIL: $($_[0]):$($_[1]) - $result", 'PASS')[$result -ceq $_[1]]
}

Python - 114 113 153 192 174 159  characters
from sys import *
s="";c=a=argv[1]
for f in a:
 o=c.find;p=f.lower
 if '@'<f<'\\':
\td=o(f)-o(p())
\ts+=")"*d
\tc=(c[:o(p())]+c[o(f)+1:])
 else:s+=("("+f)
print s

Abuses python's indentation parser to use one space for a full tab, five for two tabs.
Edit 1 - saved an unneeded space in the range() function
Edit 2 - fixed to deal with improper parse grammars, unterminated tags.
Edit 3 - fixed a bug whereby "incorrect" parses could be generated by ambiguity in the tag tree. Implemented a stack-based strategy, rather than a counter.
Edit 4 - renamed s.find to o to prevent save the chars used to repeatedly call it. did the same for f.lower.
Edit 5 - added the space/tab hack, saving three chars.
Edit 6 - ditched the loop in favor of ")"*d.

instead of ord(f)... you can use '@'<f<'\\' If you don't need to check for '\\' you can use ']' instead

you can use a single tab instead of 5 spaces. SO code markup can't handle it though :(. In your case just put leave out the newline and the spaces altogether. eg if ...:s+=")";c-=1 and else:s+="("+f;c+=1

for i in range(d):s+=")" can be rewritten as s+=")"*d. And you have 174 chars.

@cemper - good point that. I do "_"*80 all day long and forget about it when golfing.... Also, thanks to @gnibbler for the suggestions!

Actually, I meant that you had had 174 chars before. So you are at 159 now.

@cemper93 - good catch, thanks! Proving that I cannot, in fact read.


text:
Generate Newton fractals
You all know the Newton method to approximate the roots of a function, don't you? My goal in this task is to introduce you into an interesting aspect of this algorithm.
Newton's algorithm converges only for certain, but most of all complex input values. If you picture the convergence of  the method for all input values over the complex plane, you usually get a beautiful fractal like this:
 Image from Wikimedia commons
Specifications
The goal of this task is, to generate such fractals. This means, that you get a polynomial as the input and have to print out the corresponding fractal as an image in a format of your choice as the output.
Input
The input is a whitespace-separated list of complex numbers. They are written down in the style <Real part><iImaginary part>, like this number: 5.32i3.05. You may assume, that the input number has no more than 4 decimal places and is smaller than 1000. The first of them must not be zero. For example, this could be an input to your program:
1 -2i7.5 23.0004i-3.8 i12 0 5.1233i0.1
The numbers are interpreted as the coefficients of a polynomial, beginning with the highest power. Throughout the rest of this specification, the input polynomial is called P. The above input is equal to this polynomial:
f(x) = x5 + (-2 + 7.5i)x4 + (23.0004 - 3.8i)x3 + 12ix2 + 5.1233 + 0.1i
The input may come to you either from stdin, from an argument passed to the program or from a prompt displayed to your program. You may assume, that the input does not contain any leading or trailing whitespace characters.
Rendering
You have to render the fractal in the following way:

Choose as many colors as roots of P plus an extra color for divergence
For each number in the visible plane, determine whether the method converges and if yes to which root. Color the point according to the result.
Do not print rulers or other fancy things
Print a black point at the points, that are the polynomials roots for orientation. You may print up to four pixels around each root.
Find a way to choose the visible plane in a way, that all roots are distinguishable and spread widely across it, if possible. Although a perfect placement of the output frame is not required, I reserve the right to refuse to accept an answer that chooses the frame in an unacceptable way, eg. always at the same coordinates, all roots are in one point, etc.
The output image should have a size of 1024*1024 pixels.
Rendering time is 10 minutes maximum
Using single precision floating-point values is enough

Output
The output should be a raster graphics image in a file format of your choice, readable by standard software for a brand X operating system. If you want to use a rare format, consider adding a link to a website where one can download a viewer for it.
Output the file to stdout. If your language does not support putting something to stdout or if you find this option less convenient, find another way. In any way, it must be possible to save the generated image.
Restrictions

No image processing libraries
No fractal generating libraries
The shortest code wins

Extensions
If you like this task, you could try to color the points according to the speed of convergence or some other criteria. I'd like to see some interesting results.

I'm not entirely sure whether this is suitable as a code golf. In my eyes the task is way too complex. I may be proven wrong, though.

@Joey: It IS complex. But I think a solution takes at most 1500 chars.

@Joey: Indeed.  I would like for this to be a [tag:code-challenge] myself.

I think 1500chars is on the long side for code-golf. I don't like the time limits, as languages which don't use native floats/ints are severly disadvantaged. eg, Python can be almost 2 orders of magnitude slower than C for the same algorithm (especially with math)

The requirements are impossible to meet in their full generality. E.g. consider input 1 -1000 0.01 -10. It has roots -0.1, 0.1, 1000. If the x-axis is linear and the output image is 1024 pixels then two of the roots cannot be distinguished.

graphic format is too much, consider 2D array, or is Processing (processing.org ) or HTML5 canvas allowed?

@SHiNKiROU, .bmp and .tga are pretty trivial file formats.

... or PPM for that matter.

@Joey: My intention was to create a rather difficult task, as many people dislike very easy tasks.

Well, Ventero already told me that this strikes the other end of the scale. It also helps to have at least two different reference solutions (usually golfed) to a task to judge its complexity. But that's probably only my own opinion on that :-). The problem with such complex tasks is that you cannot just throw it away and try a different implementation if it takes you an hour or two to write even the first one. While longer solutions offer more places to golf it also makes iterating on an answer more complex and time-consuming which is why I at least don't like too complex tasks too much.

It's easily broken down into separate tasks, and if your language supports complex floating point numbers natively then you can save a large chunk. I have a not-fully-golfed version running at 1600 chars, of which 340 are the complex number class. It doesn't yet identify the roots and use colours, but I'm trying to track down what I presume is a bug in the N-R code. (Finding a root of x^3-1 starting at -0.5+0.866i surely shouldn't diverge!)

"This task is doable in less than 450 characters in more than 3 languages" [Ev's conjecture (: ]

Can I cheat by using the svg or even html format? (putting full of divs)

@SHiNKiROU: It says "raster graphics", so no vectors. But you may use SVG and embed a raster image. If you plan something interesting, just show me.

so I can't draw full of vector squares as pixels

Ah, that's what you mean. If you like just Do it. You could also submit an SVG with embedded javascript as a submission.

"0" and "1" are not of the form <Real part>i<Imaginary part>. Neither is "i12" unless the brackets mean "optional".

clarified: EIther part may be dropped if zero, but not both.

@MartinBüttner Please do not edit parts of the question without knowing why they are the way they are. For instance, I use <pre> instead of four spaces so no syntax highlighting takes place. Also, the question says <Real part><iImaginary part> for a reason because the right format is 1234 instead of 1234i when the imaginary part is missing.

@MartinBüttner Sorry, I missed one instance where you corrected to polynomial. Of course, polynomial is the correct word in this case.

Python, 827 777 chars
import re,random
N=1024
M=N*N
R=range
P=map(lambda x:eval(re.sub('i','+',x)+'j'if 'i'in x else x),raw_input().split())[::-1]
Q=[i*P[i]for i in R(len(P))][1:]
E=lambda p,x:sum(x**k*p[k]for k in R(len(p)))
def Z(x):
 for j in R(99):
  f=E(P,x);g=E(Q,x)
  if abs(f)<1e-9:return x,1
  if abs(x)>1e5or g==0:break
  x-=f/g
 return x,0
T=[]
a=9e9
b=-a
for i in R(999):
 x,f=Z((random.randrange(-9999,9999)+1j*random.randrange(-9999,9999))/99)
 if f:a=min(a,x.real,x.imag);b=max(b,x.real,x.imag);T+=[x]
s=b-a
a,b=a-s/2,b+s/2
s=b-a
C=[[255]*3]*M
H=lambda x,k:int(x.real*k)+87*int(x.imag*k)&255
for i in R(M):
 x,f=Z(a+i%N*s/N+(a+i/N*s/N)*1j)
 if f:C[i]=H(x,99),H(x,57),H(x,76)
for r in T:C[N*int(N*(r.imag-a)/s)+int(N*(r.real-a)/s)]=0,0,0
print'P3',N,N,255
for c in C:print'%d %d %d'%c

Finds display bounds (and roots) by finding convergence points for a bunch of random samples.  It then draws the graph by computing the convergence points for each starting point and using a hash function to get randomish colors for each convergence point.  Look very closely and you can see the roots marked.
Here's the result for the example polynomial.

Good! I like this.

Java, 1093 1058 1099 1077 chars
public class F{double r,i,a,b;F(double R,double I){r=R;i=I;}F a(F c){return
new F(r+c.r,i+c.i);}F m(F c){return new F(r*c.r-i*c.i,r*c.i+i*c.r);}F
r(){a=r*r+i*i;return new F(-r/a,i/a);}double l(F c){a=r-c.r;b=i-c.i;return
Math.sqrt(a*a+b*b);}public static void main(String[]a){int
n=a.length,i=0,j,x,K=1024,r[]=new int[n];String o="P3\n"+K+" "+K+"\n255 ",s[];F z=new
F(0,0),P[]=new F[n],R[]=new F[n],c,d,e,p,q;for(;i<n;)P[i]=new
F((s=a[i++].split("i"))[0].isEmpty()?0:Float.parseFloat(s[0]),s.length==1?0:Float.parseFloat(s[1]));double
B=Math.pow(P[n-1].m(P[0].r()).l(z)/2,1./n),b,S;for(i=1;i<n;){b=Math.pow(P[i].m(P[i-1].r()).l(z),1./i++);B=b>B?b:B;}S=6*B/K;for(x=0;x<K*K;){e=d=c=new
F(x%K*S-3*B,x++/K*S-3*B);for(j=51;j-->1;){p=P[0];q=p.m(new
F(n-1,0));for(i=1;i<n;){if(i<n-1)q=q.m(c).a(P[i].m(new
F(n-1-i,0)));p=p.m(c).a(P[i++]);}c=c.a(d=q.r().m(p));if(d.l(z)<S/2)break;}i=j>0?0:n;for(;i<n;i++){if(R[i]==null)R[i]=c;if(R[i].l(c)<S)break;}i=java.awt.Color.HSBtoRGB(i*1f/n,j<1||e.l(c)<S&&r[i]++<1?0:1,j*.02f);for(j=0;j++<3;){o+=(i&255)+" ";i>>=8;}System.out.println(o);o="";}}}

Input is command-line arguments - e.g. run java F 1 0 0 -1. Output is to stdout in PPM format (ASCII pixmap).
The scale is chosen using the Fujiwara bound on the absolute value of the complex roots of a polynomial; I then multiply that bound by 1.5. I do adjust brightness by convergence rate, so the roots will be in the brightest patches. Therefore it's logical to use white rather than black to mark the approximate locations of the roots (which is costing me 41 chars for something which can't even be done "correctly". If I label all points which converge to within 0.5 pixels of themselves then some roots come out unlabelled; if I label all points which converge to within 0.6 pixels of themselves then some roots come out labelled over more than one pixel; so for each root I label the first point encountered to converge to within 1 pixel of itself).
Image for the example polynomial (converted to png with the GIMP):

@FUZxxl, the image is from the old version. I'll upload one with the rate of convergence later. But the problem with marking the roots is determining which pixel to mark. It's the classic problem that with floating point you can't use exact equality tests, so you have to compare to an epsilon. As a result, I don't have "canonical" values for the roots. I could mark pixels which converge in one step, but that doesn't guarantee to mark anything, and could mark a block of 4 pixels for a single root.

@Peter Taylor: As you see, Keith Randall also found a solution to that problem. I added this requirement as an extra difficulty. One approach to do it would be to calculate the nearest pixel for each root and then checking each pixel for being equal to it.

@FUZxxl, you haven't understood my point. "The nearest pixel" of a root is not well defined. However, I can hack something in which might work for all the test cases you throw at it, and I get the impression that that will make you happy. I'm going to colour it white, not black, because that's more logical.

@Peter Taylor: Okay.

@FUZxxl, looking closely, Keith also seems to have multiple pixels labelled for one of the roots. As I say, it's not a feasible task to label "the" correct pixel.

@Peter Taylor: Umph... okay I am going to change the requirements: It is allowed to color up to for pixels around the roots.

My profile pic should soon change to x^6-9x^3+8, carefully designed by choosing the roots and then using Wolfram Alpha to simplify the polynomial. Ok, I cheated by swapping the hues around afterwards in the GIMP.

Python, 339 char/bytes
import numpy as n;import matplotlib.pyplot as p;from colorsys import hls_to_rgb as h
a,d=1,2001j;x,y=n.ogrid[-a:a:d,-a:a:d];z=x+1j*y
for i in range(3): z-=(z**3-1)/3/z**2
z[n.isnan(z)]=0
z=n.array(n.vectorize(h)((n.angle(z)+n.pi)/3/n.pi,1.-1/(1.+n.abs(z)**.1),.8)).swapaxes(0,2)
p.figure();p.imshow(z,interpolation='nearest');p.axis('off')

The plot below is for Newton Fractal of z^3 - 1 function.

Edit: Thanks to @Khuldraeseth na'Barya now the code is even shorter. Removed the irrelevant code and image.

You can use shorter (1 char) names and remove whitespace by combining multiple lines using ;. Also, remove all the spaces possible.

Some regular golfs reduce this to just 353 bytes! Haven't tested it (no matplotlib here), so no guarantee that it still works.

source: Stack Exchange

license: 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/

sort: votes


text:
Remove r-th powers
Given two numbers r and n on separate lines, write a program to print n natural numbers starting from 1 onwards, excluding the r-th powers. For example,
If r=2 and n=10, the results would be 2,3,5,6,7,8,10,11,12,13
4 and 9 were excluded because 4 is 2^2 and 9 is 3^2
Sample Input
2
10
Sample Output
2 3 5 6 7 8 10 11 12 13

Sample Input
3
30
Sample Output
2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 29 30 31 32 33

1 < r < 10
0 < n < 1,000,000

Since nobody came up with this, here's
  a hint to reduce your solution sizes:
The ith term of the output is given by
  floor(i+pow(i+pow(i,1/r), 1/r)).

Is one number per line an acceptable output format?

Just printing numbers 2 to 1,000,000 with ruby/python take around 26 seconds on my dual core machine, I think your upper limit is too high, IMHO

@s-mark What if you print the output to the file? You can assume printing to files for large outputs.

@peter-taylor Yes.

@fR0DDY, Oh, ok if that is acceptable. I thought I have to output to console.

Printing a million numbers in Golfscript using 1000000,{p}/ (which should be efficient - I can't see why that wouldn't be linear time) takes 55 seconds on my 2.5GHz machine.

Golfscript, 18 characters
~.3*,.{3$?}%-@;<n*

Basically a direct port of my Ruby solution. Also probably not completely golfed yet, I'll take a look at it later today again.

Ruby, 56 characters
r,n=$<.map &:to_i;puts ([*l=1..2*n]-l.map{|i|i**r})[0,n]

Pretty straightforward (and similar to Lars' solution). Takes about 5 seconds to complete for r = 2, n = 1000000 and 8 seconds for r = 10, n = 1000000 here.

Nice improvement! Just had another of those "duh!" moments.

Golfscript (18 17 chars)
~.3*,@{?}+1$%-<n*

This turns out to be similar to Ventero's solution, but slightly shorter (at time of writing!)
For a more efficient solution, 26 chars gives
~2.@{.2$4$?={)\)\}*.p)}*];

which uses the obvious algorithm:
int k = 2, x = 2;
for (i = 0; i < n; i++) {
    if (pow(k,r) == x) {k++; x++;}
    println(x++);
}

@S.Mark, I see what the problem is. Hopefully fixed, if not I'll have a look when I have access to the interpreter.

Seems to work now. You can save 2 characters by joining with n instead of ' '  (see fR0DDY's comment on the question).

@Ventero, why do you think I asked that? By I think there might be potential for saving a couple more by rewriting with a loop using p.

Woops, didn't realize that you were the one who asked :)

Python 2, 84 83  80 chars
r,n=input()
r+=.0
i=c=1
while c<=n:
    p=i**(1/r)
    if p!=int(p):print i;c+=1
    i+=1

Runs in about 3 seconds for r=2, n=1000000

Python 68 Chars
r=input();i=0;exec'i+=1;print int(i+(i+i**(1./r))**(1./r));'*input()

Windows PowerShell, 88
for($x,$r,[int]$n=,1+@($input);$n--){if((1..$n|%{[Math]::Pow($_,$r)})-eq$x){$x++}($x++)}

Fairly straightforward, but probably way too long.

Ruby (79 77 chars)
n,r=$<.map &:to_i
a=(0..n*2).map{|x|[x,x**r]}.transpose
p (a[0]-a[1])[0,n]*?,

Yes, this does a lot of wasted effort, but it completes in about 8 secs
for n=1E6,r=10 on my laptop.

J, 32
(4 :'y{.I.(~:<.)x%:i.1001000')/,

This assumes the input has the shape 2 1, i.e., a vertical list of two rows with one atom per row, e.g.,
 2
10

This solution is instantaneous for r = 9, n = 999999, which (unless I've misread the question) are the upper bounds for the input parameters.

Qwerty RPN (52)
@=r@=n>L$i)=i$i 1$r/^:\=<S$n(=n$i#32.>S 0$n=<B 1<L>B

Ungolfed
@ =r  ; input number r
@ =n  ; input number n, counter variable

0 =i  ; the next number to be printed (pre-assigning variable is optional)
>loop ; label loop
  $i ) =i ; pre-increase i

  $i 1 $r / ^ : \ = <skipped ; skip printing and increasing counter n if i^(1 / r) == round(i^(1 / r))
    $n ( =n ; decrease n
    $i #    ; print number i
    32 .    ; print space
  >skipped

  0 $n = <break ; if n == 0: break loop
  1 ; TRUE
<loop  ; go back to beginning of loop
>break ; this is where the loop ends

JavaScript, 118 111 bytes
function d(r,n){for(var a=[],i=m=0,p=1;i<n;p++,m=Math.pow(p,1/r))if((m|0)!=m){a.push(p);i++}return a.join(" ")}

Perl - 51
map{print$_.$/if($_**(1/$ARGV[0])!~/^\d+$/)}1..pop;

Not quite up to spec, as it takes ~12/13s for r=10/n=1000000, and takes r/n as command line args instead of on separate lines -- but other than that it works.

Vyxal, 11 bytes
+¹$r'¹Ėe:I≠

Try it Online!
+¹$r        # Input range
'¹Ėe         # r-th root of each item in range
:I≠           # Filter roots with no fractional part

9

C++, 97 95 90
int main(){int r,s,n,m=0;cin>>r;cin>>n;s=r;while(m++!=n)r!=m?cout<<m<<' ',r*=r<m?s:1:++n;}

(eventually +20)
using namespace std;

Are you sure this is solving the correct problem? I don't see any raising numbers to powers.

It solves the wrong problem, indeed. Also it's missing a few namespace declarations somewhere and an #include to even compile. And my compiler tells me that main() as default-int isn't valid in C++.

sorry about that guys, thanks for support. glad your concerns joey, but my project file adds them by default. eventualy i can add using declaration.

Scala 172
def p(r:Int,n:Int)={def f(n:Int):Stream[Int]=n#::f(n+1);lazy val i=f(0);lazy val o=i.filter(a => math.pow(a,1.0/r)!=math.pow(a,1.0/r).toInt);print(o.take(n).mkString(","))}

Python 2, 60 bytes
r,n=input();i=0
while n:
 i+=1
 if i**r**-1%1:
	print i;n-=1

Try it online!

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


text:
Data theft via remote desktop connection
A software vendor friend of mine wants to clamp down the development environment by limiting access to the software's source code to only Remote Desktop access, disallowing any digital communication including clipboard, printer, network shares, and internet access from that environment.
The reasoning is that they are contractually obligated to provide a company-standard-issue development environment to an overseas partner and there is a concern of theft.
I want to convince them that this is a futile effort and vain burden on good developers since the otherwise unsupervised access to the source code will provide ample opportunity to steal the data.  No matter how many firewall rules and group policies are in place, one channel remains that cannot be removed - the screen.
Assuming the development environment has Visual Studio 2010, data compression software, and other common development environment tools, what is the slickest way to use the Remote Desktop screen to steal the data?  Keep in mind any limitations of the screen refresh rate.
Candidate approach: a monochrome bitmap of the screen can hold over 200KB of an archive of such source code.  Without error correction, that's just over 500 screenshots of monochrome data for 100MB of compressed source code.  The data must be encoded, decoded, and I'm entirely too lazy to save 500 screenshots into paint.  Existing free software can be involved, but not installed on the environment.
Other ideas?  Implementations?

100MB of compressed source code?! The mind boggles.

Well, it's got images and other crap in there.  The point is that the solution should be able to handle large payloads.

@PeterTaylor: The source code hasn't been golfed yet, obviously.

Why only monochrome? Assuming you can connect in True Color, that's three bytes per pixel, or roughly 5 MiB per screenshot. Error correction isn't needed since you're (hopefully) not taking a camera to do the screenshots – so they come out pixel-perfect anyway.

Wait...is this a code challenge that actually has a practical application?

Who is the vendor? Please let us know so that we can all avoid all products ever produced by them. Clearly they are clueless about security.

Use FRAPS to capture video from your local machine.  Then you can flash stuff up on the remote desktop at up to the frame rate and it will all get recorded to a local video file.
I don't see a way to sync to exactly to the frame rate, so you'll need some error detection to make sure you're not getting data mid-draw.  Here's a simple scheme using text and a python script:
framerate = 30  # fps of viewer
numlines = 24   # lines of text you can see at once
import sys,time,md5,base64
lineno = 0
while 1:
  lines = 'chunk starting at line %d\n' % lineno
  for i in xrange(numlines - 2):
    lines += sys.stdin.readline()
    lineno += 1
  print 'md5:', base64.encodestring(md5.new(lines).digest()),
  print lines
  time.sleep(1.0/framerate)

Run this script in the RemoteDesktop window and pipe in the text you wish to capture.  When it is done, OCR each frame of your FRAPS output (that's the hard part, I'm not sure what you'd use for that).  Throw away any duplicate frames and frames where the md5 isn't right.
You probably want to base64 encode your input, as OCR doesn't do well with nonprinting characters like tabs and spaces.

My experience of remote desktop is that if you're changing the entire contents of the screen every frame you should expect an fps nearer 5.

@Peter: then set framerate=5.


text:
Find Possible Word Rectangles
Johnny is trying to create crossword puzzles, but he is having difficulty making words match each other.
He has come up with several simple word rectangles: that is, groups of words that form a rectangle where all horizontal and vertical paths form a word.
//2x2
PA
AM

//2x3
GOB
ORE

//3x3
BAG
AGO
RED

//3x4
MACE
AGES
WEES

However, to make a good puzzle, he needs some word rectangles that are somewhat larger than 3x4. Instead of agonizing over the arrangement letters for hours, Johnny would prefer to have a program that does this for him--and in as few characters as possible, because long blocks of code are extremely intimidating for casual programmers like Johnny.

Given

a text file dictionary where words are separated by newlines in alphabetical order,
input specifying the number of rows and columns in the words rectangle (which can be provided however is most convenient in your programming language of choice)

generate at least one word rectangle. If it is not possible to generate a word rectangle with the given lexicon and dimensions, the program need not have defined behaviour. It is not necessary for the program to be able to generate rectangles which contain more than 64 letters or have dimensions that exceed 8 in either direction. The program should be able to complete in a reasonable amount of time, say, in thirty minutes or less.

EDIT: If you are doing an NxN rectangle, you are permitted to use a smaller dictionary file that only contains words that have a length of N letters.

I may be able to adapt the code I wrote for a Java4k game.

I'm curious if anyone has an implementation that can generate an 8x8 from that word list in under ½ hour.

@MtnViewMark If not, I'll be willing to lower the size requirement. Even so, I think that Keith's implementation could be made quite a bit faster if he could do some checking to reduce the number of possiblities.

and all words must be different?

@shinkirou No, there can be duplicate words in the rectangle.

Did anyone manage to generate a solution grid greater than 6x6 in under ½ hour?

@MtnViewMark, 7x6 in 21 seconds. But I left it running for 5 hours looking for 8x8 without finding anything. I have an idea for a reduction to exact set cover which I want to try.

@Peter - That's fast.. or do you just a blazing computer on your desk? What is the implementation in? And are you using something other than one of the two algorithms represented here?

@MtnViewMark, 2.5GHz probably doesn't count as "blazing" nowadays. Implementation in Java. Prefix-based with heuristics; I think it's a bit more complex than the algorithms posted, although I can't decipher the Python one entirely.

@Peter - the Python one is the same algorithm as the awk one: Recursive enumeration of all possible rows combinations, pruning on if the columns are viable prefixes. My Haskell solution enumerates by alternating filling out rows and columns, and now prunes by viable prefixes as well. Can you share your method?

@MtnViewMark, rather than testing merely whether a prefix is viable I use a trie which stores the number of children under each node to give a heuristic for which continuations are most likely to give a solution. (I then pick one at random weighted by the heuristic - I should probably try just picking the best candidate, since variability of results isn't explicitly in the spec). I'm testing the reduction to set cover, solving with Knuth's dancing links, on the basis that it applies heuristics globally rather than to prefixes, but so far not promising. Maybe there's a better reduction.

Haskell, 586 characters
import Data.List
import qualified Data.Vector as V
import System
data P=P[String](V.Vector P)
e=P[]$V.replicate 128 e
(a:z)∈(P w v)|a>' '=z∈(V.!)v(fromEnum a);_∈(P w _)=w
p∫w=q p w where q(P u v)=P(w:u).V.accum q v.x;x(a:z)=[(fromEnum a,z)];x _=[]
l%n=foldl'(∫)e.filter((==n).length)$l
d§(p,q:r)=map(\w->p++w:r)$q∈d;_§(p,_)=[p]
(d¶e)i=filter(not.any(null.(∈e))).map transpose.(d§).splitAt i
s i n d e m|i==n=["":m]|1<3=(d¶e)i m>>=(e¶d)i>>=s(i+1)n d e
p[b,a,n]w=take n$s 0(a`max`b)(w%a)(w%b)$replicate b$replicate a ' '
main=do{g<-map read`fmap`getArgs;interact$unlines.concat.p g.lines}

Invoked by supplying 3 arguments: number of rows, number of columns, number of solutions; and the word list is accepted on stdin:
$> ghc -O3 2554-WordRect.hs
[1 of 1] Compiling Main             ( 2554-WordRect.hs, 2554-WordRect.o )
Linking 2554-WordRect ...

$> time ./2554-WordRect 7 7 1 < 2554-words.txt

zosters
overlet
seriema
trimmer
element
remends
startsy

real    0m22.381s
user    0m22.094s
sys     0m0.223s

As you can see 7×7 runs relatively fast. Still timing 8×8 and 7×6....
It would be 9 characters shorter to remove the number of solutions argument and just produce all solutions, but then it becomes impossible to time.

Edit: (585 → 455) replaced custom data structure with a simple map of prefix string to possible replacements; oddly, this is a bit slower, perhaps because Map String a is slower than a hand-built tree of Map Char a...
Edit: (455 → 586) Bigger?!?!! This version does more optimization of the search space, using both the techniques of my original solution, and of the python and awk solutions. Further, the custom data structure, based on Vector is much faster than using a simple Map. Why do this? Because I'm think a solution that is closer to the goal of 8x8 in under ½ hour is preferable to a shorter solution.

What version of GHC are you using?  Using the same commands (except I need --make after ghc) with the word list posted in the question, I'm getting words that aren't in the list, like "zymesz" and "youthy".

Perhaps the requirements should be altered to say that the output grid shouldn't be its own transpose.

@Joey: Did you convert the words.txt file to local line endings? I'm running on Mac OS X, and I converted the file to \n line endings before using it.

Thanks, that worked.  The input file has to be in lowercase and have line endings compatible with one's system.

Python, 232 chars
x,y=input()
H=[]
P={}
for w in open('words.txt'):
 l=len(w)-2
 if l==x:H+=[w]
 if l==y:
  for i in range(y+1):P[w[:i]]=1
def B(s):
 if(x+2)*y-len(s):[B(s+w)for w in H if all((s+w)[i::x+2]in P for i in range(x))]
 else:print s
B('')

It can only handle up to 6x6 in the 1/2 hour limit, though.

Does it generate all the pair or valid words pair only? When I read vertical from above to bottom, it does not seems to form a valid word. Eg., I got one result "aahs","abet","lack", but vertical reading "stk" is not in the words list, and also for above I pass parameter 3,3 but its return words 3x4

Hmmm, that's not what I get.  I suspect the problem is with linebreaks in the dictionary.  The provided file has Windows linebreaks (\r\n) in it, so the length of the words is len(w)-2.  If you somehow converted the line breaks (or if Python on Windows does that for you?), change it to len(w)-1 and that should fix it.

...and change the other +2s to +1s.

Ah, I see. I tested with Windows, and Linux. Python on Windows automatically removed \r from w, and on Linux I have converted file to Unix format, so both didn't work.

This is a very elegant solution.

Java (1065 bytes)
import java.util.*;public class W{public static void main(String[]a){new
W(Integer.parseInt(a[0]),Integer.parseInt(a[1]));}W(int w,int h){M
H=new M(),V=new M();String L;int i,j,l,m,n=w*h,p[]=new int[n];long
I,J,K,M,C=31;long[]G=new long[h],T=new long[w],W[]=new long[n][],X;try{Scanner
S=new Scanner(new java.io.File("words.txt"));while(0<1){L=S.nextLine();l=L.length();for(i=0;i>>l<1;i++){K=0;for(j=0;j<l;j++)K+=(i>>j&1)*(L.charAt(j)-96L)<<5*j;if(l==w)H.put(K,H.g(K)+1);if(l==h)V.put(K,V.g(K)+1);}}}catch(Exception
E){}while(n-->0){j=1;if(W[n]==null){M=1L<<62;for(i=w*h;i-->0;){m=i/w;l=i%w*5;if((G[m]>>l&C)<1){X=new
long[27];I=K=0;for(;K++<26;){J=H.g(G[m]+(K<<l))*V.g(T[i%w]+(K<<5*m));X[(int)K]=K-32*J;I+=J;}if(I<1)j=0;if(I<M){M=I;p[n]=i;W[n]=X;}}}}X=W[n];Arrays.sort(X);M=X[0]*j;X[0]=0;K=M&C;i=p[n]%w;j=p[n]/w;l=5*i;m=5*j;G[j]&=~(C<<l);G[j]+=K<<l;T[i]&=~(C<<m);T[i]+=K<<m;if(M>=0){W[n]=null;n+=2;}}for(long
A:G){L="";for(i=0;i<w;)L+=(char)(96+(C&A>>5*i++));System.out.println(L);}}class
M extends HashMap<Long,Long>{long g(Long s){return get(s)!=null?get(s):0;}}}

A long way from being the shortest, but I think it's the closest to meeting the timing constraints. I saved 14 bytes by assuming that the input file has been filtered to words of the right lengths; on my netbook, if you feed the whole words.txt then it spends the first minute preprocessing it, discarding most of what it produces, and then takes a mere 20 or so seconds to solve 7x7. On my desktop it does the whole thing in under 15 seconds, giving:
rascals
areolae
serrate
coroner
alanine
latents
seeress

I've let it run for over 50 hours without finding a solution to 8x7 or 8x8. 8-letter words seem to be a critical boundary for this problem - it just hovers around half-full without making much progress.
The approach used is full pivoting and a heuristic based on the number of possible horizontal completions times the number of possible vertical completions. E.g. if we have intermediate grid
*ean*
algae
*ar**
*ier*
*nee*

then we give the top-left corner a heuristic value of count(aean*)count(aa***) + count(bean*)count(ba***) + ... + count(zean*)count(za***). Of all the cells we pick the one with the smallest heuristic value (i.e. hardest to satisfy), and then work though the letters in descending order of the amount they contributed to the heuristic value of that cell (i.e. starting with the most likely to succeed).

Lovely approach and explanation.

F#
Backtracking solution, but I'm going to optimize the search space later.
open System

(*-NOTES
    W=7 H=3
    abcdefg<-- searching from wordsW
    abcdefg
    abcdefg
    ^
    partial filtering from wordsH
  *)

let prefix (s : char[]) (a : char[]) =
  a.[0..s.Length - 1] = s

let filterPrefix (s : char[]) =
  Array.filter (prefix s)

let transpose (s : char[][]) =
  [|
    for y = 0 to s.[0].Length - 1 do
      yield [|
        for x = 0 to s.Length - 1 do
          yield s.[x].[y]
      |]
  |]

[<EntryPoint>]
let main (args : String[]) =
  let filename, width, height = "C:\Users\AAA\Desktop\words.txt", 3, 3
  let lines = System.IO.File.ReadAllLines filename |> Array.map (fun x -> x.ToCharArray())
  let wordsW = Array.filter (Array.length >> ((=) width)) lines
  let wordsH = Array.filter (Array.length >> ((=) height)) lines

  let isValid (partial : char[][]) =
    if partial.Length = 0 then
      true
    else
      seq {
        for part in transpose partial do
          yield Seq.exists (prefix part) wordsH
      }
      |> Seq.reduce (&&)

  let slns = ref []
  let rec back (sub : char[][]) =
    if isValid sub then
      if sub.Length = height then
        slns := sub :: !slns
      else
        for word in wordsW do
          back <| Array.append sub [| word |]

  back [| |]
  printfn "%A" !slns
  0

awk, 283
(may need to add 14 for parameter input flags)
Call with e.g. awk -v x=2 -v y=2...
Find first match and print it (283 chars):
{if(x==L=length)w[++n]=$0;if(y==L)for(;L>0;L--)W[substr($0,1,L)]++}END{for(i[Y=1]++;i[j=1]<=n;){b[Y]=w[i[Y]];while(j<=x){s="";for(k=1;k<=Y;k++)s=s substr(b[k],j,1);W[s]?0:j=x;j++}if(W[s])if(Y-y)i[++Y]=0;else{for(k=1;k<=Y;k++)print b[k];exit}i[Y]++;while(Y>1&&i[Y]>n)i[--Y]++}print N}

Find number of matches (245 chars, much slower):
{if(x==L=length)w[++n]=$0;if(y==L)for(;L>0;L--)W[substr($0,1,L)]++}END{for(i[Y=1]++;i[j=1]<=n;){b[Y]=w[i[Y]];while(j<=x){s="";for(k=1;k<=Y;k++)s=s substr(b[k],j,1);W[s]?0:j=x;j++}W[s]?Y-y?i[++Y]=0:N++:0;i[Y]++;while(Y>1&&i[Y]>n)i[--Y]++}print N}

For both programs (of course more so for the solutions count), the running time far exceeds 30 minutes for some values of x and y.
Just as a matter of interest, here is the word count for each word length:
 2     85
 3    908
 4   3686
 5   8258
 6  14374
 7  21727
 8  26447
 9  16658
10   9199
11   5296
12   3166
13   1960
14   1023
15    557
16    261
17    132
18     48
19     16
20      5
21      3


text:
Respawning Factorial
Write a program that does one step of the computation of factorial, then, generate (quine) a new program, and performs the rest of the process in the new program
The seed and spawned programs will have a variable n for the factorial to be computed and m for the accumulator.
I don't care if you use scripted or compiled language.
You can use the cheat of "reading the source file".
You MUST create a new file and run the new file to qualify: no self-modifying code or using code loaded in memory, but spawning with data: url in JS is allowed.
Here is an example in Java: https://gist.github.com/968033
Shortest code wins.

Perl, 95
$m=1;$n=12||die$m;@ARGV=$0;$_=<>;$m*=$n--;s/\|/;\$m=$m;\$n=$n|/;open _,">$0";print _;exec$^X,$0

The program really has to be on a single line, and overwrites itself at each iteration.

Javascript (163)
g=document.location;if(s=g.search.split(",")[1]){
n=s.split(":");i=n[1];n=n[0];i*=--n;
n==1?alert(i):g.search="?a=,"+n+":"+i}
else{n=prompt();g.search="?a=,"+n+":"+n}

This uses the querystring to pass values and refreshes the page.

Python (189)
It's not very short but it does take its argument on the command line.
n,m=0,1
from sys import*
a,f=argv,file
_,n=a[0],len(a)>1and n<1and int(a[1])or n
if n>1:x=f(_).readlines();x[0]='n,m=%s\n'%`n-1,m*n`;f(_,'w').write(''.join(x));exec f(_).read()
else:print m


text:
Fill in the lakes
Given the topography of land in ASCII picture format, figure out where lakes would go and fill them in.  Assume an infinite amount of rain.
example
input
         #
         ##
      # ####
#    #########
##  ###########
## #############   ####
## ##############  #####
################# #######
#########################
#########################

output
         #
         ##
      #@####
#@@@@#########
##@@###########
##@#############@@@####
##@##############@@#####
#################@#######
#########################
#########################

The input will contain only spaces and # marks.  Each line will be the same length.  The output should be the identical # pattern with spaces where water would accumulate filled in with @ marks.
The bottom input row will always be all # marks.  There will be no holes or overhangs in the land.  Shortest code wins.

This seems a bit easy.  I think we should also have to display the number of lake units @ that were filled in.

@mellamokb: This would be roughly a ([char[]]"$a"-eq'@').Count here. Not that much too add. Agreed on this being a little too easy, though. Doesn't fall into the realm of what I'd downvote, though.

Related on Stack Overflow: Code Golf: Running Water. One of LiraNuna's better one, I thought.

So do we also have to handle underground caverns, which may have air above the water level like the Running Water puzzle?  That makes things a little more challenging and I think should definitely be an example use case.

@dmckee: That one wasn't as easy as this though.

@mellamokb: I think we agreed some time ago that the questions from SO are not to be replicated here. Mostly because there are already solutions there.

@joey: No. The possibility of the caves seems to rule our a simple regexp solution to the LiraNuna one.

Since # and @ are both massive characters, I suggest using . instead of @, which gives better pictures, IMHO.

sed -r, 27 24 (27 with -r)
24 (27):
:;s/(#|@) ( *#)/\1@\2/;t

27 (30):
:e;s/([#@]) ( *#)/\1@\2/;te

Competes with the better of the two perl solutions

#|@ would be one char shorter

You should add 3 to the count for the -r flag. You can cut off two from removing the es, and another from S.Mark's suggestion to get back to 27 though.

@Nabb thanks, discovered something with the empty label

I tried sed before, but failed

Perl, 25
s/# +#/$_=$&;y| |@|;$_/ge

I added a character count. Please look whether it's actually correct, as it might need to include some interpreter flags (-p maybe?).

i dont know perl language, but i can feel its power :)

Actually it needs  -pe to function on my box, so that should be an additional 4 chars. Or does the e not count and thus only 3 additional chars required?

Don't need the e, like I mentioned elsewhere, for the same reasons.  :)

You can save a couple of bytes on this approach by inlining the change to $& without assigning to $_: s/# +#/$&=~y! !@!r/ge

Try it online!

Perl (>= v5.9.5), 24 chars
Run with perl -p:
1while s/#.*\K (?=\S)/@/

This requires Perl 5.9.5 or later to use the special escape \K.

Except that if Nabb is correct, you need to count  -p as 3 chars, bringing your total to 27. And it actually requires  -pe. I don't know the full rules about flags, so not sure the e counts.

Wouldn't actually need the e, if you simply hit enter and type it in afterwards, or put the code in a file and run it.  So -e isn't really needed.  :)

Windows PowerShell, 36 74 138
$input-replace'(?<!^ *) (?! *$)','@'

Retina, 10 bytes
Retina is (much) newer than this challenge. But this solution is too neat not to post it:
T` `@`#.*#

Try it online.
This is simply a transliteration stage which replaces spaces with @, but the operation is restricted to matches of #.*#, i.e. characters which are surrounded by land on both sides.

Ruby 1.8, 30 characters
#!ruby -p
gsub(/# +#/){$&.tr" ","@"}

If anyone has an idea why this doesn't work in Ruby 1.9 (tested with 1.9.2p0 and 1.9.2p204), even though the documentation says it should work, let me know!

That's really weird, adding in $_=$_. to the start of the second line makes it work in 1.9.2 so it's something to do with Kernel.gsub.  Rubinius also fails without explicitly adding $_.

According to 1.9.1 NEWS log, Kernel#getc, #gsub, #sub are deprecated.

I think you can count this as 30 (27 + 3 for needing the -p flag). The hash-bash and name of the interpreter doesn't count.

Python, 95 92 bytes
for s in S.split('\n'):b=s.find('#');e=s.rfind('#');print s[:b]+s[b:e].replace(' ','@')+s[e:]

05AB1E, 17 16 bytes
|εγć?D¨ð'@:sθJJ,

Try it online.
Explanation:
|            # Take all input-lines as list
 ε           # For each line:
  γ          #  Split the line into chunks of consecutive equal characters
             #   i.e. " ##   # " → [' ','##','   ','#',' ']
   ć         #  Split into head and the rest of the list
             #   i.e. [' ','##','   ','#',' '] → ['##','   ','#',' '] and ' '
    ?        #  Print this head
   D         #  Duplicate the rest of the list
    ¨        #  Remove the last element
             #   i.e. ['##','   ','#',' '] → ['##','   ','#']
     ð'@:    #  Replace every space with a "@"
             #   i.e. ['##','   ','#'] → ['##','@@@','#']
     sθ      #  Swap so the duplicated list is at the top, and take the last item as is
             #   i.e. ['##','   ','#',' '] → ' '
         JJ  #  Join the lists and individual items in the list together to a single string
             #   i.e. ['##','@@@','#'] and ' ' → "##@@@# "
           , #  Print with trailing new-line

Pip, 15 bytes
aR:`#.*#`_TRs'@

Takes input as a multiline string via command-line argument: Try it online! (Alternately, specify the -rn flags and change the first a to g, and you can give input via stdin: Try it online!)
Same idea as the Retina answer: replace every match of the regex #.*# with the result of transliterating space to @ in the match. Pip can't match Retina's terseness for a pure regex problem--but it's not everyday that you can tie with Jelly, after all.

Vyxal, 20 bytes
□⟑Ġvṅḣ$₴:Ṫ\@Ḟ$¤ptJṅ,

Try it Online!
How?
□⟑Ġvṅḣ$₴:Ṫ\@Ḟ$¤ptJṅ,
□                    # All inputs wrapped in a list
 ⟑                   # Open an apply lambda, apply for each:
  Ġvṅ                # Group consecutive identical characters
     ḣ               # Head extract, push a[0], a[1:]
      $              # Swap
       ₴             # Print without a trailing newline
        :Ṫ           # Duplicate and remove the last item
          \@Ḟ        # Replace all spaces with "@"
             $       # Swap
              ¤p     # Prepend an empty string for the case that the list is empty
                t    # Last item
                 J   # Join top two things on the stack together
                  ṅ  # Join by nothing
                   , # Print with trailing newline

Javascript (ES6), 44 bytes
x=>x.replace(/# +#/g,s=>s.replace(/ /g,"@"))

Nice answer :) You can replace (hah!) replaceAll(" ", ... with replace(/ /g,... (removing the space) to save another three bytes too!

Python, 108 106 92 bytes
import re
n=1
while n: S,n=re.subn('# +#',lambda m:'#'+'@'*len(m.group(0)[2:])+'#',S)
print S

Javascript, 107 bytes
var f=function(x){return x.replace(/# +#/g, function(x){return "#"+new Array(x.length-1).join("@")+"#";})};

Ungolfed:
var f = function(x) {
    return x.replace(/# +#/g, function(x){
        return "#" + new Array(x.length - 1).join("@") + "#";
    })
};

I recommend that you (1) post a normally formatted version of your answer so it is easier to read and follow along and (2) look into to ES6... it could save you a lot of characters with your functions.

I'll post a normal version, but I'm not a ES6-type person.

@BobTheAwesome Why did you just suggest this edit?

Oh goodness, I was attempting to fix the test-case error but I have this extension enabled in chrome, if you know xkcd. Sorry about that.

Besides the ES6 stuff: you don't need the space after the comma, you don't need the space after the second return, and you can remove the two semicolons, and it can just be function f(x)... or f=function(x)...

Jelly, 15 bytes
Ỵ”@ẹ”#ṂrṀḟƲ$¦€Y

Try it online!

APL (Dyalog Unicode), 28 bytes
'# +#'⎕R{'@'@(' '∘=)⍵.Match}

Try it online!


text:
Most Compact Code For A Simulated Explosion
Can you write a program that renders to screen a group of pixels exploding apart (as in a simple particle engine) and can you do this in any remarkably small number of characters (key strokes)? (Recall the game lemmings, when those little guys would explode and their little pixel pieces fly apart.)
Someone programmed a simple particle system here as a Processing sketch and it is pretty hefty compared to what I think others should be able to accomplish if they tried. But I'd be much more impressed if it someone could do the same in c++ and sdl, or even java or c#.

"Lines of code" is a metric that opens a lot of ambiguity, and is certainly not [code-golf] which is "number of characters" or sometimes "number of bytes". Related discussion on meta.

BTW--The issue I raised above, and the rather incomplete specification are things that could have been usefully hammered out by discussing this in advance in the Puzzle Lab chat or the Sandbox on meta. But, in any case, welcome to CodeGolf.SE.

Updated question, replaced LOC with number of characters.

yeah, if you write C/C++/Java/Any C derivative you could write an entire OS in 1 line of code

Related: http://stackoverflow.com/questions/1947031/code-golf-new-years-fireworks

Python, 245 chars
import random,time
R=lambda:random.randrange(-999,999)/1e3
P=[(40+20j,R()+1j*R())for i in' '*20]
for i in' '*20:
 C=([' ']*80+['\n'])*40
 for p,v in P:C[int(p.real)+81*int(p.imag)]='*'
 print''.join(C);P=[(p+v,v*.95)for p,v in P];time.sleep(.1)

It's no lemming explosion, but definitely a +1 for brevity!

C#, WPF – 1523
Not terribly serious; this was mainly an attempt whether it actually worked.
What I'm doing here is using an ItemsControl (Menu, since it's shorter) in WPF to display particles via data binding and templating. A data template controls how the particles look like (in this case a simple circle) and data binding controls color and position of the particles.
Each particle has a position, a color and a direction which get updated by a timer. Initially a bunch of particles are generated in the center of the window with (normal-distributed) random directions. That collection gets data-bound to the ItemsControl which then handles displaying the particles automatically, whenever the properties are updated. Particles are dragged down a bit due to gravity.
It got a little lengthy, admittedly. But at least it looks nice:

It can surely be made shorter by omitting:

gravity, causing particles to expand uniformly to all sides;
the normal distribution for the initial vectors, causing the particles to expand in a sparse »box«;
the brightness variation, leaving particles black.

I opted not to do so in the interest of aesthetics. This solution is way longer than almost anything else regardless. The data-binding and templating approach might be elegant but it's also quite verbose compared with simply updating a bitmap. (Note: I got it down to 1356 by leaving all of the above out, but it looks horrible then.)
The code is distributed in three files, which are given here in formatted form for legibility:
App.xaml
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" StartupUri="W.xaml"/>

W.xaml
<Window x:Class="W" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Menu Name="i">
        <Menu.ItemTemplate>
            <DataTemplate>
                <Ellipse Width="2" Height="2" Fill="#000" Opacity="{Binding O}">
                    <Ellipse.RenderTransform>
                        <TranslateTransform X="{Binding X}" Y="{Binding Y}"/>
                    </Ellipse.RenderTransform>
                </Ellipse>
            </DataTemplate>
        </Menu.ItemTemplate>
        <Menu.Template>
            <ControlTemplate>
                <ItemsPresenter/>
            </ControlTemplate>
        </Menu.Template>
        <Menu.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas/>
            </ItemsPanelTemplate>
        </Menu.ItemsPanel>
    </Menu>
</Window>

W.xaml.cs
using M = System.Math;
using T = System.Timers.Timer;
using System;
using System.ComponentModel;

partial class W
{
    int a;
    T t = new T(99);

    public W()
    {
        InitializeComponent();
        Height = Width = 500;
        var r = new Random();
        Func<double> n = () => 2 * (M.Sqrt(-2 * M.Log(r.NextDouble())) * M.Sin(6 * r.NextDouble()));
        var l = new System.Collections.Generic.List<P>();
        for (; a++ < 300; )
            l.Add(new P { X = 250, Y = 250, f = n(), g = n() });
        i.ItemsSource = l;
        t.Elapsed += delegate
        {
            foreach (P x in l)
            {
                x.X += x.f;
                x.Y += x.g += .2;
                x.O = M.Max(1 - M.Sqrt(M.Pow(250 - x.X, 2) + M.Pow(250 - x.Y, 2)) / 250, 0);
            }
        };
        t.Start();
    }
}

class P : System.Windows.ContentElement, INotifyPropertyChanged
{
    public double y, f, g;
    public double X { get; set; }
    public double O { get; set; }
    public double Y
    {
        get { return y; }
        set
        {
            y = value;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(""));
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
}

+1 Great looking example! Much like those classic exploding lemmings of days gone by. And I think this beats the Processing code in the initial Question.

@icnivad: I have to admit that the Processing sketch (I only looked at the final result, not the code) was my inspiration for the looks.

Gah! I stop golfing this, now. It has some nice tricks in it by now (such as the PropertyChanged for all properties and only on the last one that is set). Given that I started out above 2000 characters, I guess a 500-char reduction isn't too bad. It also got quite slow by now. DispatcherTimer works much better than Timer, but is way longer. I might be tempted to port this to Silverlight and run it on my phone, though.

I think this is the one to beat for the combination of code size and aesthetic quality of the explosion.

icnivad: I'll rewrite the whole thing to paint directly on a bitmap later; it should be much shorter, then. 45 % of the code are XAML; a large portion of code goes into being able to bind UI elements to the particle properties. Add to that the general verbosity of C# and it's way more verbose than it'd need to be.

postscript - 287 244 chars
currentpagedevice/q{exch def}def/PageSize get/z{dup 3 1 roll add exch 4 2 roll}def{2
div}forall/y/r{rand 2 27 exp div 8 sub}def q/x q[99{[x r y r]}repeat]50{dup{aload/t q
3 index 2 index 4 4 rectfill 1 sub z z t astore pop}forall showpage}repeat

run with gs -dNOPAUSE asplode.ps
You could even print it out and make a flipbook

Wonderful! It's  beautiful!

Javascript - 268 chars
Here's a 1 dimensional, 2 particle, explosion:
javascript:d=document;c=d.createElement('canvas');d.body.appendChild(c);g=c.getContext("2d");function e(x,y,m){g.arc(x,y,m,0,2*Math.PI,false);g.fill()}function s(a,b,v,t){c.width=c.width;e(50+t*v,50,b);e(50+t*b*v/(b-a),50,a-b);setTimeout(function(){s(a,b,v,t+1)},100)};s(9,5,1,0)

To run it, open an about:blank page in a good web browser, paste into the url bar and press enter. You can modify the explosion by editing the values at the end in s(10,5,1,0). The first value is the size of the particle that is exploded. The second value is the size of the particle that is exploded out of it. The third value is the speed of the particle exploded out of it. Leave the '0' as it is.

This does not work in Safari 5.0.5 (shows something that looks a bit like a baseball bat) or in Chrome 11.0.696.68 (shows two balls, one slightly larger than the other, moving apart slowly).

@marinus what's happening in Chrome is what's supposed to be happening.

Can't get it to work on FF4, IE8. :(

Well I tested it on Firefox 4.0.1 and Chromium 11.0.696.65. Make sue you copied the whole script - I find its easy to miss out the end bracket when copying.

@st0le IE8 does not support the canvas tag, unless you perform some dirty tricks: http://stackoverflow.com/questions/1332501/how-can-i-use-the-html5-canvas-element-in-ie

APL (120 118)
It has the same kind of output as the Python entry (i.e. it just outputs the states on a character grid). Only the grid is 30x15 and the particle origin is at 15x7.
⍎⊃,⌿(9⍴⊂'(⎕DL.1)⊢{{(A+2↑⍵),0.95×A←2↓⍵}¨⍵⊣⎕←'' ⍟''[1+(⍳15 30)∊2↑¨⌊⍵]}'),⊂',⌿⍉10 4⍴⍎''⍬'',420⍴'',(7 15,.01×99-?2⍴199)'''

JavaScript 502 500 496
This is a combination of the Joey's and david4dev's answers (it's a shameless copy of Joey's algorithm implemented using Javascript/canvas ☺):
W=500;H=250;function r(){return 2*m.sqrt(-2*m.log(m.random()))*m.sin(6*m.random())}function n(){z=[];for(i=W;i;i--){s={};s.x=s.y=H;s.f=r();s.g=r();z.push(s)}}function w(){x.clearRect(0,0,W,W);z.forEach(function(a){a.x+=a.f;a.y+=a.g+=.2;x.fillStyle="rgba(0,0,0,"+m.max(1-m.sqrt(m.pow(H-a.x,2)+m.pow(H-a.y,2))/H,0)+")";x.fillRect(a.x,a.y,2,2)})}z=[];m=Math;d=document;c=d.createElement("canvas");c.width=c.height=W;d.body.appendChild(c);x=c.getContext("2d");n();setInterval(n,2e3);setInterval(w,10)

JSFiddle preview: http://jsfiddle.net/GVqFr/60/ (you can press the TidyUp button to format the code nicely)

I'm not javascript expert, but you use the constant 500 a lot.  If you can define a global variable a=500, you can save a few characters by replacing all 500 with a.

@GigaWatt you're right; that worked for 250 as well.

Bash 380
C="4443311177"
t=".-xxXMXxx-."
alias c='echo -e "\e[2J"'
g(){
echo -e "\e[1;$4\e[$2;$1H$3"
}
f(){
x=$1
y=$2
p=$((2-RANDOM%5))
q=$((2-RANDOM%5))
for i in {-5..5}
do
x=$((x+p))
y=$((y+q))
n=$((5+i))
c=$((5+i))
g $x $y ${t:n:1} 3${C:c:1}m
w=$(printf "%04i\n" $((5*i*i)))
sleep ${w/0/0.}
g $x $y " " 3${C:c:1}m
done
}
e(){
c
for i in {1..10}
do
f $((COLUMNS/2)) $((LINES/2)) &
done
}

Call e like explode.
update: colorized
t=text, c=cls, g=gotoxy, f=fly, C=COLOR

C with SDL, 423 chars
Since the original problem description explicitly mentioned SDL, I felt it was past time that an SDL solution was submitted. Unfortunately, the names of the SDL function and structs aren't particularly terse, so this program is a little long. In fact, I can't even leave out the #include.
#include<math.h>
#include"SDL.h"
SDL_Surface*s;SDL_Event e;SDL_Rect p;int i,n;double q[256];main(){
SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(320,320,32,0);
for(srand(time(0));e.type-SDL_QUIT;n=-~n%64){
for(i=256*!n;i;q[--i]=rand()%65536*9.5874e-5);
for(SDL_FillRect(s,0,i=0);++i<256;SDL_FillRect(s,&p,-n*67372036))
p.x=160+cos(q[i])*q[i-1]*n,p.y=160+sin(q[i])*q[i-1]*n,p.w=p.h=1;
SDL_Flip(s);SDL_Delay(50);SDL_PollEvent(&e);}}

(Since the code is already so huge, I left in some extra bits so that it would compile without warnings. I miss compiling without warnings sometimes. Removing them would save about 30 or so chars.)
The animation runs in an infinite loop. Close the window to exit the program. Each explosion uses a new set of random particles.
I would also like to point out the number67372036 in the code. It appears in the expression for the last argument in the second call to SDL_FillRect(). As the code stands, the explosion is rendered entirely in grays. Changing this number slightly will add a very subtle but pleasant color effect to the explosion. The number 67372032 colors the particles at the start of the explosion, while the number 67372034 provides a color effect as they fade out at the end. Other numbers can produce less subtle color-cycling effects. I encourage you to try them out.

After seeing some of the other great examples here, I decided to give it a go, and make a particle function that fits in 140byt.es
Javascript, 282 chars
(138 chars particle function and 150 chars basic canvas drawing boilerplate)
p=function(a,t,x,y,n,g,s,i,d){with(Math)for(i=n;i--;d=cos(i*sin(i*s)),a.globalAlpha=n/t/i,a.fillRect(x+t*sin(i)*d, y+t*cos(i)*d+t*g,2,2));};d=document;a=d.body.appendChild(d.createElement('canvas')).getContext('2d');t=setInterval("a.clearRect(0,0,300,150);p(a,t++, 50,50,1e3,.2,1)")

Live JSFiddle example here
By making the code fully procedural I no longer needed any array or object-assignment code, reducing the size a lot. Making a procedural effect also has some other nice side-effects.
The code could be made smaller by ommitting Gravity, Seeds, Number of Particles, etc, but I think these features are too nice to remove ;).
Features

Configurable X,Y center of explosion.
Configurable number of particles
Gravity in the vertical direction: Have your particles fall down or fly up!
Seedable, each seed has its own explosion and will show exactly that explosion each time, across computers.
Slowmotion, Fast Forward and playing explosions Backwards is all possible, due to the procedural way the effect is created.
Size:138 bytes.

Also check it out on GitHub, for an annotated version.

Python with PyGame, 240 chars
I realize that there is already a solution in python, but since that one just prints characters, I thought it would be worthwhile to make one that draws a nice animation.
Ungolfed, what I started with:
import math
import random
import pygame
pygame.init()

screen = pygame.display.set_mode((800, 800))
particles = [(random.gauss(0,.5), random.uniform(0,6.28318)) for i in range(2000)]

for i in range(399):
    screen.fill((255,255,255))
    for speed, angle in particles:
        distance = i * speed
        x = 400 + distance * math.cos(angle)
        y = 400 + distance * math.sin(angle)
        screen.set_at((int(x), int(y)), (0,0,0))
    pygame.display.flip()

After much hackery. Fullscreen to save some characters. Not using sound or fonts, so I think init() is unnecessary (it works for me).
import math as m,random,pygame
d,x,g=pygame.display,range(999),random.gauss
s,e=d.set_mode(),[(g(0,.2),g(0,9))for i in x]
for i in x:
 d.flip(),s.fill([255]*3)
 for v,a in e:
        y=400+i*v*m.cos(a),400+i*v*m.sin(a)
        s.set_at(map(int,y),[0]*3)

Python -- 327 chars
Intresting things:

Use complex number as 2D vector
(v * cos(a), v * sin(a)) implemented as v*e**(1j*a)
Looks like a 3D explosion.
Gravity.

.
import pygame as P,random as R,math
R=R.random
D=P.display
D.init()
W=800
S=D.set_mode((W,W))
T=P.time.Clock()
C=lambda v:map(int,(v.real,v.imag))
X=[(8+R())*math.cos(R()*1.57)*2.7**(1j*R()*6.28) for i in range(999)]
for t in range(250):
 D.flip();T.tick(30);S.fill(2**24-1)
 for v in X:S.set_at(C(v*t+.005j*t*t+W/2*(1+1j)),0)

dwitter 112
c.width^=0
t?o.push({X:1e3,Y:500,U:S(99*t),V:C(9*t)}):o=[]
o.map(a=>{a.X+=a.U,a.Y+=a.V,x.fillRect(a.X,a.Y,9,9)})

try it out by copy/pasting the code to dwitter.net


text:
Golf a mutual quine
Using two languages of your choice, write the smallest “mutual quine” you can.
That is, write a program P in language A that outputs the source code for a program Q in language B, such that the output of program Q is identical to the source code for P.
Empty files don't count, nor do "read the source file and print it"-style programs.
Edit: Answers with P=Q no longer count.

Btw, this should preclude cases where the sources match. For example 1 is a quine in several languages. So you could say its a J program that prints a Golfscript program that prints a...... and so on.

you can adopt the rule of "Try to avoid or rather don't use 1 byte submissions like this one ,since it spoils all fun." from http://codegolf.stackexchange.com/questions/1393/code-golf-quine-challenge-i

A Brainfuck + Befunge solution should be posted.

Can language A = language B?

Since this is golf, can you clarify the scoring criteria? For example, is the final score the sum of the byte counts of P and Q? Or the minimum of the byte counts of P and Q?

Gol><> and APL, 10 bytes and 13 bytes
'r3d*:::}H

Try it online! Which outputs:
'''r3d*:::}H'

Try APL online!
Which simple prints the code as a string (with the ' escaped with another ')

Python and Ruby, 39 characters
This Python snippet
s='puts %%q{s=%r;print s%%s}';print s%s

generates this Ruby snippet
puts %q{s='puts %%q{s=%r;print s%%s}';print s%s}

which then generates the inital Python snippet again:
$ diff -s mutualquine.py <(ruby <(python mutualquine.py))
Files mutualquine.py and /dev/fd/63 are identical

Note that this is similar to J B's answer.

C and Perl, 73
This C:
main(s){printf(s="print q<main(s){printf(s=%c%s%c,34,s,34);}>",34,s,34);}

...outputs the following Perl:
print q<main(s){printf(s="print q<main(s){printf(s=%c%s%c,34,s,34);}>",34,s,34);}>

...that outputs the C back.

Save 4 bytes: main(s){printf(s="print q<main(s){printf(s=%c%s%1$c,34,s);}>",34,s);}

C and C++, 123 chars

This C (compilable with gcc v4.3.4):
#include <stdio.h>
main(){char *c="#include <stdio.h>%cmain(){char *c=%c%s%c;printf(c,10,34,c,34);}";printf(c,10,34,c,34);}

outputs this (identical) C++ (compilable with g++ 4.3.4, one warning):
#include <stdio.h>
main(){char *c="#include <stdio.h>%cmain(){char *c=%c%s%c;printf(c,10,34,c,34);}";printf(c,10,34,c,34);}

This is within the rules as posted.  :P  And, like Ventero's, this is based on J B's answer.

OK, so it was within the rules as posted until the edit saying the sources can't be the same. A minor change could fix that, but I'm disinclined to encourage such late edits.

><> (Fish) and Python - 26 characters
"00gr00g:a9*2+$' tnirp'>o<

Generates this Python
print "\"00gr00g:a9*2+$' tnirp'>o<"

You have an issue with the ><> code because " and ' enable string parsing, so the entire program is just pushed onto the stack and never displayed.

@Bass5098 That's precisely how the whole thing works. The first " enables string parsing. It reads.the whole program and then wraps back around to.the first " and runs the program with itself on the stack

Fixed the issue in my interpreter.  Your ><> code outputs print \00gr00g:a9*2+$' tnirp'>o< after timing out.  I'm pretty sure this is because g copies the actual cell contents, but o outputs the ASCII version of the character, and " isnt a valid ASCII character code. http://ideone.com/kaM0r

@Bass5098 " is ASCII 34. Your interpreter must be off.

Python + Piet one-liners: 417 chars + 7391 7107 executing codels
This Python script produces a 7393 x 2 image; the rightmost 2x2 block of which is a "sentinel" which terminates the program; so I'm not counting those; and the second row is otherwise white.  I can probably golf the piet code down further by using addition/subtraction/multiplication chains instead of the naive binary algorithm... but I don't want to give away a solution to a future puzzle.
I'm not going to post the image here, because of its ridiculous dimensions.  If you want to see it, run the python code, and pipe the output to a .ppm file.  Then, convert the .ppm to a .gif, and run the output at Rapapaing.  (alternately, use a non-web Piet interpreter that groks .ppm)
A='P=lambda A:reduce(lambda(D,H,B),P:(D[P/3:]+D[:P/3],H[P%3*2:]+H[:P%3*2],B+"".join("%i "%H[(D[0]/P)%2]for P in[1,2,4])),map(" A !        @    B".find,A),([1,3,2,6,4,5],[0,192,192,255,0,255],"P3 %i 2 255 "%(len(A)+2)))[2]+"255 "*4+"0 0 "+"255 "*len(A)*3+"255 0 0 "*2;B=lambda D:["@!%s","@@!%s!"][D%2]%B(D/2)if 1<D else"";print P("".join("A%sB"%B(ord(D))for D in"A=%s;exec A[:-13]"%`A`)+" ");exec A[:-13]';exec A[:-13]

edit: golfed the piet a bit by reducing Hamming weight of variable names.
less golfed pre-quine:
This is a previous version, before I realized I could make it a one-liner.  It's marginally easier to understand.  The function P translates a special instruction set into Piet; and the function p takes an integer and produces a sequence of instructions to create that integer on the stack.  I'm only using the instructions =,+,:,|, so this could probably be made more efficient... but I kinda like having a fullblown Piet compiler (of sorts) in the source.
s="""def P(s):
 l=len(s)+1;R="P3 %i 2 255 "%(l+2);C=[1,3,2,6,4,5];V=[0,192,192,255,0,255]
 for x in map("=|^+-*/%~>.,:@$?#!".find,"="+s):
  C=C[x//3:]+C[:x//3];V=V[x%3*2:]+V[:x%3*2]
  for i in [1,2,4]:R+="%i "%V[(C[0]//i)%2]
 return R+"255 "*4+"0 0 "+"255 "*l*3+"255 0 0 "*2
p=lambda x:[":+%s","::+%s+"][x%2]%p(x/2)if x/2 else""
print P("".join("|%s!"%k(ord(c))for c in "s="+`s`+";exec s[:-13]"))
exec s[:-13]"""
exec s[:-13]

Piet Creator is a much nicer (and far less buggy) Piet IDE. Written by a user of this site, by the way :)

I've used Piet Creator before; it's a great tool.  Rapapaing is nice for people who are lazy, like me, and don't want to bother.  FWIW, I'd use Piet Creator if you ran it through http://github.com/kripken/emscripten/wiki, and put that up on your page.

I couldn't even get the Qt version to compile here ;)

;) Thanks for trying, anyway.  I wrote you a fuzz tester: http://codegolf.stackexchange.com/questions/2922/generate-a-random-program-in-your-favorite-language/3226#3226

Well, you could poke Casey in chat and point him to it ;-)

Java to Python - 219
Java:
class Q{public static void main(String[]a){char q=34,c=39;String s="print%sclass Q{public static void main(String[]a){char q=34,c=39;String s=%s%s%s;System.out.printf(s,c,q,s,q,c);}}%s";System.out.printf(s,c,q,s,q,c);}}

Python:
print'class Q{public static void main(String[]a){char q=34,c=39;String s="print%sclass Q{public static void main(String[]a){char q=34,c=39;String s=%s%s%s;System.out.printf(s,c,q,s,q,c);}}%s";System.out.printf(s,c,q,s,q,c);}}'

Makes use of the fact that python allows ' for strings; this makes it much easier to write the java program's source in the python program.

+1 for doing the dirty work in the worst golfing language ever. :P

/Brainf..k/, 6988 bytes
Brainfuck
++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++>>>+>>>++++++++++>>>+++++++++++>>>++>>>+++++++++>>>+>>>++>>>++++++>>>+>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>++>>>+++++++>>>++>>>++++++++++>>>+>>>++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++++>>>+++++++++++>>>+>>>++>>>+>>>++>>>++>>>+++++++>>>++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>+>>>++++++>>>+++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++>>>++++++>>>+++++++>>>+>>>+>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>+>>>+>>>+>>>+>>>++++++++++>>>+++++++++++>>>++>>>+>>>+>>>+>>>+>>>++>>>+>>>++>>>+>>>++>>>++>>>++>>>++++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++>>>++++++++++>>>+++++++++++>>>+>>>++>>>++>>>++>>>++>>>++++++>>>+++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++++>>>+++++++++>>>++>>>++++++++++>>>+>>>+>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++>>>++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>++++++>>>+++++++>>>+++++++>>>++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>++++++>>>++++++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++++>>>+>>>++>>>+++++++++>>>++++++>>>++++++>>>+++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++++++>>>++++++>>>+++++++>>>+>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>+>>>++++++>>>+++++++>>>++>>>++++++++++>>>++++++>>>++++++>>>++++++>>>++++++++>>>++++++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++>>>++++++++>>>+++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++>>>++++++>>>++++++++>>>++++>>>+++++++>>>+++++>>>+++>>>+++++>>>++++>>>+++++++>>>+++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++>>>+++++>>>++++++++>>>++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++++>>>++++++>>>++++++++>>>++++++>>>++++++>>>++++++>>>+++++++++>>>+++++++>>>+++++++>>>+++++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++>>>+++++++>>>++++>>>++++++++>>>++++++>>>+++>>>+++>>>+++++++>>>++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>+++++++++>>>++++++>>>+++++>>>+++++++>>>+++++++>>>+++++++>>>+++++++>>>+++++++++>>>+++++++++++>>>++++++++++>>>+++++++++++>>>++++++>>>+++++++>>>{({}<>)<>}<>{([({})]()<((((()()()()()){}){}){})>){({}()<({}())>){({}()<({}()())>){({}()<({}()())>){({}()<({}())>){({}()<({}((()()()){}()){})>){({}()<({}()())>){({}()<({}(((()()()){}()){}){}())>){({}()<({}()())>){({}()<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}}}}{}({}<(<>)<>{({}<>)<>}{}>)(<><>)<>{({}<>)<>}{}<>{({}[()])<>(((((()()()){}())){}{}){}())<>}{}<>(((({})(((()()())){}{}){}())))<>}{}([]){((({}[()])<{({}[()]<({}<({}<>)<>>)>)}{}>)<{({}[()]<<>({}<>)>)}{}>)}{}{<>({}<>)}{}(<>){<<<[<<<]>>>[>++++++++++++++++++++++++++++++++++++++++.<[->.+.->+<<]>+.[-]>>]<[<<<]>>>[<++++++++++++++++++++++++++++++++++++++++>-[<+>-[<++>-[<++>-[<+>-[<++++++++++++++>-[<++>-[<+++++++++++++++++++++++++++++>-[<++>-[<++++++++++++++++++++++++++++++>-[<++>-]]]]]]]]]]<.>>>>]}{}<>

Try it online!
Brain-Flak
(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()())(())(()())(()()()()()())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()())(())(()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(())(()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(())(()()()()()())(()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()())(()()()()()())(()()()()()()())(())(())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(())(())(())(())(()()()()()()()()()())(()()()()()()()()()()())(()())(())(())(())(())(()())(())(()())(())(()())(()())(()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()())(()()()()()()()()()())(()()()()()()()()()()())(())(()())(()())(()())(()())(()()()()()())(()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()()()())(()()()()()()()()())(()())(()()()()()()()()()())(())(())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()())(()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()())(()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(()()()()()())(()()()()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()())(())(()())(()()()()()()()()())(()()()()()())(()()()()()())(()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()())(()()()()()()())(())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()())(()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(())(()()()()()())(()()()()()()())(()())(()()()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()())(()()()()()())(()()()()()()()())(()()()())(()()()()()()())(()()()()())(()()())(()()()()())(()()()())(()()()()()()())(()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()())(()()()()())(()()()()()()()())(()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()()())(()()()()()())(()()()()()()()())(()()()()()())(()()()()()())(()()()()()())(()()()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()())(()()()()()())(()()())(()()())(()()()()()()())(()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()()()()())(()()()()()())(()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()())(()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()())(()()()()()()()()()()())(()()()()()())(()()()()()()()){({}<>)<>}<>{([({})]()<((((()()()()()){}){}){})>){({}()<({}())>){({}()<({}()())>){({}()<({}()())>){({}()<({}())>){({}()<({}((()()()){}()){})>){({}()<({}()())>){({}()<({}(((()()()){}()){}){}())>){({}()<({}()())>){({}()<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}}}}{}({}<(<>)<>{({}<>)<>}{}>)(<><>)<>{({}<>)<>}{}<>{({}[()])<>(((((()()()){}())){}{}){}())<>}{}<>(((({})(((()()())){}{}){}())))<>}{}([]){((({}[()])<{({}[()]<({}<({}<>)<>>)>)}{}>)<{({}[()]<<>({}<>)>)}{}>)}{}{<>({}<>)}{}(<>){<<<[<<<]>>>[>++++++++++++++++++++++++++++++++++++++++.<[->.+.->+<<]>+.[-]>>]<[<<<]>>>[<++++++++++++++++++++++++++++++++++++++++>-[<+>-[<++>-[<++>-[<+>-[<++++++++++++++>-[<++>-[<+++++++++++++++++++++++++++++>-[<++>-[<++++++++++++++++++++++++++++++>-[<++>-]]]]]]]]]]<.>>>>]}{}<>

Try it online!
The Brain-Flak might time out on TIO.
Explanation
Coming soon.

That polyglot at the end is quite impressive...

Explanation coming soon -> Jan 27

@MDXF Explanation coming soon checks date

When you'll add an explanation?

@Fmbalbuena Soon.

@MDXF it’s already May 5 now!

Ruby and Python (393 + 413 = 806 chars)
Slight change of this answer of mine.  Could definitely be reduced since I just hard-coded the input without any optimisation.
Ruby (393 chars)
require 'json';s=%q[{"ruby":[" %q[","require 'json';s=##;j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))"," ]"],"python":["' ''","import json,re;s=##;j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))","' ''"]}];j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))

Python (413 chars)
import json,re;s='''{"ruby":[" %q[","require 'json';s=##;j=JSON.load s;puts j[l='python'][1].sub('##',j[l][0].delete(' ')+s+j[l][2].delete(' '))"," ]"],"python":["' ''","import json,re;s=##;j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))","' ''"]}''';j=json.loads(s);l='ruby';print(re.sub('##',j[l][0].replace(' ','')+s+j[l][2].replace(' ',''),j[l][1],1))

Python 2 to Befunge 98, 94 78
Again, making use of Python's two ways of making strings:
Python:
s='<@,kM%c%cs=%c%s%c;print s%%(39,34,39,s,39,34)%c';print s%(39,34,39,s,39,34)

Befunge 98:
<@,kM'"s='<@,kM%c%cs=%c%s%c;print s%%(39,34,39,s,39,34)%c';print s%(39,34,39,s,39,34)"

The python program formats the string to include itself and the characters for the single and double quote.
The Befunge program works like this:

<: move to the left, and wrap around. So now we execute the commands from right to left
": make it so that every char we encounter is pushed to the stack until we encounter another ", so we push:
)43,93,s,93,43,93(%s tnirp;'c%)43,93,s,93,43,93(%%s tnirp;c%s%c%=sc%c%Mk,@<'=s

Which is actually just the python program, reversed because of the way Befunge prints (which is a pop+print loop)
'M:  push M to the stack. M is also the number 77, which is one less than the number of chars pushed to the stack by the "s.
k: pop the top value off the stack (M) and do the next operation that many times, plus one.
,: pop the top value off the stack and print the char.
@: end the program.

Good grief, and in a notoriously difficult esoteric language too. Thats..... terrifying.

Clipper and C (111 + 108 = 219 chars)
Clipper (111)
?'char*f="%c%cchar*f=%c%s%c;main(){printf(f,63,39,34,f,34,39,10);}%c%c";main(){printf(f,63,39,34,f,34,39,10);}'

C (108)
char*f="%c%cchar*f=%c%s%c;main(){printf(f,63,39,34,f,34,39,10);}%c%c";main(){printf(f,63,39,34,f,34,39,10);}

This is a bit of a cop-out because:

the "print" command in Clipper is really simple: ?'foo' :-)
I based it on the "classic C" quine from http://www.nyx.net/~gthompso/quine.htm, with some modification to squeeze in the ? and 's.
I didn't #include <stdio.h>, so it gives a compiler warning
The C code output by the Clipper version had to be prodded to remove a line break that had been introduced by an 80-character column limit in either my terminal or the Harbour printing routine or something.

Well, the BASIC PRINT command could be abbreviated ? as well :-)

Underload and Betaload, 16 bytes
Underload:
(a(:^)*a(S)*S):^

Betaload:
((a(:^)*a(S)*S):^)S

Betaload is a superset of Underload, so this could be two Underload answers.

Jelly, 13 bytes
“Ṿ;⁾v`+/ŒṘ”v`

Try it online!
RAD
'“Ṿ;⁾v`+/ŒṘ”v`'

Try it online!
A Jelly quine that wraps itself in single quotes, such that the resultant RAD program simply prints the original Jelly program back out.

Vyxal, 10 bytes
`:qpq`:qpq

Try it Online!
Vyxal V
`\`:qpq\`:qpq`

Try it Online!
The V flag does nothing, the first is a quine that unevaluates itself, and the second is a string.
Or...
Vyxal DrV, 16 bytes
`q\`:Ė\`p1→ip`:Ė

Try it Online!
Vyxal Dr
0`q\`:Ė\`p1→ip`:Ė

Try it Online!
The 0 at the start is a NOP - Vyxal pads the stack with 0s anyway, so the two programs are functionally identical.
`q\`:Ė\`p    `:Ė # Standard eval quine
         1→ip    # If `V` (single-char variable names) is off, this stores 1 to the variable ip.
                 # If it's on, this stores 1 to the variable i and prepends a 0 to the current program.

Guile, 114 bytes
((lambda(v)(format #t".\\~s"(format #f" (~a~s)"v v)))"(lambda(v)(format #t\".\\\\~s\"(format #f\" (~a~s)\"v v)))")

Try it online!
Forth (gforth), 139 bytes
.\" ((lambda(v)(format #t\".\\\\~s\"(format #f\" (~a~s)\"v v)))\"(lambda(v)(format #t\\\".\\\\\\\\~s\\\"(format #f\\\" (~a~s)\\\"v v)))\")"

Try it online!

Python and ~-~! - 77 and 81 = 158
This Python code:
q=chr(124);s='@%sq=chr(124);s=%s;print(s%%repr(s))%s:';print(s%(q,repr(s),q))

outputs this ~-~! code:
@|q=chr(124);s='@%sq=chr(124);s=%s;print(s%%repr(s))%s:';print(s%(q,repr(s),q))|:

Can definitely be improved a lot, and adopts a whole bunch from the other answers.

Javascript and Windows .bat, 71 bytes and 81 bytes
f=()=>{console.log('echo f='+(f+';f()').replace(/(?=[>^\\])/g,'^'))};f()

and
echo f=()=^>{console.log('echo f='+(f+';f()').replace(/(?=[^>^^^\^\])/g,'^^'))};f()


text:
nth number with n distinct prime factors
A073329 is a sequence where the \$n\$th term is the \$n\$th number with exactly \$n\$ distinct prime factors. For example, \$a(3) = 60\$ as the first \$3\$ integers with \$3\$ distinct prime factors are \$30 = 2 \times 3 \times 5\$, \$42 = 2\times3\times7\$ and \$60 = 2^2 \times 3 \times 5\$.
You are to take a positive integer \$n\$ and output the first \$n\$ terms of the sequence. You may assume the input will never exceed the bounds of your language's integers. This is code-golf so the shortest code in bytes wins.
The first 10 terms of the sequence are
2, 10, 60, 420, 4290, 53130, 903210, 17687670, 406816410, 11125544430

Limits/bounds??

I'm not really concerned with limits and bounds, but if it's important to you, do the algorithm assuming the input will be no more than 8, and we'll pretend it works for higher numbers. As I said, I'm interested in the abstract mathematical algorithm, not the details of a particular language's integer limitations.

Maybe it is more open, when we say: output a(1), ... a(n) instead of return something, like an array of ...

I've edited the challenge to be slightly more up to date, as well as include an example and some relevant tags. Feel free to revert any changes you dislike

Python, 144 chars
R=range
P=[x for x in R(2,99)if all(x%i for i in R(2,x))]
for a in R(input()):
 x=n=0
 while n<=a:n+=sum(x%p==0for p in P)==a+1;x+=1
 print x-1

It takes about 2 minutes to run to completion for x=8.

Java, 170 characters in one line
int a(int n) {
    int a = 2, t = a, m = 1, i = 1;
    Set s = new HashSet();
    while (i++ > 0) {
        if (t % i == 0) {
            s.add(i);
            t /= i;
            if (t == 1) {
                if (s.size() == n) {
                    if (n == m) {
                        break;
                    }
                    m++;
                }
                t = ++a;
                s.clear();
            }
            i = 1;
        }
    }
    return a;
}

Update, +77 characters IOL
int[] f(int n) {
    int[] f = new int[n];
    for (int i = 0; i < n; i++) {
        f[i] = a(i+1);
    }
    return f;
}

This is actually incorrect, but close, though I think I should perhaps make my question clearer. You should be returning an integer sequence. For instance, if the input 8, you should return the first 8 elements in the A073329 sequence.

@Gregory look at update

I'm sorry - I voted you down, based on my own misunderstanding of the task, which clarified after reading the OEIS-link. If you do a minor edit of your post, I can and will revoke my downvote.

@user because of my own misunderstanding of your comment, clarify your request, please

I misunderstood the question, and thought, all factors must be distinct primes, so 235*2 would be a wrong answer. So I voted your answer down for beeing false. Then I discovered, how 'distinct primes' is to understand, and wanted to correct my voting, but I'm not allowed to change my vote - it's only possible in the first, few minutes. But if you edit your answer, I can change my vote. So I'm asking you to edit just a little bit.

Java (Ungolfed)
public class M {

    public static void main(String[] a) {
        final int N = 100000000;
        int[] p = new int[N];
        for(int f = 2; f * f < N; f++) {
            if(p[f] == 0)
                for(int k = f; k < N; k += f)
                    p[k]++;
        }
        for(int i = 1; i <= 8; i++) {
            int c = 0, j;
            for(j = 1; j < N && c < i; j++)
                if(p[j] == i)
                    c++;
            if(c == i)
                System.out.println(i + " = " + --j);
        }
    }
}

Uses a sieve algorithm. It's pretty quick. (6 Seconds)
Will work accurately for upto 8, will probably fail for anything higher.

JavaScript, 149 chars
function(n){function f(x){for(r=[],o=x,z=2;z<=o;x%z?++z:(x/=z,r.indexOf(z)+1?0:r.push(z)));return r}for(c=0,i=1;c<n;)f(++i).length==n?c++:0;return i}

Feels unresponsive for n >= 6 so I haven't tested how long it takes (my browser pops up a hung script notification every 10 seconds or so therefore I can't time it accurately and I don't want to completely hang if I check "don't show this again"...)
Edit: To return array is 200 characters (+51):
function(n){function F(){function f(x){for(r=[],o=x,z=2;z<=o;x%z?++z:(x/=z,r.indexOf(z)+1?0:r.push(z)));return r}for(c=0,i=1;c<n;)F(++i).length==n?c++:0;return i}for(a=[];n>0;n--)a.push(f());return a}

Jelly, 9 bytes
Æv=¥ḷ#)Ṫ€

Try it online!
How it works
Æv=¥ḷ#)Ṫ€ - Main link. Takes n on the left
      )   - For each integer 1 ≤ k ≤ n, so the following:
   ¥ḷ#    -   Find the first k integers for which the following is true:
Æv        -     The number of distinct prime factors
  =       -     equals k
       Ṫ€ - Return the last element from each list

J, 32 bytes
({"0 1~i.@#)(]/.~#@~.@q:)

But since I'm answering my own question so late, we'll just leave this answer as a curiosity.

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