text:
Find the next number in the pattern
Write a program, that takes 5 numbers as input and outputs the next number in the pattern.
Heres a text file with 1835 test patterns, containing 6 numbers separated by commas each line. Using the first 5 numbers calculate the 6th number and then check if it matches. You must get all the test cases correct.
There are 3 types of patterns:

xn = xn-1+k
xn = xn-1*k
xn = xn-1^2

The first x value and k were chosen randomly between a set range to create the pattern sample file.
This is code-golf, lowest number of bytes to get all of the test cases correct wins.

It seems fairly easy to get 100%. Is there a tiebreak?

The tiebreaker should be the length of the code because any solution can easily be O(n) time, i'll edit the question. Well this is just a duplicate of the other question then, should it be closed?

In that case, why don't you make it code golf and require getting all the test cases right?

I wouldn't consider it a duplicate. In the other question, different operations are applied cyclically, which makes it a lot harder than a single operation applied repeatedly in this one.

Thanks for the advice, edited. I was considering using doubles and decimals instead of integers for this question, but then I would have to get tangled in all the rounding and accuracy check and such.

What's the story with 4,16,256,65536,4294967296,0 in the pattern?  Is it a bug due to you not using an arbitrary precision type or what?

Most likely. Sorry about that. I will change the link in a minute.

Heh, I had used a java long to hold the number, it couldn't fit 2^64...

We also seem to disagree on what 152587890625 * 152587890625 is.

Fixed that too, thanks for spotting those. I'll be off to bed now haha its 3am. I will fix anything else that is found when I wake up. Thanks again :)

Now that code length matters: Is the code required to open the given file and run on the test cases?

Its pretty disappointing there are no trick rows; contestants are getting a perfect score by checking just the first three ints, and there's no divide-by-zeros being thrown either.

-1 for doing big changes in the scoring system. Please use the sandbox the next time

@JanDvorak ok I will use that, thanks for telling me :) (I had no idea it existed haha)

@Rodolvertice most sandbox questions get a great response on the main site. However, I think some people like to get a head start on questions while they are in the sandbox, so if you want people on an equal footing for whatever reason, you aren't required to post it there. It's a useful tool but not necessary in every case.

I have a task and would like to know if it is good for CodeGolf: Write a programme that calculates the next (2,3,..) number(s) in the sequence: 2,2,5,12,62,749,46490,___ It is a difficult Fibonacci.

Python 2: 55 bytes
f=lambda a,b,c,d,e:e+c-d*2and e*e/d**(d*d==e*c)or e*2-d

We check for the three cases as follows:

Check for arithmetic sequence: If e+c==d+d, output e+e-d
Check for geometric sequence: If e*c==d*d, output e*e/d
Otherwise, squared sequence: Output e*e.

Case 3 is used as the else-case to avoid the more-lengthy checking for successive squaring.
Case 1 is checked first, with Boolean short-circuiting to avoid checking Case 2 after a success, as this causes an error when d=0. There's a test case of all zeroes, so we can't cheat this by picking another position in place of d.
Afterwards, we can treat both Cases 2 and 3, since there's no risk of a divide-by-0 error. Noting that the choices are similar (e*e vs e*e/d), we combine them with an arithmetic expression by dividing by either d**1 for Case 3 or d**0 for Case 2. Although this division produces an integer value, we must use Python 2 (or //) to avoid float errors that case the largest-output test case to fail.
Thanks to @Will for inspiration on the code structure and a very-helpful test framework.

Still, like the multiply instead of and :)

Python all right, 72 74 75 chars
p=lambda i,j,k,l,m:j-i!=k-j and(k==j*j==j*i*i and m*m or m*l/k)or m+j-i

Thx to xnor for showing me the if/else to and/or trick and golfing off a char :)
Thx to flornquake for fixing the k==j*j==j*i*i and saving another two chars :)
Actually, it gets one wrong... but that's a bug in the test patterns which was acknowledged yesterday but still not fixed.
Testing code, hopefully useful for all competitors to test with:
def check(func,title):
    right = 0
    print "===", title, "==="
    for i,test in enumerate(open('patterns.txt')):
        test = map(int,test.split(','))
        try:
            got, expected = func(*test[:5]), test[5]
        except Exception as e:
            got = e
        if got != expected:
            print "ERROR on line %d: %s != %d" % (i, got, expected)
            print " test :", ", ".join(map(str,test))
            plus = multi = cube = str(test[0])
            for i in range(1, 6):
                plus += ", %d" % (test[i-1]+(test[1]-test[0]))
                multi += ", %s" % ((test[i-1]*(test[1]/test[0])) if test[0] else "DivZero")
                cube += ", %d" % (test[i-1]**2)
            print " as + :", plus
            print " as * :", multi
            print " as ^2:", cube
        else:
            right += 1
    print right, "out of", i+1, "right!"

says:
ERROR on line 19: 23283064365386962890625 != 3273344365508751233
 test : 5, 25, 625, 390625, 152587890625, 3273344365508751233
 as + : 5, 25, 45, 645, 390645, 152587890645
 as * : 5, 25, 125, 3125, 1953125, 762939453125
 as ^2: 5, 25, 625, 390625, 152587890625, 23283064365386962890625
1834 out of 1835 right!

You can usually save chars from the if/else ternany operator using the and/or trick: http://codegolf.stackexchange.com/a/57/20260

I had deleted my suggestion of k==j*j==i**4 on realizing it fails for 1, -1, 1, -1, 1, -1, but it turns out you can dodge it by using j,k,l instead, which changes the parity. I assume it's allowed to take advantage of a coincidental hole in the test cases?

@xnor thx for the encouragement and leads :)  I don't really want to take advantage of holes in the test cases.  And the I didn't know that neat and/or trick!  But its not applicable for this particular problem because the correct prediction may be falsy, e.g. -10, -8, -6, -4, -2, 0.  Still neat to learn.

Hmm, I think and/or should just work, independent of the truthiness of the output. Let's try to fix it. Can you check that you converted a if b else c to b and a or c? And also that the two of it are nested right and perhaps parenthesized to parse right? If it still doesn't work, could you please tell me what you have.

@xnor q=lambda i,j,k,l,m:j-i==k-j and m+j-i or(j==i*i)&(k==j*j)and m*m or m*l/k is how I wrote it.

Weird, that seems totally right, I have no idea why the behavior changes. I'll have to figure that out. The switched version works though: q=lambda i,j,k,l,m:j-i!=k-j and((j==i*i)&(k==j*j)and m*m or m*l/k)or m+j-i

@xnor thx that was neat :)

@xnor It doesn't work because the a if b else c-to-b and a or c trick relies on a being truthy.

It think k==j*j==j*i*i should work in place of (j==i*i)&(k==j*j).

@flornquake oooh thx of course!

@flornquake Thanks, I see. To be more specific, the if/else to and/or conversion always gives the same value if it evaluates, but has slightly different short-circuiting behavior. When b is Truthy and a is Falsey, c is evaluated though its value doesn't matter.

Python 3 -1833
Length 198 chars
Now updated to conform to the rules.
m=0
for i in open('s'):
 if','in i:
  i,j,k,l=list(map(int,i.split(',')[2:]))
  if j-i==k-j:
   if k+(j-i)==l:m+=1
  elif j/i==k/j:
   if k*(j/i)==l:m+=1
  elif i**2==j:
   if k**2==l:m+=1
print(m)

You can golf this a lot (the rules are changing under us and code size is now important) e.g. for i in open('s.txt'): and unpacking the first three ints in the split etc.

here's a 112 byte version, but I miss tricks: https://gist.github.com/williame/f8ae068ff7e658cde28f

@Will Thanks, what do you mean by tricks?

Here's an alternative one-liner at 112 chars that copes with the first or second int being 0: print sum((lambda i,j,k:j-i==k-j or(i*j and j/i==k/j)or i**2==j)(*map(int,s.split(',')[:3]))for s in open('s'))

I know this has been accepted by the poster, so must meet their criteria of correctness, but it seems to be overlooking the requirement Using the first 5 numbers calculate the 6th number and then check if it matches?

i**2 is longer than i*i.

Python can read from files without a .txt extension (I just tested this). The name of the file was not specified in the problem, so you should shave off four characters by naming it a single letter. for i in open('s'):, assuming the file was named "s".

This seems to be reading the file and giving itself a point for each row it would have gotten right. What I thought was asked for is a function that takes five numbers and gives the sixth, with the file not part of the code, but a check for scoring. But it's up to OP I guess.

You are right, I'm sorry i'm taking so long to respond and fix stuff (school), the program/function is only required to take 5 inputs of numbers and output the next number in the sequence. (first line in the challenge question). You can then test it on all the test cases.

Checking the third and forth items because I said the first two may contain zeros does not solve the divide by zero problem ;)

the program should only take 5 numbers as input and output the sixth. The testing program is different.

C# - 1835
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace pattern
{
    class Program
    {
         static void Main(string[] args)
         {
            string[] lines = File.ReadAllLines("in.txt");
            int matches = 0;
            for(int i = 0; i < lines.Length; i++)
            {
                long[] numbers = lines[i].Split(',').Select(a=>long.Parse(a)).ToArray();

                long nextnum = 0;
                if(numbers[1]-numbers[0]==numbers[2]-numbers[1])
                nextnum = numbers[numbers.Length-2]+(numbers[1]-numbers[0]);
            else if(numbers[1]/numbers[0]==numbers[2]/numbers[1])
                nextnum = numbers[numbers.Length-2]*(numbers[1]/numbers[0]);
            else if(numbers[1] == numbers[0]*numbers[0])
                nextnum = numbers[numbers.Length-2]*numbers[numbers.Length-2];
            if(nextnum == numbers[numbers.Length-1])
                matches++;
        }
        Console.WriteLine(matches + " matches found!");
        Console.ReadLine();
    }
}
}

