text:
Voice recognition: "Yes" or "No"?
Task
Implement a program in minimum bytes of source or binary code that does voice recognition of a voice sample (me saying "yes", "yeah" or "no" in voice or in whisper, plainly or quirkily) based on training samples with maximum accuracy.
The program should read train/yes0.wav, train/no0.wav, train/yes1.wav and so on (there are 400 yeses and 400 noes in training dataset), then start reading inputs/0.wav, inputs/1.wav until it fails to find the file, analysing it and outputting "yes" or "no" (or other word for intermediate answer).
If you want, you may pre-train the program instead of reading train/, but the resulting data table counts towards the score (and beware of overfitting to training samples - they don't overlap with examination ones). Better to include the program used to produce the data table as an addendum in this case.
All sample files are little endian 16-bit stereo WAV files, just from laptop mic, without filtering/noise reduction.
Limits
Forbidden features:

Using network;
Trying to reach the answers file inputs/key;
Subverting the runner program that calculates accuracy;
Using existing recognition libraries. Linking to FFT implementation not allowed: only external math functions taking constant amount of information (like sin or atan2) are allowed; If you want FFT, just add it's implementation to your program source code (it can be multilingual if needed).

Resource limits:

The program should not take more than 30 minutes of CPU time on my i5 laptop. If it takes more, only output produced in the first 30 minutes are counted and eveything else is assumed a half-match;
Memory limit: 1GB (including any temporary files);

Tools
The tools/runner program automatically runs your solution and calculates the accuracy.
$ tools/runner solutions/example train train/key
Accuracy: 548 ‰

It can examine the program using training data or using actual exam data. I'm going to try submitted answers on examination dataset and publish results (accuracy percentage) until I make the dataset public.
Scoring
There are 5 classes of solution depending on accuracy:

All samples guessed correctly: Class 0;
Accuracy 950-999: Class 1;
Accuracy 835-950: Class 2;
Accuracy 720-834: Class 3;
Accuracy 615-719: Class 4;

Inside each class, the score is number of bytes the solution takes.
Accepted answer: smallest solution in the best nonempty class.
Links

Github project with tools: https://github.com/vi/codegolf-jein
Training dataset: http://vi-server.org/pub/codegolf-jein-train.tar.xz
Examination dataset is kept private so far, there are checksums (HMAC) available in the Github repository.

All samples should be considered CC-0 (Public Domain), scripts and programs should be considered MIT.
Example solution
It provides very poor quality of recognition, just shows how to read files and output answers
#define _BSD_SOURCE
#include <stdio.h>
#include <assert.h>
#include <endian.h>

#define Nvols 30

#define BASS_WINDOW 60
#define MID_WINDOW 4

struct training_info {
    double bass_volumes[Nvols];
    double mid_volumes[Nvols];
    double treble_volumes[Nvols];
    int n;
};

struct training_info yes;
struct training_info no;

static int __attribute__((const)) mod(int n, int d) {
    int m = n % d;
    if (m < 0) m+=d;
    return m;
}

// harccoded to 2 channel s16le
int get_file_info(const char* name, struct training_info *inf) {
    FILE* in = fopen(name, "rb");

    if (!in) return -1;

    setvbuf(in, NULL, _IOFBF, 65536);

    inf->n = 1;

    fseek(in, 0, SEEK_END);
    long filesize = ftell(in);
    fseek(in, 128, SEEK_SET);
    filesize -= 128; // exclude header and some initial samples

    int nsamples = filesize / 4;

    double bass_a=0, mid_a=0;
    const int HISTSIZE  = 101;
    double xhistory[HISTSIZE];
    int histpointer=0;
    int histsize = 0;

    //FILE* out = fopen("debug.raw", "wb");

    int i;
    for (i=0; i<Nvols; ++i) {
        int j;

        double total_vol = 0;
        double bass_vol = 0;
        double mid_vol = 0;
        double treble_vol = 0;

        for (j=0; j<nsamples / Nvols; ++j) {
            signed short int l, r; // a sample
            if(fread(&l, 2, 1, in)!=1) break;
            if(fread(&r, 2, 1, in)!=1) break;
            double x = 1/65536.0 * ( le16toh(l) + le16toh(r) );

            bass_a += x;
            mid_a  += x;

            if (histsize == HISTSIZE-1) bass_a   -= xhistory[mod(histpointer-BASS_WINDOW,HISTSIZE)];
            if (histsize == HISTSIZE-1) mid_a    -= xhistory[mod(histpointer-MID_WINDOW ,HISTSIZE)];

            double bass = bass_a / BASS_WINDOW;
            double mid = mid_a / MID_WINDOW - bass;
            double treble = x - mid_a/MID_WINDOW;

            xhistory[histpointer++] = x;
            if(histpointer>=HISTSIZE) histpointer=0;
            if(histsize < HISTSIZE-1) ++histsize;

            total_vol  += bass*bass + mid*mid + treble*treble;
            bass_vol   += bass*bass;
            mid_vol    += mid*mid;
            treble_vol += treble*treble;

            /*
            signed short int y;
            y = 65536 * bass;

            y = htole16(y);
            fwrite(&y, 2, 1, out);
            fwrite(&y, 2, 1, out);
            */
        }

        inf->bass_volumes[i] = bass_vol / total_vol;
        inf->mid_volumes[i] = mid_vol / total_vol;
        inf->treble_volumes[i] = treble_vol / total_vol;

        //fprintf(stderr, "%lf %lf %lf    %s\n", inf->bass_volumes[i], inf->mid_volumes[i], inf->treble_volumes[i], name);
    }
    fclose(in);

    return 0;
}

static void zerotrdata(struct training_info *inf) {
    int i;
    inf->n = 0;
    for (i=0; i<Nvols; ++i) {
        inf->bass_volumes[i] = 0;
        inf->mid_volumes[i] = 0;
        inf->treble_volumes[i] = 0;
    }
}

static void train1(const char* prefix, struct training_info *inf)
{
    char buf[50];

    int i;

    for(i=0;; ++i) {
        sprintf(buf, "%s%d.wav", prefix, i);
        struct training_info ti;
        if(get_file_info(buf, &ti)) break;

        ++inf->n;

        int j;
        for (j=0; j<Nvols; ++j) {
            inf->bass_volumes[j]   += ti.bass_volumes[j];
            inf->mid_volumes[j]    += ti.mid_volumes[j];
            inf->treble_volumes[j] += ti.treble_volumes[j];
        }
    }

    int j;
    for (j=0; j<Nvols; ++j) {
        inf->bass_volumes[j]   /= inf->n;
        inf->mid_volumes[j]    /= inf->n;
        inf->treble_volumes[j] /= inf->n;
    }
}

static void print_part(struct training_info *inf, FILE* f) {
    fprintf(f, "%d\n", inf->n);
    int j;
    for (j=0; j<Nvols; ++j) {
        fprintf(f, "%lf %lf %lf\n", inf->bass_volumes[j], inf->mid_volumes[j], inf->treble_volumes[j]);
    }
}

static void train() {
    zerotrdata(&yes);
    zerotrdata(&no);

    fprintf(stderr, "Training...\n");

    train1("train/yes", &yes);
    train1("train/no", &no);

    fprintf(stderr, "Training completed.\n");

    //print_part(&yes, stderr);
    //print_part(&no, stderr);

    int j;
    for (j=0; j<Nvols; ++j) {
        if (yes.bass_volumes[j]   > no.bass_volumes[j]) {   yes.bass_volumes[j] = 1;   no.bass_volumes[j] = 0; }
        if (yes.mid_volumes[j]    > no.mid_volumes[j]) {    yes.mid_volumes[j] = 1;    no.mid_volumes[j] = 0; }
        if (yes.treble_volumes[j] > no.treble_volumes[j]) { yes.treble_volumes[j] = 1; no.treble_volumes[j] = 0; }
    }
}

double delta(struct training_info *t1, struct training_info *t2) {
    int j;
    double d = 0;
    for (j=0; j<Nvols; ++j) {
        double rb = t1->bass_volumes[j] - t2->bass_volumes[j];
        double rm = t1->mid_volumes[j] - t2->mid_volumes[j];
        double rt = t1->treble_volumes[j] - t2->treble_volumes[j];
        d += rb*rb + rm*rm + rt*rt;
    }
    return d;
}

int main(int argc, char* argv[])
{
    (void)argc; (void)argv;

    train();

    int i;

    int yes_count = 0;
    int no_count = 0;

    for (i=0;; ++i) {
        char buf[60];
        sprintf(buf, "inputs/%d.wav", i);

        struct training_info ti;

        if(get_file_info(buf, &ti)) break;

        double dyes = delta(&yes, &ti);
        double dno = delta(&no, &ti);

        //printf("%lf %lf %s ", dyes, dno, buf);

        if (dyes > dno) {
            printf("no\n");
            ++no_count;
        } else  {
            printf("yes\n");
            ++yes_count;
        }
    }

    fprintf(stderr, "yeses: %d noes: %d\n", yes_count, no_count);

}

Are the test files will be taken out of the training files, or separate samples altogether?

no fft libraries? Why?

Can we use WAV libraries (such as Python's wave)?

@mnbvmar, Yes.

What about built-in FFT functions? What exactly counts as external? Also, what counts as a math library function? Are we allowed to use sum, or we need to use foldl (+) 0 (foldl not being math-specific, and + not being variadic)?

@JanDvorak, Separate samples, but from the same larger dataset. Samples were shuffled, first 400 of each kind were marked as training, the rest are examination.

Why is it a half-match if your program ran out of time? Why not a complete miss?

@Claudiu just assume the program starts guessing rapid-fire in desperation

@JanDvorak, You can insert some FFT implementation into your code and optionally golf it down. If allow FFT, then somebody may ask to allow some other transformation, and it would be tricky to put a line between "Just FFT" and "Ready-made recognition library". So the rule "external math libraries should only provide constant input size functions".

@JanDvorak, fold is not a math funciton. (+) takes constant-sized input, so is allowed.

still... you're effectively forbidding sum. I guess that's not your intention?

What's the exact definition of math functions? Those that are specialised to operate on numbers? What about a generic "sum" function that uses addition for numbers, but concatenation for strings? Is this sum now allowed?

You can easily implement sum using other functions. "sum" allowed => "sum with coefficients" allowed => "sub with coefficients + filtering at the end" allowed => ... => neuron implementation allowed => ...

@JanDvorak, Yes, functions for processing numbers, unrelated to input/output.

What about J's vector operations? Are they disallowed?

@JanDvorak, (Looking up what is J's vector... Can't find it easily). If it's a speedy processing of a fixed block of data (i.e. 32 floats array), it looks more or less OK.

Operations in J, K and other APL derivatives have an implicit rank (dimension they operate on). If you apply them to a data structure with a larger dimension, they perform an implicit iteration. + can mean (+), zipWith (+), zipWith $ zipWith (+)...

@JanDvorak, Consider that this "implicit iteration" is not a part of mathematical function, just a special zero-byte-consuming part of your program. The inner function being iterated takes const-sized input.

zipWith is not a mathematical function, it's list-processing function. And (+) is OK. If there were a library cozysum = zipWith (+), then this library whould be forbidden (because of both zipWith and (+) is outsourced to the library).

I guess that stuff like J's +/ (plus-over = fold with addition = sum) and *\ (times-table = table of multiplications)  are fine, then? / and \ are separate entities (adverbs = functions on functions).

@JanDvorak, "/ and \  are separate entities" -> So it's OK. In general, the rule is to forbid big simplification like ready-made FFT, ready-made OCR, ready-made noise reduction, not some "elementary " language iteration features. Just a sum probably would not be that noticable (and such minor "violations" are probably easy fixable if needed).

How does a polymorphic sum (fold an arbitrary list with the + operator, whatever it does) fare?

This polymorphic sum can be viewed as a fold by other name (hence a control function, not math one), unless the overridden + can take an array of numbers or something like that. Even if + processes arrays, if implementation of such + is in your code then it's OK. If not, it can be not OK. You can post both "common sense" and "100% compliant" solutions if you want. A real problem is when they diverge too much.

@JanDvorak, BTW how do I run an APL program on my Linux Debian? It's not feasible to use some online runner because of there is a big blob of input data.

I've never used APL, but I've used J. IIRC, there is a J runtime for linux.

Can you train the program prior to submitting, then remove all training code?

@NicRobertson, Yes. But it's better include the training part as an addendum.

Does all training set/examination set have the same sample rate?
ie.
2 channels,
16 bits per sample ,
44.1 khz sample rate.

@NicRobertson, All audio files (training and examination samples) have the same format (the one you mentioned), the one of arecord -f cd > file.wav. Training samples are just random subset taken off from examination samples.

C++11 (gcc; 1639 1625 1635 bytes, Class 1, score=983, 960)
Let's get it started. It's probably the longest code I've ever shortened...
#include <bits/stdc++.h>
#define $ complex<double>
#define C vector<$>
#define I int
#define D double
#define P pair<D,I>
#define Q pair<D,D>
#define E vector<D>
#define V vector<P>
#define W vector<Q>
#define S char*
#define Z(x)if(fread(&x,2,1,y)!=1)break;
#define B push_back
#define F(i,f,t)for(I i=f;i<t;i++)
#define _ return
#define J first
#define L second
const I K=75,O=16384;using namespace std;C R(C&i,I s,I o=0,I d=1){if(!s)_ C(1,i[o]);C l=R(i,s/2,o,d*2),h=R(i,s/2,o+d,d*2);C r(s*2);$ b=exp($(0,-M_PI/s)),f=1;F(k,0,s){r[k]=l[k]+f*h[k];r[k+s]=l[k]-f*h[k];f*=b;}_ r;}C T(C&i){_ R(i,i.size()/2);}char b[O];E U(S m){FILE*y;if(!(y=fopen(m,"r")))_ E();setvbuf(y,b,0,O);fseek(y,0,2);I z=ftell(y)/4-32;fseek(y,128,0);C p;F(i,0,z){short l,r;Z(l);Z(r);if(i&1)p.B($(0.5/O*le16toh(l),0));}p.resize(O);E h(O),n(O);p=T(p);F(j,0,O)h[j]=norm(p[j])/O;F(i,1,O-1)n[i]=(h[i-1]+h[i+1]+h[i]*8)/10;fclose(y);_ n;}W G(E&d){V p;F(i,3,O/2-3)if(d[i]==*max_element(d.begin()+i-3,d.begin()+i+4))p.B({d[i],i});sort(p.begin(),p.end(),greater<P>());W r;F(i,3,K+3)r.B({D(p[i].L)/O*22050,log(p[i].J)+10});D s=0;F(i,0,K)s+=r[i].L;F(i,0,K)r[i].L/=s;_ r;}char m[O];I X(S p,W&r){E t(O),h(t);I f=0;while(1){sprintf(m,"%s%d.wav",p,f++);h=U(m);if(!h.size())break;F(j,0,O)t[j]+=h[j];}F(j,0,O)t[j]/=f;r=G(t);}D Y(W&a,W&b){D r=0;F(i,0,K){D d=b[i].L;F(j,0,K)if(abs((b[i].J-a[j].J)/b[i].J)<0.015)d=min(d,abs(b[i].L-a[j].L));r+=d;}_ r;}I H(S p,W&y,W&n){I f=0;while(1){sprintf(m,"%s%d.wav",p,f++);E h=U(m);if(!h.size())break;W p=G(h);D q=Y(p,y),r=Y(p,n);printf(abs(q-r)<=0.01?"?\n":q<r?"yes\n":"no\n");}}I main(){W y,n;X("train/yes",y);X("train/no",n);H("inputs/",y,n);}

"Ungolfed" (although it's hard to call an over 1.5K source code golfed):
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <endian.h>
#include <functional>

using namespace std;

typedef complex<double> CD;

vector<CD> run_fft(vector<CD>& input, int offset, int size, int dist){
    if(size == 1){
        return vector<CD>(1, input[offset]);
    }
    vector<CD> partLow = run_fft(input, offset, size/2, dist*2),
               partHi  = run_fft(input, offset+dist, size/2, dist*2);

    vector<CD> result(size);
    CD factorBase = exp(CD(0, (inv?2:-2)*M_PI/size)), factor = 1;

    for(int k = 0; k < size/2; k++){
        result[k] = partLow[k] + factor*partHi[k];
        result[k+size/2] = partLow[k] - factor*partHi[k];
        factor *= factorBase;
    }
    return result;
}

vector<CD> fft(vector<CD>& input){
    int N = input.size();
    return run_fft(input, 0, N, 1);
}

const int MAX_BUF = 65536;
const int PWR_TWO = 16384;
const int NUM_CHECK = 75;
int sampling;

char buf[MAX_BUF];
vector<double> read_data(char* filenam){
    FILE* fp = fopen(filenam, "r");
    if(!fp)
        return vector<double>();
    setvbuf(fp, buf, _IOFBF, MAX_BUF);

    fseek(fp, 0, SEEK_END);
    int filesiz = ftell(fp);
    fseek(fp, 128, SEEK_SET);
    filesiz -= 128;

    int insamp = filesiz / 4;
    int freqsamp = 2,
        act_mod = 0;
    sampling = 44100 / freqsamp;
    int inputSize;

    vector<CD> input;

    for(int i = 0; i < insamp; i++){
        signed short int l, r;
        if(fread(&l, 2, 1, fp) != 1) break;
        if(fread(&r, 2, 1, fp) != 1) break;

        double act = 1/32768.0 * (le16toh(l));

        if((++act_mod) == freqsamp){
            inputSize++;
            input.push_back(CD(act,0));
            act_mod = 0;
        }
    }
    inputSize = input.size();

    //printf("%s\n", filenam);
    int numParts = (inputSize+PWR_TWO-1)/PWR_TWO;
    double partDelta = (double)inputSize / numParts, actDelta = 0;
    vector<CD> ndata(PWR_TWO);
    for(int i = 0; i < numParts; i++){
        vector<CD> partInput(PWR_TWO);
        int from = floor(actDelta),
            to = floor(actDelta)+PWR_TWO;

        for(int j = from; j < to; j++)
            partInput[j-from] = input[j];

        vector<CD> partData = fft(partInput);
        for(int j = 0; j < PWR_TWO; j++)
            ndata[j] += partData[j]*(1.0/numParts);
    }

    vector<double> height(PWR_TWO);
    for(int i = 0; i < PWR_TWO; i++)
        height[i] = norm(ndata[i])/PWR_TWO;

    vector<double> nheight(height);
    nheight[0] = (height[0]*0.8 + height[1]*0.1)/0.9;
    nheight[PWR_TWO-1] = (height[PWR_TWO]*0.8 + height[PWR_TWO-1]*0.1)/0.9;
    for(int i = 1; i < PWR_TWO-1; i++)
        nheight[i] = height[i-1]*0.1 + height[i]*0.8 + height[i+1]*0.1;

    fclose(fp);

    return nheight;
}

vector< pair<double,double> > get_highest_peaks(vector<double>& freqData){
    vector< pair<double,int> > peaks;

    for(int i = 3; i < PWR_TWO/2-3; i++){
        if(freqData[i] == *max_element(freqData.begin()+i-3, freqData.begin()+i+4)){
            peaks.push_back(make_pair(freqData[i], i));
        }
    }

    sort(peaks.begin(), peaks.end(), greater< pair<double,int> >());

    vector< pair<double,double> > res;
    for(int i = 3; i < NUM_CHECK+3; i++){
        res.push_back(make_pair((double)(peaks[i].second)/PWR_TWO*sampling, log(peaks[i].first)+10));
    }

    double sum_res = 0;
    for(int i = 0; i < NUM_CHECK; i++)
        sum_res += res[i].second;
    for(int i = 0; i < NUM_CHECK; i++)
        res[i].second /= sum_res;

    /*for(int i = 0; i < NUM_CHECK; i++)
        printf("%12lf %12lf\n", res[i].first, res[i].second);
    printf("\n");*/

    return res;
}

void train(char* dir, const char* type, vector< pair<double,double> >& res){
    vector<double> result(PWR_TWO), height(PWR_TWO);

    int numFile = 0;
    while(true){
        char filenam[256];
        snprintf(filenam, 255, "%s/%s%d.wav", dir, type, numFile);
        height = read_data(filenam);

        if(height.size() == 0)
            break;

        for(int j = 0; j < PWR_TWO; j++)
            result[j] += height[j];

        numFile++;
    }
    fprintf(stderr, "trained %s on %d files\n", type, numFile);

    for(int j = 0; j < PWR_TWO; j++)
        result[j] /= numFile;

    res = get_highest_peaks(result);
}

double dist_ab(vector< pair<double,double> >& A, vector< pair<double,double> >& B){
    double result = 0;
    for(int i = 0; i < NUM_CHECK; i++){
        double add = B[i].second;

        for(int j = 0; j < NUM_CHECK; j++){
            double dist = (B[i].first-A[j].first)/B[i].first;
            if(abs(dist) < 0.015)
                add = min(add, abs(B[i].second - A[j].second));
        }
        result += add;
    }
    return result;
}

void trial(char* dir, const char* pref, vector< pair<double,double> >& yes,
                                        vector< pair<double,double> >& no){
    int numFile = 0;
    int numYes = 0, numDunno = 0, numNo = 0;
    while(true){
        char filenam[256];
        snprintf(filenam, 255, "%s/%s%d.wav", dir, pref, numFile);

        vector<double> height = read_data(filenam);
        if(height.size() == 0)
            break;

        vector< pair<double,double> > peaks = get_highest_peaks(height);

        double distYes = dist_ab(peaks, yes),
               distNo = dist_ab(peaks, no);

        if(abs(distYes-distNo) <= 0.01){
            printf("dunno\n");
            numDunno++;
        } else if(distYes < distNo){
            printf("yes\n");
            numYes++;
        } else {
            printf("no\n");
            numNo++;
        }
        //printf(" (%lf %lf)\n", distYes, distNo);

        numFile++;
    }
}

int main(int argc, char** argv){
    vector< pair<double,double> > yes, no;

    train("train", "yes", yes);
    train("train", "no", no);

    trial("inputs", "", yes, no);
}

I have no freaking idea if it will work correctly on real data set (I bet it won't, but I must have a try).
How it works:

Take N=214 samples from left channel, each in equal time span. Normalize them so that min value=0 and max value=1.
Process them using FFT. Now we switched from time domain to frequency domain. We might say that 0th cell of resulting array is 0Hz equivalent and 213-1st cell is 22050Hz equivalent (that is because I took every other sample from L channel, so my sampling is 22050Hz instead of WAV's frequency, 44100Hz).
Find the mean of all such signals - call it "mean frequency distribution". Find K highest peaks in such distribution (here K=75), omitting first few (probably noise) and find their strength. I used log(mean distribution)+10 and then normalized so that the sum of the biggest peaks was 1.
We have two "peak distributions" - one for Yes, second for No. If we have a WAV to test, we transform it in the same way as before (steps 1, 2, 3) and get distribution D. Then we have to check which distribution (Y/N) D is more similar to. I used the following approach: for each peak in Y/N, try to find it in D. If we find it (approximately), the score for this peak is absolute difference between Y/N's and D's strength; in opposite case, it's Y/N's strength (we assume it's always positive). Better (smaller) score wins. If the results are very close (I used 0.01 absolute difference), output dunno.

As I said, probably on final tests it will be classified as "even worse than random". Of course, I hope it won't :D
Edit: fixed bug (forgot to close the files).

You are in luck if it performs worse than random. You literally only need to change one byte - distYes > distNo, and it will do better than random. Or to put it another way, it would be quite astonishing if you could guess the outcome of a coin flip incorrectly 100 times in a row! And it's not unheard of that simple algorithms out-perform than more complex ones, so +1 and I wish you good luck.

Testing... It terminates prematurely due to EMFILE (Too many open files)... Trying to fix...

Bumped maximum open file counter, now it works. Results: training dataset: Accuracy: 983 ‰; Time: 0m27.570s;; examination dataset: Accuracy: 960 ‰; Time: 0m32.957s. Good job.

Okay, I fixed this. 10 bytes more. :)

Incredible use of #defines :P

Wouldn't typedef be better than #define, at least for some types?


text:
Extraction of Bits
Your task is to devise a programme that extracts the bits, in order, represented by the first argument based on the set bits represented by the second argument (the mask).
Formal Definition:

Let the first argument x represent the binary string
S=(xn)(xn-1)...(x1) with n>=0 and x1 being the least
significant digit and xn = 1.
Let the second argument y represent the binary string T=(ym)(ym-1)...(y1) with m>=0 and y1 being the least significant digit and ym = 1.
Let the result represent 0 if x represents 0 or y represents 0.
Let the number of 1 digits in T be p. Let {di}, i in [1, p] be the set of binary strings of the form (dim)(di(m-1))...(d1) defined by (for all i, (for all k, |{dik such that dik = 1}| = 1)) and (if 1 <= i < j <= p then 0 < di < dj) and (dp | dp-1 | ... | d1 = T). In other words, {di} is the ordered set of strings with a single 1 digit that makes up the string T when | is applied.
Let the result of the programme represent the following binary string:
((dp & S) << (p - 1))| ... | ((d2 & S) << 1) | (d1 & S)

Examples:

1111, 110 -> 11
1010, 110 -> 01
1010, 10110 -> 01
1101010111, 11111000 -> 01010

Input and Output:

The two arguments may be taken in any way
The two arguments need not be binary strings. They can also be integers which represent binary strings.
Answers which do not take input representing binary strings of arbitrary length are permitted.

Winning:
Shortest code wins.
Clarifications:

If your output gives a bit string, order of bits is not important. Simply state the order in your answer. As stated before, the output of your programme need only represent the bits required.

What's your objective winning criterion, i.e. how do you determine who wins? Shortest code, or something else?

I assumed that shortest code was the default criterion. I will add this to the post.

Is there a maximum number of bits in each binary string? For example, can we assume that both inputs will be less than 100 characters long?

@Doorknob "Answers which do not take input representing binary strings of arbitrary length are permitted." ?

As per the formal definition, there is no maximum input size. As per the third criterion of the Input and Output section, reasonable limits on input size may be imposed by the programmer, such as using only 32bit or 64bit input.

Your clarification allows reversed output. I assume it also allows reversed input?

Yes, if the input involves bit strings.

Would you, could you, change the subscripting to use ? It won't work in backticks, but I think it would improve readability considerably.

In the first step of "Formal Definition:", I think n>=0 should be n>0 to disallow (x_0)(x_1).

Regarding subscripts: I would rather not take what is in backticks outside of backticks. On n>=: I don't see what you mean. Could you please explain?

You could use something like x0; I'll edit the post when I get home.

And the reward for the first sensible edit description in this question goes to... @MartinBüttner (thank you!)

This really left itself open to exploitation of standard loopholes. That's why I downvoted.

Let's just say that there was absolutely nothing prohibiting people from using specializes functions. Also, it was poorly defined enough that I lost interest rather quickly. It isn't a very clear specification (the ES6 specification is easier than this, and it's a full WIP language specification, with a lot of new features including module support, which is really complex).

related on SO: Mask and aggregate bits

CJam, 9 bytes
eaz{)~*}%

This reads the bit strings (LSB first) as command line arguments and prints the result (also LSB first).
To try this code in the CJam interpreter, change ea to qS% and separate the strings with a space.
Example run
$ cjam <(echo 'eaz{)~*}%') 1110101111 00011111; echo
01011

How it works
ea         " Read both command line arguments and collects them in an array. ";
  z        " Interleave the characters of both strings.                      ";
   {   }%  " For each pair of characters:                                    ";
    )~     " Pop the last character and interpret it as an integer.          ";
      *    " Repeat the remaining strings that many times.                   ";

If the mask character is 0, the string consisting of the corresponding character is repeated zero times.
If the mask character or the corresponding character do not exist, popping a character will result in an empty string to be repeated.

In either case, the result will be an empty string.

I'm accepting this as it's the shortest, and doesn't use any loopholes. Sorry it took half a decade.

Edit: APL, 1 character
/, the compression operator (Documentation).
Example of use:
0 0 1 1 1 1 1 0 0 0/1 1 0 1 0 1 0 1 1 1
0 1 0 1 0

Try it yourself at http://ngn.github.io/apl/web/index.html
The mask is left, and the input bitstring is right. Disclaimer: I'm not an expert in APL and have never used it; I only submitted this to substitute the disqualification of my machine-code solution below. I admit that a limitation of the code above is that the left and right bitstrings must be of equal length in APL, and lack the APL skills to fix this.
Rejected as loophole:
x86-64 Machine Code (BMI2, Haswell+), 5 bytes
c4 e2 f2 f5 d0 is the hex representation of the raw bytes of the program as they would appear in an executable x86-64 binary program.
This represents the single instruction pext %rax, %rcx, %rdx, which accepts S in rax, T in rcx and stores the result in rdx. Max 64 bits. Runs in 3 clock cycles on Haswell, has throughput of 1 per clock cycle.
xxx@xxx:~/Documents/SO> cat > bmi2.s
.text
pext %rax, %rcx, %rdx
xxx@xxx:~/Documents/SO> gcc bmi2.s -c -o bmi2.o
xxx@xxx:~/Documents/SO> objdump -d bmi2.o

bmi2.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <.text>:

0:   c4 e2 f2 f5 d0          pext   %rax,%rcx,%rdx

Of course, requires a pretty modern assembler.
The documentation for PEXT is much clearer than OP's description, so here it is:

c4 e2 f2 f5 d0 is hex, not binary...

@immibis The CPU has to execute the raw bytes in order for them to do what they must do. When I want to say "take these values and consider them as raw bytes" I generally use "binary", in the sense of "raw binary data". Is there a better way to convey that meaning? I can't paste the actual bytes c4 e2 f2 f5 d0, so I've given their hex expression, but they must be actually "binary" when executed.

@immibis I've changed the wording a bit, better?

This is a standard loophole. I've updated it to not be as Mathematica-specific, but it equally applies here.

@impinball How can I invite you to chat? I'd like to discuss your characterization of my solution as a mere loophole.

I forgot to link it...it's http://meta.codegolf.stackexchange.com/a/1078/14668 (the answer).

@IwillnotexistIdonotexist Chat room created: http://chat.stackexchange.com/rooms/16851/discussion-between-iwillnotexist-idonotexist-and-impinball

If that single opcode is a loophole (which it is), then the / solution is even less acceptable. Both because it's a loophole and because it doesn't follow the spec. Sorry!

@impinball downvoted the loophole and it's now just below the threshold. If a one-op solution exists, it's now officially a fault of the question, not of the answer.

@JanDvorak Yeah... I discussed it in chat already. I refrained from going after the second because it would unnecessarily escalate the situation. It also clearly counts, but you're right. It's a fault of the question, not the answer.

If we're allowed APL's / on its own, then surely we're allowed J's # on its own? :)

Haskell, 68 characters
f[c:d,'0':b]=f[d,b];f[c:d,_:b]=c:f[d,b];f _="";main=interact$f.words

Prints nothing if the input isn't exactly two words.
The first argument can contain any characters. So can the filter; only 0 is treated as "not select".
If arguments are of different length, they are taken left-aligned (LSB first; explicitly allowed since revision #4).
Haskell function, 48 characters
f(c:d)('0':b)=f d b;f(c:d)(_:b)=c:f d b;f _ _=""

Subtract two more characters if "function of two integer arrays" is an acceptable signature

J, 1 character
#, the tally operator (Documentation).
Example of use:
0 0 1 1 1 1 1 0 0 0#1 1 0 1 0 1 0 1 1 1
0 1 0 1 0

This solution does not cater for the case when the length of the mask is less than that of the string. Given that the above might be seen as a loophole, we have the following solution.
J, 11 characters
[#~],0$~-&#

This solution is like the original #, but also caters for the case when the length of the mask is less than that of the string. Note here that the mask is the right argument, and not the left argument as in the first solution.
x ([ #~ ] , 0 $~ -&#) y
   x #~ (y , (0 $~ (x -&# y)))
   x #~ (y , (0 $~ ((# x) - (# y))))
   x #~ (y , (((# x) - (# y)) $ 0))
   x #~ (y , 0 0 ... 0 0)
   x #~ y 0 0 ... 0 0
   y 0 0 ... 0 # x

[ and ] choose x and y respectively.
x (u&v) y -> (v x) u (v y).
(x -&# y) -> (# x) - (# y).
# x -> length of x.
x v~ y -> y v x.
n $ 0 -> list of n 0s.
(0 $~ (x -&# y)) -> m 0s, where m is the difference between the length of the string and the length of the mask.
(y , 0 0 ... 0 0) -> the list y 0 0 ... 0 0 such that its length is equal to that of the string.
a # b -> the elements of b chosen by the binary mask a.

Even though this solution is shorter than my other solution of 16 characters, I think it still makes unfair use of #. In any case, I think it's still interesting.

+1. The question somewhat begs for the use of compression/reduction/fold/inject operators, but I find it interesting how you pad the mask with 0s in the APL-derived languages.

@IwillnotexistIdonotexist The fun thing is that the # operator can actually do many more things, like representing a number in an arbitrary base.

Haskell, 33 characters
((map snd.filter((>0).fst)).).zip

Usage
(((map snd.filter((>0).fst)).).zip) [1, 0, 1, 0] [1, 0, 0, 1]
[1, 0]

(((map snd.filter((>0).fst)).).zip) [1, 1] [1, 1, 0, 1]
[1, 1]

Golfscript, 54 51 characters
'0':x;{.,64\-x*\+}:b~:m;'X':x;b{m(\:m;48={;}*}%'X'-

Only works for binary strings of length 64 or less.
Explanation:
'0':x;       store '0' in the x variable (which will be used in the following)
{.,64\-x*\+} block that pads strings to a length of 64 with the character stored in x
:b~          store the block in b and execute, second argument (y) is now padded with '0's
:m;          store second argument as mask (m)
'X':x;b      pad the first argument with 'X's (will be removed later)
{...}%       for each character in the first argument (x), ...
  m(\:m;     grab and delete the first character of m (mask)
  48={...}*  if this character is equal to 48 (0 in ASCII)...
    ;        remove the digit. Hence, this if statement keeps a digit only if the mask is 1.
'X'-         finally, remove the 'X's added in step 5

49={}{;}if -> 48={;}*

@JanDvorak Thanks; that's pretty interesting. Execute the block n times, where n is a boolean (0 or 1), meaning that it will only execute the block if the boolean is true. Great trick!

Taking the input LSB-first is now allowed. Can it shorten your code?

J, 16 Characters:
(#=@i.@#)@],@:#[

Usage:
1 0 1 0 1 1 ((#=@i.@#)@],@:#[) 0 1 1 1 0 0 -> 0 1 0

Explanation:
First argument is left, second argument is right (mask).
(#=@i.@#)@],@:#[ -> (# =@i.@#)@] ,@:# [

Take right argument, produce identity matrix of size length of right argument.
Use set bits of right argument to choose rows of produced identity matrix.
Use chosen rows of identity matrix to choose digits of left argument.
Concatenate the digits chosen from left argument.

J, 13 Characters
According to the rules, the form of output is not important. Therefore, if we omit the concatenation of the output digits, we can have the following shorter answer.
`(#=@i.@#)@]#[`

J, 10 characters, no use of tally #
This solution does not cater for input where mask is shorter than string.
;@:(<@$"0)

Usage
1 0 0 1 (;@:(<@$"0)) 1 0 1 0
1 0

Explanation

This makes no use of #, which on its own can be used to solve this golfing problem.
This solution works by interleaving both sides, one element by one. This is expressed by "0, which makes <@$ applied to each pair of elements.
x $ y means x ys as a list. 3 $ 4 -> 4 4 4.
< x puts x in a "box". A box can contain an object of any dimension (list, matrix, nothing). Boxes can be concatenated into lists.
1 $ x -> one-dimensional list consisting of x.
0 $ x -> nothing
1 (<@$"0) x -> one-dimensional list consisting of x inside a box.
0 (<@$"0) x -> nothing in a box.
; takes a list of boxes and concatenates its contents, throwing away empty boxes.
u@:v composes u and v in such a way that u is applied only after v has been applied to the whole of the arguments. In this case ; is applied only after the right side of the @: has been applied to each interleaved pair x and y made from the arguments.

source: Stack Exchange

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

sort: votes


text:
Multiply with restricted operations

There's a 500 rep unofficial bounty for beating the current best answer.

Goal
Your goal is to multiply two numbers using only a very limited set of arithmetic operations and variable assignment.

Addition x,y -> x+y
Reciprocal x -> 1/x (not division x,y -> x/y)
Negation x -> -x (not subtraction x,y -> x-y, though you can do it as two operations x + (-y))
The constant 1 (no other constants allowed, except as produced by operations from 1)
Variable assignment [variable] = [expression]

Scoring: The values start in variables a and b. Your goal is to save their product a*b into the variable c using as few operations as possible. Each operation and assignment +, -, /, = costs a point (equivalently, each use of (1), (2), (3), or (4)). Constants 1 are free. The fewest-point solution wins. Tiebreak is earliest post.
Allowance: Your expression has to be arithmetically correct for "random" reals a and b. It can fail on a measure-zero subset of R2, i.e. a set that has no area if plotted in the a-b Cartesian plane. (This is likely to be needed due to reciprocals of expressions that might be 0 like 1/a.)
Grammar:
This is an atomic-code-golf. No other operations may be used. In particular, this means no functions, conditionals, loops, or non-numerical data types. Here's a grammar for the allowed operations (possibilities are separated by |). A program is a sequence of <statement>s, where a <statement> is given as following.
<statement>: <variable> = <expr>
<variable>: a | b | c | [string of letters of your choice]
<expr>: <arith_expr> | <variable> | <constant>
<arith_expr>: <addition_expr> | <reciprocal_expr> | <negation_expr>
<addition_expr>: <expr> + <expr>
<reciprocal_expr>: 1/(<expr>)
<negation_expr>: -<expr>
<constant>: 1

You don't actually have to post code in this exact grammar, as long as it's clear what you're doing and your operation count is right. For example, you can write a-b for a+(-b) and count it as two operations, or define macros for brevity.
(There was a previous question Multiply without Multiply, but it allowed a much looser set of operations.)

Is this even possible?

@Ypnypn Yes, and I've written an example to make sure.

This feels like a challenge where an optimal solution is likely to be found (once any solution has been found). So what's the tie breaker in that case?

@MartinBüttner Tiebreak is earliest posting in that case. I think there's a good amount of room for optimizations, so I don't think it will just be a race to find one that works and write it cleanly. At least, that's what I found in trying it; maybe someone will find a clearly minimal solution.

Ok since not everyone thought my anwer was as funny as I did, I deleted it and comment here: The rule about the measure zero set is not very wisely chosen since rational numbers are a measure zero set regarding the lebesgue measure, I'd suggest using a certain percentage instead. (Or another kind) But I totally like the idea of this challenge!

@flawr I was imagining the fake language to express arithmetic formulas for real numbers, not act on bits or any sort of finite representation, so I think the measure requirement over the real plane (a,b) ∈ R^2 works fine. But if you actually think it's unclear, I'll edit it.

Of course it is clear what you mean but I think it does not help using precisely defined technical terminology for something that does not meet the definition. Sorry for being a stickler! In my opinion you can also write I know what you mean or (most as in common sense).

@flawr I was typing up the same stuff when I saw your comments. Exactly, the set of IEEE floating point numbers is measure zero, and so is all pairs of them. And so is the set of all numbers representable on any machine.

OK, thanks for the feedback, I guess I should have realize that coders would interpret numbers as stored in bits. I edited it to try to make clear I'm requiring arithmetically correct results for all but a measure-zero set of pairs of real numbers.

@xnor How much operations you got when you solved this question?

@proudhaskeller 33 :-P It was basically a worse version of algorithmshark's answer.

I don't know that there's a better choice for an algorithmic search other than brute force... And if the actual best solution is, say, 22 operations, that's not really feasible for a brute force search.

I will give a bounty of 300 rep to anyone who posts an  optimal solution with proof. A brute force search can be a proof if you explain how it checks everything needed. An optimal result restricted not to use variable assignment will be given 150 rep. Other partial bounties may be given for partial results.

@xnor What do you mean by optimal here ? less than 23 operations ?

@Optimizer No, the best theoretically possible. It might be 23, it might be less. A solution of 22 operations with no proof of optimality would not suffice. (Clarified in the post, thanks.)

You mean 22 operations (instead of chars), right ? Also, if someone posts a 24 operations solution, will that count ?

@Optimizer Yes, operations, thanks. Not sure what you mean about a 24 op solution -- it can't be optimal because there's a 23. If you mean for the no-assignment half-prize, yes, I'd count an optimal solution for that that's more than 23 ops.

I see. So the existing 23 operations won't get 300 if no one else posts, right ? Also, are you really sure an answer less than 23 exists ?

@xnor Currently, I have the answer which works best without assignment allowed (assignment used only once, and will only double it (approximately)). Does that count for the optimal result without assignment, or does it need to be proven to be the optimal result?

@proudhaskeller No, I'm looking for a proof of optimality. (Sorry, I had missed your comment in my feed.)

22 operations
itx = 1/(1+a+b)     #4
nx = -1/(itx+itx)   #4
c = -( 1/(itx + itx + 1/(1+nx)) + 1/(1/(a+nx) + 1/(b+nx)) ) #14

Try it online!
The ops are 10 additions, 7 inverses, 2 negations, and 3 assignments.
So, how did I get this? I started with the promising-looking template of the sum of two double-decker fractions, a motif that had appeared in many previous attempts.
c = 1/(1/x + 1/y)  +  1/(1/z + 1/w)

When we restrict the sum to x+y+z+w=0, a beautiful cancellations occur, giving:
c = (x+z)*(y+z)/(x+y)

which contains a product. (It's often easier to get t*u/v rather than t*u because the first has degree 1.)
There's a more symmetric way to think about this expression. With the restriction x+y+z+w=0, their values are specified by three parameters p,q,r of their pairwise sums.
 p = x+y
-p = z+w
 q = x+z
-q = y+w
 r = x+w
-r = y+z

and we have c=-q*r/p. The sum p is distinguished as being in the denominator by corresponding to the pairs (x,y) and (z,w) of variables that are in the same fraction.
This is a nice expression for c in p,q,r, but the double-decker fraction is in x,y,z,w so we must express the former in terms of the latter:
x = ( p + q + r)/2
y = ( p - q - r)/2
z = (-p + q - r)/2
w = (-p - q + r)/2

Now, we want to choose p,q,r so that c=-q*r/p equals a*b. One choice is:
p = -4
q = 2*a
r = 2*b

Then, the doubled values for q and r are conveniently halved in:
x = -2 + a + b
y = -2 - a - b
z =  2 + a - b
w =  2 - a + b

Saving 2 as a variable t and plugging these into the equation for c gives a 24-op solution.
#24 ops
t = 1+1   #2
c = 1/(1/(-t+a+b) + 1/-(t+a+b))  +  1/(1/(-b+t+a) + 1/(-a+b+t)) #1, 10, 1, 10

There's 12 additions, 6 inverses, 4 negations, and 2 assignments.
A lot of ops are spent expressing x,y,z,w in terms of 1,a,b. To save ops, instead express x in p,q,r (and thus a,b,1) and then write y,z,w in terms of x.
y = -x + p
z = -x + q
w = -x + r

Choosing
p = 1
q = a
r = b

and expressing c with a negation as c=-q*r/p, we get
x = (1+a+b)/2
y = -x + 1
z = -x + a
w = -x + b

Unfortunately, halving in x is costly. It needs to be done by inverting, adding the result to itself, and inverting again. We also negate to produce nx for -x, since that's what y,z,w use. This gives us the 23-op solution:
#23 ops
itx = 1/(1+a+b)     #4
nx = -1/(itx+itx)   #4
c = -( 1/(1/(-nx) + 1/(1+nx))  +  1/(1/(a+nx) + 1/(b+nx)) ) #15

itx is 1/(2*x) and nx is -x. A final optimization of expressing 1/x as itx+itx instead of the templated1/(-nx) cuts a character and brings the solution down to 22 ops.

If a and b are only one apart, then either a + nx = 0 or b + nx = 0, causing your solution to divide by zero.

@MooseOnTheRocks That's fine, see the "allowance" in the challenge that the code can fail on a measure-zero subset. I think the challenge is impossible otherwise.

23 operations
z = 1/(1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b))
res = z+z

proof by explosion:
z = 1/(1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b))
             1/(a+1)+1/(b+1)                            == (a+b+2) / (ab+a+b+1)
          1/(1/(a+1)+1/(b+1))                           == (ab+a+b+1) / (a+b+2)
          1/(1/(a+1)+1/(b+1))-1                         == (ab - 1) / (a+b+2)
          1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1)             == ab / (a+b+2)
       1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))            == (a+b+2) / ab
                                              1/a+1/b   == (a+b) / ab
       1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b)  == 2 / ab
    1/(1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b)) == ab / 2

z = ab / 2 and therefore z+z = ab

I abused wolfram alpha to get this beautiful image (wolfram alpha tried to get me to subscribe to pro to save it, but then ctrl-c ctrl-v ;-)):

score (with added + on subtraction):
z = ////++/++-+/++++-/+/
res = +

Not to be nit-picky, but shouldn't ...(b+1))-1+1... and ...1))-(1/a+... be ...(b+1))+-1+1... and ...1))+-(1/a+... respectively?

@tfitzger I think it's easier that way. The question does say that it doesn't matter. Note I do count the score correctly (Every minus is a two)

Wolfram Alpha has a 7-day free trial, fyi.

@ghosts_in_the_code I had already used that at the time

@proudhaskeller You can always create dummy accounts and keep using the trial.

"Proof by explosion" has got to be the coolest-sounding method of proof out there.

29 operations
Does not work for the set \$\{(a,b) \in \mathbb{R}^2 : a\pm b=0 \text{ or } a\pm b = -1\}\$. That's probably measure zero?
sum = a+b
nb = -b
diff = a+nb
rfc = 1/(1/(1/sum + -1/(sum+1)) + -1/(1/diff + -1/(diff+1)) + nb + nb)  # rfc = 1/4c
c = 1/(rfc + rfc + rfc + rfc)

# sum  is  2: =+
# nb   is  2: =-
# diff is  2: =+
# rfc  is 18: =///+-/++-//+-/+++
# c    is  5: =/+++
# total = 29 operations

The structure of rfc (Reciprocal-Four-C) is more evident if we define a macro:
s(x) = 1/(1/x + -1/(x+1))              # //+-/+ (no = in count, macros don't exist)
rfc = 1/(s(sum) + - s(diff) + nb + nb) # =/s+-s++ (6+2*s = 18)

Let's do the math:

s(x), mathematically, is 1/(1/x - 1/(x+1)) which is after a bit of algebra is x*(x+1) or x*x + x.
When you sub everything into rfc, it's really 1/((a+b)*(a+b) + a + b - (a-b)*(a-b) - a + b + (-b) + (-b)) which is just 1/((a+b)^2 - (a-b)^2).
After difference of squares, or just plain expansion, you get that rfc is 1/(4*a*b).
Finally, c is the reciprocal of 4 times rfc, so 1/(4/(4*a*b)) becomes a*b.

+1, I was in the middle of finishing up this identical calculation

That's definitely measure zero; it's a union of lines.

Not gonna make a comment about union of lines... @algorithmshark Can you tell us more how you did come up with this identity? How did you aproach the problem?

@flawr I recalled that the properties of s(x) fit the requirements of the question, from calculus, so that meant I had a square function. After some faffing about, I found I could get an a*b term with the difference of squares trick. Once I had that, it was a matter of trying out which assignments saved operations.

Since you use -1 three times in rfc, couldn't you golf a character out by assigning it to a variable?

@isaacg notice he didn't use (-1)/(..), as division is not a legal operation, but -(1/(...))

27 operations
tmp = 1/(1/(1+(-1/(1/(1+(-a))+1/(1+b))))+1/(1/(1/b+(-1/a))+1/(a+(-b))))
res = tmp+tmp+(-1)

# tmp is 23: =//+-//+-+/++///+-/+/+-
# res is 4: =++-

There is no theory behind this.  I just tried to get (const1+a*b)/const2 and started with (1/(1-a)+1/(1+b)) and (-1/a+1/b).

25 operations
two = 1+1
c = 1/(1/(a+b) + -1/(a+b+two)) + 1/(-1/a + 1/(a+two)) + 1/(-1/b + 1/(b+two))

Definitely not optimal, but probably optimal when restricted to only two levels of nested inversions (i.e. not using 1/(1/(1/...). There might be ways to optimize this...
Uses the property
$$
\frac{1}{\frac{1}{x}-\frac{1}{x+2}} = \frac{x(x+2)}{2} = \frac{x^2}{2}+x
$$
If we substitute \$x\$ with \$a+b, a, b\$ respectively:
$$
\begin{align}
\frac{1}{\frac{1}{a+b}-\frac{1}{a+b+2}} &= \frac{(a+b)^2}{2}+(a+b) = \frac{a^2}{2} + ab + \frac{b^2}{2} + a + b \tag1 \\
\frac{1}{\frac{1}{a}-\frac{1}{a+2}} &= \frac{a^2}{2}+a \tag2 \\
\frac{1}{\frac{1}{b}-\frac{1}{b+2}} &= \frac{b^2}{2}+b \tag3 \\
\end{align}
$$
We can easily see that \$(1)-(2)-(3)\$ conveniently gives \$ab\$.
Proof by Wolfram|Alpha:
> simplify c = 1/(1/(a+b) + -1/(a+b+2)) + 1/(-1/a + 1/(a+2)) + 1/(-1/b + 1/(b+2))
c = ab

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

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


text:
CodeBots 2: Event Driven Design
Welcome to Code Bots 2!
You've learned your lesson since the last Code Bots.  You've tried to figure out more ways to fit more actions in less lines, and now you finally have it.  You're going to make an event-driven Code Bot.
Your bot must consist of 24 lines.  Each line follows one of the two formats:
Condition:Action

or
Action

Your bot also have enough storage to store 5 integers named A through E.  An integer can store values from 0 to 23.
Each turn, you will execute line C, unless one of the conditions is true.  If so, then C will then contain the line number of the conditional that is true, and then that line will be executed.  At the end of each turn, C will be incremented.
There are the available conditions:

Start is true only on the first turn.  You must have this in your code exactly once
BotAt(N) is true if there is a bot at the location defined by N
Equals(A,B) is true if A equals B.  They can be different types, if so, they will not be equal.
Modified(A) is true if A was copied to during the last turn.  A must be a variable name, a line, or a condition
Any(C1,C2,...) is true if any of the conditions are true
None(C1,C2,...) is true if none of the conditions are true
All(C1,C2,...) is true if all of the conditions are true
Not(C) is true if C is false. C must be a condition.

Variables can be in one of the following formats.  The first 9 are numerical, and can be be used for whenever N is used in this page.

A,B,C,D,E
A number from 0 to 23
This will return the line number it is currently on
Add(N1,N2,...) will return the sum of all values
Sub(N1,N2) will return N1 minus N2
Mult(N1,N2,...) will return the product of all values
Div(N1,N2) will return N1 divided by N2
Mod(N1,N2) will return N1 mod N2
OVar(N) will accept a variable name, and will return the opponent's variable
Line(N) will return the Nth line in your code
Type(N) will return the Nth line type in your code (the types are the names of the actions)
Cond(N) will return condition on the Nth line
CondType(N) will return the condition type on the Nth line  (the types are the names of the conditions)
OLine(N) will return the Nth line in your opponent's code
OType(N) will return the Nth line type in your opponent's code
OCond(N) will return the condition on the Nth line
OCondType(N) will return the condition type on the Nth line

A and B are for your personal use, C is used to determine which line to execute in your code, and D is used as a direction. Each value of D refer to a different square and direction pair.E produces a random value each time.  D and E will be initialized to a random value, otherwise 0.
The direction used will be [North,East,South,West][D%4].  Your opponent is the bot in the immediate square in that direction.
There are 4 actions available to you:

Move will move you 1 square forward in the Dth direction.  If there is a bot there, you will not move.
Copy(A,B) will copy the variable A to B.  B cannot be a numerical value, except for a variable name.  A and B cannot be of different types.  Copying a line does not copy the condition.
Flag does nothing.  The bot with the most flags in your code will get a point.  The bot with the most points wins.
If(C,L1,L2) will perform the line on L1 if C is true, else performs L2. C is a condition, and L1 and L2 must be lines.

The Big Picture
50 copies of every bot will be placed in the world.  Your goal is to get your flag into as many bots as possible.  For each bot that has more of your flag type than any other flag type, you get a point.
The bots will be placed as follows:
B...B...B...B...
..B...B...B...B.
B...B...B...B...

There will be 10 games run, and points will be averaged across all of the games, determining who the winner is.
Side Notes
If multiple conditions apply, then the one that most immedately follows Start will be executed
The bots will be closely packed but you will not start neighboring another bot.  (It techincally will be the same format as the last CodeBots)
As this challenge was not posted in the sandbox (to give nobody an advantage), I reserve the right to change small details for fairness, or additional capabilities.  Also, if there is a bug in the CodeBots runner, I will change it, even if a bot depended on that bug for its success.  I am trying to be as fair as possible.
Recursive If statements will not be executed
If your bot is shorter than 24 lines, the remaining lines will be filled with Flag
Remember when copying to your own C, that C is incremented at the end of your turn.
The CodeBots interpreter can be found here.  It includes a .jar file for easy execution.  Simply add your bot to the bots folder
Scores

893.9    Borg
1.3  LazyLioness
0.9  Defender
0.5  Flagger
0.4  CliqueBot
0.4  Insidious
0.3  Attacker
0.3  Gard
0.3  SingleTarget
0.2 FreezeBot
0.2 Sentinel
0.2 Driveby
0.0 AntiInsidious
0.0 MoveBot
0.0 CliqueBorg
0.0 Calculator
0.0 TestBot
0.0 Imitator

UPDATE
Lines of code are now rotated when you view your opponent's code.  That means, your opponent's line 1 may be line 14 (or whatever line).  A bot will have a fixed offset which will offset his lines by X amount when viewed by an opponent.  The opponent's C variable will also be offset by the same X amount.  X will not change within the same game, but it will change from game to game.

Nathan: Are you able to check out "Lazy Lioness" to see whether the bugs I've reported are legitimate (or if I'm just out to lunch)? No rush. Just making sure you're aware of the submission.

@COTO Sorry, schools been crazy.  I'll try to get to it tonight.

The 'All' condition could be made implicit for any comma separated list of conditions. It would make reading the entries a bit easier.

I think I found your bug. The FuctionParser objects are being used as keys in a HashMap which means you need a proper equals method. This fixes the problem with CliqueBot and likely Lazy Lioness as well. I sent you a pull request.

@ccarton the HashMap only memoizes the values, it isn't used for testing equality

HashMaps don't work properly unless the keys have .equals() methods. See this. This is causing the memoizer to return different objects for the same line text.

Here is a better explanation of reason for the hashcode and equals requirements.

@ccarton I understand that that is a bug.  However, it does not affect the actual program execution.  It simply prevents additional parsing from being done.

It does affect execution because your Action class also does not have a .equals() method which means it is relying on reference equality. So when the HashMap returns two different Action objects for the same line text those Actions won't evaluate as equal.

Ah.  Then that is the bug.  I know how to fix it.  Thank you.

@ccarton: That does fix the problem of the spurious interrupts. Unfortunately, Lazy Lioness still does nothing. The conditions seem to be evaluating properly (i.e. green in the right places), and the instruction pointer seems to be at the right location (i.e. blue at the right place), but it's as if the controller is ignoring the instructions. I might have time on the weekend to look into it, but since you're already familiar with the code, maybe you could take another look. It sounds like Nathan is swamped with work.

Glad I could help. I couldn't tell if that was by design or not. It would theoretically work fine if the memoizer worked properly. Even if you change that, you should still fix the other bug as well.

@COTO: If I get a chance I'll have a look. It's possible that the lack of an equals method on the Action class is causing some additional issues, as apparently that wasn't by design. Give it another try after Nathan fixes that.

When will you refresh your scoreboard?

Ok.  I fixed that bug (and another one dealing with BotAt()).  Scoreboard posted.

@COTO It looks like LazyLioness is working as expected.  Realize that priority of conditions is based off of your Start condition, not the first line.

In my tests, his (LasyLioness') start action is not being executed on the first turn. It only executes if I move the start line to the first position. I think there is a bug in Bot.checkConditions(). Should it not be conditionIsTrue(lineNum)?

"Copy(A,B) will copy the variable N to M" - Huh?

@NathanMerrill: I placed the Start condition on the last line so that the instructions would have the highest priority on line 1 and descending priority below. I assumed the priority queue "wrapped around" the same way as execution order did. But maybe I'm missing something. I'll have more time to play around with the simulator this coming Sunday.

What happens if I clone a Start condition into a non-Start condition?

@TwiNight the initial position of Start is used throughout the simulation

Hey Nathan, did you see my last comment about a possible bug in Bot.checkConditions()?

@ccarton sorry, I missed it.  fixed and pushed

I think there is a problem with the offset code. OLine(OVar(C)) doesn't reference the correct line. For example, if C is 1 and the offset is 5, then OVar(C) returns 6 and then OLine(6) returns data from line 11. I think you need to be subtracting the offset in one of those cases to get them to line up.

I think BotAt is still bugged. Look at Gard. The BotAts are green at all the wrong places.

I think the problem with BotAt is in the getShiftY function. It's ignoring it's parameter and calculating direction from D. Looks like maybe it's old code that you meant to delete?

@ccarton thanks for the help with the bugs.  It's tough to find them all.  They are fixed.

Unfortunately, the offset makes porting MindControl impossible (due to the victim unable to correctly reference my own lines), and Borg is doing so well that all my resistance attempts so far are indeed futile.

Bugs!! TypeArgument splits spaces but lines no longer have spaces in CB2

@TwiNight Ah, good catch.

Borg
Converts all other bots into clones of itself. Resistance is futile.
Start:Copy(2,A)                               # Cloning will begin at line 2
All(Not(BotAt(D)),Not(Equals(2,A))):Copy(2,A) # Reset A if the opp left before we were done
Not(BotAt(D)):Move
All(Equals(Line(Sub(This,3)),OLine(0)),Equals(Line(Sub(This,2)),OLine(1)),Equals(Line(Sub(This,1)),OLine(2)),Equals(Line(This),OLine(3)),Equals(Line(Add(This,1)),OLine(4)),Equals(Line(Add(This,2)),OLine(5)),Equals(Line(Add(This,3)),OLine(6)),Equals(Line(Add(This,4)),OLine(7)),Equals(Line(Add(This,5)),OLine(8))):Copy(E,D) #  Check if cloning is complete
All(Equals(A,2),Not(Equals(OCond(1),Cond(Add(This,4))))):Copy(Cond(Add(This,4)),OCond(1)) # Copy freeze cond to OLine(1) before cloning starts
All(Equals(A,2),Not(Equals(OLine(1),Line(Add(This,3))))):Copy(Line(Add(This,3)),OLine(1)) # Copy freeze line
Not(Equals(Cond(Add(Sub(This,6),A)),OCond(A))):Copy(Cond(Add(Sub(This,6),A)),OCond(A))    # Copy Cond(A) to OCond(A)
Not(Equals(Line(Add(Sub(This,7),A)),OLine(A))):Copy(Line(Add(Sub(This,7),A)),OLine(A))    # Copy Line(A) to OLine(A)
Equals(A,A):Copy(Add(A,1),A) # Increment A. It will wrap around all 24 lines before the completion check matches

Edit: Small fix to reset A if the opponent moves before I'm done with him. Doesn't seem to affect the score but it makes me feel better.
Edit #2: Added a more complete check to ensure the cloning process has completed properly (line 3)
Edit #3: Update to handle the new random offsets. The difficulty here was that new clones would have their code located at random offsets which means they don't know the location of their own lines. That means that all references to my own lines must be relative (to This). Opponent line numbers can still be absolute since they are random anyway.

Hey, can we chat about this bot? http://chat.stackexchange.com/rooms/17128/private-chat-between-ccarton-and-nathan

@Nathan, did you use the latest version of this entry in the most recent run?

I am amazed that this bot is able to infect other bots so successfully. I'd love to see a rundown of how it works.

@ccarton no.  I didn't realize it was updated.  Rerunning.

@Sparr I've added some comments. Hope that makes it easier to follow. I think the bot is so effective because of the exponential effect of the cloning. Each bot it infects goes out and infects others. Also, they will naturally try to repair each other when they take damage.

I think any bot that beats this will be based on this. I've got an idea for a Borg+RowBot mashup, but it wouldn't beat this by much if at all.

@Sparr I think you'd be surprised at the snowball effect of the cloning strategy. If you can improve this design by even a small amount it might multiply into a massive lead in overall score. Maybe.

@ccarton that much is obvious in reverse. I can make tiny changes to this bot that still produce 99% scores alone, but lose to this bot by a large margin.

Flagger
Shoot for the moon
Start:Flag

And the rest gets auto-filled with flag.

Calculator
This bot doesn't understand the goal of this challenge, so he decided to calculate some numbers for the enemy.
Equals(Mod(OVar(E),5),0):Copy(Add(OVar(A),OVar(B)),OVar(D))
Equals(Mod(OVar(E),5),1):Copy(Sub(OVar(A),OVar(B)),OVar(D))
Equals(Mod(OVar(E),5),2):Copy(Mult(OVar(A),OVar(B)),OVar(D))
Equals(Mod(OVar(E),5),3):Copy(Div(OVar(A),OVar(B)),OVar(D))
Equals(Mod(OVar(E),5),4):Copy(Mod(OVar(A),OVar(B)),OVar(D))
Start:Move

you should put the results into OVar(D) not A!

@MegaTom Done ;)

CliqueBot
Flag
Start: Copy(11,B)
Not(Equals(Line(20),Line(21))): If(Equals(Line(21),Line(22)),Line(7),Line(8))
Not(Equals(Line(21),Line(22))): If(Equals(Line(20),Line(21)),Line(9),Line(10))
All(BotAt(D),Not(Equals(11,OVar(B)))): If(Equals(Line(20),OLine(OVar(C))),Line(10),Line(11))
Any(BotAt(D),Equals(E,B)): Copy(Add(D,1),D)
Equals(1,1): Move
Copy(Line(21),Line(20))
Copy(Line(20),Line(21))
Copy(Line(21),Line(22))
If(Equals(Line(20),OLine(Sub(OVar(C),1))),Line(5),Line(12))
Copy(Line(20),OLine(OVar(C)))
Copy(Line(20),OLine(E))

Recognizes friends via their B value, fills everyone else's lines with flags. Also goes to some length to preserve the integrity of one of its own flags (this part is cute but probably not very useful).
Edit: Unsurprisingly, there appears to be a bug here somewhere, judging by the score.
Suspect that lines are 0-indexed and my code is 1-indexed. Should really have checked that earlier. Added a Flag at the beginning to bump everything up one.

I think I found the bug in the controller. I sent him a pull request. Until he accepts it, you can try my fork if you like and let me know if it works for you.

The bug has been fixed in the latest version.

Defender
Start:Copy(0,A)
Copy(0,B)
Flag
Flag
All(Modified(Line(2)),Equals(A,0)):Copy(1,A)
Copy(Line(3),Line(2))
Copy(0,A)
Copy(10,C)
All(Modified(Line(3)),Equals(B,0)):Copy(1,B)
Copy(Line(2),Line(3))
Copy(0,B)
BotAt(D):Copy(Line(2),OLine(E))

MoveBot
Start:Move
Copy(E,D)
Copy(-1,C)

Shouldn't that be Copy(23,C)?

Negative values are now allowed.

Attacker
Start:Move
BotAt(D):Copy(Line(Add(Mod(E,6),4)),OLine(E))
Any(BotAt(0),BotAt(1),BotAt(2),BotAt(3)):Move
None(BotAt(0),BotAt(1),BotAt(2),BotAt(3)):Copy(E,D)

BotAt(D):Copy(Line(X),OLine(E)) where line X contains Equals(1,1):Flag ... for fun

@Sieg Line copies only the action, not the condition.

My overpowered tactic :(

Single Target
Start:Move
All(BotAt(D),Not(Equals(OVar(D),D))): Copy(D,OVar(D))
BotAt(D):Copy(Line(E),OLine(E))
Equals(A,A):Move

Will hunt you down and fill you with flags!

The All condition needs a )

Insidious
Start:Flag           # comments -->                                                                                # why move when we can fit another flag here?
Equals(E,0):Copy(Add(D,Sub(Mult(2,Mod(E,2)),1)),D)                                                                  # 1/24 chance to turn left or right
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),1)),Cond(Add(This,4))))):Copy(Cond(Add(This,4)),OCond(Sub(OVar(C),1)))    # Copy the freeze condition
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),1)),Line(Add(This,4))))):Copy(Line(Add(This,4)),OLine(Sub(OVar(C),1)))    # Copy the flag-copying line
All(BotAt(D),Not(Equals(OLine(Add(OVar(C),0)),Line(Add(This,Add(4,Mod(E,14))))))):Copy(Line(Add(This,Add(4,Mod(E,14)))),OLine(Add(OVar(C),0))) # copy one of my flags to them
BotAt(D):Copy(Add(D,Sub(Mult(2,Mod(E,2)),1)),D)                                                                     # turn left or right if we've infected our target
Equals(A,A):Move                                                                                # move if all else fails, also infection freeze condition
Copy(Line(Add(This,1)),Line(Add(This,Mod(E,22))))                                                                   # infection line 1
Flag                                                                                # first of many flags

Similar idea to the bot by the same name in the previous contest. Move until I hit another bot, then freeze it into a loop overwriting its own code with my flags. This time the infected bots overwrite random lines instead of sequential lines, making the infection process a little less effective but much faster.

Line(4) can be simplified a bit. Add(OVar(C),0) is the same as OVar(C) and Add(This,Add(4,Mod(E,14))) is the same as Add(This,4,Mod(E,14)).

@MegaTom I did the first unnecessary Add to make the logical parts of the preceding lines line up.
The second one was due to not knowing that Add could take multiple parameters. Thanks

Gard
Start: Move
BotAt(D):IF(Equals(Line(7),OLine(C)),Line(6),Line(5))
BotAt(Add(D,1)):Copy(Add(D,1),D)
BotAt(Add(D,2)):Copy(Add(D,2),D)
BotAt(Add(D,3)):Copy(Add(D,3),D)
Copy(Line(7),OLine(OVar(C)))
Copy(Cond(7),OCond(Sub(OVar(C),1)))

Attacks any robot next to it.

Your last line cannot copy from a condition to a line.

@NathanMerrill I was just fixing that...

OCon needs to be OCond

Freeze Bot
Start:Move
All(BotAt(D),Not(Equals(OCond(1),Cond(5)))):Copy(Cond(5),OCond(1))
All(BotAt(D),Not(Equals(OLine(1),Line(6)))):Copy(Line(6),OLine(1))
All(BotAt(D),Equals(Mod(OVar(A),24),0)):Copy(Add(D,1),D)
BotAt(D):Copy(Line(20),OLine(OVar(A)))
Equals(A,A):Move
Copy(Add(A,1),A)

Traps you in a loop Incriminating your own A variable, then fills you with flags and moves on to the next victim.

Line 3: Please replace D+1 with Add(D,1)

You're assuming that Start is on line zero. Now everyone is incentivized to put their Start on line 2. This is going to lead to a silly escalation/resubmission trend :(

Imitator
Start:Move
BotAt(D):If(OCond(0),OLine(0),Line(2))
If(OCond(1),OLine(1),Line(3))
If(OCond(2),OLine(2),Line(4))
If(OCond(3),OLine(3),Line(5))
If(OCond(4),OLine(4),Line(6))
If(OCond(5),OLine(5),OLine(OVar(C)))
Not(BotAt(D)):If(BotAt(Add(D,1)),Line(8),Line(0))
Copy(Add(D,1),D)

Predicts what you would do, then does that.

Please replace D+1 with Add(D,1)

Also, you cannot pass in a command as a line.  You either have to pass in a OLine or a Line

@NathanMerrill ready to go! (At least I think it is)

This bot really put my code through some trouble, but that was my fault, not yours.  There are a few bugs, please put Line around the 2, and Add(D,1) instead of D+1

Lazy Lioness
Originally just "Lioness", my first submission to the contest earned the title "lazy" by literally doing nothing when introduced into the simulator.
Her lethargy is in fact due to a bug (or possibly my misunderstanding the event model) wherein the conditions in the first three lines (a simple parity check for ensuring that flags are not overwritten) occasionally, inexplicably evaluate true, locking leo in a lemniscate loop. Several other conditions (particularly those that rely on the BotAt() condition) also evaluate true at times when no adjacent bot(s) are present. Finally, Move and Copy directives are clearly ignored when stepping through the simulator. Since my conditional logic chains are somewhat epic, there's plenty of room for bugs in my code and in the simulator. ;)
In any case, I submit Lazy Lioness as a test case for either error diagnosis or simulator debugging, which will hopefully lead to the emergence of not-so-lazy Lioness that I can then simulate and refine as my first bona fide submission to the Bots v2 competition.
It Does Nothing
All(Not(Equals(Line(18),Line(21))),Equals(Line(21),Line(22))):Copy(Line(21),Line(18))
All(Not(Equals(Line(21),Line(22))),Equals(Line(22),Line(18))):Copy(Line(22),Line(21))
All(Not(Equals(Line(22),Line(18))),Equals(Line(18),Line(21))):Copy(Line(18),Line(22))
All(Any(BotAt(Add(D,1)),BotAt(Add(D,2)),BotAt(Add(D,3))),Not(BotAt(D))):Move
All(Any(All(BotAt(D),BotAt(Add(D,2))),All(BotAt(D),BotAt(Add(D,1))),All(BotAt(Add(D,1)),BotAt(Add(D,2)))),Not(BotAt(Add(D,3)))):Copy(Add(D,3),D)
Any(All(Any(All(BotAt(D),BotAt(Add(D,2))),All(BotAt(D),BotAt(Add(D,3))),All(BotAt(Add(D,2)),BotAt(Add(D,3)))),Not(BotAt(Add(D,1)))),All(BotAt(Add(D,1)),BotAt(D),Any(Equals(OCond(2),Cond(20)),Equals(OLine(2),Line(19))))):Copy(Add(D,1),D)
All(BotAt(Add(D,3)),BotAt(D),Any(Equals(OCond(2),Cond(20)),Equals(OLine(2),Line(19)))):Copy(Add(D,3),D)
All(BotAt(D),Not(Equals(OCond(2),Cond(20))),Not(Equals(OLine(2),Line(19)))):Copy(Cond(20),OCond(2))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OLine(3),Line(18)))):Copy(Line(18),OLine(3))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OLine(4),Line(21)))):Copy(Line(21),OLine(4))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OCond(0),Cond(22)))):Copy(Cond(22),OCond(0))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OLine(0),Line(17)))):Copy(Line(17),OLine(0))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OCond(1),Cond(21)))):Copy(Cond(21),OCond(1))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OLine(1),Line(20)))):Copy(Line(20),OLine(1))
All(BotAt(D),Equals(OCond(2),Cond(20)),Not(Equals(OLine(2),Line(19)))):Copy(Line(19),OLine(2))
All(BotAt(D),Not(Equals(OCond(2),Cond(20))),Equals(OLine(2),Line(19))):Copy(Add(D,A),D)
Equals(E,1):Copy(Add(A,2),A)
Any(Equals(E,4),Equals(E,8)):Copy(Add(D,E,A),D)
Not(Equals(A,A)):Flag
Not(Equals(A,A)):Copy(Line(3),OLine(E))
Equals(A,A):Move
Any(Equals(E,4),Equals(E,5),Equals(E,6),Equals(E,7),Equals(E,8),Equals(E,9)):Flag
Any(Equals(E,10),Equals(E,11),Equals(E,12),Equals(E,13)):Flag
Start:Copy(1,A)

