text:
Sort an array only using recursion
Your task is to write a function that sorts an array.

Your function:

Cannot call other functions (excluding itself, of course);
Must receive an array of integers as input, and it must return the ordered array. Feel free to add other parameters as input, if you need them.
Cannot use any kind of loop (for, while...) except recursion;
Cannot access the internet;
Can be overloaded if you need it.

Code-Golf here. Shortest code wins, as usual.
Happy coding!

Most of the solution to http://codegolf.stackexchange.com/questions/2027/implement-a-sorting-algorithm-with-no-change are recursive in nature (though they work on characters rather than integers).

I find 'cannot call other functions' very vague.  How would one define a function?  I think one could reasonably consider array-indexing a function (see e.g. Haskell's (!!)), and similarly for all other means of accessing the content of the array, but in order to sort the array one has to have a means of acessing its content.  Sure, array-indexing might be one extreme, but it's a slippery slope and it's not clear to me where the line is.

In Ruby, all comparison operators (<=> and < and so on) and array operators ([] and []=) are function calls, so this task is impossible, unless I can call functions defined by the language.

I’m voting to close this question because the "cannot use any kind of loop" requirement is unobservable.

APL (36)
{⍵≡⍬:⍬⋄(∇z/m),p,∇m/⍨~z←(p←⊃⍵)≥m←1↓⍵}

It's quicksort:

⍵≡⍬: if the list is equal to the empty list
:⍬: then return the empty list
⋄: otherwise:

m←1↓⍵: m is the list minus its first element
p←⊃⍵: p (pivot) is the first element
z←(p←⊃⍵)≥m: z is a bitmask of those values of m that are smaller than p.
∇m/⍨~z select the inverse of z from m (= larger numbers) , and sort it recursively
p,: pivot
∇z/m: select z from m (= smaller or equal numbers) and sort it recursively

Surely the filtering must fall foul either of calling another function or of being a loop?

C - 137 char (including whitespaces)
int*s(int*a,z,x,c){if(c){if(a[c-1]>a[c]){int t=a[c];a[c]=a[c-1];a[c-1]=t;}if(c>=z-1)c=-1;s(a,z,x,c+1);}if(x<z&&!c)s(a,z,x+1,1);return a;}

expanded version
int* s(int *a,z,x,c)  // this give a warning because of not specified type, but default is int so it's ok
{
    if (c)
    {
        if (a[c-1] > a[c])
        {
            int t = a[c];
            a[c] = a[c-1];
            a[c-1] = t;
        }
        if (c >= z-1)
            c = -1;

        s(a, z, x, c+1);

    }

    if (x < z && !c)
        s(a, z, x+1, 1);

    return a;
}

If you want to test it add:
int anArray[10] = {10, 1, 123,121,34,12,43,65,86,34};
s(anArray, 10, 1, 1);
printArray(anArray);

void printArray(int *arr)
{
    for(int i = 0; i < 10; i++) {
        printf("%d ", arr[i]);
        printf("\n");
    }
    printf("\n");
}

GolfScript (42 41)
{.,2={[.(+].~>=}*.,2>{(\S+)\S\+(\S+}*}:S;

Note: this assumes that bool{...}* is acceptable as an if without else. (Technically it's a loop). Replacing it with bool{...}{}if would add 3 chars twice.
This is a pessimisation of an already bad sorting algorithm presented in an exercise of Introduction to Algorithms, by Cormen, Leiserson, and Rivest. From memory, their version is
sort(A, off, len):
    if (len == 2) special case.
    if (len > 2):
        third = floor(len / 3)
        sort(A, off, len - third)
        sort(A, off + third, len - third)
        sort(A, off, len - third)

But all that mucking around with thirds uses characters. I do
sort(A, off, len):
    if (len == 2) special case.
    if (len > 2):
        sort(A, off, len - 1)
        sort(A, off + 1, len - 1)
        sort(A, off, len - 1)

are you actually returning the array, or are you just modifying it?

@Quincunx, returning it. Arrays are immutable in GolfScript. The pseudocode is to show the high-level algorithm, not the low-level detail.

Haskell - 51
Standard insertion sort in Haskell. I hoped I would beat golfscript for once but alas, I could not.
I could save two chars if I left out the [] from first line and require the user to pass an extra empty array as parameter, but since it makes no difference I opt not to do so.
Actually I'm not sure if foldr is allowed. It's a higher order function that sort of automates one family of recursion. If it's not drop a comment and I'll do my best to fix this.
s=foldr(%)[]
e%[]=[e]
e%(s:t)|e<s=e:s:t|e>=s=s:e%t

Not only is foldr a function, but you seem to be defining two functions, one of which calls the other, which is also against the rules on my reading of them. This is a curious task because the requirement for recursion would seem to favour functional languages, but then their strict static typing restricts their options considerably.

Actually the s in the last line is not the one defined in the first one, so it's not mutual recursion. (%) actually calls only itself. I still think functional programming languages have a huge advantage over non-functional ones, but I consider golfscript and the likes to have the necessary functional paradigm traits. Compared to your answer though, Haskell has floor and addition as functions, and default lists have two character indexing and no slicing.

Actually I thought it was the other way round: it looks to me like you're defining a main function s which calls an auxiliary function %. Have I misread it?

That is true, or even more accurately I pass % as a parameter to foldr in s. I admit that in the strictest sense this is not allowed, but then also the whole problem would be impossible in haskell. Only way to add elements to a list is with a concatenation binary operator (:), which is actually a function since haskell makes no difference between the two.

Python 3 and 2 - 129 125 bytes
def s(a,i,m,o,l):
 if i<l:return s(a,i+1,[m,i][a[m]<a[i]],o,l)
 if l-o:a[o],a[m]=a[m],a[o];return s(a,o+1,-1,o+1,l)
 return a

This is called as s(list,0,-1,0,list_length).
The i<len(a) part simply runs through the array, finding the index of the max value. Then, we swap the value at that index with the current index (which I decided to call offset (o)).
This works even for an empty list and a one element list.
Note:Since it wasn't specified, I sorted descending. If the order should be ascending, replace the < at a[m]<a[i] with >.

shuffle is definitely a function. Your old solution is better because it follows the rules.

@PeterTaylor Oops, missed that rule.

Javascript - 147 characters
function s(a,i,j,l){(!l)&&(i=0,j=1,l=a.length);if(i<l){(n=a[i],m=a[j],1)&&(m<n)&&(a[i]=m,a[j]=n);return (j<l)?s(a,i,j+1,l):s(a,i+1,i+2,l)}return a}

Expanded:
function s(a,i,j,l) {
  (!l) && (i=0,j=1,l=a.length)
  if(i<l) {
    if(j<l) {
      if(a[j] < a[i]) {
        var t = a[i];
        a[i] = a[j];
        a[j] = t;
      }
      return s(a,i,j+1,l);
    }
    return s(a,i+1,i+2,l);
  }
  return a;
}

You can use an arrow function - From Review

GolfScript, 47 46 characters
{.,1>{.,3<{.~>{[~\]}*}{(\S(@[\]S~@+S+}if}*}:S;

The code became quite long in the end without using all those useful operators. You can try it online.
{
  .,1>{               # if length(array)>1
    .,3<{             # if length(array)<3
      .~>             #   copy array, expand and compare
      {               #   if two elements have wrong order
        [~\]          #     swap
      }*              #   end if
    }{                # else (recursive sort)
      (\S             #   remove first element, recursively sort rest of array
      (@              #   take first element and first element (smallest) of rest of array
      [\]S            #   sort those two
      ~               #   take smaller one
      @+S             #   concat other with rest of array and sort again
      +               #   join results
    }if               # end if
  }*
}:S;

Ruby - 69 characters
f=->(a){a[1]?(b,c=a.shift,f.(a);b>c[0]?[c.shift]+f.([b]+c):[b]+c):a}

Explanation:
f=->(a){
  a[1]?                     # if array length is larger than 1
    (
      b,c=a.shift,f.(a);    # recurse on the tail of the array
      b>c[0]?               # compare the head with the first item in the sorted array
        [c.shift]+f.([b]+c) # bigger - sort the array with the original head and concat with its own head
        :[b]+c              # add the head back to the sorted array
     )
    :a                      # array with 1 item or less - returns itself
}

Python (78)
Edit:
def s(a,b,i):d=a[:1]>b[i:];b[i:i]=a[:d];return a and s(a[d:],b,[i+1,0][d])or b

Golfed into a one-liner by replacing if clause with Boolean d and actions that do nothing unless d is 1. Now sorts descending.
Also, used list slicing and comparisons to shorten the condition, taking advantage of the empty list being smaller than nonempty ones.
I'm still hoping for a shorter way to do [i+1,0][d]. One can do equal with i+=1;i-i*d. Operator precedence is annoying here. I'd like to do something like (i+1)*!d, where ! is some higher-precedence way to complement d. Unfortunately, 1^d is too low-precedence.

Old version: (108 chars)

def s(a,b,i):
 if not a:return b
 if b[i:]and a[0]>b[i]:i+=1
 else:b[i:i]=a[:1];a=a[1:];i=0
 return s(a,b,i)

Call this as s(a,[],0), where a is the list to sort. In the recursion, a is the remaining list to sort and b is the part that's been sorted so far. Elements from a are pushed into b, which is maintained sorted. The index i tracks where we're looking to put the current element of a.
The line if not a:return b is horrendously wasteful. I'll try to golf it into something better when I get a chance.

C, 114, characters
int*f(int*a,int s,int i){int*c=a+i,*d=c+1;return s>1?*c>*d&&(*c^=*d,*d^=*c,*c^=*d),i+2<s?f(a,s,i+1):f(a,s-1,0):a;}

ungolfed:
int*f(int*a,int s,int i){
    int*c=a+i,*d=c+1;
    return s>1
                ?   *c>*d
                        &&(*c^=*d,*d^=*c,*c^=*d), //xor-swap
                    i+2<s
                        ?f(a,s,i+1) // swap the biggest number to the end of the array
                        :f(a,s-1,0) // last element of array is the biggest & sorted
                :a;
}

Explaination
This solution uses a bubble-sort. The result of every iteration of the bubble sort is that the largest element is at the end of the array, so we don't need to sort that part anymore and reduce the size of the array after every iteration. The algorithm is finished if we get to sort an array of the length 1.
Instead of swapping using a temporary variable I'm using a xor-swap. This only works on integers.
Further Golfing:
I have to write int a lot and it wastes a lot of characters, but I can't remove these like seen in the other C solution by @LombaX, because GCC throws an error if I do.
An other thing I could do which may result in a shorter code size is using a int* parameter as output instead of the return variable. The memory for the int* output parameter could be provided by the user of the function. In this solution I wouldn't have to swap and there would probably be a better algorithm.

C 142 bytes
Golfed
void s(int *a, int i,int j,int n)
{if((i+1)>=n)return;int t=0;if(a[i]>a[j]){t=a[i];a[i]=a[j];a[j]=t;}j++;
if((j+1)>=n){j=i+1;i++;}s(a,i,j,n);}

Ungolfed source: sorts in ascending order by swapping elements using i,j as indices.
void rec_sort(int *a, int i,int j,int n)
{
    if((i+1)>=n) return;
    int t=0;
    if(a[i]>a[j])
    {
        t=a[i];
        a[i]=a[j];
        a[j]=t;
    }
    j++;
    if((j+1)>=n)
    {
        j=i+1;
        i++;
    }
    rec_sort(a, i, j, n);
}

Python 2: 116
A simple bubble sort implementation
def s(l,i,d):
 n=i+1
 if n==len(l):return l if d else s(l,0,1)
 if l[i]>l[n]:l[i:i+2]=l[n],l[i];d=0
 return s(l,n,d)

len is a function.  I think it could be replaced with "if l[n:]:"


text:
Count occurrences of an integer
Based on the question How many positive integers < 1,000,000 contain the digit 2?. I'm looking for the most creative solution to count all the Integers from X to Y containing the Integer Z.  Z can be from 0 to Y.
Every found Integer only counts once, even if the integer Z appears more often.
For example:
Z = 2
123 counts 1
22222 also counts 1

I will start with a really simple algorithm written in Java (because it's beloved by everyone):
public class Count {
    public static void main(String[] args) {
        int count = 0;
        for (int i = Integer.parseInt(args[0]); i <= Integer.parseInt(args[1]); i++) {
            if (Integer.toString(i).contains(args[2])) {
                count++;
            }
        }
        System.out.println(count);
    }
}

if you run this with
java -jar Count.jar 0 1000000 2

you get this as the result:
468559

Because this problem is not hard to solve it's just a popularity-contest. Most upvoted answer posted by 28th of February wins!

It's not entirely clear from your post, but I guess Z can be between 0 and inf? Or just between 0 and 9?

Z can be between 0 and Y. It doesn't make sense that Z can be bigger than Y.

@OblTobl Do you really want to explicitly exclude the Z>Y case? Why not just have expected output in that case be 0?

@Cruncher i don't mind! but it's a little bit useless i think ;-)

Does this mean that N can be 123 and it would only match if the substring 123 exists?

@Populus exactly!

bash (20)
seq $1 $2|grep -c $3

Usage
$ bash count.sh 0 1000000 2
468559

it's funny if the call is longer than the program itself ;-)

Funciton
As usual, since the line height added by StackExchange breaks up the lines, consider running $('pre').css('line-height',1) in your browser console to fix that.
Unlike my other Funciton answers, this one does not use any function declarations. It’s just a program. It uses a lambda expression, though — a feature I added to Funciton in December :)
Expects the input as three decimal integers (can be negative) separated by spaces (i.e. x y z). In fact, z can be any string; for example, it could be just the minus sign (−, U+2212) to count the number of negative numbers in the interval :)
           ┌───╖
     ┌───┬─┤ ♯ ╟──────────┐
     │   │ ╘═══╝ ╔════╗ ┌─┴─╖             ┌────╖ ╔═══╗
   ┌─┴─╖ └────┐  ║ 21 ║ │ × ╟─────────────┤ >> ╟─╢   ║
 ┌─┤ ʃ ╟───┐  │  ╚══╤═╝ ╘═╤═╝             ╘═╤══╝ ╚═══╝
 │ ╘═╤═╝   │  └──┐  └─────┘   ┌───────────┐ │
 │ ╔═╧═╗ ┌─┴─╖ ┌─┴─╖ ╔════╗ ┌─┴─╖   ┌───╖ ├─┴────────┐
 │ ║   ╟─┤ · ╟─┤ ʘ ╟─╢ 32 ╟─┤ · ╟───┤ ʘ ╟─┘          │
 │ ╚═══╝ ╘═╤═╝ ╘═══╝ ╚════╝ ╘═╤═╝   ╘═╤═╝ ┌─────┐    │
 │         └───────┐  ╔═══╗ ┌─┴─╖     │ ┌─┴─╖   │    │
 │ ┌───────────┐   └──╢ 0 ╟─┤ ʃ ╟─┐   │ │ ♯ ║   │    │
 │ │   ┌───╖ ┌─┴─╖    ╚═══╝ ╘═╤═╝ │   │ ╘═╤═╝ ┌─┴─╖  │
 │ │ ┌─┤ ♯ ╟─┤   ╟─┬─┐ ╔════╗ │ ┌─┴─╖ │   │ ┌─┤ × ║  │
 │ │ │ ╘═══╝ └─┬─╜ └─┘ ║ −1 ║ └─┤ · ╟─┴───┘ │ ╘═╤═╝  │
 │ │ │    ┌────┴────┐  ╚══╤═╝   ╘═╤═╝       │ ╔═╧══╗ │
 │ │ │    │ ┌───╖ ┌─┴─╖ ┌─┴─╖ ┌───┴─────╖   │ ║ 21 ║ │
 │ │ │    └─┤ ♯ ╟─┤ ? ╟─┤ = ║ │ str→int ║   │ ╚════╝ │
 │ │ │      ╘═══╝ ╘═╤═╝ ╘═╤═╝ ╘═╤═══════╝   │ ┌────╖ │
 │ │ │      ╔═══╗ ┌─┴─╖   └─┐ ┌─┴─╖         └─┤ >> ╟─┘
 │ │ │      ║ 0 ╟─┤ ? ╟─┐   └─┤ · ╟───┐       ╘═╤══╝
 │ │ │      ╚═══╝ ╘═╤═╝ └─┐   ╘═╤═╝   └───┐   ┌─┴─╖
 │ │ │            ┌─┴─╖   └─┐ ┌─┴─╖       └───┤ ʘ ║
 │ │ └────────────┤ · ╟─┐   └─┤ ≤ ║           ╘═╤═╝
 │ │              ╘═╤═╝ │     ╘═╤═╝ ┌─────────╖ │
 │ │        ╔═══╗ ╔═╧═╕ │       └─┬─┤ int→str ╟─┘
 │ │        ║ 0 ╟─╢   ├─┤         │ ╘═════════╝
 │ │        ╚═══╝ ╚═╤═╛ └─────────┘
 │ └────────────────┴─┐              │
 │    ┌─────────╖   ┌─┴─╖ ┌─┐   ┌────┴────╖
 └────┤ str→int ╟───┤   ╟─┴─┘   │ int→str ║
      ╘═════════╝   └─┬─╜       ╘════╤════╝
                      └──────────────┘

That's pretty cool! Using a language you made yourself

@pcnThird: I think Timwi spends all his time either golfing or creating languages in which to golf (see also Sclipting)!

C#
public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine(Enumerable.Range(Convert.ToInt32(args[0]), (Convert.ToInt32(args[1]) + 1) - Convert.ToInt32(args[0])).Count(x => x.ToString().Contains(args[2])));
    }
}

Example
count.exe 0 1000000 2
468559

clever solution! i like it that you did it without a loop.

@OblTobl without a visible loop.

of course, nice anyways

It has a bug, .Range accepts (int start, int count), not (start, end). I always fall into this trap myself :)

Serves me right for quickly knocking this up in Notepad... I've tweaked the code so it is now correct!

Actually it has another bug. It only runs correctly if the system locale is one that uses 0123456789 digits. int.ToString() is culture-sensitive, meaning, it would use ٠١٢٣٤٥٦٧٨٩ on an Arabic machine :)

@mo_roodi Go grab LINQPad! ;)

@Timwi I don't see a problem here, if the last input is also in arabic it should work fine.

APL (29)
{+/∨/¨(⍕⍺)∘⍷¨⍕¨⊃{⍺+0,⍳⍵-⍺}/⍵}

This is a function that takes Z as the left argument and the interval [X,Y] as the right argument:
      2 {+/∨/¨(⍕⍺)∘⍷¨⍕¨⊃{⍺+0,⍳⍵-⍺}/⍵} 0 1e6
468559
      0 {+/∨/¨(⍕⍺)∘⍷¨⍕¨⊃{⍺+0,⍳⍵-⍺}/⍵} 0 1e6
402131
      42 {+/∨/¨(⍕⍺)∘⍷¨⍕¨⊃{⍺+0,⍳⍵-⍺}/⍵} 0 1e6
49401

not really clear...but really cool!

Python 2.7
Need for Speed
Explanation

Implementation
def Count(lo,hi,key):
    if hi == 0: return 0
    # Count(lo,hi,key) = Count(0,hi,key) - Count(0,lo - 1,key)
    if lo != 0: return Count(0, hi, key) - Count(0, lo - 1, key)
    # Calculate no of digits in the number to search
    # LOG10(hi) may be a descent trick but because of float approximation
    # this would not be reliable
    n = len(str(hi)) - 1
    # find the most significant digit
    a_n = hi/10**n
    if a_n < key:
        count = a_n*(10**n - 9**n)
    elif a_n > key:
        count = (a_n - 1)*(10**n - 9**n) + 10**n
    else:
        count = a_n*(10**n - 9**n) + 1
    if hi % 10**n != 0:
        if a_n != key:
            return count + Count(0, hi%10**n, key)
        else:
            return count + hi%10**n
    else:
        return count

Demo
In [2]: %timeit Count(0,123456789987654321,2)
100000 loops, best of 3: 13.2 us per loop

Comparison
@Dennis
$ \time -f%e bash count.sh 0 1234567 2
585029
11.45

@arshajii
In [6]: %timeit count(0,1234567,2)
1 loops, best of 3: 550 ms per loop

This is, of course, much faster, but it doesn't fulfill the question's requirements. key can be any integer, not digit, between lo and hi.

there is still a mathematical solution, though it would be even longer...

Scala:
args(0).toInt to args(1).toInt count (_.toString contains args(2))

PHP
Nothing original, just celebrating my first post here.
<?php

    $x = $argv[1];
    $y = $argv[2];
    $z = $argv[3];
    $count = 0;

    do
    {
        if (!(strpos($x, $z) === false))
            $count++;
        $x++;
    } while ($x <= $y);

    echo $count;

?>

Input
php script.php 0 1000000 2

Output
468559

bash - 32 31 17 14 characters + length of X, Y and Z
Thanks to devnull for suggesting seq!
seq [X] [Y]|grep -c [Z]

e.g. X = 100, Y = 200, Z = 20
$ seq 100 200|grep -c 20
2

e.g. X = 100, Y = 200, Z = 10
$ seq 100 200|grep -c 10
11

e.g. X = 0, Y = 1000000, Z = 2
$ seq 0 1000000|grep -c 2
468559

nice and clear one!

Why use echo when you could use seq and reduce the length by 4 characters? (1 for length of command, 2 for being able to omit curly braces and 1 for replacing .. with a single space)

@devnull - thank you, and can also get rid of xargs and wc - and it also runs much faster!

Python 2.7
A solution using regular expressions:
>>> from re import findall as f
>>> count=lambda x,y,z:len(f('\d*%d\d*'%z,str(range(x,y+1))))
>>>
>>> count(0,1000000,2)
468559

You can use re.findall in a one-liner by doing __import__('re').findall('\d...

R 23 25 27chars
Just get the right tool for the job. Simple use of grep in R, nothing fancy.
This is what it does: grep all instances of 2 in the vector 0 until 10e6 and count the number of results using length.
length(grep(2,0:100000,value=TRUE))
length(grep(2,0:10e6))

Result: [1] 468559

Offcourse you can write a function that takes the numbers as an input, just like it is shown in the example.
count = function(x=0, y=1000000, z=2){
  length(grep(z,x:y))
}

Now you can call count with with x, y and z, if unset (that is by default), the values for x, y and z are 0, 1000000 and 2 respectively. Some examples:
count()
[1] 468559

or
count(20, 222, 2)
[1] 59

or
count(0, 100, 10)
[1] 2

Some here think time is of importance, using this function in R takes around 1 second.
system.time(count())
user  system elapsed
0.979   0.003   0.981

maybe it's quite too short ;-)

Well, this is not [tag:code-golf] anyway :) I wonder: what would the program look like if it had to take the numbers as input (rather than hardcoding them)?

Created a function for the unimaginative ;)

