LDC 0.9.2 release candidate

bearophile bearophileHUGS at lycos.com
Sun Feb 14 10:47:20 PST 2010


DMD/D1/Phobos + dlibs:

import std.conv: toInt;
import d.string: xsplit;
import d.xio: xfile;
import d.func: max, select, map, putr, xrange, pop;

void main() {
    string line;
    auto triangle = select(map(&toInt, line.xsplit()), line, xfile("triangle.txt"));

    while (triangle.length > 1) {
        auto last_row = triangle[$ - 1];
        foreach (i; xrange(triangle.length - 1))
            triangle[$ - 2][i] += max(last_row[i], last_row[i + 1]);
        triangle.pop();
    }

    putr(triangle[0][0]);
}

Bye,
bearophile



More information about the Digitalmars-d mailing list