I can't see a bug, but just in case you should probably use Modified condition instead of some of the Equals

cliqueBot looks like it has the same problem. I think it is a compiler bug.

@MegaTom: The Modified condition is an invitation for an infinite loop. If I can't use a parity check, I'll just remove the lines entirely. Figure out something else useful to put in 'em. ;)

I think I found the bug in the controller. I sent him a pull request. Until he accepts it, you can try my fork if you like and let me know if it works for you.

CliqueBorg
Flag
BotAt(D): Copy(Line(Sub(This,1)),OLine(E))
Equals(1,1): Copy(Line(Sub(This,2)),Line(Add(This,Mod(E,21))))
Start: Move
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),1)),Line(3)))):Copy(Line(3),OLine(Sub(OVar(C),1)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),1)),Cond(3)))):Copy(Cond(3),OCond(Sub(OVar(C),1)))
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),2)),Line(2)))):Copy(Line(2),OLine(Sub(OVar(C),2)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),2)),Cond(2)))):Copy(Cond(2),OCond(Sub(OVar(C),2)))
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),3)),Line(1)))):Copy(Line(1),OLine(Sub(OVar(C),3)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),3)),Cond(4)))):Copy(Cond(4),OCond(Sub(OVar(C),3)))

Trying to combine CliqueBot and Borg technology to create a bot that recognizes copies of itself despite the line offset. It also starts its copying process at the last executed line of code on the opposing bot, rather than line 0, which is more likely to freeze it in place but also more likely to result in a corrupted copy (in fact, I'm not sure this even works, I haven't tested it and it's pretty complex).

Please replace Plus with Add and Minus with Sub

Driveby
One last try before the deadline.
Flag
Flag
BotAt(D):Copy(Line(Sub(This,1)),OLine(E))
Equals(1,1):Copy(Line(Sub(This,2)),Line(Add(This,Mod(E,21))))
Start:Move
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),1)),Line(3)))):Copy(Line(3),OLine(Sub(OVar(C),1)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),1)),Cond(3)))):Copy(Cond(3),OCond(Sub(OVar(C),1)))
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),2)),Line(2)))):Copy(Line(2),OLine(Sub(OVar(C),2)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),2)),Cond(2)))):Copy(Cond(2),OCond(Sub(OVar(C),2)))
All(BotAt(D),Not(Equals(OLine(Sub(OVar(C),3)),Line(1)))):Copy(Line(1),OLine(Sub(OVar(C),3)))
All(BotAt(D),Not(Equals(OCond(Sub(OVar(C),3)),Cond(4)))):Copy(Cond(4),OCond(Sub(OVar(C),3)))
BotAt(D):Copy(Add(D,1),D)
Equals(1,1):Move