Java8
Using the new IntStream stuff, this becomes essentially a one liner, if you ignore the obligatory Java Framework stuff:
import java.util.stream.IntStream;
public class A{
  public static void main(String[] args){
    System.out.println(IntStream.rangeClosed(Integer.parseInt(args[0], Integer.parseInt(args[1])).filter(x -> ((Integer)x).toString().contains(args[2])).count());
  }
}

It can be run here, although I did have to hardcode the values.

Really interesting Java solution

Regular Expression
Following will count 1's digits up to 49.
#!/bin/bash

echo "12313451231241241111111111111111111111111111111111111"  |\
sed "s/[^1]//g;s/11111/5/g;s/1111/4/g;s/111/3/g;s/11/2/g;s/555555555/45/g;s/55555555/40/g;s/5555555/35/g;s/555555/30/g;s/55555/25/g;s/5555/20/g;s/555/15/g;s/55/10/g;s/54/9/g;s/53/8/g;s/52/7/g;s/51/6/g;s/50/5
/g;s/40/4/g;s/30/3/g;s/20/2/g;s/10/1/g"

F#
This solution uses IndexOf to search the string, then a little bit of number fiddling to convert the result to 1 if found, and 0 if not found, then sums the result:
let count x y (z : string) =
    [ x .. y ] |> Seq.sumBy(fun n -> min 1 (n.ToString().IndexOf z + 1))

And it can be called like this:
count 0 1000000 "2" // 468559

Ruby
This is a great example to use reduce!
puts (ARGV[0]..ARGV[1]).reduce(0) { |c, n| n.to_s.include?(ARGV[2].to_s) ? c + 1 : c }

Input:
ruby script.rb 0 1000000 2

Output:
468559

Python golf - 61
f=lambda x,y,z:len([i for i in range(x,y)if str(z)in str(i)])

Python non-golf
def f(x, y, z):
    c = 0
    for i in range(x, y):
        c += str(z) in str(i)
    return c

Perl - 44 chars
$x+=/$ARGV[2]/ for$ARGV[0]..$ARGV[1];print$x

Usage
C:\strawberry\projects>perl county.pl 0 1000000 2
468559

My first golf with Perl(I'm learning it currently) so I'm open for suggestions! I'd appreciate them.

Okay, just saw after posting this, that one already posted a good golf with perl. atleast I was close! Will use grep in future since I understand it now after this example. :D

After some edits I beat the other one golfing with perl!

After fixing bugs I'm behind again. yey~

Ruby
Basically I took Pablo's answer and semi-golfed (38 chars if you drop unnecessary whitespace) it into a not-so-great example of using select.
It selects every index in the range (x .. y) that contains z. This intermediate result is unfortunately stored in an array, whose size is then returned.
x,y,z = $*
p (x..y).select{ |i| i[z] }.size

It looks pretty neat both syntactically and semantically, although the i[z] part doesn't really seem to make sense.
It works because x and y actually are strings, not numbers! Thus each i is also a string, and i[z] of course checks if the string z is contained in i.
$ ruby count-digits.rb 100 200 20
2
$ ruby count-digits.rb 0 1000000 2
468559

Python 2.7, 70 signs
f = lambda x,y,z: sum(map(lambda x: str(z) in str(x), range(0, y+1)))

>>> f(0, 1000000, 2)
468559

Shorter, 65 signs
g = lambda x, y, z: sum(str(z) in str(i) for i in range(0, y+1))
>>> g(0, 1000000, 2)
468559

I don't think you need range(0,y+1) if range(y+1) does the same thing.  Also, you can remove most of those spaces if you're golfing...

Using Ruby's Enumerable#grep:
start, stop, target = $*
p (start..stop).grep(Regexp.new target).size

T-SQL
If I can assume variables @X, @Y, and @Z are available:
With an (arbitrarily large ;) existing numbers table - 65
select count(*)from n where n>=@X and n<=@Y and n like '%'+@Z+'%'

With a recursive CTE - 127
with n(n)as(select @X union all select n+1 from n where n<@Y)select count(*)from n where n like'%'+@Z+'%'option(MAXRECURSION 0)

If the variables need to be defined explicitly:
Add 58 to both answers -- Numbers table: 123, Recursive CTE: 185
declare @X int=0;declare @Y int=100;declare @Z varchar(30)='2';

I have no idea how much memory the recursive CTE can use, but it's certainly not going to win any speed contests.  The example of searching for 2 in 0 to 1000000 takes 8 seconds on my system.
Here's a SQL Fiddle if anyone wants to play with it. The 1000000 query takes 30+ seconds to run.

not fast but very creative!

Mathematica
First way: strings
x, y, z are converted to strings. If a string-integer is not free of z, it is counted.
f[{x_,y_},z_] :=Length[Select[ToString/@Range[Max[x, z], y], !StringFreeQ[#, ToString@z] &]]

Examples
f[{22, 1000}, 23]
f[{0, 10^6}, 2]

20
468559

Second way: lists of digits
g[{x_,y_},z_]:=(t=Sequence@@ IntegerDigits@z;Length@Cases[IntegerDigits@Range[190],
{s___,t,e___}])

Examples
g[{22, 1000}, 23]
g[{0, 10^6}, 2]

20
468559

Mathematica is always fascinating, even for simple problems

Rebol
; version 1 (simple loop counting)

count: func [x [integer!] y [integer!] z [integer!] /local total] [
    total: 0
    for n x y 1 [if found? find to-string n z [++ total]]
    total
]

; version 2 (build series/list and get length)

count: func [x [integer!] y [integer!] z [integer!]] [
    length? collect [for n x y 1 [if find to-string n z [keep true]]]
]

Usage example in Rebol console (REPL):
>> count 0 1000000 2
== 468559

PowerShell
Two solutions, both 40 37 chars.
For all versions of PowerShell:
$a,$b,$c=$args;($a..$b-match$c).count

PowerShell V3 and up have the sls alias for Select-String. This requires the @ to force an array if only one value makes it through the pipeline.
$a,$b,$c=$args;@($a..$b|sls $c).count

Batch
@setLocal enableDelayedExpansion&@set a=0&@for /L %%a in (%1,1,%2) do @set b=%%a&@if "!b:%3=!" NEQ "!b!" @set/aa+=1
@echo !a!

H:\uprof>count 0 1000000 2
468559

H:\uprof>count 1 2 3
0

A bit more readable -
@setLocal enableDelayedExpansion
@set a=0
@for /L %%a in (%1,1,%2) do (
    @set b=%%a
    @if "!b:%3=!" NEQ "!b!" @set/aa+=1
)
@echo !a!

Nice and simple. Uses string manipulation to check if the variable !b! is the same as itself without the third user input, %3 (!b:%3=!).

GolfScript
I've been trying to improve my GolfScript skills so I thought I'd give it a shot with this question. Here's what I came up with:
`@@0\{.3$>}{.`4$?-1>@+\(}while@;;\;

This can be broken down like this:
0 1000000 2    # parameters

`@@            # convert Z to string and put at bottom of stack
0\             # init counter and swap
{.3$>}         # loop condition: Y > X
{              # loop body
  .`           # convert to string
  4$?          # search for substring
  -1>@+        # if found add to counter
  \(           # decrement Y
}              # end loop body
while          # perform loop
@;;\;          # cleanup

Even though it's GolfScript, by goal was more to try to make it relatively efficient rather than compact, so I'm sure that someone can point out various ways this can be improved.
Demonstration: Note that I've reduced Y in the demo so that it can complete in < 5 seconds.

PHP - 112
No visible loops, but a bit heavy on memory!
<?=count(array_filter(range($argv[1],$argv[2]),function($i)use($argv){return strpos($i,$argv[3].'')!==false;}));

Usage php script.php 0 1000000 2

ECMAScript 3 to 6 (javascript, JScript, etc)
using regex:
function f(x,y,z,r){for(r=0,z=RegExp(z);x<y;r+=+z.test(''+x++));return r}

breakdown:
function f(x,y,z,r){        // note argument `r`, eliminating the need for `var `
  for( r=0, z=RegExp(z)     // omitting `new` since ES will add it if omitted
     ; x<y                  //
     ; r+=+z.test(''+x++)   // `x++` == post increment
                            // `''+Number` == convert Number to string
                            // `test` gives true | false
                            // `+Boolean` converts boolean to 1 | 0
                            // `r+=Number` incrementing r (were Number is always 1 or 0)
     );                     // no body thus semicolon is mandatory!
  return r;                 // returning r
}

using indexOf:
function f(x,y,z,r){for(r=0;x<y;r+=+!!~(''+x++).indexOf(z));return r}

breakdown:
function f(x,y,z,r){                // note argument `r`, eliminating the need for `var `
  for( r=0                          // omitting `new` since ES will add it if omitted
     ; x<y                          //
     ; r+=+!!~(''+x++).indexOf(z)   // `x++` == post increment
                                    // `''+Number` == convert Number to string
                                    // `indexOf` returns index or `-1` when not found
                                    // `!!~ indexOf` converts sentinel value to boolean
                                    // `+Boolean` converts boolean to 1 | 0
                                    // `r+=Number` incrementing r (were Number is 1 or 0)
     );                             // no body thus semicolon is mandatory!
  return r;                         // returning r
}

this function-body is one char less then florent's, so when using ES6 => function notation the total would be 62 char
Example call: f(0,1e6,2)
Example use: alert( f(0,1e6,2) );
JSFiddle here
PS: both functions above return their local variable r.
So when leaking the result variable r into the global scope, one can again save 10 characters:
function f(x,y,z){for(r=0;i<=j;r+=+!!~(''+i++).indexOf(z));}

Example use: alert( f(0,1e6,2)||r );

Delphi - 120
Bit to much for my taste, going to see if i can get some off.
var x,y,z,i,c:int16;begin readLn(x,y,z);for i:=x to y do if inttostr(i).contains(inttostr(z))then inc(c);writeln(c);end.

don't mind for the length, i love to see a delphi solution ;-)

@OblTobl Great, but its so much fun to try make it short :P

k [28 chars]
{+/($x+!y)like"*",$:[z],"*"}

Usage
{+/($x+!y)like"*",$:[z],"*"}[0;1000000;2]
468559

You can save a character by replacing $:[z] with ($z).

However, the upper bound of your solution is incorrect. It enumerates from x to x+y-1, not from x to y.

Javascript - 55 54 chars (Loop)
(Shortest JS solution!)
Edit: 12/Feb/14 - Updated search condition - 1 char reduced
a=(x,y,z,c)=>{while(x<=y)c+=(x+++'').search(z)+1?1:0}

Using the new fat arrow notation.
Usage: a(1,20,2,0),c gives 3 (Note the fourth argument is compulsorily set to 0 and don't forget the ,c also. Just some work to save chars ;) ).
Javascript - 62 61 chars (Recursive)
Edit: 12/Feb/14 - Updated search condition - 1 char reduced
c=0
a=(x,y,z)=>{if(x<=y)c+=(x+'').search(z)+1?1:0,a(x+1,y,z)}

Usage: a(1,20,2),c gives 3
Feedback appreciated!

@ Everyone Just to let know, I miscounted the chars of recursive version. They are 62 instead of 72 :P Fixed.

Python 2.7 - 50 chars
Bit of a saving on the existing Python answers.
lambda x,y,z:sum(1for n in range(y-x)if`z+x`in`n`)

Using the following tricks:

Sum can be applied to a generator, unlike len, so use sum(1...) instead of len([n...])
Use `` instead of str(), which also allows...
Kill all spaces - see '1for' and 'ifz+xinn'
Remove the first range() arg by starting at 0 and testing the offset (actually...saves me nothing but I like the look of it better :) )

In action:
In [694]: (lambda x,y,z:sum(1for n in range(y-x)if`z+x`in`n`))(0,1000000,2)
Out[694]: 468559

k (28)
{+/($x+!y-x)like,/3#"*",,$z}

Takes three arguments, like this:
  {+/($x+!y-x)like,/3#"*",,$z}[0;1000000;42]
49401

Haskell (56 code, 16 import)
Thought I'd throw a little Haskell version into the mix!
import Data.List
c x y z=length$filter(isInfixOf(show z))$map show$[x..y]

It can be shorter if we are allowed to require that z be input as a string:
import Data.List
c x y z=length$filter(isInfixOf z)$map show$[x..y]

Usage:
> c 0 1000000 2
468559

perl [41 chars]
print 0+grep/$ARGV[0]/,$ARGV[1]..$ARGV[2]

Run:
> perl -le 'print 0+grep/$ARGV[0]/,$ARGV[1]..$ARGV[2]' 2 0 1000000
468559

Actually this are 43 needed chars.

You can remove the brackets () around the range, then it would be 41 chars.

sorry, my counting sucks. but thanks for the shortening

@LeoPflug your code doesn't work - try giving it '22' as the search parameter (i don't have enough rep to comment on your post), and also try giving it 1000 as the lower limit.

Thanks, now it works again. Although I still have to fix the lower limit, damn ... Should have used test cases. :(

Javascript
function f(s,e,n){for(r=0;e-->s;){if(~(''+e).indexOf(n))r++}return r}

f(0,1e6,2) returns 468559
What is --> operator ? Not an operator

Since you are leaking return variable r to the global scope, one could omit the return..

Also you can save a char by using a for loop. function f(s,e,n){for(r=0;e-->s;){if(e.toString().indexOf(n)>=0)r++}return r}

You can also change e.toString() to (e+'') and (...)>=0 to ~(...)`.

JavaScript (ES6), 63
f=(i,j,n)=>{for(c=0;i<=j;!~(''+i++).indexOf(n)?0:c++);return c}

Usage:
f(0, 1e6, 2)
> 468559

Un-golfed:
f = (i,j,n) => {
  for(
    // Initialize the counter.
    c=0;
    // Iterate through all integers.
    i<=j;
    // Convert current number into string then increment it.
    // Check if the digit appears into the current number.
    !~(''+i++).indexOf(n)
      // Occurence not found.
      ? 0
      // Occurence found.
      // Add 1 to the counter.
      : c++
  );
  return c
}

Golfscript - 18
My contribution in golfscript
`:i;,\>{`i?1+},,

Explaination:
`:i;        #Convert Z to string, store in i, and pop
,\>         #Generate range 0 ... Y and then remove values < X
{`i?1+},    #Filter all non-matches out of the array
,           #Count the number of values in the array

Try it here

TI-BASIC
As usual, -> represents the STO-> arrow:
:0->I
:Prompt X,Y,Z
:randIntNoRep(X,Y)
:Z=Ans
:cumSum(Ans)

Let's try it out:
X=?1
Y=?10
Z=?2
               1
            Done

This does not work. the Z=Ans line will return zero if the number is not exactly the same. It will for example not recognize the 2 in 12.

source: Stack Exchange

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

sort: votes


text:
Graphical, networked, two-(human)-player Tic-Tac-Toe
Create a Tic-Tac-Toe game that allows two human players to play against each other using two networked devices.
Requirements:

Network play.
Program must let both players know whose turn it is.
Program must show who won and how (like drawing a line through the three in a row).
Graphical game board displayed for both players.
Player moves inputted "graphically" (point and click, etc...).
Enforce all Tic-Tac-Toe rules.

Preferred:

Any libraries are allowed but smaller libraries are better.
Support as many different platforms/devices as possible.
Make it "pretty".

I would love to invent scoring that would take into account the "Preferred" points, but that appears impossible.  So vote for the code that does the best on the "Preferred" points.
Scoring:

byte count / vote count
lowest score wins

code-golf and popularity-contest should never be together in the same question. One excludes the other.

If you are unsure about the scoring for a problem, use the sandbox before posting.

Quincunx: I wasn't unsure of scoring.  I just knew my preferred scoring was impossible.  Fez Vrasta: I had hoped that byte count/vote count was a clever way to combine code-golf and popularity-contest!

Someone added a close-vote as off-topic. I can't see how this is off-topic.

I’m voting to close this question because it lacks an "objective validity criterion" as required by the first point in the requirements for the [tag:popularity-contest] tag wiki excerpt.

I'm echoing Justin's suggestion of using the sandbox, you've got the scoring fixed now, but it's still a long way from being clear enough for answers' validity to be judged semi-objectively.

PHP, work in progress (474 chars / 2 upvotes = 237 score)
It's fully functional except it doesn't have win detection yet.

What I really like about this solution is that I only learned PHP about 3 days ago, so the code is probably terrible. :D
t.php, 474 chars (newlines can be removed and are there only for readability):

<?php
$f=file("a");$p=$_GET["p"];if($p!="x"&&$p!="o")die();
if(isset($_GET["m"])){$s=$f[0];$s[intval($_GET["m"])]=$p;fwrite(fopen('a','w'),$s.($f[1]=='x'?'o':'x'));echo"back";}
else{$i=0;while($i<9){$s=($p==$f[1]&&$f[0][$i]=='.')?'a':'div';echo"<$s href='t.php?p=$p&m=$i'>".$f[0][$i++]."</$s>";}echo $f[1]."'s turn";}
?>

reset.php, 57 chars
<?php fwrite(fopen('a','w'),"..........\nx");?>Reset done

It's live on my website. Player X should go to this URL:
http://keyboardfire.com/misc/tictactoegolf/t.php?p=x

And Player O should go here:
http://keyboardfire.com/misc/tictactoegolf/t.php?p=o

(don't worry, I added a check that only lets player "o" or "x" in so that you can't do any fancy XSS stuff :P)
To reset, go here:
http://keyboardfire.com/misc/tictactoegolf/reset.php

Obviously, it's really easy to cheat (moving for the other player, randomly resetting the board, etc.), but it's code golf so it doesn't matter :P

+1 for exceeding the 2 player criteria and allowing INF players at once!

Accepted this as the answer since it nearly meet the spec and had no competitors.  Good job.

@Wally Lol, sorry, I never finished it :-P I might tomorrow morning.

Update: Due to a site reorganization, the misc has been removed and it's now just http://keyboardfire.com/tictactoegolf/t.php.

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


text:
String of alphanumeric characters to a sorted list of comma-separated ranges
Given a string of unsorted alphanumeric characters, e.g.
ABC321STPpJqZZr0

output a ", "-separated list of character ranges, sorted by ASCII value, ignoring case and removing duplicates (i.e. outputting only uppercase and numeric characters), e.g.
0-3, A-C, J, P-T, Z

Rules

The length of your program is your base score, as usual.
You must initialize (hardcode) the above example within your program, but you may discount the length of that example from your program length, e.g. for char* s="ABC321STPpJqZZr0"; you may discount 16 chars, the other 11 chars counting toward your program length.

Bonus (+50 bounty)

As this was a real problem encountered by my coworker today, needing to be written in Tcl 8.0.5 (an ancient version, lacking many of the latest Tcl built-ins), I'll award 50 points to whomever writes the shortest Tcl 8.0.5 solution, if there are at least 2 valid submissions in Tcl 8.0.5.

@FezVrasta - I intentionally wrote ", " to include the space, but we can leave your edit and let this comment serve as that indication.

Why intentionally include GolfScript? Why not allow other languages, such as Befunge?

We can say all is fair game. I just won't be able to check most of them very easily.

So is that a Code-Golf tag then?

@Chron - Good catch. A-B in my case but since there have already been many submissions, let's allow both ways.

Ruby, 87-16=71
EDIT:  Had to add some characters so that two-character ranges are displayed correctly.  Also using ?[ instead of ?Z to fix a bug with ranges ending in Z.
$><<[*?0..?[].join.gsub(/[^ABC321STPpJqZZr0]/i,$/).gsub(/\B.+\B/,?-).scan(/.-.|./)*', '

You can see the Ideone run here.

+1 For one-liner. Very clever use of various methods; This is really brilliant.

Note that gsub(/[]/i) is shorter than tr(''.upcase) by 2 characters. Moreover, scan(/.+/) -> split saves 5, and $><< instead of puts another one.

@Howard Great suggestions, thanks!

Julia, 131
julia> l=sort(unique(uppercase("ABC321STPpJqZZr0")))
julia> prod([!(c+1 in l)?"$c"*(c==l[end]?"":", "):!(c-1 in l)?"$c":(c+1 in l)&&!(c+2 in l)?"-":"" for c in l])

"0-3, A-C, J, P-T, Z"

Not supported by Ideone.com, and will probably be crushed anyway.

Thanks anyway! The Ideone.com constraint was only so I could test it but I suppose I can trust the integrity of golfers and remove that rule. +1, anyway.

GolfScript 57 54  52
 'ABC321STPpJqZZr0'
 {.95>32*-}%.|:x..{(}%&-x..{)}%&-+$2/{.|'-'*}%', '*

Try it here.
The code first capitalizes everything:
{.95>32*-}%

Then gets unique characters and saves it in a variable:
.|:x

Then, we get the characters whose direct predecessors are not in the string (so that they are the beginning part of a range):
..{)}%&-x

We similarly get the ends of ranges with x..{)}%&-.
Now actually form the ranges by concatenating the lists, sorting, and splitting into groups of 2:
+$2/

The rest is just formatting, using * as string join.

In the output, the ranges need to be separated by ', ' and not just ','

Also .95>{32-}{}if -> .95>32*- saves 5 characters.

@Howard Great!  I knew that part was suboptimal.

@Chron Fixed the space issue!

C#, 221 bytes
class P{
    static void Main(){
        var s="ABC321STPpJqZZr0";
        var l=new int[257];
        foreach(int c in s.ToUpper())
            l[c]=1;
        var r="";
        for(int i=0;i<255;){
            if(l[i++]-l[i]<0)
                r+=", "+(char)i;
            else if(l[i+1]-l[i]<0)
                r+="-"+(char)i;
        }
        System.Console.Write(r.Substring(2));
    }
}

C, 193
char*s="ABC321STPpJqZZr0";
int c[99];memset(c,0,396);while(*s){++c[toupper(*s++)];}for(int i=0,f=1,r=0;
i<=99;++i){if(!r&&c[i])r=i;if(r&&!c[i]){if(!f)printf(", ");putchar(r);
if(i-r>1)printf("-%c",i-1);r=f=0;}}

Can you add a small explanation?

Iterate over the string, accumulating a count of instances of each alphanumeric character. Then, iterate over all alphanumeric characters in alphabetical order, writing out the start of each compact range and, if appropriate, a dash followed by the end of the range. If this is not the first range that's been written, add the comma-space separator. Code must be embedded in a main() function with appropriate headers (stdio, string, ctypes) included, so I kinda cheated there.

Q, 94
{","sv(,/){{"-"sv(?) -1 1#\:x}'[cut[;a]0,1_(&)1<(-':)"i"$'a:asc upper[x]inter y]}[x]'[.Q`n`A]}

q [116 chars]
{.a:();{m:6h$x;.a:.a,$[m[1]=1+m[0];45;m[0],44,m 1];1_x}/[x:asc distinct upper x];p where differ 6h$p:-3_10h$x[0],.a}

Usage
{.a:();{m:6h$x;.a:.a,$[m[1]=1+m[0];45;m[0],44,m 1];1_x}/[x:asc distinct upper x];p where differ 6h$p:-3_10h$x[0],.a}"ABC321STPpJqZZr0"

Output

"0-3,A-C,J,P-T,Z"

There is a scope of saving chars, i'll try some other method and post it.

Python 2.x, 304 - 16 = 288
This can surely be golfed further, all comments welcome!
e=[""]*11;f=[""]*27
for c in"ABC321STPpJqZZr0".lower():e["0123456789".find(c)]=f["abcdefghijklmnopqrstuvwxyz".find(c)]=c
e[-1]=f[-1]=""
def h(j):
 g=[];k=l=i=0
 for e in j:
  if e:
   if not l:k=i;l=1
  elif l:l=g.append((k,i-1))
  i+=1
 print", ".join([j[m],j[m]+"-"+j[n]][n-m>1]for m,n in g)
h(e);h(f)

Rebol (218 - 16 = 202)
m: s: sort uppercase unique"ABC321STPpJqZZr0"i: :to-integer f: does[either 1 = length? x: copy/part m s[x][rejoin[x/1"-"last x]]]while[not tail? s: next s][if(1 + i pick back s 1)!=(i s/1)[prin join f", "m: s]]print f

Non-minified version:
m: s: sort uppercase unique "ABC321STPpJqZZr0"
i: :to-integer

f: does [
    either 1 = length? x: copy/part m s [x] [rejoin [x/1 "-" last x]]
]

while [not tail? s: next s][
    if (1 + i pick back s 1) != (i s/1) [
        prin join f ", "
        m: s
    ]
]

print f

Tcl 8.0.5, 344 (360 bytes)
set a ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
set s string
set x [join [lsort [split [$s toupper ABC321STPpJqZZr0] ""]] ""]
regsub -all (.)\\1+ $x \\1 x
set i 36
while {[incr i -1]} {set j -1
while {$i+[incr j]<36} {set y [$s range $a $j [expr $i+$j]]
regsub $y $x [$s index $y 0]-[$s index $y end],\  x}}
while {[regsub -all {(\w)(\w)} $x {\1, \2} x]} {}
puts $x

Tcl 8.0.5, 340 (356 bytes)
Tinkering with the rename command yielded some fun tricks! I've documented them in another thread.
rename rename &
& set =
& regsub R
& string S
& while W
= a ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
= x [lsort [split [S toupper ABC321STPpJqZZr0] ""]]
R -all {(.) \1+| } $x \\1 x
= i 36
W {[incr i -1]} {= j -1
W {$i+[incr j]<36} {= y [S range $a $j [expr $i+$j]]
R $y $x [S index $y 0]-[S index $y end],\  x}}
W {[R -all {(\w)(\w)} $x {\1, \2} x]} {}
puts $x

Tcl 8.0.5, 332 (348 bytes) [Unstable—depends on $PATH]
info script ""
set tcl_interactive 1
set a ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
set x [lso [sp [st toupper ABC321STPpJqZZr0] ""]]
regs -all {(.) \1+| } $x \\1 x
set i 36
wh {[inc i -1]} {set j -1
wh {$i+[inc j]<36} {set y [st range $a $j [exp $i+$j]]
regs $y $x [st index $y 0]-[st index $y end],\  x}}
wh {[regs {(\w)(\w)} $x {\1, \2} x]} {}
pu $x

Credit to @JohannesKuhn for the interactive trick.

Sometimes you can save bytes replacing while by time constructs. https://codegolf.stackexchange.com/a/126236/29325


text:
Make a Valentine wish with your favourite language
Write the most creative program to display your Valentine wish to your favorite programming language, in that language.
E.g.
#!/usr/bin/perl

use Modern::Perl;

say "I love Perl";

Accepted @ugoren

C/Python Polyglot/Polygamist
Monogamy isn't for everyone.
Based on my answer to Execute Prints Backwards.
#define def main(){0?
#define print printf(
#define return 0)));}

def main():
    print "Python",
    print ", I love you much more than ",
    print "C",
    return

main();

Output, when run as C:
C, I love you much more than Python

Output, when run as Python:
Python , I love you much more than  C

This is freaking brilliant.

JavaScript (ES6)
Pretty version:
           r=/c/g         ,n='\n'
       ,m=/.\d+/g,[,    ,'ca','8b',5,
     'a10b',6,'ca3b',  13,'a4b',1,3,'c'
    ,'a1b',16,'a2b1',5,'cb35cb',35,'ca',
    ,'1b7 JS b',22,'ca2b',31,'ca3b',29,
     ,'ca',5,'b',25,'ca7b',2,1,'ca',9,
      ,'b','17ca',11,'b13ca',14,'b',
       '7c','a1',7,'b1c'].join('').
         replace(m, c=>(c[0]!='a'?
           '\u2665':' ').repeat
              (+c.substr(1))).
                 replace(r,
                     n);

Console output:
            ♥♥♥♥♥          ♥♥♥♥♥♥
       ♥♥♥♥♥♥♥♥♥♥♥♥♥    ♥♥♥♥♥♥♥♥♥♥♥♥♥
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
     ♥♥♥♥♥♥♥ JS ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
       ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
         ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
           ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
             ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
               ♥♥♥♥♥♥♥♥♥♥♥♥♥
                  ♥♥♥♥♥♥♥
                     ♥

Annotated version:
[
  // Contains the instruction to draw the heart.
  //   * `a` is a space
  //   * `b` is a heart
  //   * `c` is a line break
  //
  // `a` and `b` instructions are followed by an integer
  // telling how many times the character should be printed.
  //
  // Abuse JS arrays to split the string in smaller parts.
  ,,'ca','8b',5,'a10b',6,'ca3b',13,'4b13ca1b16a2b1cb35cb35ca1b7'
  // This is the text we want to display.
  ,' JS '
  // Other instructions to draw the heart.
  // This part isn't splitted for readability purpose.
  ,'bca2bca3b29ca5b25ca7b21ca9b17ca11b13ca14b7ca17b1c'
]
// Join every substring.
.join('')
// Process instructions.
.replace(
  // Match all `a` and `b` instructions.
  /.\d+/g,
  c => (
    // Fetch the right character.
    c[0] != 'a'
      ? '\u2665' // `b` Heart
      : ' '      // `a` Space
  )
  // Repeat the character.
  .repeat(
    // Extract the number from the instruction.
    +c.substr(1)
  )
)
// Replace `c` by a line break.
.replace(/c/g,'\n');

Processing
public static final int px = 25;
public static final int rectRad = 3;
PFont font;

public boolean[][] used;
public int[] heart = {
               65, 66, 67,                 72, 73, 74,
           84, 85, 86, 87, 88,         91, 92, 93, 94, 95,
      103,104,105,106,107,108,109,110,111,112,113,114,115,116,
  122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,
  142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,
  162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,
      183,184,185,186,187,188,189,190,191,192,193,194,195,196,
          204,205,206,207,208,209,210,211,212,213,214,215,
          224,225,226,227,228,229,230,231,232,233,234,235,
              245,246,247,248,249,250,251,252,253,254,
                  266,267,268,269,270,271,272,273,
                      287,288,289,290,291,292,
                          308,309,310,311,
                              329,330
                                 };
void setup() {
  size(500, 500);
  background(255);
  stroke(127+64);
  strokeWeight(1.75);
  //font=loadFont("Font1.vlw");
  font=createFont("Purisa",28);
  textFont(font,28);
  frameRate(50);
  used = new boolean[width/px][height/px]; // initialised to false by default
}

void draw() {
  int i, j;
  int drawingframes = width * height / px / px;
  int textframesdelay = (int)(500 * frameRate / 1000);
  do {
    i=(int)random(0, width / px);
    j=(int)random(0, height / px);
  } while(used[i][j] && frameCount <= drawingframes);
  used[i][j] = true;
  if(frameCount > drawingframes + textframesdelay) {
    noLoop();
    return;
  } else if(frameCount == drawingframes + textframesdelay) {
    fill(63 + 32);
    text("Dear Processing,", 10, 50);
    text("Happy Valentine's Day!", 80, 200);
    text("Love,\nAce", 10, 430);
    return;
  } else if(frameCount > drawingframes) {
      return; // effectively creating a small delay after drawing the tiles
              // and before writing the text
  }
  int R = (int)random(64, 255 - 64);
  int G = (int)random(128, 255);
  int B = (int)random(128, 255);
  int alpha = (int)random(55, 85);
  int hash = j * width / px + i;
  if(java.util.Arrays.binarySearch(heart,hash)>=0) {
  //if(heart.indexOf(hash) >= 0) {
    R = (int)random(128 + 64, 255);
    G = (int)random(0, 63);
    B = (int)random(0, 63);
    alpha = (int)random(70, 100);
  }
  fill(R, G, B, alpha);
  rect(i * px, j * px, px, px, rectRad, rectRad, rectRad, rectRad);
}

See it run online here.
Screenshot of one possible output:

Nice one. I enjoyed it.

Befunge 98
"/\ "7k:a"/ ":"\ "6k:a"/ "2k:"\ "5k:a"/ ":"89 ":"\ "4k:a"/ "6k:"\ "3k:a"| ":"egnufeB | "2k:a"| "8k:"| "2k:a"\ /____\ / "3k:a'_' 5k:'_\4k:a"?enitnelaV ym eb uoy lliW"aa >:!2+j4,<@

Output (as image, because it looks nicer in the console than here):

PHP
Why overcomplicate, when you can do simplest thing that works?
Program:
I ♥ PHP!

Output:
I ♥ PHP!

It's not about the shortest code - it's about the most creative and beautiful one.

BASH
What is better than to SSH to your wifeys/husbands machine and then let her NIC do the fun part of flashing morse code for "Happy Valentines Day" for your favourite scripting language I am sure you've nearly all started with - BASH? And as we Geeks all know - you should always have an eye on your machine's NIC ;)
#!/bin/bash

#.... .- .--. .--. -.-- ...- .- .-.. . -. - .. -. . ... -.. .- -.--
#1111 12 1221 1221 2122 1112 12 1211 1 21 2 11 21 1 111 211 12 2122

while IFS= read -r -n1 char
do
    ethtool eth0 p$char
done < morse

Of course "morse" contains the morse code "translated" to numbers:

111131231221312213212231112312312113132132311321313111321131232122

'1' is short, '2' is long and '3' is space. Obviously the obligatory 'ethtool' should be installed. If not, then do your spouse the favour of doing so.

BASIC
Just because we all wrote one of these once, and this is really the only style that truly expresses this language's simple honest heart.
10 PRINT "HAPPY VALENTINES DAY BASIC"
20 GOTO 10

Mathematica
ContourPlot3D[(2 x^2 + y^2 + z^2 - 1)^3 - (1/10) x^2 z^3 - y^2 z^3 ==
  0, {x, -1.5, 1.5}, {y, -1.5, 1.5}, {z, -1.5, 1.5}, Mesh -> None,
 ContourStyle -> Opacity[0.8, Red]]

That's Taubin's heart surface. Yes, I realize the challenge asks for ASCII art. However, if you're going to downvote it, don't do so because it's excessively beautiful, do it because I stole the code from https://math.stackexchange.com/questions/12098/drawing-heart-in-mathematica

~-~!
Just for the sake of interest, the character count is 865.
'=~~~~:''=<<'+~>,'+~~~>,':'''=<'+~>,<',<'+~>-~>:''''=<'+~>,<<',~~>+~>+~~:'''''=',',~~:''''''=',<<'+~>,<'+~~>+~>:'''''''=',~~+~~:
@''''':@''':@''':@''':@''':@''''':@''''':@''''':@''':@''':@''':@''':@''''''':
@'''':@''''':@''''':@''''':@''''':@'':@''''':@'''':@''''':@''''':@''''':@''''':@'':@''''''':
@'''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@'''''':@''''''':
@'':@''''':@|I|:@''''':@|<|:@|3|:@''''':@|~|:@|-|:@|~|:@|!|:@''''':@'''':@''''''':
@''''':@'':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@'''':@''''''':
@''''':@''''':@'':@''''':@''''':@''''':@''''':@''''':@''''':@''''':@'''':@''''''':
@''''':@''''':@''''':@'':@''''':@''''':@''''':@''''':@''''':@'''':@''''''':
@''''':@''''':@''''':@''''':@'':@''''':@''''':@''''':@'''':@''''''':
@''''':@''''':@''''':@''''':@''''':@'':@''''':@'''':@''''''':

Output:
 ____   ____
/    \ /    \
|           |
\ I <3 ~-~! /
 \         /
  \       /
   \     /
    \   /
     \ /

Python
Remember when people didn't have computers for Valentines and had to etch their lovelife on trees? That's what I'm doing:
def valentine(person1,person2):
    leading_whitespace = range(0,4)[::-1] +[0]+range(0,8)
    inside = [3,5,14,14]+range(0,15)[::-1][::2]
    layers = ["  ___    ___",r" /   \  /   \ ",r'/     \/     \ ','|             |']
    for i in range(5,12):
        layers.append(' ' * leading_whitespace[i] + '\\' + ' ' * inside[i] + '/')
    #inserts person1 into layers[4]
    temp = []
    for char in layers[3]: temp.append(char)
    temp[1:len(person1)+1] = person1
    layers[3] = ''.join(temp)

    temp = []
    layers[4] = '|      +     |'

    # do that again for person2
    for char in layers[5]: temp.append(char)
    temp[-len(person2)-1:-1] = person2
    layers[5] = ''.join(temp)

    print '\n'.join(layers)

valentine('Me','Python')

Note: the first values of the inside variable are hard-coded.
Output:
  ___    ___
 /   \  /   \
/     \/     \
|Me           |
|      +     |
 \    Python/
  \        /
   \      /
    \    /
     \  /
      \/

But the code doesn't use any trees.

mhm is it something like this ?

<?echo "I love PHP";

It's a popularity contest - get creative.

#include<stdio.h>
#include<conio.h>
main();
{
  int i, n;
   printf(" enter n=");
    scanf("%d",&n);
         for(i=0;i<n;i++)
      {
          printf(" i love you honey ");
      }
         scanf("%d",&i);
        getch();
}


text:
Eco-ize data for printing
Inspired by ecofont.

Given a string containing # and , output it more eco-friendly by cutting out circles, while keeping it "recognizable" (defined later, in the Circles section). # represents black, and represents white. This program is supposed to do something like this:
Input:
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################

Sample output (rather bad score):
####################
#### ###############
##     #############
##     #### ########
#       #     ######
##     ##     ######
##     #       #####
#### ####     ######
#########     ######
########### ########
####################

Circles
These are the only valid circles (#s indicating characters that would be cut out):
  #
 ###
#####
 ###
  #

   #
 #####
 #####
#######
 #####
 #####
   #

Every circle cut out must be of the same radius. By "recognizable", I mean that there must be a gap of at least one pixel / point between each circle, and each circle and the edge of the shape (outside of the # region):
Again, # indicates characters that would be cut out, not characters that would be left behind
   #      #
 #####  #####
 #####  #####
##############
 #####  #####
 #####  #####
   #      #

Is invalid, but:
   #
 #####
 #####
#######   #
 #####  #####
 #####  #####
   #   #######
        #####
        #####
          #

Is valid. Note that corners are considered touching. That is, in
#
 #

the two "pixels" are considered touching, thus circles cannot touch in that way.
Also, just to restate it, if we have a shape like:
########
########
########
########
########
########
########
########

Cutting circles like this is invalid (they both touch the edge of the figure):
####   #
###
####   #
## ## ##
#   ####
     ###
#   ####
## #####

Scoring
Your score is the total number of #s left from the specified inputs. Lowest score wins.
Input #1:
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
##################################################
#################################################
#################################################
#################################################
#################################################
################################################
################################################
################################################
###############################################
###############################################
##############################################
##############################################
##############################################
#############################################
############################################
############################################
###########################################
###########################################
##########################################
#########################################
#########################################
########################################
#######################################
######################################
######################################
#####################################
####################################
###################################
##################################
################################
###############################
##############################
############################
###########################
#########################
#######################
######################
###################
#################
##############

Input #2:
                                         #####################
                                        #######################
                                        #######################
                                       #########################
                                       #########################
                                      ###########################
                                     ############################
                                     #############################
                                    ##############################
                                    ###############################
                                   ################################
                                   #################################
                                  ##################################
                                 ####################################
                                 #################   ################
                                #################    #################
                                #################     ################
                               #################      #################
                               #################       ################
                              #################        #################
                              #################        #################
                             #################          #################
                            ##################          #################
                            #################            #################
                           #################             #################
                           #################              #################
                          #################               #################
                          #################                #################
                         #################                 #################
                        ##################                  #################
                        #################                   ##################
                       ##################                    #################
                       #################                     #################
                      ##################                      #################
                      #################                       #################
                     ##################                        #################
                     #################                         ##################
                    ##################                         ##################
                    #################                           #################
                   ###############################################################
                  ################################################################
                  #################################################################
                 ###################################################################
                 ###################################################################
                #####################################################################
               ######################################################################
               ######################################################################
              ########################################################################
              ########################################################################
             ##########################################################################
             ##################                                      ###################
            ###################                                       ##################
            ##################                                        ###################
           ###################                                         ##################
           ##################                                          ###################
          ###################                                           ##################
         ###################                                            ###################
         ###################                                             ##################
        ###################                                              ###################
        ###################                                              ###################
       ###################                                                ###################
       ###################                                                 ##################
      ###################                                                  ###################
     ####################                                                  ###################
     ###################                                                    ###################
    ####################                                                    ###################
    ###################                                                      ###################
   ####################                                                      ###################
   ###################                                                        ###################
  ####################                                                        ###################
  ###################                                                          ###################
 ####################                                                          ###################
####################                                                            ###################
####################                                                            ###################
###################                                                              ###################

Input #3:
              ##############
          #####################
        #########################
      #############################
    #################################
   ###################################
  #####################################
  ####################################
 ##################################
################################
#############################
##########################
#######################
######################
##########################
#############################
###############################
 ##################################
  ####################################
  #####################################
   ###################################
    #################################
      #############################
        ##########################
          #####################
             ###############

Note: Tailoring specifically to the samples is not allowed.

You either need to provide (examples of) correct output for the sample inputs, or explain the challenge in more detail, because as it stands I don't understand what the program is supposed to do, at all.

@breadbox how is that? Also, note that since this is inspired by eco-font, that should help with understanding what this problem is.

"Inspired by ecofont": If we need to visit that site and read up on what it is and then get back to your question to figure out the exact challenge than all I see is an attempt to "spam" ecofont. Your challenge should be clearly described here, period. "defined later, in the Circles section": where? I don't see it. Tip: adding an image like this one will clarify a lot (something about a picture and 1000 words ;-) )

I went to http://www.ecofont.com and I still have no idea what this challenge is asking for.

Python 2.7
Expects the input file to be passed via the command line, e.g.
python thisscript.py input1.txt

I implemented 5 2 options to run:

Using the small shape
Using the large shape
Alternating between the small and large shape
Alternating between the small and large shape randomly
Completely random

I just scan the input starting from the top left and a shape is cut away as soon as possible.
The shapes themselves can be modified quite easily.
import sys,random,copy

def char2val(c):
    if (c=='#'):
        return 1 # this is the shape itself
    elif (c=='o'):
        return 2 # this is the boundary, for collision detection
    else:
        return 0
def val2char(v):
    if (v==0):
        return ' '
    else:
        return '#'
# convert string to array for processing
def str2arr(s):
    arr = []
    for line in s.split('\n'):
        arr.append( [ char2val(c) for c in line ] )
    return arr
# convert array to string for output purposes
def arr2str(arr):
    s=""
    for i in range(len(arr)):
        for j in range(len(arr[i])):
            s+=val2char(arr[i][j])
        s+="\n"
    return s
# check if a cut we want to make is a valid one
def validate_cut(arr,shape,r,c):
    valid = True
    for i in range(len(shape)):
        for j in range(len(shape[i])):
            if shape[i][j] == 1: #hard cut here
                valid = ( 0 < i+r < len(arr)-1 ) and ( 0 < j+c < len(arr[i+r])-1) # bounds check
                valid = valid and ( arr[i+r][j+c]==1) # site must be cut-able
            elif shape[i][j]==2: #edge of shape
                valid = ( 0 <= i+r <= len(arr)-1 ) and ( 0 <= j+c <= len(arr[i+r])-1) # bounds check, edge allowed to lie on border
                valid = valid and arr[i+r][j+c]!=0 # edge cannot go into cut/empty space
            if not valid:
                return False
    return valid

def cut(arr,shape,r,c): # cut shape from arr, @ position r,c
    for i in range(len(shape)):
        for j in range(len(shape[i])):
            if (shape[i][j] > 0):
                arr[i+r][j+c] -= shape[i][j]
def run(inarr,opt=0):
    arr = copy.deepcopy(inarr)
    for r in range(len(arr)):
        for c in range(len(arr[r])):
            if (opt==0):
                shape = c1arr
            elif (opt==1):
                shape = c2arr
            else:
                raise Exception("run option not supported!")
            if validate_cut(arr,shape,r,c):
                cut(arr,shape,r,c)
    return arr
# global variables for the shapes,...
# \# are the shapes themselves
# o is the boundary used for collision detection
c1 = \
"\
  ooo  \n\
 oo#oo \n\
oo###oo\n\
o#####o\n\
oo###oo\n\
 oo#oo \n\
  ooo  \
"
c2 = \
"\
   ooo   \n\
 ooo#ooo \n\
 o#####o \n\
oo#####oo\n\
o#######o\n\
oo#####oo\n\
 o#####o \n\
 ooo#ooo \n\
   ooo   \
"
c1arr = str2arr(c1)
c2arr = str2arr(c2)
def main():
    #input processing
    random.seed('117')
    f = file(sys.argv[1],"r")
    inp = f.read().rstrip('\n') #input string
    inarr = str2arr(inp)        #convert string to array
    #run the algorithm
    arr0 = run(inarr,opt=0)
    arr1 = run(inarr,opt=1)
    minarr = arr0 if arr2str(arr0).count('#') < arr2str(arr1).count('#') else arr1
    #output
    print arr2str(minarr)
    print " %d # of %d remaining " % (arr2str(minarr).count('#'),inp.count('#'))
main()

The results are
Input1
1102 # of 2030 remaining

Input2
1766 # of 2955 remaining

Input3
514 # of 748 remaining

Full output for input3:
              ##############
          ##### ##### #########
        ######   ###   #### #####
      ### ###     #     ##   ######
    ####   ###   ###   ##     #######
   ####     ### ## ## ####   #########
  ### ##   ######   #### ## ###########
  ##   ## ## ###     ##   ############
 ##     ###   ###   ##     ########
####   ###     ### ####   ######
##### ## ##   ## ####### ####
#######   ## ##   ########
### ##     ###     ####
##   ##   ## ##   ####
#     ## ##   ## ## ######
##   #####     ###   ########
### ## ####   ###     ## ######
 ####   #### ## ##   ##   #########
  ##     #####   ## ##     ## ########
  ###   #####     #####   ##   ########
   ### #######   ## #### ##     ######
    ########### ##   #######   ######
      ###########     ####### #####
        ##########   #############
          ######### ###########
             ###############

Total score: 3382

Nice one. Total score is 3382 if we take the minimum for each input.

Three things: 1st, your program is supposed to decide which method to run. 2nd, the first two options are the only valid options. 3rd, can you show an output for one of the inputs?

Updated my post accordingly.

@camelthemammel Don't forget the @ when responding to comments; I did not notice that you updated your post until now.

PHP
**WARNING : spaghetti english and spaghetti code ahead **
Okay, not sure I understood everything but here's my try.
So what is done ?

Convert text input to an image. " " = white pixel, "#" = red pixel. Example :
Draw holes inside image, cheking to not collide on a previous one. Example :
Convert back image to text

(not sure about this red dot in the bottom right corner but, he, yolo)
<?php

    /* Check collision between white pixels in 2 images. */
    function checkCollision ($img1, $img2, $width, $height, $circle_x, $circle_y, $circle_size)
    {
        $start_x = $circle_x - round($circle_size / 2);
        if ($start_x < 0) return false;

        $stop_x = $circle_x + round($circle_size / 2);
        if ($stop_x > ($width - 1)) return false;

        $start_y = $circle_y - round($circle_size / 2);
        if ($start_y < 0) return false;

        $stop_y = $circle_y + round($circle_size / 2);
        if ($stop_y > ($height - 1)) return false;

        $color_white = array("red" => 255,
                "green" => 255,
                "blue" => 255,
                "alpha" => 0
                );

        for ($y = $start_y; $y < $stop_y - 1; $y++)
            for ($x = $start_x; $x < $stop_x - 1; $x++)
            {
                $pixel_img1 = imagecolorsforindex($img1, imagecolorat($img1, $x, $y));
                $pixel_img2 = imagecolorsforindex($img2, imagecolorat($img2, $x, $y));

                if ($pixel_img1 == $pixel_img2
                    && $pixel_img1 == $color_white)
                        return false;
            }

        return true;
    }

    $input      = file_get_contents("input.txt");
    $lines      = explode("\n", $input);
    $image_width    = strlen($lines[0]);
    $image_height   = count($lines);
    $circle_size    = 5;

    /* Creating an image matching dimensions and some colors. */
    $img            = imagecreatetruecolor($image_width, $image_height);
    $color_red      = imagecolorallocate($img, 255, 0, 0);
    $color_white        = imagecolorallocate($img, 255, 255, 255);

    /* Filling the freshly created image. '#' is replaced by a red pixel, ' ' by a white one. */
    for ($y = 0; $y < $image_height; $y++)
    {
        $line = $lines[$y];
        for ($x = 0; $x < strlen($line); $x++)
            if ($line[$x] == '#')
                imagesetpixel($img, $x, $y, $color_red);
            else
                imagesetpixel($img, $x, $y, $color_white);
    }

    /*Try to draw a circle on any red pixel then check if
    it not collides with any other white space before commiting */

    for ($y = 0; $y < $image_height; $y++)
        for ($x = 0; $x < $image_width; $x++)
        {
            $img_tmp = imagecreatetruecolor($image_width, $image_height);
            imagecopy($img_tmp, $img, 0, 0, 0, 0, $image_width, $image_height);

            imagefilledellipse($img_tmp, $x, $y, ($circle_size + 2), ($circle_size + 2), $color_white);

            if (checkCollision ($img, $img_tmp, $image_width, $image_height, $x, $y, ($circle_size + 2)))
                imagefilledellipse($img, $x, $y, $circle_size, $circle_size, $color_white);
        }

    /* Convert image to text */
    $output = "";
    $color_white = array("red" => 255,
            "green" => 255,
            "blue" => 255,
            "alpha" => 0
            );

    for ($y = 0; $y < $image_height; $y++)
    {
        for ($x = 0; $x < $image_width; $x++)
        {
            $pixel_img = imagecolorsforindex($img, imagecolorat($img, $x, $y));
            if ($pixel_img == $color_white)
                $output = $output . " ";
            else
                $output = $output . "#";
        }
        $output = $output . "\n";
    }

    file_put_contents("output.txt", $output)

?>

Spent a lot of time because I didn't know I could not just copy a GD ressource doing $a = $b.. (it creates a ref)
Example :
Input :
              ##############
          #####################
        #########################
      #############################
    #################################
   ###################################
  #####################################
  ####################################
 ##################################
################################
#############################
##########################
#######################
######################
##########################
#############################
###############################
 ##################################
  ####################################
  #####################################
   ###################################
    #################################
      #############################
        ##########################
          #####################
             ###############

Output :
              ##############
          #####################
        ########## ###### #######
      ###########   ####   ########
    ######## ###     ##     #########
   ########   ###   ####   ###########
  ########     ### ###### #############
  ##### ###   ########################
 #####   ### ######################
#####     ######## #############
######   ########   #########
####### ########     #####
############# ###   ###
############   ### ###
###### ####     ##########
#####   ####   ##############
####     #### ###### ##########
 ####   ###########   #############
  #### ###########     #### ##########
  ########## ######   ####   ##########
   ########   ###### ####     ########
    ######     ###########   ########
      #####   ############# #######
        #### #####################
          #####################
             ###############

I hope this hit the target. It's obvious that we can do it better and more properly but maybe it would help the others to understand what this code challenge is about.
Score
Input 1 :

Before : 2030 "#"
  After : 1575 "#"
  455 removed

Input 2 :

Before : 2955 "#"
  After : 2370 "#"
  585 removed

Input 3 :

Before : 748 "#"
  After : 618 "#"
  130 removed

Total :

"#" input : 5733
  "#" left : 4563 (~80%)
  "#" removed : 1170 (~20%)

FINAL SCORE : 4563
;_;

AFAIU, your "circles" can't touch the edges, so this doesn't qualify.

Okay it's corrected. I did not noticed this. Does it qualify now ?

Looks good to me. +1

edited to add total score

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


text:
Tips for golfing in Delphi

Code-golfing is incredibly fun to do, trying to solve the given problem is one thing but the real challenge is getting your code as short as possible.
Some languages are perfect for golfing because of their short commands, sadly Delphi isn't one of them.
I'm looking for tips that are useful for golfing in Delphi.
Tips like "Use 1 letter variables" don't really count in my opinion since that is pretty obvious.
Tips I learned working with Delphi or found in other peoples answers so far are:

Semicolon isn't always required (Example 1)
Use int8 or int16 as datatype rather than integer (saves 3 or 2 characters)
Combine string manipulations(Example 2)

Example 1:
Procedure Example1(i:int16);
var x:int16;
begin
  for x:=0to 99do
    if i=1then
      inc(i)//Semicolon not allowed because of "else"
    else
     i:=i+3//No semicolon required
end;//Semicolon required

Example 2
function WrongExample2(myString:string):string;
const
  f:string='The result of your manipulation is: %s';
begin
  myString:= StringReplace(s,'x', '_', [RfReplaceAll]);
  Result := Format(f,[myString])
end;

function CorrectExample2(myString:string):string;
const
  f:string='The result of your manipulation is: %s';
begin
  Result := Format(f,[StringReplace(s,'x', '_', [RfReplaceAll])])
end;

Actually i:=i+3 is shorter then inc(i,3).

Touche ;-)  i usually do that lol, dont know why I didnt do it now. Ill edit that example.

Usually const can automatically resolve types, in your case :string is not required.

@mniip try putting it as an answer, that way I can upvote it and youll actually gain some rep with it ;-)

I don't think that's enough for an answer... And it was too long since I coded any pascal to think of anything else...

Honestly I believe you picked a wrong language for golfing :P

@mniip well im pretty new to delphi and im affraid youre right, but this way I can have fun and still learn new things which is usefull for work ^.^ Besides that you hardly see delphi on here (it became obvious why lol) so its fun to use something different for a change :)

@TeunPronk You should move the actual tips you give out of the question and into an answer. It's OK to answer your own post, and that keeps the structure aligned with the standard Q&A format.

@mniip typed and untyped consts are different in delphi. the former isn't really a constant in the usual sense (immutable value); they are more like scope modifiers. untyped consts are what we typically expect from a constant and cannot be modified at runtime

Group definitions by keyword
This will save you from having to retype the keyword.
type WD=(Su,M,Tu,W,Th,F,Sa);M=(Ja,F,Mr,Ap,My,Jn,Jl,Ag,S,O,N,D);
const A=1;B=2;
var X,Y,Z:string;

Use function name instead of Result for holding function return value
Functions' return value can be referenced by the function name. Unless the function is required to be a particular name it will usually be shorter than Result.
function F:Int8;
begin
  F:=1
end;

Using the Exit short hand (Delphi 2009 or newer) is shorter than assigning to Result also:
function F:Int8;
begin
  Exit(1)
end;

Use comma-separated variable declarations
procedure Z(A,B,C: string);
var A,B,C:string;

Constants usually require fewer characters than variable declarations
With the exception of the above mentioned comma separated variable declarations constant declarations use fewer characters than variable declarations when initialization is taken into consideration.
const A=1; // True constant = 10 chars
const A:Int8=1; // Typed constant = 15 chars
var A:Int8; // Variable = 11 chars
begin
  A:=1; // + 5 chars for initialization = 16 chars

Use set data types and their operators
If ordering isn't important, then use sets instead of arrays or lists for more concise statements. Unfortunately you are limited to a maximum of 256 elements in a set
+  The union of two sets
*  The intersection of two sets
-  The difference of two sets
=  Tests for identical sets
<> Tests for non-identical sets
>= Is one set a subset of another
<= Is one set a superset of another
in Test for set membership of a single element

The in operator is particularly useful when testing if a variable equals any one of possible values. Silly example using in and .. (the range operator):
// expensive:
if ( A = 1 ) or ( A = 2 ) or ( A = 3 ) or ( A = 6 ) then ...;
if ( A > 0 ) and ( A < 4 ) or ( A = 6 ) then ...;

// better:
if A in [ 1 .. 3, 6 ] then ...;


text:
Write a program for splitting the string with alternative spaces
Write a program in the minimum number of bytes that prints a string split into chunks of every length from 1 to the string's length (ascending and then descending), separated by spaces.
Example
Input : abcdef
Output: a b c d e f
        ab cd ef
        abc def
        abcd ef
        abcde f
        abcdef
        abcde f
        abcd ef
        abc def
        ab cd ef
        a b c d e f

Why were the tags [tag:fastest-code] and [tag:functional-programming] added?  The former conflicts with the winning condition given already (which is shortest code) and the latter doesn't apply terribly much...

Ruby, 84 81 characters
i=gets.chop
puts (a=(1..i.size).map{|n|i.scan(/.{0,#{n}}/)*' '})+a.reverse[1..-1]

The magic is in the regex: i.scan(/.{0,#{n}}/). Since Ruby does regex interpolation too, it will become
i.scan(/.{0,1}/)
i.scan(/.{0,2}/)
...

This means it will grab as many characters as it can, limited to n. n progressively gets bigger, and is used to generate the first half of the output.
Then I just call reverse to generate the second half. I had to use [1..-1] in order to avoid repeating the middle line (what that does is basically chop off the first element of the array).
Sample run:
c:\a\ruby>spacesplitgolf.rb
CodeGolfStackExchange         // (this is the input)
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e

4th line contain single and double string Co de  G ol f  St ac k  Ex ch an ge-this is not correct...correct is  Co de  Go lf  St ac kE xc ha ng e

@Boopathi That's because the spaces in the string count as letters too... I've edited the example to use an input with no spaces.

70 bytes, or 66 using newer Ruby features.

GolfScript, 22 characters
:I,,{)I/' '*n+}%.-1%1>

Try the example here.
> abcdef
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

Code explained:
:I          # Save input to variable I
,,          # Create array [0..n)
{
  )         # Increment loop variable by 1
  I/        # Split input into chunks with as many characters
  ' '*      # Join with spaces
  n+        # Append newline
}%
.-1%1>      # Create reverse copy (minus first element)

You can save a byte if you remove the + and use 3> instead of 1>.

Smalltalk (Smalltalk/X) (137 chars)
s := Stdin nextLine.
(1 to:s size),(s size-1 downTo:1) do:[:n |
 ((s asCollectionOfSubCollectionsOfSize:n) asStringWith:' ') printNL]

output (first line is input):
abcdef
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

That is quite an impressive score when it includes identifiers such as asCollectionOfSubCollectionsOfSize...

that's right, smalltalk was designed to be more readable than writable - bad for this kind of contest...

J - 32 27 char
Thanks to randomra for improvements.
(,&' '\(,@)"{~#-~|@i:@<:@#)

Explained:

<:@# - One less than the length of the string.
|@i: - Count from that number down to 0, then back up to that number. (J has weird primitives!)
#-~ - Subtract from each of those numbers the length. When you do the math, the result is that you count from -1 to the negation of the length and back up.
u\(,@)"{~ - For each negative integer, apply the verb u on non-overlapping infixes of the string, with length the negative of the integer, and then run it into a single string. So e.g. for _2 it will split the string up into non-overlapping pairs of letters, apply u, then make a string back of all the new infixes.
,&' ' - Append a space. (This fills in u above.)

Usage:
   (,&' '\(,@)"{~#-~|@i:@<:@#) 'abcdef'
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

(,&' '\(,@)"{~(-~|@i:@<:)@#) saves a total of 4 bytes. I improved an algorithmshark solution by several bytes! Yay!

@randomra (,&' '\(,@)"{~#-~|@i:@<:@#) for one more ;)

JavaScript - 242
I'm new to CodeGolf (and JS as well) and this is my first try. Any suggestions are welcome :)
function f(s){var i,j,a=s.split(''),t;for(i=1;i<=a.length;i++){t='';for(j=1;j<=a.length;j++){t+=a[j-1];if(j%i==0)t+=' ';}
console.log(t);}
for(i=a.length;i>0;i--){t='';for(j=1;j<=a.length;j++){t+=a[j-1];if(j%i==0)t+=' ';}
console.log(t);}}

Example:
>>> f('CodeGolfIsAwesome');

C o d e G o l f I s A w e s o m e
Co de Go lf Is Aw es om e
Cod eGo lfI sAw eso me
Code Golf IsAw esom e
CodeG olfIs Aweso me
CodeGo lfIsAw esome
CodeGol fIsAwes ome
CodeGolf IsAwesom e
CodeGolfI sAwesome
CodeGolfIs Awesome
CodeGolfIsA wesome
CodeGolfIsAw esome
CodeGolfIsAwe some
CodeGolfIsAwes ome
CodeGolfIsAweso me
CodeGolfIsAwesom e
CodeGolfIsAwesome
CodeGolfIsAwesom e
CodeGolfIsAweso me
CodeGolfIsAwes ome
CodeGolfIsAwe some
CodeGolfIsAw esome
CodeGolfIsA wesome
CodeGolfIs Awesome
CodeGolfI sAwesome
CodeGolf IsAwesom e
CodeGol fIsAwes ome
CodeGo lfIsAw esome
CodeG olfIs Aweso me
Code Golf IsAw esom e
Cod eGo lfI sAw eso me
Co de Go lf Is Aw es om e
C o d e G o l f I s A w e s o m e

Delphi XE3 - WayToMany characters (WayToMany==321 261 245)
Im sure I can get this shorter so consider this as Work In Progress ^.^
Edits:
Removed use of array making 2 units redundant saving a total of 61 chars
Removed useless begin..end for loop saving 16 chars
{$APPTYPE CONSOLE}uses idglobal;var i,st:int16;s,r:string;p:boolean;begin readln(s);st:=1;p:=true;repeat r:='';for I:=1to Length(s)do r:=r+iif(i mod st=0,s[i]+' ',s[i]);writeln(r);if st=length(s)then p:=false;st:=iif(p,st+1,st-1);until st<1;end.

With indent
{$APPTYPE CONSOLE}
uses idglobal;
var
i,st:int16;
s,r:string;
p:boolean;
begin
readln(s);
st:=1;
p:=true;
repeat
  r:='';
  for I:=1to Length(s)do
    r:=r+iif(i mod st=0,s[i]+' ',s[i]);
  writeln(r);
  if st=length(s)then
    p:=false;
  st:=iif(p,st+1,st-1);
until st<1;
end.

Result: (first line is input)

Python 94 (bit verbose, but that;s Python)
s=raw_input();print'\n'.join(' '.join(map(''.join,zip(*[iter(s)]*n)))for n in range(1,len(s)))

Rebol (144 chars)
s: input o:[]repeat i(length? s) - 1[t: copy s forskip t i + 1[insert t" "]append o next t]append o reverse append copy o s forall o[print o/1]

Un-golfed:
s: input
o: []

repeat i (length? s) - 1 [
    t: copy s
    forskip t i + 1 [insert t " "]
    append o next t
]

append o reverse append copy o s

forall o [print o/1]

Usage example:
rebol script.reb <<< "abcdef"
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

R, 95
x=scan(,"");z=1:nchar(x);for(i in c(z,rev(z)[-1]))cat(gsub(paste0("(.{",i,"})"),"\\1 ",x),"\n")

(based on regular expressions)
Example:
> x=scan(,"");z=1:nchar(x);for(i in c(z,rev(z)[-1]))cat(gsub(paste0("(.{",i,"})"),"\\1 ",x),"\n")
1: abcdef
2:
Read 1 item
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

Perl, 77 71
Better late, than never (and since so far no Perl solution):
chomp($s=<>);say$s=~s/.{$_}/$& /gr for@a=1..length$s,reverse@a[-@a..-2]

Requires 5.014 because of r modifier. Uses 'say' feature. And
echo CodeGolfStackExchange| perl -M5.010 spaces.pl
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e

CJam, 20 19 18 bytes
Not a valid entry as CJam was created sometime after this question and moreover, this code is using some of the even newer features of the language.
q:Q,{)Q/S*N}%_W%3>

1 byte saved thanks to Martin.
Explanation:
q:Q,                   "Read the input, store it in Q and take its length";
    {      }%          "Map over 0 to length - 1";
     )Q/               "Increment iterator and split Q into pieces of length iterator";
        S*N            "Join by space and add new line";
              _W%      "Copy the mapped string array and reverse it";
                 3>    "Remove the first 3 elements, which comprise of 2 new lines and";
                       "the original string which should appear once only";

Example input:
CodeGolfStackExchange

Output:
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e

Try it online here

k [50 chars]
{x c,1_|c:{1_,/-1,/:(y*!-_-(#x)%y)_x}[!c]'1+!c:#x}

Example
{x c,1_|c:{1_,/-1,/:(y*!-_-(#x)%y)_x}[!c]'1+!c:#x}"abcdef"

"a b c d e f"
"ab cd ef"
"abc def"
"abcd ef"
"abcde f"
"abcdef"
"abcde f"
"abcd ef"
"abc def"
"ab cd ef"
"a b c d e f"

Example 2
{x c,1_|c:{1_,/-1,/:(y*!-_-(#x)%y)_x}[!c]'1+!c:#x}"CodeGolfStackExchange"

"C o d e G o l f S t a c k E x c h a n g e"
"Co de Go lf St ac kE xc ha ng e"
"Cod eGo lfS tac kEx cha nge"
"Code Golf Stac kExc hang e"
"CodeG olfSt ackEx chang e"
"CodeGo lfStac kExcha nge"
"CodeGol fStackE xchange"
"CodeGolf StackExc hange"
"CodeGolfS tackExcha nge"
"CodeGolfSt ackExchang e"
"CodeGolfSta ckExchange"
"CodeGolfStac kExchange"
"CodeGolfStack Exchange"
"CodeGolfStackE xchange"
"CodeGolfStackEx change"
"CodeGolfStackExc hange"
"CodeGolfStackExch ange"
"CodeGolfStackExcha nge"
"CodeGolfStackExchan ge"
"CodeGolfStackExchang e"
"CodeGolfStackExchange"
"CodeGolfStackExchang e"
"CodeGolfStackExchan ge"
"CodeGolfStackExcha nge"
"CodeGolfStackExch ange"
"CodeGolfStackExc hange"
"CodeGolfStackEx change"
"CodeGolfStackE xchange"
"CodeGolfStack Exchange"
"CodeGolfStac kExchange"
"CodeGolfSta ckExchange"
"CodeGolfSt ackExchang e"
"CodeGolfS tackExcha nge"
"CodeGolf StackExc hange"
"CodeGol fStackE xchange"
"CodeGo lfStac kExcha nge"
"CodeG olfSt ackEx chang e"
"Code Golf Stac kExc hang e"
"Cod eGo lfS tac kEx cha nge"
"Co de Go lf St ac kE xc ha ng e"
"C o d e G o l f S t a c k E x c h a n g e"

D - 178 176
Golfed:
import std.stdio,std.range;void main(string[]a){int l=a[1].length;for(int i=1;i<=l;++i)a[1].chunks(i).join(" ").writeln;for(int i=l-1;i>0;--i)a[1].chunks(i).join(" ").writeln;}

Un-golfed:
import std.stdio, std.range;

void main( string[] a )
{
    int l = a[1].length;

    for( int i = 1; i <= l; ++i )
        a[1].chunks( i ).join( " " ).writeln;

    for( int i = l - 1; i > 0; --i )
        a[1].chunks( i ).join( " " ).writeln;
}

Example 1:
F:\Code\D\Other>rdmd spaces.d abcdef
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

Example 2:
F:\Code\D\Other>rdmd spaces.d CodeGolfStackExchange
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e

C# - 182 176
using C=System.Console;class P{static void Main(string[]p){int l=p[0].Length,i=-l,j;for(;++i<l;){for(j=0;++j<=l;)C.Write(p[0][j-1]+(j%(i>0?l-i:l+i)>0?"":" "));C.WriteLine();}}}

Ungolfed:
using C=System.Console;

class P
{
    static void Main(string[] p)
    {
        int l=p[0].Length,i=-l,j;
        for (; ++i < l;)
        {
            for(j=0;++j<=l;)C.Write(p[0][j-1]+(j%(i>0?l-i:l+i)>0?"":" "));
            C.WriteLine();
        }
    }
}

Output:
D:\>program CodeGolfStackExchange
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e

Edit: now using parameters instead of ReadLine().

JavaScript 127
function f(s) {
o=s+'\n'
for(i=s.length;--i;){
l='',j=0
while((p=s.substr(i*j++,i)))l+=p+' '
l+='\n',o=l+o+l
}
console.log(o)
}

Python - 153

a=raw_input()
k=0
b=len(a)
for i in range(b+1)+range(b-1):
 k+=1
 p=[i,b-2-i][k>b]
 s=a
 if kb+1:
    for j in a[p::p+1]:s=s.replace(j, j+" ",1)
    print s

Vyxal, 5 bytes
żvẇ∞⁋

Try it Online!
  ẇ   # Cut into slices of length...
 v    # Each of...
ż     # Range from 1 to length of input
   ∞  # Mirror
    ⁋ # Join by newlines, joining each line with spaces

Gosh dang it, ninja'd because I had to sign into a uni workshop!

Q, 34
{a,1_(|)a:" "sv'(1+(!)(#)x)cut\:x}

C - 134 132
Maximum 8 characters of input, ignoring buffer overflow
#define L n){for(i=0;b[i];){if(i%n==0)p(32);p(b[i++]);}p(10);}
main(i){char b[9],n=1,(*p)()=putchar;gets(b);for(;b[n];++L for(;n;--L}

Haskell, 109 bytes
p s=putStr$unlines$f s++(reverse$init$f s)
f s=map(unwords.(s#))[1..length s]
[]#i=[]
s#i=take i s:drop i s#i

Usage example: p "abcdef". Output:
a b c d e f
ab cd ef
abc def
abcd ef
abcde f
abcdef
abcde f
abcd ef
abc def
ab cd ef
a b c d e f

Factor, 78 bytes
[ dup length [1,b] dup reverse rest append [ group " "join print ] with each ]

Try it online!

Japt -R, 9 bytes
Êõ@òX ¸Ãê

Try it
Êõ@òX ¸Ãê
Ê         # Get the length of the input
 õ@    Ã  # For each X in the range [1...length]:
   òX     #  Split the input into substrings with length X
      ¸   #  Join them with spaces
        ê # Palindromize

-R        # Join with newlines and print

Raku, 44 bytes
{.put for map {.comb($^n)},(1...+.comb...1)}

Try it online!
Raku conveniently has a comb method on strings that can split one into chunks of a given size, so it's just a matter of mapping that method from 1, up to the number of characters in the string, then back down to 1 again.

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