Sha256: 0a346dd60b884603905945e080334aef7f028514d2ce22507ab9ae383aac7d31

Contents?: true

Size: 663 Bytes

Versions: 181

Compression:

Stored size: 663 Bytes

Contents

module raindrops;

import std.array : appender;
import std.format : formattedWrite;

string convert(int n) {
    auto builder = appender!string();
    if (isPling(n) || isPlang(n) || isPlong(n)) {
        if (isPling(n)) {
            builder.put("Pling");
        }
        if (isPlang(n)) {
            builder.put("Plang");
        }
        if (isPlong(n)) {
            builder.put("Plong");
        }
    } else {
        builder.formattedWrite("%s", n);
    }

    return builder.data;
}

private bool isPling(int n) {
    return n % 3 == 0;
}

private bool isPlang(int n) {
    return n % 5 == 0;
}

private bool isPlong(int n) {
    return n % 7 == 0;
}

Version data entries

181 entries across 181 versions & 1 rubygems

Version Path
trackler-2.0.8.20 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.19 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.18 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.17 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.16 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.15 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.14 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.13 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.12 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.11 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.10 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.9 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.8 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.7 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.6 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.5 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.4 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.3 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.2 tracks/dlang/exercises/raindrops/raindrops_example.d
trackler-2.0.8.1 tracks/dlang/exercises/raindrops/raindrops_example.d