sentinel
improvment on Gard. Hits nearby bots with flags on the first 8 lines. (that is, all the most used ones)
flag
flag
Start:Copy(11,B)
All(BotAt(D),Not(Equals(OLine(Mod(E,8)),Line(0))),Not(BotAt(Add(D,1,Mod(E,3))))):If(Equals(OVar(D),Add(D,2)),Line(7),Line(8))
BotAt(Add(D,1)):Copy(Add(D,1),D)
BotAt(Add(D,2)):Copy(Add(D,2),D)
BotAt(Add(D,3)):Copy(Add(D,3),D)
copy(D,OVar(D))
copy(Line(Mod(E,2)),OLine(Mod(E,8)))
Not(Equals(Line(0),Line(1))):copy(Line(Add(9,Mod(E,16))),Line(Mod(E,2)))

I think you have a misplaced bracket on line 3. The first Not isn't closed properly. I think it should be All(BotAt(D),Not(Equals(OLine(Mod(E,8)),Line(0))),Not(BotAt(Add(D,1,Mod(E,3))))):

authors: อุทัย ทุมทอง


text:
Create a "hacker typer" program that renders its own source code
If you are unfamiliar with hacker typer, see hackertyper.net. In short, it is a program that outputs one chunk of a code base per keystroke for comedic effect. BUT, the hackertyper.net version is far too easy to implement. It simply outputs three characters at a time from an arbitrary piece of code. For this challenge, a program must output its own source code, and print one space delimited chunk of code per keystroke.
Details

