Sha256: 0cf9573f53231fbc766c7500ccfc14957288ebbb08d74e95ce9980c66e52b21d

Contents?: true

Size: 1.27 KB

Versions: 284

Compression:

Stored size: 1.27 KB

Contents

import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Arrays.stream;

enum Digit {

    ZERO(asList(" _ ",
                "| |",
                "|_|")),

    ONE(asList("   ",
               "  |",
               "  |")),

    TWO(asList(" _ ",
               " _|",
               "|_ ")),

    THREE(asList(" _ ",
                 " _|",
                 " _|")),

    FOUR(asList("   ",
                "|_|",
                "  |")),

    FIVE(asList(" _ ",
                "|_ ",
                " _|")),

    SIX(asList(" _ ",
               "|_ ",
               "|_|")),

    SEVEN(asList(" _ ",
                 "  |",
                 "  |")),

    EIGHT(asList(" _ ",
                 "|_|",
                 "|_|")),

    NINE(asList(" _ ",
                "|_|",
                " _|"));

    private final List<String> ssdRepresentation;

    Digit(List<String> ssd) {
        this.ssdRepresentation = ssd;
    }

    static String fromSsdConfiguration(final List<String> ssdConfiguration) {
        return stream(values())
                .filter(digit -> digit.ssdRepresentation.equals(ssdConfiguration))
                .map(Digit::ordinal)
                .map(Object::toString)
                .findFirst()
                .orElse("?");
    }

}

Version data entries

284 entries across 284 versions & 1 rubygems

Version Path
trackler-2.0.8.15 tracks/java/exercises/ocr-numbers/src/example/java/Digit.java
trackler-2.0.8.14 tracks/java/exercises/ocr-numbers/src/example/java/Digit.java
trackler-2.0.8.13 tracks/java/exercises/ocr-numbers/src/example/java/Digit.java
trackler-2.0.8.12 tracks/java/exercises/ocr-numbers/src/example/java/Digit.java