<commit_before><commit_msg>CountDiv.java<commit_after>package org.tinywind.codility.lesson5;

/**
 * https://codility.com/programmers/task/count_div/
 * Compute number of integers divisible by k in range [a..b].
 *
 * @author tinywind
 *         score: 100
 */
public class CountDiv {
    public static void main(String[] args) {
        p(6, 11, 2);
        p(0, 1, 11);
        p(0, 2000000000, 1);
    }

    private static void p(int A, int B, int K) {
        System.out.println("A(" + A + ") B(" + B + ") K(" + K + ") : " + solution(A, B, K));
    }

    private static int solution(int A, int B, int K) {
        int result = 0;

        if (B > 0)
            result += B / K;
        else if (B == 0)
            result += 1;
        else
            result -= (B + 1) / K;

        if (A > 0)
            result -= (A - 1) / K;
        else if (A == 0)
            result += 1;
        else
            result -= A / K;

        if (A == 0 && B == 0)
            result -= 1;

        return result;
    }
}
{'fraction_non_alphanumeric': 0.1553588987217306, 'fraction_numerical': 0.035398230088495575, 'mean_word_length': 1.453012048192771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '971438', 'n_tokens_mistral': 378, 'n_tokens_neox': 338, 'n_words': 107}