One cannot hard code a file name for the program; it must determine its name dynamically. If the program compiles to an executable, it may append the standard file extension to the name of the executable (excluding the .exe if using Windows) and assume that the source file is within the executable's directory. For example, if a C executable is named "hacker", it should pull its source code from a file named "hacker.c" in its same directory. If a compiled program has an extension, it should be dropped before determining the name of its source code ("typer.exe" -> "typer.cs").
Programs must contain at least 5 spaces, with at least one character between each space. This means that the smallest possible size for this challenge is 9 bytes. The spaces do not have to be crucial to the functioning of the program.
Any formatting (indentation, new lines, etc.) must be maintained in the output. This formatting may either be printed with the code that proceeds it or follows it, what matters is that the formatting be maintained.
Avoid using comments to satisfy the 5 space requirement unless there is no other way to implement the spaces in your language of choice.

EDIT: New lines can be used in place of, or in addition to, spaces as chunk separators.

I'm a little confused. Should the program be a quine, or not?

The way you've described it makes it sound as if its acceptable to read the code from the original source file, which would not be a quine. I think it would be a better contest if the program had to be an actual quine.

@Orby I'd say the program is not a quine in the traditional sense, regardless of if reading the source is allowed or not. Quines don't have input but these programs clearly do.

@DrJPepper Your third bullet point makes it sound like any sequence of whitespace counts as a delimiter but you specifically say that only space is. Can you clarify?

