Sha256: e241dbaa4ef87e1fa8b8ad77b65760fa833eb8ecd4f5ef1e95659deba7ed408a

Contents?: true

Size: 404 Bytes

Versions: 290

Compression:

Stored size: 404 Bytes

Contents

import java.util.Arrays;

public class Hexadecimal {
    private static final String HEXES = "0123456789abcdef";
    public static int toDecimal(String input){
        boolean  isHex = input.matches("^[0-9a-f]+");
        if (!isHex) return 0;
        return Arrays.stream(input.split(""))
                .map(HEXES::indexOf)
                .reduce(0, (decimal, hex) -> decimal * 16 + hex);

    }
}


Version data entries

290 entries across 290 versions & 1 rubygems

Version Path
trackler-2.2.1.72 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.71 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.70 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.69 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.68 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.67 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.66 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.65 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.64 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.63 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.62 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.61 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.60 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.59 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.58 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.57 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.56 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.55 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.54 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java
trackler-2.2.1.53 tracks/java/exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java