This is obviously not golfed at all, but it finds all numbers eventually. It just prints how many matches it found, but you could potentially display all found numbers, only non-matches, etc...
(This is conceptually very similar to Beta Decay's answer, just a little bit more complicated)

I love C#, it is like a mixture of everything, it has lambdas, anonymous delegates, LINQ, and a bunch of other features haha, not exactly fit for golfing though :P

Yeah, C# is great for some purposes. Well, like I said, I didn't golf this a whole lot :P

TI-BASIC, 120 117 136
Prompts for input and returns the output.
Input L1:0:If not(L1(5:Stop
If L1(5)-L1(4)=L1(4)-L1(3:L1(5)+(L1(5)-L1(4
If L1(5)/L1(4)=L1(4)/L1(3:L1(5)(L1(5)/L1(4
If L1(4)²=L1(5:L1(5)²

Edit: Fixed divide by zero error.


text:
Word Search Puzzle
Given a rectangular text as a word search puzzle and a search string, determine if the text contains the search string. The search string may appear:

horizontally, vertically or diagonally
forwards or backwards

You may write a function or a program and take two strings as input via function argument, ARGV or STDIN. The output should be a truthy or falsy result which can either be returned from the function or written to STDOUT.
Assume that the text will contain arbitrary printable ASCII characters (hex codes 20 to 7E) and line break characters. Letters are case sensitive. You may assume that the input text is rectangular, i.e. all lines have the same length. You may whether the input ends with a trailing newline or not (if it matters for your submission).
This is code golf, the shortest answer (in bytes) wins.
Examples
Using this grid from Wikipedia's article on word searches as the first input:
WVERTICALL
ROOAFFLSAB
ACRILIATOA
NDODKONWDC
DRKESOODDK
OEEPZEGLIW
MSIIHOAERA
ALRKRRIRER
KODIDEDRCD
HELWSLEUTH

the following search strings should yield truthy or falsy results respectively:
Truthy: RANDOM, VERTICAL, HORIZONTAL, WORDSEARCH, WIKIPEDIA, TAIL
Falsy:  WordSearch, CODEGOLF, UNICORN

Alternatively, using this input text
Lorem ipsum dolor sit amet consectetu
r adipisicing elit sed do eiusmod tem
por incididunt ut labore et dolore ma
gna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco lab
oris nisi ut aliquip ex ea commodo co
nsequat. Duis aute irure dolor in rep
rehenderit in voluptate velit esse ci
llum dolore eu fugiat nulla pariatur.

We get the following search results (using quotes now, because there are spaces in some search strings):
Truthy: "Lorem", "mine", "uma bop", "tuetdod", "snol,a", "texas", "pii.d  v", "vexta"
Falsy:  "lorem", "wordsearch", "pii.d v", "mute"

Related: http://codegolf.stackexchange.com/questions/31743/is-this-word-on-the-boggle-board/31752#31752

CJam, 46 37 bytes
qN%{_zW%__,N**2$2$+,)/z\}4*]:+N*eas#)

Reads the grid from STDIN and the word as a command-line argument. Prints positive integers for matches and 0 for non-matches.
At the cost of two extra bytes, both strings (word, linefeed, grid) can be read from STDIN:
qN%(\{_zW%__,N**2$2$+,)/z\}4*](\:+N*\#)

You can try this version online with the CJam interpreter.
Example run
$ for W in Lorem mine uma\ bop tuetdod snol,a texas pii.d\ \ v vexta WordSearch CODEGOLF UNICORN; do echo -e "$(cjam wordsearch.cjam "$W" < grid)\t$W"; done
1       Lorem
3085    mine
2055    uma bop
5142    tuetdod
3878    snol,a
1426    texas
5371    pii.d  v
2536    vexta
0       WordSearch
0       CODEGOLF
0       UNICORN

Background
Assume the input was the following grid:
ABCD
EFGH
IJKL

Splitting at linefeeds, we obtain the following array:
A := [
         "ABCD"
         "EFGH"
         "IJKL"
     ]

That covers East words (words going from left to right).
Now, we join the elements of A using a string of len(A) linefeeds as separator:
"ABCD⏎⏎⏎EFGH⏎⏎⏎IJKL"

Then, we chop the resulting string in chunks of length len(A) + len(A[0]) + 1:
[
    "ABCD⏎⏎⏎E"
    "FGH⏎⏎⏎IJ"
    "KL"
]

If we "zip" the array (transpose rows and columns), we obtain:
[
    "AFK"
    "BGL"
    "CH"
    "D⏎"
    "⏎⏎"
    "⏎⏎"
    "I⏎"
    "EJ"
]

That covers South East words.
If we zip A and reverse the order of the result's rows, we obtain:
[
    "DHL"
    "CGK"
    "BFJ"
    "AEI"
]

That covers South and – after repeating the process for diagonals – South West words.
Zipping and reversing again, we obtain:
[
    "LKJI"
    "HGFE"
    "DCBA"
]

That covers West  and – after repeating the process for diagonals –  North West words.
Zipping and reversing once more, we obtain:
[
    "IEA"
    "JFB"
    "KGC"
    "LHD"
]

That covers North and – after repeating the process for diagonals – North East words.
How it works
The code does as explained in the previous section, with two minor differences:

It zips and reverses once at the very beginning.
It computes len(A) + len(A[0]) as len(A + zip(A)).

Finally, it joins all rows of all generated arrays using linefeeds as separators and searches for the word in the resulting string.
qN%                                   " A := split(input(),'\n')                          ";
   {                    }4*           " Do 4 times:                                       ";
    _zW%                              "   B := reverse(zip(A))                            ";
        __,N**                        "   C := B.join(len(B) * '\n')                      ";
              2$2$+,)/z               "   D := zip(C.chunks(len(A + B) + 1))              ";
                       \              "   A := B                                          ";
                           ]          " Collect all values of A and D in an array R.      ";
                            :+        " R := flatten(R)                                   ";
                              N*      " R := R.join('\n')                                 ";
                                eas   " I := flatten(ARGV)                                ";
                                   #) " print R.index(I) + 1                              ";

Java : 183 211 321
boolean s(char[]w,char[]s){int j,z,a=s.length,i=a*9,f=1,q=0;for(;s[q++]>10;);for(;i-->0;)for(j=w.length,z=i/9;i%9!=4&j-->0&z>=0&z<a&&s[z]==w[j];z+=q*(i/3%3)+i%3-q-1)f*=j;return f==0;}

A basic brute force. There's not much else to say, I guess. Input is needle first and haystack second. Assumes grid is newline-terminated.
A slightly more readable version with test case shown:
public class WordSearch {
    static String grid = "WVERTICALL\nROOAFFLSAB\nACRILIATOA\nNDODKONWDC\nDRKESOODDK\nOEEPZEGLIW\nMSIIHOAERA\nALRKRRIRER\nKODIDEDRCD\nHELWSLEUTH";
    static String search = "RANDOM";

    public static void main(String[] args) {
        System.out.println(new WordSearch().s(search.toCharArray(),grid.toCharArray()));
    }

    boolean s(char[]w,char[]s){
        int j,z,a=s.length,i=a*9,f=1,q=0;
        for(;s[q++]>10;);
        for(;i-->0;)
            for(j=w.length,z=i/9;
                i%9!=4&j-->0&z>=0&z<a&&s[z]==w[j];
                z+=q*(i/3%3)+i%3-q-1)
                f*=j;
        return f==0;
    }
}

if(e<1)return 1>0; could be return e<1; couldn't it?

@FryAmTheEggman No, that would return after finding the first failure, so it wouldn't search the whole grid.

Ah sorry, got kinda lost in there ;_;

The out two for loops could be collapsed into one instead so you'd do i=a*9, and for(;i-->0;) and then z=i/9; and i%a!=4& and so on?

@Will Thanks! I was looking at that before, but for some reason I came to the conclusion it wouldn't work. Stupid brain :)

Wow, this is so similar to mine. And I only glanced at it after I'd already started. I didn't take time to see how it works. +1.

JavaScript (E6) 111 116
Brute force search for every character in every direction - as golfed as I can
F=(b,w)=>
  [1,-1,r=b.search('\n'),-r,++r,-r,++r,-r].some(d=>
    [...b].some((_,p)=>
      [...w].every(c=>c==b[p+=d],p-=d)
    )
  )

Test In FireFox/Firebug console
;["RANDOM", "VERTICAL", "HORIZONTAL", "WORDSEARCH", "WIKIPEDIA", "TAIL",
"WordSearch", "CODEGOLF", "UNICORN"]
.forEach(w=>console.log('\n'+ w +' -> '+
  F("WVERTICALL\nROOAFFLSAB\nACRILIATOA\nNDODKONWDC\nDRKESOODDK\nOEEPZEGLIW\nMSIIHOAERA\nALRKRRIRER\nKODIDEDRCD\nHELWSLEUTH",w)))

Output
RANDOM -> true
VERTICAL -> true
HORIZONTAL -> true
WORDSEARCH -> true
WIKIPEDIA -> true
TAIL -> true
WordSearch -> false
CODEGOLF -> false
UNICORN -> false

Python, 175
Not very inspired, but here goes:
def s(h,n):
 l=h.find('\n')+2;h+='\n'*l;L=i=len(h)
 while i>0:
  i-=1
  for d in[-l,1-l,2-l,-1,1,l-2,l-1,l]:
    j=i;m=len(n)
    for c in n:m-=c==h[j%L];j+=d
    if m<1:i=-1
 return-i

First argument is haystack, second is needle.

I think you can save 6 characters by using h,n=input() and print. Also, does this work with non-square inputs? (m=len(n)? I admit to not fully understanding what you are doing, so I might be completely wrong!)

@FryAmTheEggman: Yes, it works with nonsquare inputs.

Some standard Python optimizations: while i>0 to while i: (since i can never become negative),  if m<1:i=-1 to i-=m<1.

@xnor I think you may have misread if m<1:i=-1 as if m<1:i-=1 as neither of those will work because he is setting i to be negative.

@FryAmTheEggman Oh, yes, I totally did misread that.

I really like this approach!  I think it inspired :)  A function that has no return value implicitly returns None, which is falsy.  So you can make it if m<1:return 1, strip the return off the end, and have the while be while i:?  I tried it out, 161 (second indent being tabs): https://gist.github.com/williame/77fbf6ff13d6ea0261fb  - so thx for the inspiration :)

C# - 218 197 186 bytes
C# function that takes 2 strings, the first the word to search for, the later the grid with line feeds (\n) between lines. Things are getting desperate now... so desperate in-fact that my previous edit didn't work!
Golfed code:
bool F(string D,string S){int l=S.Length,i=l*13,r,p;for(S+="\n";i-->l*5;i=r<0?r:i)for(r=D.Length,p=i%l;p>-1&p<l&r-->0&&D[r]==S[p];p+=(S.IndexOf('\n')+1)*(i/l%9/3-1)+i/l%3-1);return i<0;}

Less golfed with test code:
class P
{
    static void Main()
    {
        System.Console.WriteLine(new P().F(System.Console.ReadLine(),System.Console.In.ReadToEnd())?"Truthy":"Falsy"); // because why not
    }

    bool F(string D,string S)
    {
        int l=S.Length,i=l*13,r,p;

        for(S+="\n";i-->l*5;i=r<0?r:i) // for each cell/direction
            for(r=D.Length,p=i%l;p>-1&p<l&r-->0&&D[r]==S[p];p+=(S.IndexOf('\n')+1)*(i/l%9/3-1)+i/l%3-1); // test against string (backwards)

        return i<0;
    }
}

Bash+coreutils, 214 169 bytes
r()(tee >(rev) $@)
t()(eval paste -d'"\0"' `sed 's/.*/<(fold -1<<<"&")/'`)
d()(while IFS= read l;do echo "$a$l";a+=_;done|t)
r<<<"$2"|r >(d) >(r|t) >(r|d)|r|grep -q "$1"

Uses 3 transform functions r, t and d to reverse, transpose and diagonal shift, in all the necessary combinations.
Update - the r function now produces reversed and non-reversed output for extra golfiness
Input via commandline arguments - search string, followed by (newline separated) rectangular wordsearch block.
Output is an idiomatically correct shell exit status code - 0 meaning TRUE and 1 meaning FALSE.
Output:
$ for w in "Lorem" "mine" "uma bop" "tuetdod" "snol,a" "texas" "pii.d  v" "vexta" ; do ./ws.sh "$w" "Lorem ipsum dolor sit amet consectetu
r adipisicing elit sed do eiusmod tem
por incididunt ut labore et dolore ma
gna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco lab
oris nisi ut aliquip ex ea commodo co
nsequat. Duis aute irure dolor in rep
rehenderit in voluptate velit esse ci
llum dolore eu fugiat nulla pariatur."; echo $?; done
0
0
0
0
0
0
0
0
$ for w in WordSearch CODEGOLF UNICORN ; do ./ws.sh "$w" "Lorem ipsum dolor sit amet consectetu
r adipisicing elit sed do eiusmod tem
por incididunt ut labore et dolore ma
gna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco lab
oris nisi ut aliquip ex ea commodo co
nsequat. Duis aute irure dolor in rep
rehenderit in voluptate velit esse ci
llum dolore eu fugiat nulla pariatur."; echo $?; done
1
1
1
$

I was about to suggest T()(tee >(r) $@), but that's even better. 2. I don't think I've ever seen that function syntax before. 3. Considering non-empty strings truthy and empty strings falsy, I think you can omit -q.

If you define r()(tee >(rev) $@), r<<<"$2"|r >(d) >(r|t) >(r|d)|r|grep "$1" should work as well.

I haven't tested anything else, but the two test cases in the question checked out when I tried.

@Dennis Nice - yep it works now.  I checked with Martin - he wants the -q to remain.

C,163
f(char*h,char*n){int i,j,d,p,y=0,l=strlen(h),w=strchr(h,10)-h+1;for(i=l*9;i--;y+=d&&!n[j]){p=i/9;d=i%9/3*w-w+i%3-1;for(j=0;p>=0&p<l&h[p]==n[j];j++)p+=d;}return y;}

No rearrangement of the grid, I simply try every starting letter in every direction, and walk along until I run off the grid or find a mismatch.
I take advantage of the fact that a C string terminates in a zero byte. As there are no zero bytes in the grid, there will ALWAYS be a mismatch. But if the mismatch occurs at the zero byte we know we have found the end of the string to be searched for, and record it as a match.
Ungolfed in a test program
char h[]="WVERTICALL\nROOAFFLSAB\nACRILIATOA\nNDODKONWDC\nDRKESOODDK\nOEEPZEGLIW\nMSIIHOAERA\nALRKRRIRER\nKODIDEDRCD\nHELWSLEUTH\n";

f(char*h,char*n){                                   //haystack,needle
  int i,j,d,p,y=0,l=strlen(h),w=strchr(h,10)-h+1;   //l=length of whole grid. w=width of row, including terminal newline ASCII 10
  for(i=l*9;i--;){                                  //for each start letter and direction
    p=i/9;                                          //pointer to start letter
    d=i%9/3*w-w+i%3-1;                              //9 possible values of direction vector {-w,0,w}+{-1,0,1}
    for(j=0;p>=0&p<l&h[p]==n[j];j++)p+=d;           //walk p in the direction defined by d until we walk off the top or bottom of the grid or a mismatch is fount
    y+=d&&!n[j];                                    //if we got all the way to the terminal 0, record it as a hit. If d=0, don't record as this is an invalid direction.
  }
  return y;
}

main(int c, char**v){
  printf("%d",f(h,v[1]));
}

Output
Note that the function will return the total number of incidences of the string searched for in the grid. Thus for OD it returns 6. If no incidences are found it returns 0 which is the only falsy value in C. Changing to y|=d*!n[j] would save one character but lose this functionality.
$ ./a UNICORN
0

$ ./a CODEGOLF
0

$ ./a WordSearch
0

$ ./a RANDOM
1

$ ./a WORDSEARCH
1

$ ./a VERTICAL
1

$ ./a HORIZONTAL
1

$ ./a WIKIPEDIA
1

$ ./a TAIL
1

$ ./a OD
6

Python 2 - 246 259 275 308 298 297 294 313 322
w,s=input()
r=range
d='\n'
I=''.join
w=w.split(d)
t,u=len(w),len(w[0])
v=d.join([I(x)for x in zip(*w)]+[d]+[I([w[i+j][i]for i in r(min(u,t-j))])+d+I([w[i][i+j]for i in r(min(t,u-j))])for j in r(max(t,u))]+[d]+w)
print s in v or s[::-1]in v

Thanks to Will for some help with dealing with the print and defining join.
Thanks to underground railroad for reminding me to golf spaces properly ;p
Fixed for bad matches thanks to using ',' as delimiter.
Apparently the best way to golf is to add tons of horizontal scrolling.
Input as whitespace bang newline delimited lines in quotes:
"WVERTICALL\nROOAFFLSAB\nACRILIATOA\nNDODKONWDC\nDRKESOODDK\nOEEPZEGLIW\nMSIIHOAERA\nALRKRRIRER\nKODIDEDRCD\nHELWSLEUTH","RANDOM"

L=len;J=''.join etc and print any(s in(v,d,w,r...)) ?  I was going along the same lines when I saw you posted :)

@Will Thanks for the help! Defining len costs just as many characters as it saves, and I'm not sure about how to define join optimally (some have commas), so I'll do it in a bit.

Anywhere you have ) or ] followed by a space, you can take out the space.

Haskell - 173
Instead of searching directly on the grid, I transform the grid in different ways and match the word with each row of the new grid.
For example,
G1    G2    G3       G4   G5

abcd  aA1   abcd     a..  ..1
ABCD  bB2   .ABCD    bA.  .A2
1234  cC3   ..1234   cB1  aB3
      dD4            dC2  bC4
                      D3  cD
                       4  d

Search the word in each row of G1, G2, G4 and G5, then we're done. Note that G3 is not used, I post it here just for illustration.
A similar idea is applied to search forward and backward: just search the original word and reversed word.
So now we have searched 8 directions. Here's the code, whose correctness was verified by another script.
import Data.List
v=reverse
t=transpose
y=any
d r=zipWith(++)(scanr(\_->('\n':))[]r)r
g r w=y(y$y((==w).take(length w)).tails)[r,t r,t.d$r,t.d.v$r]
f r w=y(g(lines r))[w,v w]

The function f is what we want and its argument r is the rectangle string, w is the word to search.

APL (Dyalog Classic), 44 bytes
1∊⍞⍷↑{⍉0,⍵,↑(0,⊢)\↓0,⍵}¨{⍉⌽⍵}\4⍴⊂↑a⊆⍨a≠⊃⌽a←⎕

Try it online!

Um, I'm sorry, but it seems that you can't get input like that here, it needs to be \n-separated (that is, having ⎕TC[2] as the separator).

@EriktheOutgolfer oh crap... I'll fix it later. Thanks.

fixed now, unfortunately much longer

J, 60 53 bytes
<@[e.[:,[:(;|.)@>[:<\\.@>[:(<"1,</.)@>@(;|.@|:)[;.2@]

Try it online!
Requires the first input to contain no newlines.
Explanation:
linkrotate=: ;|.@|:     NB. link with itself rotated 90° ccw
infixes   =: <\\.       NB. list of boxes containing the infixes
lines     =: <"1 , </.  NB. horizontal and diagonal lines, boxed
linkrev   =: ;|.        NB. link with itself reversed
appearin  =: <@[ e. [: , [: linkrev@> [: infixes@> [: lines@>@linkrotate [;.2@]

Try it online!
Hooks are useful.

It seems that this works too. (51 bytes)

Jelly, 16 bytes
Solved a related (possibly a duplicate) challenge with 15 of these 16 bytes as the core of the code...
ỴZU$3Ð¡;ŒD$€Ẏw€Ẹ

A dyadic link accepting a list of characters on the left and a list of characters on the right which returns 1 if found and 0 if not.
Try it online!
How?
ZU$3Ð¡;ŒD$€Ẏw€Ẹ - Link: words, grid
   3Ð¡          - repeat three times and collect the results (inc input):
  $             -   last two links as a monad:
Z               -     transpose
 U              -     upend     (together these rotate by a quarter)
          €     - for €ach:
         $      -   last two links as a monad:
       ŒD       -     get forward-diagonals
      ;         -     concatenate
           Ẏ    - tighten (to get all the runs across the grid)
             €  - for €ach run:
            w   -   sublist-index (0 if not found)
              Ẹ - any truthy? (i.e. was the word found?)

source: Stack Exchange

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

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

sort: votes


text:
Golfscript Diagonal Array
Is there a way in Golfscript to bring all of the diagonals of an array into a single array?
For example, for the array
[[1 2 3][4 5 6][7 8 9]]

return
[[7][4 8][1 5 9][2 6][3]]

(not necessarily in that order) and for
["ABCD""EFGH""IJKL"]

return
["I""EJ""AFK""BGL""CH""D"]

(not necessarily in that order). Assume the lengths of the arrays are the same.
I am struggling with figuring it out. I tried doing something with = and iterating through the (length+1)th character of the strings, but that didn't work. Can someone help me?
I'd like the shortest way to do this, if possible.

This isn't your regular Q&A site; you need to have a winning criterion. I suggest a popularity content for starters.

@Timtech I understand. I'll try regular stackexchange.

Language-specific golf advice questions are officially on-topic: http://meta.codegolf.stackexchange.com/a/1725/20260

@xnor You linked to wrong answer there. That one is about those tips lists we have. But asking for specific advice is also on topic so it would be nice if people could stop downvoting and close voting this.

Tips most definitely are on topic, but should be posted as community wiki. However I'm not convinced that this question should be reopened as the main Golfscrip tips question already has several answers that are as specific as the one requested here. Maybe anyone who has an answer should post it there. http://codegolf.stackexchange.com/q/5264/15599

@steveverrill I don't agree that these should be made CW. That only applies to the list questions (in fact, I don't even agree that those should be CW), but there's really no reason for specific advice question to be CW - they are basically micro-optimisation golfing contests, and the people answering them do deserve the rep for it (as does the asker, if the question is interesting).

Consider
[
    "ABCD"
    "EFGH"
    "IJKL"
]

To obtain the main diagonal and the diagonals above it, we can shift out the first char of the second row and the first two of the third:
[
    "ABCD"
    "FGH"
    "KL"
]

Note that all columns correspond to a diagonal, so "zipping" the array (i.e., transposing rows and columns) will yield an array containing the aforementioned four diagonals:
[
    "AFK"
    "BGL"
    "CH"
    "D"
]

We're still missing the diagonals below the main diagonal.
If we zip A itself and repeat the above process, we'll obtain an array containing the main diagonal and all diagonals below it. All that's left it to compute the set union of both arrays.
Putting it all together:
[.zip]{:A,,{.A=>}%zip}/|

[.zip]{              }/  # For the original array and it's transpose, do the following:
       :A                # Store the array in A.
         ,,{    }%       # For each I in [ 0 1 ... len(A) ], do the following:
            .A=>         # Push A[I] and shift out its first I characters.
                  zip    # Transpose the resulting array.
                       | # Perform set union.

Try it online.
Finally, if we only need the diagonals because we're searching for a string inside them (like in the Word Search Puzzle, which I assume inspired this question), a "less clean" approach might also be suitable.
You can use
..,n**\.0=,\,+)/zip

to obtain all diagonals, plus some unnecessary linefeed characters.
I've explained the process in detail in this answer.
Try it online.

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


text:
Graph Google Search Results
When you search for something on Google, it conveniently gives a message near the top of the page saying something like About 53,000,000 results (0.22 seconds). (The numbers change depending on what was searched of course.)
In this challenge you will write a program that draws a logarithmic ASCII graph of the number of results given by Google when all the non-empty prefixes of a given search-phrase are searched.
A search-phrase is defined as one or more strings of lowercase alphanumeric characters, separated by one space from each other. In Regex a search-phrase is (?:[a-z0-9]+ )*[a-z0-9]+.
So im ok, r, and 1a 2 are all search-phrases, but I'm OK, R, 1a  2, and  , are not.
(The character restrictions are in place because Google rarely takes case or special symbols into account. Escaping non-alphanumeric characters in URLs is also a hassle.)
Spec
Your program must take in a search-phrase and a positive floating point number H from either stdin or the command line. (You can assume they are valid and it's fine if you need quotes or something around the search-phrase.)
As a working example let's assume the search phrase is a car and H = 0.75.
Step 1:
Gather the non-empty prefixes of your search-phrase, and put them in double quotes. The quotes ensure that that the exact phrase will be searched for, avoiding any 'did you mean...' redirections.
Exclude all prefixes that end in a space such as a[space].
Prefixes
"a"
"a c"
"a ca"
"a car"

Step 2:
Search each of these terms exactly as they appear using https://www.google.com, and note the number of results returned.
Search Term    Message                                       Results
"a"            About 6,950,000,000 results (0.27 seconds)    6950000000
"a c"          About 861,000,000 results (0.27 seconds)      861000000
"a ca"         About 2,990,000 results (0.30 seconds)        2990000
"a car"        About 53,900,000 results (0.39 seconds)       53900000

If the search term did not match any documents, put a 0 in the Results column.
Step 3:
Compute y = floor(H * log10(r + 1)) for each row, where r is the Results value. H is still 0.75 here.
Search Term    Results       y
"a"            6950000000    7
"a c"          861000000     6
"a ca"         2990000       4
"a car"        53900000      5

Step 4:
Arrange y number of vertical bars (|) above the last character of each unquoted search term, using spaces to fill empty areas, in a sort of bar graph.
|
| |
| | |
| |||
| |||
| |||
| |||
a car

This graph is the final result of your program and the only thing it needs to output. It should go to stdout.
Scoring
This is code-golf, so the shortest program in bytes wins.
Notes

You may use URL shorteners or other search tools/APIs as long as the results would be the same as searching https://www.google.com.
I know that double quotes are not a surefire way to exclude "did you mean..." redirections. Adding &nfpr=1 to the URL doesn't always work either. Don't worry about these inaccuracies. Just look for the About X results... message no matter what pops up, or set Results to 0 if there is none.
There is an empty column above any space in the search-phrase in the graph.
The graph should not be wider or taller than it needs to be (e.g. with whitespace).
It's ok if your program has side effects like opening a web browser so the cryptic Google html/js pages can be read as they are rendered.

I know it's not typical to get zero results, but when you do there is no "About x results...". I assume that should be detected and shown as 0 bars?

@Geobits Yes, assume 0 results.

Just so you know - don't hammer google - it will respond with a captcha if you hit it too hard/too often, which might break your program

Ruby, 316 295 bytes
require 'open-uri'
s,h=*$*
r=[]
s.size.times{|i|r<<(s[i]==' '?'':?|*(h.to_f*Math.log10((URI.parse("http://google.com/search?q=#{URI::encode ?"+s[0..i]+?"}").read[/About [\d,]+ results/]||?0).gsub(/\D/,'').to_i+1)).floor)+s[i]}
puts r.map{|l|l.rjust(r.map(&:size).max).chars}.transpose.map &:join

Unfortunately, the requests just stopped working on the online tester I was using, so I need to golf this down further tonight or tomorrow.
Explanation: I'm taking the input via ARGV. Then I'm just sending a request for each substring that doesn't end in a space, find the results via regex (and default to 0 if the regex doesn't match), and then build the histogram with horizontal bars. At the end, I'm reversing all lines and transposing them to create the vertical histogram.


text:
Shortest parser for a left-recursive grammar
Write the shortest parser for the grammar:
M -> M + n | n

Output must be some representation of a structured value representing the concrete syntax tree produced by the input n+n+n.
The code to produce the textual output from the structured value is not necessary.
The code to read/validate input is not necessary.
Solution is anything that can somehow be called; a function, an object, doesn't matter.
How your solution receives input (currying character-by-character, whole-string, some kind of input reader) does not matter.

For example a bottom-up parser (Javascript, 284 characters):
function M(d){function c(a){throw"unexpected "+a;}function f(a){if("+"==a)return b.push(a),e;if(null==a)return b;c(a)}function e(a){if("n"==a)return b.push(a),b=[b],g;c(a)}function g(a){if("+"==a)return b.push(a),e;if(null==a)return b;c(a)}var b=[];if("n"==d)return b.push(d),f;c(d)};

When called:
 M('n')('+')('n')('+')('n')(null)

will return an array that in JSON-notation looks like this:
[["n", "+", "n"], "+", "n"]

Edit for the uninitiated in parsing: This is one of those questions where making a program produce the correct output is easy but the form of the program is essential for up-boats.
M -> M + n | n

Means that M consists of a previous M, a plus sign and a literal "n". Or good M is a single "n" literal character.
There are several way of approaching this challenge, I'll describe my own solution, which is called bottom-up parsing. Character by character:
 Stack               Incoming Character         Action on stack
                     n
 n                   +                          reduce "n" to M
 M+                  n
 M+n                 +                          reduce "M + n" to M
 M+                  n
 M+n                 EOF                        reduce "M + n" to M
 M

The twist in this question is that the simplest form of parsers called "recursive-descent" parsers won't work because the grammar is left-recursive and that throws a recursive-descent parser into an infinite loop.

Would this question make more sense to me if I had ever taken any CS classes? ;-). Perhaps you can give a couple if input/output examples for the rest of us

@DigitalTrauma I have edited my answer.

Ruby, 51 bytes
f=->s{s.split(/(\+)(?=n$)/).map{|t|t['+n']?f[t]:t}}

This seems weirdly cumbersome. It can be called like f['n+n+n'].

CJam, 13 15
If I have understood what did you mean by "the code to validate input is not necessary" correctly:
{'+/{[\"+"@]}*}

Example
{'+/{[\"+"@]}*}:T;
"n+n+n" T`
N
"n+n+n+n" T`

Output:
[["n" "+" "n"] "+" "n"]
[[["n" "+" "n"] "+" "n"] "+" "n"]

Or if I have to check the grammar:
CJam, 24
{'+/_"n"a-L@{[\"+"@]}*?}

Am I doing something wrong? The Code only prints itself on http://cjam.aditsu.net/

@Falco I have changed the code to a function (or block) but forgot to change the "from stdin to stdout" line... Now added some examples.

What was wrong with the 13-char version? It seemed to work.

@MartinBüttner said it should be a function...

Augeas, 42
module A=let rec l=[key"n".(del"+""+".l)?]

Example usage, by adding:
test l get "n+n+n" = ?

and launching:
$ augparse a.aug
Test result: a.aug:2.0-.22:
{ "n"
  { "n"
    { "n" }
  }
}

Due to the bidirectional nature of Augeas lenses, the provided code also manages the reverse transformation, e.g. by using:
test l put "n" after clear "n/n/n" = ?

then launch augparse:
$ augparse a.aug
Test result: a.aug:2.0-.38:
"n+n+n"

Pyth, 20 13 bytes
L.U[b\+Z)cz\+

Took me forever to shorten it, but I did! I changed pretty much the entire algorithm. Defines a function y that takes one string argument.
Live demo with 3-byte test harness and test cases.
Original
?tJu?qH\n+GH,GHzkJ]J

Live demo and test cases.

For those (like me) that don't grok Pyth, how exactly does it create a function called y?

@JerryJeremiah The L creates a function named y that takes an argument b. If you want, I'll add an explanation in a few. :)

Thanks so much.  I really want to learn one of these golfing languages.   I am just not competitive at all with the languages I am good at...

@JerryJeremiah Just remember that algorithms beat languages. I've been beated by Python because the other person had a better method of solving the problem than I did. :)


text:
Frogger Champion
The Game
Most of us know about Frogger, the 80's era arcade game where the objective is to hop a frog safely across a busy highway and a hazard-filled pond to arrive safely at home.
A challenge was issued some months ago to develop a Frogger clone. But why clone Frogger when you can play Frogger? :)
Consider the following simplified playing grid:
 XXXXXXXXXXXXXXXXXXXXXXX  North Safe Zone
 -----------------------
|                       | <<<<       Express Lane West        (Lane 1)
|                       |     >      Gridlock East            (Lane 2)
|                       |   <<       Freeflowing Traffic West (Lane 3)
|                       |    <       Gridlock West            (Lane 4)
|                       |     >>>>   Express Lane East        (Lane 5)
 -----------------------
 XXXXXXXXXXX@XXXXXXXXXXX  South Safe Zone
 \__________ __________/
            '
  23 cells horizontally

We have five lanes of traffic, each 23 cells wide, and two safe zones (where the frog can move safely left and right), also 23 cells wide. You may ignore the right and left borders as these are for pictorial clarity.
Our frog starts in the southern safe zone, on the center (12th) cell, as indicated by a @ in the above figure.
Time in the game is divided into discrete steps called frames. Froggy is a fast frog and can hop one cell in any direction (up, down, right, left) per frame. He may also choose to remain stationary for any frame. The traffic in the five lanes moves at constant speeds as follows:

the traffic in the express lane west (lane 1) moves 2 cells left every frame
the traffic in the gridlock east lane (lane 2) moves 1 cell right every second frame
the traffic in the freeflowing traffic west lane (lane 3) moves 1 cell left every frame
the traffic in the gridlock west lane (lane 4) moves 1 cell left every second frame
the traffic in the express lane east (lane 5) moves 2 cells right every frame

The traffic itself is uniquely defined for approx. 3,000 timesteps in this text file. 'Traffic' consists of vehicles and spaces between the vehicles. Any character that is not a space is part of a vehicle. The text file contains five lines, corresponding to the five lanes of traffic (with the same order).
For the westbound lanes, at the start of frame 0 (the start of the game), we consider the first vehicle in the lane to be just beyond the right edge of the playing grid.
For eastbound lanes, the traffic string should be considered "backwards" in the sense that the vehicles appear starting at the end of the string. At the start of frame 0, we consider the first vehicle in these lanes to be just beyond the left edge of the playing field.
Consider as an Example:
Traffic Lane 1:  [|==|  =
Traffic Lane 2:  |) =  o
Traffic Lane 3:  (|[]-[]:
Traffic Lane 4:  <| (oo|
Traffic Lane 5:  |==|] :=)

Then the playing grid will appear as follows:
Start of Frame 0       XXXXXXXXXXXXXXXXXXXXXXX
                                              [|==|  =
                |) =  o
                                              (|[]-[]:
                                              <| (oo|
              |==|] :=)
                       XXXXXXXXXXXXXXXXXXXXXXX

Start of Frame 1       XXXXXXXXXXXXXXXXXXXXXXX
                                            [|==|  =
                |) =  o
                                             (|[]-[]:
                                              <| (oo|
                |==|] :=)
                       XXXXXXXXXXXXXXXXXXXXXXX

Start of Frame 2       XXXXXXXXXXXXXXXXXXXXXXX
                                          [|==|  =
                 |) =  o
                                            (|[]-[]:
                                             <| (oo|
                  |==|] :=)
                       XXXXXXXXXXXXXXXXXXXXXXX

Start of Frame 3       XXXXXXXXXXXXXXXXXXXXXXX
                                        [|==|  =
                 |) =  o
                                           (|[]-[]:
                                             <| (oo|
                    |==|] :=)
                       XXXXXXXXXXXXXXXXXXXXXXX

After all the traffic in a lane is "depleted" (i.e. the string runs out), we consider all characters in the string to be spaces.
Our frog is squished if any of the following occurs:

the frog occupies a cell occupied by a vehicle, on any frame
the frog remains stationary in an express lane and a vehicle of 1 cell width passes over him in that frame
the frog jumps east "through" a vehicle heading west, or jumps west through a vehicle heading east
the frog jumps outside of the 7 (line) by 23 (cell) playing grid, on any frame

Note that these are the only conditions under which a frog is squished. In particular, a frog hopping along "with" traffic is permissible, as is a frog jumping into or out of a cell in an express lane that is passed over by a width-1 vehicle in the same frame.
Objective and Scoring
The objective of the programming challenge is to get the frog across the road as many times as possible before the last vehicle exits the playing grid. That is, the program terminates immediately after the completion of frame X, where frame X is the first frame that takes the grid to a state where no more vehicles are present.
The output of your program should be a string (or text file) containing the sequence of moves for the frog using the following encoding:
<   frog moves left
>   frog moves right
^   frog moves up
v   frog moves down
.   frog remains stationary

For example, the string <<^.^ indicates that the frog moves left twice, then up, then pauses for one frame, then moves up again.
One point is scored whenever the frog crosses from the south safe zone to the north safe zone, and one point is scored whenever the frog crosses from the north safe zone to the south safe zone.
Some important rules:

The frog must not be squished.
Please post your solution (sequence of moves) along with your program code, either inline or as a text file (e.g. using pastebin.com).
Our frog is prescient and precognizant, hence your program may make use any and all traffic data in any frame while seeking out solutions. This includes data for traffic that hasn't yet reached the playing grid.
The grid does not wrap around. Exiting the grid will cause the frog to be squished and hence is not permitted.
At no point does traffic "reset" or the frog "teleport". The simulation is continuous.
The frog may return to the south safe zone after exiting it, but this is not counted as a point. Likewise for the north safe zone.
The contest winner is the program that generates the move sequence yielding the highest number of crossings.
For any additional questions or concerns, please feel free to ask in the comments section.

For some added incentive, I'll add a bounty of +100 rep to the winning program when I'm able to do so.
Bonuses
+2.5% to the base score* (up to +10%) for every corner of the playing grid the frog touches. The four corners of the grid are the leftmost and rightmost cells of the two safe zones.
+25% to the base score* if your sequence of moves keeps the frog confined to within +/- 4 cells left or right of his starting cell for the entire simulation (he can of course move freely vertically).
No scoring bonus, but special props in the OP will go to anyone who posts a quick n' dirty solution validator so that I don't have to program one. ;) A validator would simply accept a sequence of moves, ensure its legality (per the rules and the traffic file), and report its score (i.e. the total number of crossings).
*Total score is equal to base score plus the bonus, rounded down to the nearest integer.
Good luck frogging!

To anyone who wants to post a solution validator: Please don't post it as an answer.

Indeed. A link to the code in a comment, or as an addendum to a solution, would be the preferred way to submit a validator.

Shall the first frame in which the slow lanes advance be the same as the first frame in which the other lanes advance, or one frame later?

Also, is it possible to score by reaching the endzone on the first frame in which all cars have cleared the field?

@feersum: The slow lanes advance one frame later. They remain motionless in the very first frame, as indicated in the example. As for the frog scoring on the very last frame: yes, it is possible. If the frog has moved into a safe zone on the same frame that the last vehicle exits the playing field, one point is scored.

C++: 176
Output:
176
^^^^^^>vvvvvv>^^^^>^^>>>>>>><<<.vv>v<<<.vvv<<<<<<^.^.^.^.>.>^^<.>>>>>>v>v>.>v<<<<v.<.vv<<<<<^^.<^<<<<<<^.^^>>>>vv>.>.v<v.vv>>^>>^<^<<<<<<<^>.>^^<<<.>>>>>vv>v<vvv<<<<<^^.<^^^^.....vv>.>.>.>v<<vvv<<>>>>^>^<.<.^^>^^>>>>vv.>v<vv.v^>^<.<.<^<^>.>^^>>>>vv.v<<<<<<.vvv<<<<^^^<<v^^.>.^^..>>>>>>vv>.>.v.vvv>>>^>^^<<<<<<<<<^>.>^^>>>>vvv<<v.<.vv<<<<<<>>>>>^^^<<<^^^<<>>vv>.v<<>vvv<<><>>>>>>>^>^^<^^^<.>>>>>>>>vv>.>v<<<vvv<<<<<^^^<<v.<.<^<<^.^<<^...>>>>>>>>>>>>>vv>v<vvv<<<<<<<<^>^.<.^^>.>^^<<<<<<<..>>>>vv>.vvvv<<<<>^.v>>>^^.^^>^<^<>>>>>>>>>vv>vvvv<<<<^^^<^>^<<^.>>vv>v<vvv<<<<<<<>>>>>>>^>^^^.^^>>>>>vvv<<vvv<<<^^^^^^<vvv<<<<<<<vvv<<<>>>>>>>>^^.<.<.^.^.^<^<>>>>>>>>>>vvv<<.vvv<<<^^<^<<^^<<^<<<>>>>vv>.vvvv>>^>>^<.<.<^<<<<<.^^<<^.......>vv.>.>.>v<vvv>>>>>>^>^.<.<^<.^^^<.>>>>>>>vvv<<<v.<vv<<<^^<.<.<.<^<<<^>^^..........v<vvvv>v>>>>>^>>^^^>^^>>>vv>v<vvv<<<<<<<<>^^.<.<^<^^^<.........>vv.>.vvvv>>>>^^<.<.<^^^<^<<.v<v>.>.>.>.>.>.>.vvv.v<<<<<^^<^<^>.>.>.>.^<^.>>>>>>>>vv>v<<vvv<<>>>>>^^^.^.>^<^<<<<<<<<.vv.>.v<<<.vvv<>>>>>^>^.<.<.<.<^^.^<<^<.....>>vvv<.>>vvv<<<>>>>>>>>^^^<<<.^.>.>^^.>>>>>vv.>v<vvv<<<>>>>>>^>^<^<<^.^^<vvv<<<<<vv.v<>>>>>>>>>>^>^.^^>^^<<<<.>vv.>.vvvv>^>>^.<.<.<^<<<^>^^>>>vv>v<<<<<vvv<<<>>>>>^^<.<.<.<.<^<^>.^^.>>>>>vv>v<>vvv<<<<<<<^>^.<^<<<<<<<^^^.>>>>>vv>v<>vvv>>>^^<.<^<<<^>^^.>>>>vv>.v<<vvv<<<<<^^^<<<<<^>.^^<>>>>>>>vv>.>v<<vvv<<<<<<<>>>^>>.>^^^.>^^<>>>>>>vv>vv.<.<.vv>>>>^^<.<.<.<^<<^.>^^.>>>>>vv.>.>v<<vvv<<>>>>>^^<.<.<.^^>.>.>^^<<<<<<<<.>>>>>>vv>v<<v.<.<vv<<<<^^.<^<<<.^^^<.vv.>v<vvv<<<>>>>>>^>^<^<<^.^<^<<.>>vv>.>.>.>vvvv>>>>>>^>^^^^^<<<.vvv<<<<<<vvv>>>>>^>^<.<^<<^.>.>.^^>>>>vv>.>v<<<<<<vvv<<<<^^^<.^.>^^>>>>vvv<<v.vv<<<^>>^^<<<.^^<<^>>>>>>>>>vvv.v.vv<>>>>>^>^^<<<<<<<<<<<<<<<<^^^..>>>>>vv>.>.>.>v<<v.<.<.vv<<<<<^^^<^>.^^...>>>>>>>>vv.v<.vvv>>>^>^<.<^^^^>>>vv>v<<<vvv<<<<>>>>>>^>^.<.<^<^>.>^^.>>>>>vv.v<<<<<<<<vvv<<<<^^<^<<<<<><^>.>^^>>>>vv.>.>.vvv.v>>>>>>>^^<.<^<<^^^>>>vv>.>.>.>.>v<<v.<.<vv>>>>^^^<<<<<.^.>^^>>>vv>.>v<vvv<<<<^^<.<.<.^^>^^>>>vv>.>.v<<<v.<vv<<<<^^.<^<<<^^^>>>>vvvvvv<<<<<<<<>^^.^>>^^^<>>>>>>>vvv<<<v.vv>>>>>^>>^^<<<<<^>.^^>>>>vv>.>v<<<<vvv<<<^^<.<.<.<^<<<<<^>^^>>>>vv.>vv.v.v<^>.>^.<.^^^^>>>>vv>.>.>.v<<<<<<vvv>>>>^^<.<.<^<<^^<^>>>>>>vv>v<<.vvv^>^^<<<^>^^<<<<<<.vvv<<vv>.v>>>>>>^>.>^^<<<<<^>.>.>.>.>.^^>>>>vv>.>.>v<<<<<vvv<<<<^^<^<<^.^^>>>>vv>.>.>.>v<vvv<<<<<^^.<.<^<<^^^>>>>>>>>>>>vv>.>.>.>.>vvvv<<<<^^.<.<^<^^^<<<<<<vvv<v.<vv<<<<^v>>>>>>>>>>^^^<.^.>.>.^^>>>>vvv<<<<<<<vvv<<<<<<<>^^.<^<.^^^.>>>>vv>v<vvv<>>>>^^.<.^.^.>.^<^>>>>>>>>vvvv.<.<vv<<<<^^^<<<<<^>.^^<.vv>.v<<vvv<<><>>>>>^>>^.<^<^^^<<<.>>vv>.>v<<<<v.vv>^>>^.<^^.^^.>>>>>vv>.>.>.v<v.<vv<<<<<^.^^^.>^^<>>>>>>vv>.v<<<v.<vv<<<<>>>>>>>>>>>^^<.<.<.<.<^<<^^<^<<<>>>>>>>vv>v<<<vv.v>>>>>>>>^>^<.<^<<<<<<<<<<<.^.>^^<<<vvv.v.<vv<<<^.>>^.<^^.>.>^^<<......vv.v>vvv>>>^.v^>>^^<<^^^<.>>>>>>>vvv<v.<.<.vv<<<<^^<.<.<.^^^^<.>>>>>>>>vvv<v.<vv^.>^^<<^^^vv>vvvv^>>>>>>>^^^^^vvvvvv^^^^^^vvvvvv>>>>

There are under 8 million states combinations of position X time X set of visited corners, so they can be exhaustively searched in less than 1 second. If the code has no bugs, it should be impossible to beat. The optimal strategy was to use the whole board, as that allows froggy to cross the road 160 times, versus about 120 when confined to the center. Visiting the corners didn't cost any crossings since the traffic was so heavy.
/* feersum  2014/9
 https://codegolf.stackexchange.com/questions/37975/frogger-champion */

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstring>

#define B(F, CST, X, Y) best[ ((F)*NCST + (CST)) * BS + (Xmax-Xmin+1) * ((Y)-Ymin) + (X)-Xmin]
#define TL(i) ((int)t[i].length())
#define ABSPEED(I) (speed[i]<0?-speed[i]:speed[i])
#define errr(X) { cout<<"ERROR!!!!!!!!"; return X; }

#define DRAW 0
#if DRAW
    #include <unistd.h>
#endif

using namespace std;

int bc(int cs) {
    int c = 0;
    while(cs) {
        c += cs&1;
        cs >>= 1;
    }
    return c;
}

int main()
{
    const bool bonusTwentyfive = false;
    const int COLS = 23, T_ROWS = 5, YGS = T_ROWS + 2, XGS = COLS + 2;
    string t[5];
    int speed[] = {-4, 1, -2, -1, 4};
    ifstream f("t.txt");
    for(int i = 0; i < T_ROWS; i++)
        getline(f, t[i]);
    if(f.fail())
        return 1;
    f.close();
//for(int i = 0; i < 5; i ++)t[i]="xxx";

    char g[XGS][YGS];

    int mov[][3] = { {-1,  0, '<'},
                     {+1,  0, '>'},
                     { 0, -1, '^'},
                     { 0, +1, 'v'},
                     { 0,  0, '.'} };

    int Ymin = 0, Ymax = YGS-1;

    const int Xstart = 11, Xmaxmove = bonusTwentyfive ? 4 : 10;
    const int Xmin = Xstart - Xmaxmove, Xmax = Xstart + Xmaxmove;

    const int NCST = bonusTwentyfive ? 1 : 1<<4;

    int maxfr = 0;
    for(int i = 0; i < T_ROWS; i++) {
        if(speed[i] < 0) {
            for(int m = 0, n = t[i].length()-1; m < n; ++m,--n)
                swap(t[i][m], t[i][n]);
        }
        int carslen = TL(i);
        for(char*c = &t[i][speed[i]>0?TL(i)-1:0]; carslen; carslen--, speed[i]>0?--c:++c)
            if(*c != ' ')
                break;
        if(carslen)
            maxfr = max(maxfr, ( (carslen + COLS) * 2 + ABSPEED(i)-1 ) / ABSPEED(i));
    }
    const int BS = (Xmax-Xmin+1)*(Ymax-Ymin+1);
    int *best = new int[(maxfr+1)*NCST*BS];
    memset(best, 0xFF, (maxfr+1)*NCST*BS*sizeof(int));
    memset(g, ' ', sizeof(g));
    B(0, 0, Xstart, Ymax) = 0;

    for(int fr = 0; fr < maxfr; fr++) {
        for(int r = 0; r < T_ROWS; r++) {
            for(int x = 0; x < XGS; x++) {
                int ind = speed[r] > 0 ? TL(r)-1 + x - fr*speed[r]/2 : x - (XGS-1) - fr*speed[r]/2;
                g[x][r+1] = ind >= 0 && ind < TL(r) ? t[r][ind] : ' ';
            }
        }
        for(int x = Xmin; x <= Xmax; x++) {
            for(int y = Ymin; y <= Ymax; y++) {
                if(g[x][y] != ' ')
                    continue;
                for(unsigned m = 0; m < sizeof(mov)/sizeof(mov[0]); m++) {
                    int X = x + mov[m][0], Y = y + mov[m][1];
                    if(X < Xmin || X > Xmax || Y < Ymin || Y > Ymax)
                        continue;
                    if(!(mov[m][0]|mov[m][1]) && y > 0 && y > T_ROWS && g[x][y-speed[y-1]/4] != ' ')
                        continue;

                    int csor = ((X==Xmin|X==Xmax)&(Y==Ymin|Y==Ymax)&!bonusTwentyfive) << ((X==Xmax) + 2*(Y==Ymax));

                    for(int cs = 0; cs < NCST; cs++) {
                        int N = B(fr, cs, x, y);
                        if(!~N)
                            continue;
                        if((!(N&1) && y == 1 && Y == 0) ||
                              (N&1 && y == T_ROWS && Y == T_ROWS+1))
                            ++N;
                        if(N > B(fr+1, cs|csor, X, Y))
                            B(fr+1, cs|csor, X, Y) = N;
                    }

                }
            }
        }
    }

    int score = 0, xb, yb, cb, nb;
    for(int x = Xmin; x <= Xmax; x++) {
        for(int y = Ymin; y <= Ymax; y++) {
            for(int cs = 0; cs < NCST; cs++) {
                if(B(maxfr, cs, x, y) * (40 + bc(cs)) / 40 >= score) {
                    score = B(maxfr, cs, x, y) * (40 + bc(cs)) / 40;
                    xb = x, yb = y, cb = cs, nb = B(maxfr, cs, x, y);
                }
            }
        }
    }
    char *mvs = new char[maxfr+1];
    mvs[maxfr] = 0;

    for(int fr = maxfr-1; fr >= 0; --fr) {
        for(int r = 0; r < T_ROWS; r++) {
            for(int x = 0; x < XGS; x++) {
                int ind = speed[r] > 0 ? TL(r)-1 + x - fr*speed[r]/2 : x - (XGS-1) - fr*speed[r]/2;
                g[x][r+1] = ind >= 0 && ind < TL(r) ? t[r][ind] : ' ';
            }
        }
        for(int x = Xmin; x <= Xmax; x++) {
            for(int y = Ymin; y <= Ymax; y++) {
                if(g[x][y] != ' ')
                    continue;

                for(unsigned m = 0; m < sizeof(mov)/sizeof(mov[0]); m++) {
                    int X = x + mov[m][0], Y = y + mov[m][1];
                    if(X < Xmin || X > Xmax || Y < Ymin || Y > Ymax)
                        continue;
                    if(!(mov[m][0]|mov[m][1]) && y > 0 && y > T_ROWS && g[x][y-speed[y-1]/4] != ' ')
                        continue;

                    int csor = ((X==Xmin|X==Xmax)&(Y==Ymin|Y==Ymax)&!bonusTwentyfive) << ((X==Xmax) + 2*(Y==Ymax));

                    for(int cs = 0; cs < NCST; cs++) {
                        int N = B(fr, cs, x, y);
                        if(!~N)
                            continue;
                        if((!(N&1) && y == 1 && Y == 0) ||
                              (N&1 && y == T_ROWS && Y == T_ROWS+1))
                            ++N;
                        if(X==xb && Y==yb && N == nb && (cs|csor) == cb) {
                            mvs[fr] = mov[m][2];
                            xb = x, yb = y, nb = B(fr, cs, x, y), cb = cs;
                            goto fr_next;
                        }
                    }
                }
            }
        }
        errr(3623);
        fr_next:;
    }

    if((xb-Xstart)|(yb-Ymax)|nb)
        errr(789);
    #if DRAW

        for(int fr = 0; fr <= maxfr; ++fr) {
            memset(g, ' ', sizeof(g));
            for(int r = 0; r < T_ROWS; r++) {
                for(int x = 0; x < XGS; x++) {
                    int ind = speed[r] > 0 ? TL(r)-1 + x - fr*speed[r]/2 : x - (XGS-1) - fr*speed[r]/2;
                    ind >= 0 && ind < TL(r) ? g[x][r+1] = t[r][ind] : ' ';
                }
            }
            g[xb][yb] = 'F';
            for(int y = 0; y < YGS; y++) {
                for(int x = 0; x < XGS; x++)
                    cout<<g[x][y];
                cout<<endl;
            }
            cout<<string(XGS,'-')<<endl;
            usleep(55*1000);
            for(int i = 0; i < 5; i++) {
                if(mvs[fr] == mov[i][2]) {
                    xb += mov[i][0];
                    yb += mov[i][1];
                    break;
                }
            }
        }

    #endif
    cout<<score<<endl;
    cout<<mvs<<endl;
}

I'm not sure how you're defining "states". If we consider the system state to be the time profile of the frog motion, there are approximately 5^3000 states, corresponding to the motion profile for the the 5^3000 possible inputs (five possible inputs per ~3000 frames). Obviously only a fraction of these will turn out to be admissible, but the number of admissible states would be impossible to search by many hundred orders of magnitude. When you submit your final answer, please submit a list of moves along with it.

Also, in case it isn't clear, note that the frog can jump left and right while in traffic, so long as none of the "squished" rules are violated. You aren't limited to waiting for windows where the frog is able to hop vertically across with no lateral motion.

@COTO In my calculation of "states" I did forget an important thing, namely the number of crossings so far, so I tried to give a clearer explanation. The spec was pretty well written. It seems I have interpreted all of these particular issues correctly the first time.

I compute the optimum as 162 + 10% = 178 crossings, but yours is close enough. I really didn't want this to turn out to be brute force-able, but evidently I should have given the problem more thought. In fairness, I'll award you the 100 rep.

Apparently I have to wait 24 hours before awarding the "bounty". For what reason: who knows. SE must not want answers rewarded punctually. If we did that, the terrorists would win. :O

If you thought it couldn't be exactly solved, how did you compute the optimum?

I gave the problem some protracted thought, thought of a solver based on dynamic programming, then thought some more and realized the pool of states was small enough that a brute force solution was indeed possible, then programmed a solver (this morning) and used it to verify that your solution was indeed optimal. ;)  When I wrote the spec, I was more interested in consistency, clarity, etc. I did contemplate the complexity, but obviously not for long enough. My own solver is Java-based, available here, for those interested.


text:
Rosetta Stone Challenge: Run-Length Encoding v2.0
The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism!
The Challenge
We've done run-length encoding before but only considered runs of a single character. Of course, we can sometimes make even greater savings if we consider runs of multiple characters.
Take aaaxyzxyzxyzdddd for instance. This can be compressed to 3a3{xyz}4d. Your task is to write a program of function which, given a case-sensitive string of letters and spaces, compresses it optimally using run-length encoding for multi-character runs.
You may take input via function argument, STDIN or ARGV and return the result or print it to STDOUT.
Runs must not be nested, so aaabbbaaabbb must be 3a3b3a3b, not 2{3a3b}. I.e. the string should be encoded (or decoded) in a single pass.
Consequences of Optimal Compression
Some examples where naive application of run-length encoding might lead to suboptimal results:

abab must not be "compressed" to 2{ab}
aaaabcdeabcde must not be compressed to 4abcdeabcde but 3a2{abcde} instead.

If there are two optimal versions (e.g. aa and 2a or abcabc and 2{abc}) either result is fine.
Examples
Input              Output

aa                 aa -or- 2a
aaaaaAAAAA         5a5A
ababa              ababa
abababa            a3{ba} -or- 3{ab}a
foo foo bar        2{foo }bar
aaaabcdeabcde      3a2{abcde}
xYzxYz             xYzxYz -or- 2{xYz}
abcabcdefcdef      abcab2{cdef}
pppqqqpppqqq       3p3q3p3q
pppqqqpppqqqpppqqq 3{pppqqq}

Scoring
Each language is a separate competition as to who can write the shortest entry, but the overall winner would be the person who wins the most of these sub-competitions. This means that a person who answers in many uncommon languages can gain an advantage. Code golf is mostly a tiebreaker for when there is more than one solution in a language: the person with the shortest program gets credit for that language.
If there is a tie, the winner would be the person with the most second-place submissions (and so on).
Rules, Restrictions, and Notes
Please keep all of your different submissions contained within a single answer.
Also, no shenanigans with basically the same answer in slightly different language dialects. I will be the judge as to what submissions are different enough.
Current Leaderboard
This section will be periodically updated to show the number of languages and who is leading in each.

C# (265) — edc65
JavaScript (206) — edc65
Python (214) — Will
VB.NET (346) — edc65

Current User Rankings

edc65 (3)
Will (1)

JavaScript (E6) 206
Almost sure it is optimal. I start trying to encode the longest string with the max gain, and recursively encode what remains at left and right. After each try I keep the shortest result.
Golf notes (JS specific)

Pseudo arguments instead of locals (for recursion)
Compare lengths using out of bounds index that gives 'undefined'

R=(s,n=s,d=s.length>>1,w,i,j,c)=>{
  for(;d;--d){
    for(i=-1;s[d+d+i++];){
      w=s.slice(i,j=i+d);
      for(r=1;w==s.substr(j,d);j+=d)++r;
      c=d>1?r+'{'+w+'}':r+w,
      // c[d*r-1]|| /* uncomment this line (+10 bytes) to have faster response
      n[(c=R(s.slice(0,i))+c+R(s.slice(j))).length]&&(n=c)
    }
  }
  return n
}

Test In FireFox/FireBug console
;['aa','aaaaaAAAAA','ababa','abababa','foo foo bar', 'aaaabcdeabcde',
  'xYzxYz', 'abcabcdefcdef', 'pppqqqpppqqq','pppqqqpppqqqpppqqq']
.forEach(x=>console.log(x+' -> '+R(x)))

Output
aa -> aa
aaaaaAAAAA -> 5a5A
ababa -> ababa
abababa -> 3{ab}a
foo foo bar -> 2{foo }bar
aaaabcdeabcde -> 3a2{abcde}
xYzxYz -> xYzxYz
abcabcdefcdef -> abcab2{cdef}
pppqqqpppqqq -> 3p3q3p3q
pppqqqpppqqqpppqqq -> 3{pppqqq}

C# (.NET 4.0) 265
Exactly the same algorithm
string R(string s)
{
  string n=s,c,w;
  int l=s.Length,d=l/2,i,j,r;
  for(;d>0;--d)
  {
    for(i=0;d+d+i<=l;i++)
    {
      w=s.Substring(i,d);
      for(j=i+d,r=1;j+d<=l&&w==s.Substring(j,d);j+=d)++r;
      c=d>1?r+"{"+w+"}":r+w;
      // if(c.Length<d*r){ // uncomment this line for faster execution
        c=R(s.Substring(0,i))+c+R(s.Substring(j));
        n=c.Length<n.Length?c:n;
      //} // and this one of course
    }
  }
  return n;
}

Test in LinqPad, mode 'C# program', add a main after the R function
void Main()
{
  string[] test = {"aa","aaaaaAAAAA","ababa","abababa","foo foo bar","aaaabcdeabcde",
  "xYzxYz","abcabcdefcdef","pppqqqpppqqq","pppqqqpppqqqpppqqq"};
  test.Select(x => new { x, r=R(x) }).Dump("Result");
}

Same Output
VB.Net (.NET 4) 346 (probably)
Same algorithm and same library, but the language is different enough
I can't be sure about byte count, as Visual Studio keep reformatting the code and adding spaces.
Golf notes: better use something else
function R(s as string)

  dim n=s,c,w
  dim l=s.Length,i,j,d
  for d=l\2 to 1 step-1
    for i=0 to l-d-d
      w=s.Substring(i,d)
      j=i+d
      r=1
      do while (j+d<=l andalso w=s.Substring(j,d))
        r=r+1
        j=j+d
      loop
      c=if(d>1,r & "{" & w & "}",r & w)
      if(c.Length<d*r) then
        c=R(s.Substring(0,i))+c+R(s.Substring(j))
        if c.Length<n.Length then n=c
      end if
    next
  next
  return n

end function

You can undo the adding of spaces.  If you type a character that makes it reformat hit ctrl-z to just undo the formatting.  It means two characters instead of one every so often but it's better than removing all the spaces and linefeeds afterward.

Python 214
def t(s):
 b=s;l=len;r=range(1,l(s))
 for i in r:
  p=s[:i];b=min(b,p+t(s[i:]),key=l);x=1
  for j in r:k=i*j+i;x*=p==s[i*j:k];b=min(b,(b,''.join((`j+1`,"{"[i<2:],p,"}"[i<2:],t(s[k:]))))[x],key=l)
 return b

(second level indent is tab)
As this is code-golf, this is the naive recursive approach without early-exit, so its really really slow.


text:
Find all strings at distance k
The edit (or Levenshtein) distance between two strings is the minimal number of single character insertions, deletions and substitutions needed to transform one string into the other.
The challenge is to write code to output all strings with edit distance exactly k from a fixed string of length 10, where k is a variable set in your code as is the fixed string.   The alphabet is 0 or 1. To test, take
1111011010

as the fixed string. The twist is that you can't output the same string twice.
You may not use any library or built in functions that compute the Levenshtein distance for you.
Score
This is a standard code-golf challenge. You can assume k will be a one-digit number.
Reference Implementation
(added by Martin Büttner)
For reference, here is a Mathematica solution (which isn't valid, due to use of EditDistance) which can be used to check results for correctness:
s = "1111011010";
k = 2;
Union @ Cases[
     Join @@ Array[# <> "" & /@ {"0", "1"}~Tuples~# &, 2 k + 1, 10 - k],
     x_ /; x~EditDistance~s == k
]

For the first ten values of k I the following results:
 k | # of results

 0              1
 1             28
 2            302
 3           1652
 4           5533
 5          14533
 6          34808
 7          80407
 8         180663
 9         395923

I'd suggest you make the input string variable, too. Also, you might want to specify which forms of I/O are allowed. Full program? Function? ARGV? STDIN? STDOUT? Return value? Oh one more thing, all strings over which alphabet?

And examples are always a good idea. Plus explaining what "edit distance" in your description AND linking to wikipedia is also good.

What constraints are there on the alphabet? Even for 1/0 only, there are a large number of outputs for a given string length and distance. It's much worse if you're using [a-z], [A-Za-z], etc.

Reminds me of the "Causes Challenge".  And Norvig's spell checker.  The additional constraint that the found words are in some dictionary might also be interesting; it would mean you can iterate the word list and compute edit distance, or chose to mutate the input string and check each against the dictionary.  The no-word-twice seems to be natural to both approaches, though, and not be hard to program around.

@MartinBüttner Thanks. No input needed. You can just put the string directly into the source.

@Geobits The alphabet is 1 or 0.  The output size can be large is k is large and so is the string.

Do we count the length of the code by assuming k is set to a one-digit number such as 1?

@IngoBürk Usually, if the input can be hardcoded that means you just assume that k already has its value, so you don't count the assignment.

@IngoBürk Yes assume k is a one-digit number.

Can you give some example results? I get 302 different strings for k = 2.

@MartinBüttner Banned. See update.

I've added the number of results for different k so people can check there submissions (along with the script used to generate them). I would have added a CW answer but that's not where test data belongs.

Can we assume k≤length(s)?

@TwiNight length(s) = 10 and k is a single digit number.. so ... yes :)

@Lembik I was thinking about cases like s='1010' and k=5

CJam, 72 64 bytes
QaK{_{_,),\f{[\:Lm>_,L>{_)1^+_);@}*_'0+\'1+]{Lm<}/}~}%_&}*]W%:-p

Assumes the string is stored in Q and the integer in K. This can be achieved by executing
"1111011010":Q;1:K;

for example. Try it online.
Example run
$ cjam <(echo '"1111011010":Q;1:K;'; cat edit-distance.cjam)
["1111011011" "11110110100" "11110110101" "111101101" "1111011000" "11110110110" "111101100" "1111011110" "11110110010" "111101110" "1111010010" "11110111010" "111101010" "1111001010" "11110101010" "1111111010" "11110011010" "111111010" "1110011010" "11111011010" "111011010" "1101011010" "11101011010" "1011011010" "11011011010" "0111011010" "10111011010" "01111011010"]
$ cjam <(echo '"1111011010":Q;1:K;'; sed 's/p/,p/' < edit-distance.cjam)
28
$ cjam <(echo '"1111011010":Q;2:K;'; sed 's/p/,p/' < edit-distance.cjam)
302

How it works
The idea is to recursively compute all strings at distance d or less ("or less" part not exhaustive), then remove the strings at distance k - 1 or less from the array of strings at distance k or less.
Qa                " Push R := [Q].                                                    ";
K{                " Do the following K times:                                         ";
  _               " Push a copy of R.                                                 ";
  {               " For each S ∊ R:                                                   ";
    _,),\         " Push A := [ 0 1 ... len(S) ] below S.                             ";
    f{            " For each I ∊ A, push I S and:                                     ";
      [           "                                                                   ";
        \:Lm>     " Rotate S (L := I) characters to the right.                        ";
        _,L       " Push len(S) L.                                                    ";
        >{        " If len(S) > L:                                                    ";
          _)1^+   " XOR the last character code of a copy of S with 1.                ";
          _);@    " Remove the last character of a copy of S.                         ";
        }*        "                                                                   ";
        _'0+      " Append '0' to a copy of S.                                        ";
        \'1+      " Append '1' to S.                                                  ";
      ]           " Collect the modified values of S in an array T.                   ";
      {Lm<}/      " For each U ∊ T, push U rotated L characters to the left.          ";
    }~            " Dump the resulting array on the stack.                            ";
  }%              " Collect the results in R.                                         ";
  _&              " Remove duplicates from R.                                         ";
}*                "                                                                   ";
]W%               " Collect the different values of R in an array and reverse it.     ";
:-                " Reduce the array using setwise difference.                        ";
p                 " Print a string representation of the resulting array.             ";

Very impressive! Could you give some explanation of how you did it?

I always do, I just like to make sure I'm done golfing first. I'll post an explanation in a few hours.

Scala 168 228
My first submission had a bug where it didn't consider multiple insertions at the same point in the input string.
After
val k = 1
val s = "1111011010"

The code that counts is:
def e(k:Int,s:String):Set[String]=if(k<1)Set(s)else e(k-1,s).flatMap(e=>"01"map(_+e))++(if(s=="")Set()else e(k,s.tail).map(s.head+_)++e(k-1,s.tail).flatMap(e=>(Set("0","1","")-(s take 1))map(_+e)))
print(e(k,s))

To run, save both sections together as a file and run like:
$ scala distancek.scala
Set(111111010, 111101010, 1111001010, 11110011010, 1101011010, 11101011010, 111101101, 111101100, 11111011010, 1111011011, 1111011000, 11110101010, 1111010010, 11110110110, 11110110101, 111101110, 11110110010, 0111011010, 1110011010, 11110110100, 10111011010, 11011011010, 01111011010, 1011011010, 1111111010, 111011010, 11110111010, 1111011110)
$

Recursive function to build the edited strings. k is the number of edits remaining, s is the string to edit. Slightly ungolfed:
def e(k:Int,s:String):Set[String]=
  if(k<1) Set(s)                           // No edits left
  else e(k-1,s).flatMap(e=>"01"map(_+e))++ // Insert a character, consume an edit, continue from the same point
      (if(s=="") Set()                     // We're at the end of the string so only insertions are allowed
       else e(k,s.tail).map(s.head+_)++    // skip past this character, making no edit
       e(k-1,s.tail).flatMap(e=>(Set("0","1","")-(s take 1))map(_+e))) // replace this character with its inverse or ""

Note that each step makes at least one of k, s smaller so we're guaranteed to terminate.

First submission (Incorrect)
print((0 to 10).permutations.flatMap{i=>((s.map(_+""):+"")zip i).:\(Set("")){case((s,i),a)=>a.flatMap{a=>(if(i<k)Set(1+s,0+s,"","0","1")-s else Set(s))map(_+a)}}}toSet)

We take the permutations of 0..10 and zip them with the word s + a terminal "" (for insertions at the end).
All the positions < k are positions where an edit should occur. For each edit we replace the string at that position with
Set(1+s,0+s,"","0","1")-s # don't count substituting s for itself as an edit.

and finally convert to a set to remove duplicates.

Could you provide instructions for how to run your code and get it to output the list of strings at distance k? I have never used scala and would like to test it.

JavaScript (E6) 167 183
Assuming the definition of variables k (required distance) and s (fixed string, 1111011010 for test). As requested it outputs in console just the list of string, so good luck for counting.
o={},o[s]=1,
A=x=>o[x]||(o[x]=d,d-k||console.log(x)),
S=r=>{
  for(l='';A(l+1+r),A(l+0+r),c=r[0];l+=c)
    r=r.slice(1),A(l+r),A(l+1+r),A(l+0+r)
};
for(d=0;++d<=k;)
  for(q in o)S(q)

Less golfed and more sensible, a function with 2 parameters and a count in output
F=(k,s)=>
{
  o={}, o[s]=1, h=0,
  add=x=>{
    o[x]||(o[x] = d, d == k && console.log(++h,x));
  },
  scan=s=>{
    add(s+1)
    add(s+0)
    for (l='',r=s,i=0; r; l += c) // l,r:left and right
    {
      add(l+1+r)
      add(l+0+r)
      c=r[0]
      r=r.slice(1)
      add(l+r)
      add(l+1+r)
      add(l+0+r)
    }
  };
  for(d=0; ++d <= k;)
    for (q in o)
      scan(q)
}

Test In FireFox/FireBug console
F(1,'1111011010')

Output
1 11110110101
2 11110110100
3 11111011010
4 01111011010
5 111011010
6 0111011010
7 10111011010
8 1011011010
9 11011011010
10 1101011010
11 11101011010
12 1110011010
13 11110011010
14 111111010
15 1111111010
16 11110111010
17 111101010
18 1111001010
19 11110101010
20 1111010010
21 11110110010
22 111101110
23 1111011110
24 11110110110
25 111101100
26 1111011000
27 111101101
28 1111011011

Just counting, no string output:
10 -> 850064 (in 3min & 600 MB)
11 -> 1795537 (in 8min & 900 MB)

Haskell, 136 134
import Data.List
n%l=iterate(>>=foldr(\t@(x:y)r->['0':t,'1':t,'0':y,'1':y,y]++map(x:)r)["0","1"].init.tails)[l]!!n
r=nub(n%l)\\(n-1)%l

upon running r will become the list of all strings with edit distance of 3 from "1111011010". the string is embedded in the code at line 5 and the required distance is at the end of the last line.
edit: explanation is removed because it is nor relevant anymore

Would you mind adding a little explanation? Your solution looks very interesting. Also, other people haven't included the length of the string in their count.

@Lembik should i assume any Haskell knowledge in my explanation?

I love your answer.. sadly CJam always wins.  But why did you remove the explanation? It was very informative.

@Lembik Some of it was out of date and I didn't want to update it at the time. Do you want a renewed version?

Yes please! If you don't mind. I also posed a new question you might like.

Mathematica, 244 bytes
l=Length;e[s_,t_]:=(m=l@s;n=l@t;Clear@f;f[0,m_]:=m;f[m_,0]:=m;For[j=0,j++<n,For[i=0,i++<m,p=f[i-1,j-1];f[i,j]=If[s[[i]]==t[[j]],p,Min[p,f[i,j-1],f[i-1,j]]+1]]];f[m,n])#<>""&/@Union@Cases[Join@@Array[{"0","1"}~Tuples~#&,2k+1,l@s-k],x_/;x~e~s==k]

This is basically the same as the reference implementation I added to the question, except I reimplemented EditDistance (as e) using the Wagner-Fischer algorithm.
That is, I simply generate all possible strings of the relevant lengths, and then I just reject all which aren't an edit distance of 2 away from the input string.
This expects the distance to be stored in k and the input as an array of characters in s.
Less golf:
l = Length;
e[s_, t_] := (
  m = l@s; n = l@t;
  Clear@f;
  f[0, m_] := m;
  f[m_, 0] := m;
  For[j = 0, j++ < n,
   For[i = 0, i++ < m,
    p = f[i - 1, j - 1];
    f[i, j] = If[s[[i]] == t[[j]],
      p,
      Min[p, f[i, j - 1], f[i - 1, j]] + 1
      ]
    ]
   ];
  f[m, n]
  )
# <> "" & /@
 Union@Cases[Join @@ Array[{"0", "1"}~Tuples~# &, 2 k + 1, l@s - k],
   x_ /; x~e~s == k]

APL, 109 103 101
Assuming s and k are defined
~⍨/{{∪⊃,/{⍵≡'':⍕¨0 1⋄(,/⍕¨↑(⍎¨⍵)∘≠¨↓∘.=⍨x),(/∘⍵¨↓∘.≠⍨x),(,⍨-0,x)⌽¨,'01'∘.,⌽∘⍵¨0,x←⍳⍴⍵}¨⍵}⍣⍵⊂s}¨0,⍳k

Explantion
The program consists of 3 nested functions.
The inner function {⍵≡'':⍕¨0 1⋄(,/⍕¨↑(⍎¨⍵)∘≠¨↓∘.=⍨x),(/∘⍵¨↓∘.≠⍨x),(,⍨-0,x)⌽¨,'01'∘.,⌽∘⍵¨0,x←⍳⍴⍵}returns all string that is distance 1 from the argument
(,⍨-0,x)⌽¨,'01'∘.,⌽∘⍵¨0,x←⍳⍴⍵ calculate insertions:
⍴⍵ length of the argument
⍳ generate array from 1 to that number
x← assign to variable x
0, concatenate 0 to the start of the array
⌽∘⍵¨ and for each of the number in the array, rotate the argument by that amount, generating an array of strings (rotate is defined as taking characters from the start of the string and appending to the back)
'01'∘., generate a matrix whose first row are the strings with 0 concatenated to the start and the second row are the strings with 1 concatenated to the start
, unravel the matrix to give a simple array of its elements
(,⍨-0,x) give the negatives of the array constructed by concatenating 0 to the start of x, and then concatenate that with another copy of it
⌽¨ finally, rotate the strings back by using the negative numbers
(/∘⍵¨↓∘.≠⍨x) calculates deletions:
∘.≠⍨x generate a square matrix consisting of 0's on the diagonal and 1's elsewhere, whose side is same length as x
↓ split the matrix rows to create a nested array
/∘⍵¨ for each of those arrays, replicate the characters of the argument according the the array (in the case where the array only contains 0's and 1's, it means where there is a 1 in the array, keep the character in the corresponding index and where there is a 0, discard the corresponding character)
(,/⍕¨↑(⍎¨⍵)∘≠¨↓∘.=⍨x) calculates substitutions:
∘.=⍨x generate a square matrix consisting of 1's on the diagonal and 0's elsewhere, whose side is same length as x
↓ split the matrix rows to create a nested array
(⍎¨⍵)∘≠¨ generate an array by converting the argument into a numerical array of its digits, then XOR it with each of the arrays from the split
↑ "mix" the nested array to create a matrix (reverse of split)
⍕¨ for each element of the matrix (which is either 1 or 0), convert to string
,/ for each row of the matrix, concatenate the elements
⍵≡'':⍕¨0 1 is a special case for the empty string (the substitution part will throw an error on empty string)
⍵≡'': if the argument is the empty string...
⍕¨0 1 return this (an array of the strings '0' and '1')
The middle function {∪⊃,/{...}¨⍵} takes an array of strings and return an array of all strings that is distance 1 from any of them
{...}¨⍵ for each of the strings in the argument, use the inner function to get all strings distance 1 for it
,/ concatenate all of the returned arrays
⊃ as the result is "wrapped" in a scalar, "unwrap" it
∪ remove duplicates
The outer function {{...}⍣⍵⊂s}, given a number, calculates all string that is potentially that distance from s
{...}⍣⍵ repeat the middle function ⍵ times (⍵ is the argument)
⊂s "wrap" s and call the function with that as the argument
The remaining part ~⍨/{...}¨0,⍳k
0,⍳k generate array from 0 to k
{...}¨ for each of those numbers, call the outer function with it
~⍨/ remove the strings found in distances 0,1,2,...,k-1 from the strings found in distance k. This is necessary because the "distance 1" function is stateless - it does not consider stuff like substituting the same character twice or inserting and deleting the same character.

For those of us not used to APL, can you explain a) how to run your code in practice on Linux and b) why you get to use non-ASCII characters?

@Lembik Dyalog used to be free for non-commercial use but I just checked and it is no longer free... Then the best I can do is to provide results/screenshots for the input you want.

@Lembik 2) because that's how APL works?

I tried this out using http://www.gnu.org/software/apl/ but with no luck. I just ran "apl" and then tried to copy and paste your code. I get "SYNTAX ERROR".

I think http://ngn.github.io/apl/web/index.html would work. Could you explain how to set k to 1 and s to 1111011010 so I can test your code?

@Lembik: Prepend s←"1111011010" and k←2 as two separate lines.