@Calvin's Hobbies Yes, new lines between chunks are fine as well, I'll edit it in a minute to clarify.

This challenge encourages reading of the program's own source code, a practice typically verboten in the construction of quines.

@Orby Seeing as you are allowed to read the source file, it seems you are correct in this not being a Quine. The main point of the challenge was the staggering of the output. As for the quality of the contest, I feel making such a drastic change at this point would be disrespectful to the extant answers.

I'm disapppointed that newlines are now allowed to be delimiters; it simplifies the problem greatly.  Most languages have easy way to read files by line, and print a whole line.  My bash entry could be 12 shorter, for example, possibly shorter using a while read.

@Will I didn't mean in place of, I meant in addition too. But since it was an edit, I thought honoring them should be optional. Honoring spaces is not optional.

Does that mean that we can ignore newlines, as it'll make my program shorter.

@matsjoyce Yes you can ignore newlines. You still need 5 spaces, but since I was not clear new lines can either be factored in or not. It was my original intention for them to count, it just slipped my mind to clarify.

I have not enough rep to answer, but this (http://esolangs.org/wiki/Help,_WarDoq%21) language can solve it in 9 bytes, using the Q command.

bash, 51 58
for w in $(<$0);do read -sn 1;printf -- "$w ";done

It's bash, not shell: This won't work under dash, (2: read: Illegal option -s)

Assuming bash, can replace cat $0 and tildes with $(<$0)

@broslow thx for feedback; labelled bash, same length

@Will No problem. Is the IFS=\  actually needed if you omit the shebang? Default IFS is something like IFS=$'\n\t ', and since you no longer have a newline, I don't think you need to limit it to just space.

@BroSlow how on earth did I miss that? lol you really ought enter yourself ;)  Thousand thanks

