package humaneval.buggy;

import java.util.ArrayList;
import java.util.Collections;

/* Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings and never an array of numbers,
and it may contain duplicates.
The order of the list should be ascending by length of each word, and you
should return the list sorted by that rule.
If two words have the same length, sort the list alphabetically.
The function should return a list of strings in sorted order.
You may assume that all words will have the same length.
For example:
assert list_sort(["aa", "a", "aaa"]) => ["aa"]
assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"] */

public class SORTED_LIST_SUM {
    public static ArrayList<String> sorted_list_sum(ArrayList<String> lst) {
        ArrayList<String> result = new ArrayList<String>();
        for (String str : lst) {
            if (str.length() % 2 == 1) continue;
            result.add(str);
        }

        Collections.sort(
            result,
            (s1, s2) -> s1.length() - s2.length()
        );

        return result;
    }
}

package humaneval;

import java.util.ArrayList;
import java.util.Arrays;

public class TEST_SORTED_LIST_SUM {
    @org.junit.Test(timeout = 3000)
    public void test_0() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("aa", "a", "aaa"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>(Arrays.asList("aa"))
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_1() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("school", "AI", "asdf", "b"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>(Arrays.asList("AI", "asdf", "school"))
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_2() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("d", "b", "c", "a"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>()
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_3() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("d", "dcba", "abcd", "a"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>(Arrays.asList("abcd", "dcba"))
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_4() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("AI", "ai", "au"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>(Arrays.asList("AI", "ai", "au"))
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_5() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("a", "b", "b", "c", "c", "a"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>()
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_6() throws java.lang.Exception {
        ArrayList<String> result = humaneval.buggy.SORTED_LIST_SUM.sorted_list_sum(
            new ArrayList<String>(Arrays.asList("aaaa", "bbbb", "dd", "cc"))
        );
        org.junit.Assert.assertEquals(
            result, new ArrayList<String>(Arrays.asList("cc", "dd", "aaaa", "bbbb"))
        );
    }
}


package humaneval.buggy;

import java.util.ArrayList;

public class PRIME_FIB {
    public static boolean is_prime(int n) {
        if (n < 2)
            return false;
        for (int i = 2; i < (int)Math.sqrt(n) + 1; i += 1){
            if (n % i == 0)
                return false;
        }
        return true;
    }

    public static int prime_fib(int n){
        ArrayList<Integer> fib = new ArrayList<Integer>();
        fib.add(0);
        fib.add(1);

        while (true) {
            int len = fib.size();
            fib.add(fib.get(len - 1) + fib.get(len));
            if (is_prime(fib.get(len - 1)))
                n -= 1;
            if (n == 0)
                return fib.get(fib.size() - 1);
        }
    }
}

package humaneval;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
public class TEST_PRIME_FIB {
    @org.junit.Test(timeout = 1000)
    public void test_0() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(1);
        org.junit.Assert.assertEquals(
            result, 2
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_1() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(2);
        org.junit.Assert.assertEquals(
            result, 3
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_2() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(3);
        org.junit.Assert.assertEquals(
            result, 5
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_3() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(4);
        org.junit.Assert.assertEquals(
            result, 13
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_4() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(5);
        org.junit.Assert.assertEquals(
            result, 89
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_5() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(6);
        org.junit.Assert.assertEquals(
            result, 233
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_6() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(7);
        org.junit.Assert.assertEquals(
            result, 1597
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_7() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(8);
        org.junit.Assert.assertEquals(
            result, 28657
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_8() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(9);
        org.junit.Assert.assertEquals(
            result, 514229
        );
    }
    @org.junit.Test(timeout = 1000)
    public void test_9() throws java.lang.Exception {
        int result = humaneval.buggy.PRIME_FIB.prime_fib(10);
        org.junit.Assert.assertEquals(
            result, 433494437
        );
    }
}