Sort by

recency

|

228 Discussions

|

  • + 0 comments

    I tried joining Online Quran Classes For Adults after struggling to keep a consistent schedule for learning at home. The experience made it much easier to follow lessons at my own pace, and I could practice with clear guidance. It’s refreshing to see classes designed for adult learners that focus on practical understanding and daily application.

  • + 0 comments

    I think the templates need an update or the problem description needs to be adjusted.

  • + 0 comments

    import java.util.*;

    public class Solution {

    public static int minimum_index(int[] seq) {
        if (seq.length == 0) {
            throw new IllegalArgumentException("Cannot get the minimum value index from an empty sequence");
        }
        int min_idx = 0;
        for (int i = 1; i < seq.length; ++i) {
            if (seq[i] < seq[min_idx]) {
                min_idx = i;
            }
        }
        return min_idx;
    }
    
    
    public static void TestWithEmptyArray() {
        try {
            int[] seq = TestDataEmptyArray.get_array();
            int result = minimum_index(seq);
        } catch (IllegalArgumentException e) {
            return;
        }
        throw new AssertionError("Exception wasn't thrown as expected");
    }
    
    public static void TestWithUniqueValues() {
        int[] seq = TestDataUniqueValues.get_array();
        if (seq.length < 2) {
            throw new AssertionError("less than 2 elements in the array");
        }
    
        Integer[] tmp = new Integer[seq.length];
        for (int i = 0; i < seq.length; ++i) {
            tmp[i] = Integer.valueOf(seq[i]);
        }
        if (!((new LinkedHashSet<Integer>(Arrays.asList(tmp))).size() == seq.length)) {
            throw new AssertionError("not all values are unique");
        }
    
        int expected_result = TestDataUniqueValues.get_expected_result();
        int result = minimum_index(seq);
        if (result != expected_result) {
            throw new AssertionError("result is different than the expected result");
        }
    }
    
    public static void TestWithExactlyTwoDifferentMinimums() {
        int[] seq = TestDataExactlyTwoDifferentMinimums.get_array();
        if (seq.length < 2) {
            throw new AssertionError("less than 2 elements in the array");
        }
    
        int[] tmp = seq.clone();
        Arrays.sort(tmp);
        if (!(tmp[0] == tmp[1] && (tmp.length == 2 || tmp[1] < tmp[2]))) {
            throw new AssertionError("there are not exactly two minimums in the array");
        }
    
        int expected_result = TestDataExactlyTwoDifferentMinimums.get_expected_result();
        int result = minimum_index(seq);
        if (result != expected_result) {
            throw new AssertionError("result is different than the expected result");
        }
    }
    
    public static void main(String[] args) {
        TestWithEmptyArray();
        TestWithUniqueValues();
        TestWithExactlyTwoDifferentMinimums();
        System.out.println("OK");
    }
    

    } **

  • + 0 comments

    'use strict';

    process.stdin.resume(); process.stdin.setEncoding('utf-8');

    let inputString: string = ''; let inputLines: string[] = []; let currentLine: number = 0;

    process.stdin.on('data', function(inputStdin: string): void { inputString += inputStdin; });

    process.stdin.on('end', function(): void { inputLines = inputString.split('\n'); inputString = '';

    main();
    

    });

    function readLine(): string { return inputLines[currentLine++]; }

    class TestDataEmptyArray { static get_array(): number[] { return []; } }

    class TestDataUniqueValues { static get_array(): number[] { return [3, 1, 2]; }

    static get_expected_result(): number {
        return 1;
    }
    

    }

    class TestDataExactlyTwoDifferentMinimums { static get_array(): number[] { return [2, 1, 3, 1]; }

    static get_expected_result(): number {
        return 1;
    }
    

    }

    function minimum_index(seq: number[]): number { if (seq.length === 0) { throw new Error("Cannot get the minimum value index from an empty sequence"); } let min_idx: number = 0; for (let i: number = 1; i < seq.length; i++) { if (seq[i] < seq[min_idx]) { min_idx = i; } } return min_idx; }

    function TestWithEmptyArray(): void { try { const seq: number[] = TestDataEmptyArray.get_array(); const result: number = minimum_index(seq); } catch (e) { return; } throw new Error("Exception wasn't thrown as expected"); }

    function TestWithUniqueValues(): void { const seq: number[] = TestDataUniqueValues.get_array(); const result: number = minimum_index(seq); if (result !== TestDataUniqueValues.get_expected_result()) { throw new Error("Result doesn't match the expected value for unique values array"); } }

    function TestWithExactlyTwoDifferentMinimums(): void { const seq: number[] = TestDataExactlyTwoDifferentMinimums.get_array(); const result: number = minimum_index(seq); if (result !== TestDataExactlyTwoDifferentMinimums.get_expected_result()) { throw new Error("Result doesn't match the expected value for array with two minimums"); } }

    function main(): void { try { TestWithEmptyArray(); TestWithUniqueValues(); TestWithExactlyTwoDifferentMinimums(); console.log("OK"); } catch (e) { console.log((e as Error).message); } }

  • + 0 comments
    class TestDataEmptyArray():
        def get_array():
            return []
    
    class TestDataUniqueValues():
        def get_array():
            return [11, 7]
        def get_expected_result():
            return 1
    
    class TestDataExactlyTwoDifferentMinimums():
        def get_array():
            return [5, 5]
        def get_expected_result():
            return 0