for w in `<$0`;do read \-sn1;printf $w\ ;done

for w in `<$0`;{ read \-sn1;printf $w\ ;}

HTML & JavaScript, 123

This works similarly to hacker typer, but with its own source code. Let me know if I've misunderstood the rules.
And here's a styled version (170 characters):

I've made a demo. It's modified because JS Bin adds a lot of extra code, but the general idea is the same.

I'd be surprised if this didn't render correctly without the  and  tags, and without a closing .  You'd be surprised how very forgiving all browsers are in this regard.

@Will Thanks. The reason I included  was that the browser will add it if it's not there, so it will always get displayed. I forgot about  though.

Perl + Term::ReadKey, 56 bytes
use
Term'ReadKey;ReadMode
4;open
0;ReadKey,print
for
<0>

Thanks to ThisSuitIsBlackNot for the original inspiration, and to primo for suggesting open 0 and <0>.
Note that the newline after for is actually unnecessary, except that I need to include one extra newline somewhere to bring the whitespace count up to the specified minimum of five.
Also note that, like ThisSuitIsBlackNot's submission, this program requires the Term::ReadKey module from CPAN.  On Debian / Ubuntu Linux, this module, if not already present, can be easily installed with the command sudo apt-get install libterm-readkey-perl.
Also, to save a few characters, this program does not restore the input mode to normal on exit, so you may find yourself unable to see what you're typing afterwards.  Executing the shell command stty sane or reset should fix that.  This issue could be fixed, at the cost of 10 extra bytes, with:
use
Term'ReadKey;ReadMode
4;open
0;ReadKey,print
for<0>;ReadMode
0

