<commit_before>﻿using System.Linq;

namespace Codility.Katas.Lessons
{
    // Prefix Sums - https://codility.com/programmers/lessons/3/
    public class PerfixSums
    {
        // Count Div (Painless / Easy) - https://codility.com/programmers/task/count_div/
        // result 100% - https://codility.com/demo/results/trainingHDGERS-UT2/
        public static int solutionCountDiv(int A, int B, int K)
        {
            int result1 = (B / K);
            int result2 = ((A % K) != 0) ? (A / K) : ((A - 1) / K);
            int result3 = 0;

            switch (A)
            {
                case 0:
                    result3 = (B / K) - (A / K) + 1;
                    break;
                default:
                    result3 = result1 - result2;
                    break;
            }

            return result3;
        }

        // Passing Cars (Painless / Easy) - https://codility.com/programmers/task/passing_cars/
        // result 100% - https://codility.com/demo/results/trainingF54EKW-A9G/<commit_msg>updated lesson 5<commit_after>﻿using System.Linq;

namespace Codility.Katas.Lessons
{
    // Prefix Sums - https://codility.com/programmers/lessons/3/
    public class PerfixSums
    {
        public static int solutionCountDiv(int A, int B, int K) {
            int result = 0;
            int currentNumber = A;

            if (K == 1) {
                result = B - A + 1;
            } else {
                while (currentNumber <= B && currentNumber >= 0)
                {
                    if (currentNumber % K == 0) {
                        result++;
                        currentNumber += K;
                    } else {
                        currentNumber++;
                    }
                }
            }

            return result;
        }


        // --

        // Count Div (Painless / Easy) - https://codility.com/programmers/task/count_div/
        // result 100% - https://codility.com/demo/results/trainingHDGERS-UT2/
        public static int solutionCountDiv1(int A, int B, int K)
        {
            int result1 = (B / K);
            int result2 = ((A % K) != 0) ? (A / K) : ((A - 1) / K);
            int result3 = 0;

            switch (A)
            {
                case 0:
                    result3 = (B / K) - (A / K) + 1;
                    break;
                default:
                    result3 = result1 - result2;
                    break;
            }

            return result3;
        }

        // Passing Cars (Painless / Easy) - https://codility.com/programmers/task/passing_cars/
        // result 100% - https://codility.com/demo/results/trainingF54EKW-A9G/
{'fraction_non_alphanumeric': 0.1182876455125798, 'fraction_numerical': 0.020653398422831395, 'mean_word_length': 1.1380417335473516, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '7310114', 'n_tokens_mistral': 828, 'n_tokens_neox': 756, 'n_words': 180}