Bonus: Pure quine, 81 bytes
$_=q{use
Term'ReadKey;ReadMode
4;ReadKey,say
for
split$/,
"\$_=q{$_};eval"};eval

Again, the newline after the comma is only needed to meet the five whitespace minimum.
Unlike the 56-byte program above, this version doesn't actually need to read its own source code, since it's based on a quine — specifically, on this quine:
$_=q{say"\$_=q{$_};eval"};eval

The nice thing about this quine is that it can easily carry an arbitrary "payload" within the q{ } block, without having to repeat it.  While it can't quite beat <0> in shortness, it does get pretty close.
Note: This program uses the Perl 5.10+ say feature, and thus needs to be invoked with the -M5.010 (or -E) command line switch.  Per established consensus on meta, such switches used to enable modern language features do not count as extra characters.  The shortest solution I can find without say is 83 bytes:
$_=q{use
Term'ReadKey;ReadMode
4;ReadKey,print
for
split/^/,
"\$_=q{$_};eval"};eval

Both of these can also be made more terminal-friendly by (joining the last two lines and) inserting:
;ReadMode
0

before the last }.

Wow. Just wow. Very cool.

+1, but I recommend to have the habit to type stty sane instead of reset (which could, on some os, sometimes be doing something more than just resetting some terminal parameters ^^)

Very nice solution. FWIW, open F,$0 and <F> could be replaced with open 0 and <0>. Also, I would argue that one post in meta doesn't really constitute a consensus. The option -M5.01 doesn't "bring the language to a specific point", as the author suggests, it enables features. There is no version of perl for which these features are enabled by default.

@primo: Please do post your own answer to the meta thread, if you disagree with the existing one. The fact that nobody's done so in three and a half years, so far, does suggest a reasonable degree of consensus, at least among the regulars here who actively visit meta, but consensus can always change. (Anyway, the way I see it, if ruby golfscript.rb foo.gs counts as a valid command to run a program written in GolfScript, then perl -M5.010 foo.pl should count as a valid command to run a program written in "Perl 5.10". But such arguments really belong on meta, not here.)

Python 3 - 124 bytes - 7 spaces

Code:
from curses import*
s=initscr();noecho()
for x in open(__file__).read().split(" "):s.getch();s.addstr(x+" ")
echo();endwin()

Ungolfed:
from curses import*
# init curses
screen=initscr()
noecho()
# split code into spaces
code = open(__file__).read().split(" ")
for x in code:
    # wait for keypress
    screen.getch()
    # print a bit
    screen.addstr(x+" ")
# deactivate curses
echo()
endwin()

Styled version:
from curses import*
s=initscr();noecho();start_color();init_pair(2,COLOR_GREEN,COLOR_BLACK)
for x in open(__file__).read().split(" "):s.getch();s.addstr(x+" ",color_pair(2))
echo();endwin()

Ruby, 85, 71
require"io/console";f=File.open __FILE__;loop{STDIN.raw &:getc;print f.read(3)||exit}

Too bad that IO#raw is not part of the standard library.
Improvement
require"io/console";24.times{|q|STDIN.raw &:getc;$><<IO.read($0,3,q*3)}

This one eliminates the call to Kernel#exit and uses global variables to shorten the code.

Befunge - 21
~ $ g , 1 +:54*`#@_:0

I'm fairly pleased with this, as I just found out about Befunge. If you don't mind "typing" into a popup window, you can run it here or here until I find a better online interpreter.

Python 3 - 299
a="""from curses import*
s=initscr()
raw()
noecho()
for x in e:
 s.getch()
 s.addstr(x+' ')
nocbreak()
echo()
endwin()
""";b="""e=(a+'a=#%s#;b=#%s#;%s'%(a,b,b.replace('#','""''"',4))+'exec(a)').split(' ')
""";e=('a="""%s""";b="""%s""";%s'%(a,b,b.replace('#','""''"',4))+'exec(a)').split(' ')
exec(a)

Its a quine. Shortened from 507 by using exec and moving some statements around.

Powershell, 89
(gc $MyInvocation.MyCommand.Path).split(" ")|%{$l+="$_ ";write-host "$l";read-host ;cls}

C - 136 135 132 bytes (Windows only)
*fopen();**v;b[ 1<<20];main(p,q){v=q; strcpy(b,*v);strcat(b,".c") ;for(*v=fopen(b,"r");~fscanf(*v,"%s",b);printf("%s ",b))getch();}

Note: there is a space at the end of the program, which probably won't show up.
I can't guarantee this program will work on a single computer other than my own as it is awesomely hacky. Things would have been a lot simpler back when everyone only had 32-bit machines. Then I would not need to worry about sizeof(int*) being 8 (which it definitely is; I printed it out to make sure) while sizeof(int) is 4.
Happily, the name of the executable is stored in the first string in argv.  However, putting a pointer as an argument to a function means that I have to explicitly specify the type of ALL the arguments to the function--meaning I would have to type int twice--a huge waste of characters.  Fortunately I found a workaround. I had the second argument to main, q, be just another int. Then assigning q to a variable of type int** somehow managed to grab all the necessary bytes from the stack.
I was unsuccessful in finding any such tricks to interpret the return type of fopen as a pointer without declaring the function.
Edit: Noticed I should use ~fscanf(*v,"%s",b) instead of fscanf(*v,"%s",b)>0 since the return is -1 when EOF is reached.

This segfaults for me so I can't test it, but you should be able to declare a void pointer (void **v;) instead of prototyping fopen().

@Comintern this change didn't help me to correctly store the result of fopen. I don't see why substituting void for int should make a difference, as all pointers are the same size anyway.

Good point. Still shorter and more stable to just declare a pointer though - this actually runs for me: b[1<<20];main(int *c,char **v){strcpy(b,*v);strcat(b,".c");c=fopen(b,"r");for(;fscanf(c,"%s",b)>0;printf("%s ",b))getch();} (I had to substitute getchar() for getch() though).

@Comintern your code still crashes on my system, but nice job getting it to work. I guess it is like I said--each version of the program will run on 1 computer.

Why don't you use K&R prototypes? E.g. *fopen() instead of *fopen(a,b)?

@FUZxxl Yep, that works. Evidently I did not know the rules of K&R declarations when I wrote this program, as I also complained about having to declare return types of all the parameters of a function.

C, 211 186 bytes
My solution in C using the curses library. It may be longer than the other C solution, but it is a quine. Although not required by the question, it's still pretty nice. It also works quite nicely:
#define R(x)#x
#define T(x)R(x)
#define S(p)char*s="#define R(x)#x\n#define T(x)R(x)\n#define S(p)"p"\nS(T(S(p)))";main(){initscr();noecho();while(*s)if(~getch())addch(*s++);}
S(T(S(p)))

A more readable version with some comments and stuff:
#define R(x)#x /* macros to convert the source code in S into a C-string */
#define T(x)R(x)
#define S(p) char*s="#define R(x)#x\n" \
                    "#define T(x)R(x)\n" \
                    "#define S(p) " p "\n" \
                    "S(T(S(p)))";\
    main(){\
        initscr();\
        noecho(); /* don't echo input */ \
        while(*s)\
            if(~getch()) /*true if character has been typed */ \
                addch(*s++);\
}
S(T(S(p)))

compile with:

gcc -o h h.c -lncurses

Perl - 87 bytes
#!/usr/bin/perl -040
use Term::ReadKey;open F,$0;ReadMode 3;print''.<F>while ReadKey 0

I didn't see anything in the rules about what to do once the file has been read to the end, so it simply sits waiting for input after printing the last chunk.

node.js with LiveScript:
#!/usr/local/bin/lsc
console.log <| require \fs .readFileSync __filename, encoding: \utf8

asynchronous version:
#!/usr/local/bin/lsc
require \fs .readFile __filename, encoding: \utf8, -> console.log &1

Cobra - 147
class P
    def main
        while 1,for a in File.readLines(CobraCore.exePath[:-4]+'.cobra'),print if('[Console.readKey]'and (Console.cursorLeft=0)<1,a,'')*

CobraCore.exePath is so useful!

Javascript ES6, 154
Firefox 154:

(a= (i=1,b="(a= "+a+")()",s="") => {window.onkeydown=()=>{clear();i=b.indexOf(" ",i+1),d=b.slice(0,i<0?b.length:i);console.log(s+d);if(i<0){i=0,s+=d}}})()

Chrome 175:

( a= function (i,s){b="( a= "+a+")()";c=console,window.onkeydown=function(){c.clear();s=s||"",i=b.indexOf(" ",i+1),d=b.slice(0,i<0?b.length:i);c.log(s+d);if(i<0){i=0,s+=d}}})()

Both 274:

( a= function (i,s){b="( a= "+a+")()";c=console,window.onkeydown=function(){(clear)?clear():c.clear?c.clear():0;s=s||"",i=b.indexOf(" ",i+1),d=b.slice(0,i<0?b.length:i);c.log(s+d);if(i<0){i=0,s+=d}}})()

Ungolfed (chrome):
( a= function (i,s){        // starting index | undefined, output string
    b="( a= "+a+")()";      // get a string representation of the function
    c=console,
    window.onkeydown=function(){    // on each key down event
        c.clear();                  // clear the output
        s=s||"";
        i=b.indexOf(" ",i+1);       // get the index of next space
        d=b.slice(0,i<0?b.length:i);// get the string part wanted
        c.log(s+d);                 // print the string
        if(i<0){
            i=0,                    // reset counters
            s+=d                    // adding the string to the main output
        }
    }
})()

Has two versions, because Chrome does not handle arrow function and the console is not cleared with the same method
The Firefox one work with firebug, it seem that the default developer console can't be cleared from a script.

Did you miss the requirement that the user has to press random keys to get the output printed ?

sure !, gonna rewrite this.

C, 248 characters
True quine
Only works in unix, in windows it would be implemented using _getch.
main(){char *p="main(){char *p=\"%s\",s[400];sprintf(s,p,p);system(\"stty raw\");for(p=s;*p!=0;putchar(*p++))getchar();system(\"stty cooked\");}",s[400];sprintf(s,p,p);system("stty raw");for(p=s;*p!=0;putchar(*p++))getchar();system("stty cooked");}

Groovy - 379
import java.nio.file.*
Path p = Paths.get(System.getProperty("user.dir"))
DirectoryStream<Path> f = Files.newDirectoryStream(p,"*.groovy")
try{for(e in f){read(e.toAbsolutePath().toString())}}
catch(Exception e){ }
finally{f.close()}

void read(String x){
    def s = new File(x).text
    for(e in s.replace("%n"," %n").split(" "))
        print e + " "
    Thread.sleep(200)
}

Since there is no getch() or equivalent in Java and Java-esque languages like Groovy... basically my code doesn't handle keypresses. That's all :D

HTML and Javascript, 232 bytes

The traditional Javascript quine, but modified.
JSFiddle here.

SmileBASIC, 79 75 bytes
LOAD"PRG1:"+PRGNAME$()
PRGEDIT 1
@L
IF BUTTON(2)THEN?PRGGET$();
WAIT
GOTO@L

It's very easy to get a specific LINE of a program in SmileBASIC, so I just put the spaces before each line break. I thought I was so clever, putting the spaces before each line break, but apparently we're allowed to use line breaks instead of spaces...
Explanation:
LOAD "PRG1:"+PRGNAME$() 'load the code into slot 1 so we can easily read 1 line at a time
PRGEDIT 1 'Edit slot 1
@LOOP
IF BUTTON(2) THEN 'When a button is pressed...
                   PRINT PRGGET$(); 'get a line of code and print it
WAIT 'delay so we don't detect the same press multiple times in a single frame.
GOTO @LOOP

authors: عماد محمد ابراهيم عبدالله


text:
Generate the outline of an island from a seed
The challenge is to draw the outline of an 'island', generated using a seed as input.

Input (seed): string of 6 characters (exactly) allowing only lowercase letters (i.e. abcdefghijklmnopqrstuvwxyz) - examples: 'island', 'aaaaaa', 'jhgcfj'
Each seed is to give a unique island (i.e. no two seeds will give the same output)
No output is to be a transformation of another seed's output. That's translation, reflection, rotation, scaling or any combination thereof.
Using the same seed should always give the same output
Output: 600px by 600px image

A valid island is drawn using a single line, which:

forms a closed loop
is 1px thick with no smoothing, blurring etc.
is continuous (i.e. after drawing a pixel the next pixel will be in one of the 8 adjoining spaces that isn't occupied)
does not cross itself at any point
does not leave the boundaries of the image
is black (#000), on a background of white (#FFF)
has no lines of reflective symmetry
must enclose white space

Source code has a limit of 500 bytes.
Aside from that, popularity decides; most votes wins.

I think that, in this case, [tag:popularity-contest] is being used as a cover for an incomplete spec. I do think you're on to something here - I haven't seen many challenges that require a seed as input and something cool as output. The part that really needs work is "there are no specific criteria". If you want community's help settling on some solid criteria, you could post your question to the Sandbox.

This seems way too broad and is also more of an art contest than a programming contest. As it stands, almost any code which produces some blob of colour could be sold as an "island".

You might draw some inspiration from Polygonal Map Generation for Games. The entire process may be a little too broad, but you could narrow it down.

Maybe not an exact duplicate of Paralell projected voxel terrain generator, but anyone editing to make it less broad should take a look at that one to avoid making it a duplicate.

Thanks for your comments, I have edited the question and tried to improve the criteria.

What exactly approximates the outline of a natural island? They come in all shapes and sizes, from specks in the water to entire continents. It seems like almost any simple closed loop fits. Right now this just reads like "draw a black line that loops and doesn't cross" to me.

I like this question! I voted to close so we don't have people answering it since it seems like we are still discussing the spec. This question could have benefited from the sandbox, but I think we can still improve it and reopen it.

Overhauled the rules and changed to code golf

i really think this should be a popularity contest.

@proudhaskeller why? wouldn't that make it an art contest? With tight constraints, I think it might work well as code-golf. I also thought we were supposed to avoid popularity contests when possible.

@chilemagic never mind what others think, what do you think? I think the very nature of the question "draw an island" is subjective. People are likely to vote for short code that draws a realistic island (if it's a codegolf, someone will draw a star and people will complain it doesn't look like an island.) I have frequently advocated changing popularity contest to codegolf, but for certain graphical questions I think an exception should be made.

@steveverrill a star would break the "has no lines of reflective symmetry" rule. If people are going to vote for short code that draws a realistic island, then I think it would make sense to make code-golf and the requirements for what constitutes a realistic island would have to be clearly laid out (which I think the current rules may already be enough to avoid allowing loophole islands). If the question is to generically "draw an island", it becomes too broad/an art contest. It would make sense to me to make it code-golf and I wanted to understand the perspective for a popularity-contest.

@chilemagic, the current rules have some easy loopholes. As a code golf this would need a major overhaul to generate anything which looks remotely natural, and as a pop-con it's still so loosely specified that it looks more like an art contest than a programming contest.

@PeterTaylor that makes sense. Maybe there could be a byte limit to make it more of a programming challenge, and let the popularity decide which island looks the most natural. Just trying to throw out some thoughts, I would like to see some nicely generated islands though!

@chilemagic that sounds a very good idea. If others think so too, I would recommend  about 500 bytes.

Added byte limit

Is there anything I can do to have this taken off hold or is the question dead?

BBC basic
Here's a very simple algorithm, which could be refined for more realism. If there are further changes in the rules I'm willing to change / delete.
take the 6 character string and add }@ to ensure asymmetry (this particular choice of characters gives islands that vaguely resemble Antarctica)
draw a line that connects 8 points at 45 degree intervals, with distance from the centre determined by the ASCII code.
  INPUT a$
  a$=a$+"}@"
  MOVE 364,300
  FOR i=1 TO 8
    r=4*ASC(MID$(a$,i))-192
    DRAW 300+r*COS(i*PI/4),300+r*SIN(i*PI/4)
  NEXT

@BetaDecay Black-on-white is required by the spec.

There are still outputs who are variations of each other - @}zzaa and @}aazz are reflections of each other

@proudhaskeller @ and } are not allowed in the input. That is why they were chosen to be added to the input before plotting.

Algoid
Algoid is a language similar to LOGO or Turtle and is almost entirely graphics based.
algo.hide()
algo.setBgColor(15)
algo.setStroke(1)
algo.setColor(0)
algo.goTo(-400,100)
set seed="put seed here".lower()
set letters = "abcdefghijklmnopqrstuvwxyz"
set sides=seed.length()
for (set i=0;i<sides-(sides/6);i++) {
    set letter = seed.getChar(i%seed.length())
    set value = letters.indexOf(letter)*5
    set turn = 360/seed.length()
    algo.go(math.sin(value)*(1500/seed.length()))
    algo.turnRight(turn)
}
algo.lineTo(-400,100)

Seed: supercalifragilisticexpialiadocious even though the sound of it is rather quite atrocious

Seed: islands in the stream