Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:06:34+00:00 2026-06-01T17:06:34+00:00

I am developing a simple quiz app on Android. The questions in the quiz

  • 0

I am developing a simple quiz app on Android. The questions in the quiz should become more difficult as advancing in the quiz. Now, I am trying to implement a static method that takes a list of Question objects and produces (pick) a sub-list of the appropriate questions depending on the difficulty and it should be ordered (First question in the list is the simplest one). The app has 3 levels (modes) of difficulties.

Here is the method snippet:

public static List<Question> getQuestions(List<Question> availableQuestions,
                                       int quizDifficulty, int numberOfQuestion)
{
    if(availableQuestions.size() < numberOfQuestion)
        throw NotEnoughQuestionsException();

    List<Question> questions = new ArrayList<Question>(numberOfQuestion);
    if(quizDifficulty == 0) // Easy
    {
        // ...
        return questions;
    }
    else if(quizDifficulty == 2) // Hard
    {
        // ...
        return questions;   
    }
    else /*if(quizDifficulty == 1)*/ // Normal
    {
        // ...
        return questions;
    }
}

Each Question object has a field difficulty which is in range 1 (most simple) to 10 (most difficult), and this field can be access by getDifficulty() method.

As I though of a way to implement the method, I decided to make the questions’ difficulties should not exceed level 8 for Easy mode, and they should be more than level 3 in the Hard mode, and in between level 9 and level 2 in the Normal mode.

The problem is that the provided list of questions availableQuestions is not guaranteed to contain all the required levels of difficulties, for example, all the questions are in level 1.

So, my question is, what is the best idea to implement this method?


EDIT:

Here is my progress so far:

public static List<Question> getQuestions(List<Question> availableQuestions,
                                      int quizDifficulty, int numberOfQuestion)
{
    if(availableQuestions.size() < numberOfQuestion)
        throw NotEnoughQuestionsException();

    List<Question> questions = new ArrayList<Question>(numberOfQuestion);
    Map<Integer, List<Question>> map = new HashMap<Integer, List<Question>>();
    for(int i = 1; i <= 10; i++) map.put(i, new ArrayList<Question>());
    for(Question question : availableQuestions) 
        map.get(question.getDifficulty()).add(question);

    int L1 = map.get(1).size(); // number of questions with level 1
    int L2 = map.get(2).size();
    int L3 = map.get(3).size();
    int L4 = map.get(4).size();
    int L5 = map.get(5).size();
    int L6 = map.get(6).size();
    int L7 = map.get(7).size();
    int L8 = map.get(8).size();
    int L9 = map.get(9).size();
    int L10 = map.get(10).size();

    final int L1_TO_L8  = 0;
    final int L1_TO_L9  = 1;
    final int L1_TO_L10 = 2;
    final int L2_TO_L9  = 3;
    final int L2_TO_L10 = 4;
    final int L3_TO_L10 = 5;

    int status;

    if(difficulty == 0) // Easy (level 1 to level 8)
    {
        int missing = questionsCount - (L1+L2+L3+L4+L5+L6+L7+L8);
        if(missing > 0) // not enough questions in L1 through L8
        {
            if(missing - L9 > 0) // we must include all the level
            {
                status = L1_TO_L10;
            }
            else // enough questions in L1 through L9
            {
                status = L1_TO_L9;
            }
        }
        else // enough questions in L1 through L8
        {
            status = L1_TO_L8;
        }
    }
    else if(difficulty == 2) // Hard (level 3 to level 10)
    {
        int missing = questionsCount - (L3+L4+L5+L6+L7+L8+L9+L10);
        if(missing > 0) // not enough questions in L3 through L10
        {
            if(missing - L2 > 0) // we must include all the level
            {
                status = L1_TO_L10;
            }
            else // enough questions in L2 through L10
            {
                status = L2_TO_L10;
            }
        }
        else // enough questions in L3 through L10
        {
            status = L3_TO_L10;
        }
    }
    else /*if(difficulty == 1)*/ // Normal (level 2 to level 9)
    {
        int missing = questionsCount - (L2+L3+L4+L5+L6+L7+L8+L9);
        if(missing > 0) // not enough questions in L2 through L9
        {
            if(missing - L1 > 0) // we must include all the level
            {
                status = L1_TO_L10;
            }
            else // enough questions in L1 through L9
            {
                status = L1_TO_L9;
            }
        }
        else // enough questions in L2 through L9
        {
            status = L2_TO_L9;
        }
    }

    // ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:06:36+00:00Added an answer on June 1, 2026 at 5:06 pm

    I have implemented my own algorithm and it works just perfect, though it has a lot of duplicated codes:

    public static List<Question> getQuestions(List<Question> availableQuestions,
                                          int quizDifficulty, int numberOfQuestion)
    {
        if(availableQuestions.size() < numberOfQuestion)
            throw NotEnoughQuestionsException();
    
        List<Question> questions = new ArrayList<Question>(numberOfQuestion);
        Map<Integer, List<Question>> map = new HashMap<Integer, List<Question>>();
        for(int i = 1; i <= 10; i++) map.put(i, new ArrayList<Question>());
        for(Question question : availableQuestions) 
        map.get(question.getDifficulty()).add(question);
    
        int L1 = map.get(1).size(); // number of questions with level 1
        int L2 = map.get(2).size();
        int L3 = map.get(3).size();
        int L4 = map.get(4).size();
        int L5 = map.get(5).size();
        int L6 = map.get(6).size();
        int L7 = map.get(7).size();
        int L8 = map.get(8).size();
        int L9 = map.get(9).size();
        int L10 = map.get(10).size();
    
        final int L1_TO_L8  = 0;
        final int L1_TO_L9  = 1;
        final int L1_TO_L10 = 2;
        final int L2_TO_L9  = 3;
        final int L2_TO_L10 = 4;
        final int L3_TO_L10 = 5;
    
        int status;
    
        if(difficulty == 0) // Easy (level 1 to level 8)
        {
            int missing = questionsCount - (L1+L2+L3+L4+L5+L6+L7+L8);
            if(missing > 0) // not enough questions in L1 through L8
            {
                if(missing - L9 > 0) // we must include all the level
                {
                    status = L1_TO_L10;
                }
                else // enough questions in L1 through L9
                {
                    status = L1_TO_L9;
                }
            }
            else // enough questions in L1 through L8
            {
                status = L1_TO_L8;
            }
        }
        else if(difficulty == 2) // Hard (level 3 to level 10)
        {
            int missing = questionsCount - (L3+L4+L5+L6+L7+L8+L9+L10);
            if(missing > 0) // not enough questions in L3 through L10
            {
                if(missing - L2 > 0) // we must include all the level
                {
                    status = L1_TO_L10;
                }
                else // enough questions in L2 through L10
                {
                    status = L2_TO_L10;
                }
            }
            else // enough questions in L3 through L10
            {
                status = L3_TO_L10;
            }
        }
        else /*if(difficulty == 1)*/ // Normal (level 2 to level 9)
        {
            int missing = questionsCount - (L2+L3+L4+L5+L6+L7+L8+L9);
            if(missing > 0) // not enough questions in L2 through L9
            {
                if(missing - L1 > 0) // we must include all the level
                {
                    status = L1_TO_L10;
                }
                else // enough questions in L1 through L9
                {
                    status = L1_TO_L9;
                }
            }
            else // enough questions in L2 through L9
            {
                status = L2_TO_L9;
            }
        }
    
        if(status == L1_TO_L8) // Look into level 1 through level 8 only
        {
            int q = 0;
            for(int level = 1; level <= 8 && q < numberOfQuestion; level += 8 * q <= numberOfQuestion * level? 0 : 1)
            {
                if(level == 1)
                {
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                }
                else if(level == 2)
                {
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                }
                else if(level == 3)
                {
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                }
                else if(level == 4)
                {
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                }
                else if(level == 5)
                {
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 6)
                {
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 7)
                {
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 8)
                {
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
            }
        }
        else if(status == L1_TO_L9)
        {
            int q = 0;
            for(int level = 1; level <= 9 && q < numberOfQuestion; level += 9 * q <= numberOfQuestion * level? 0 : 1)
            {
                if(level == 1)
                {
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 2)
                {
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 3)
                {
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 4)
                {
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 5)
                {
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 6)
                {
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 7)
                {
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 8)
                {
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
                else if(level == 9)
                {
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 1)){q++; continue;}
                }
            }
        }
        else if(status == L2_TO_L9)
        {
            int q = 0;
            for(int level = 2; level <= 9 && q < numberOfQuestion; level += 9 * q <= numberOfQuestion * level? 0 : 1)
            {
                if(level == 2)
                {
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 3)
                {
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 4)
                {
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 5)
                {
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                }
                else if(level == 6)
                {
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 7)
                {
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 8)
                {
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 9)
                {
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
            }
        }
        else if(status == L2_TO_L10)
        {
            int q = 0;
            for(int level = 2; level <= 10 && q < numberOfQuestion; level += 10 * q <= numberOfQuestion * level? 0 : 1)
            {
                if(level == 2)
                {
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 3)
                {
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 4)
                {
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 5)
                {
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 6)
                {
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 7)
                {
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 8)
                {
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 9)
                {
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
                else if(level == 10)
                {
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 2)){q++; continue;}
                }
            }
        }
        else if(status == L3_TO_L10)
        {
            int q = 0;
            for(int level = 3; level <= 10 && q < numberOfQuestion; level += 10 * q <= numberOfQuestion * level? 0 : 1)
            {
                if(level == 3)
                {
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 4)
                {
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 5)
                {
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 6)
                {
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                }
                else if(level == 7)
                {
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                }
                else if(level == 8)
                {
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                }
                else if(level == 9)
                {
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                }
                else if(level == 10)
                {
                    if(check(readyQuestionsList, map, 10)){q++; continue;}
                    if(check(readyQuestionsList, map, 9)){q++; continue;}
                    if(check(readyQuestionsList, map, 8)){q++; continue;}
                    if(check(readyQuestionsList, map, 7)){q++; continue;}
                    if(check(readyQuestionsList, map, 6)){q++; continue;}
                    if(check(readyQuestionsList, map, 5)){q++; continue;}
                    if(check(readyQuestionsList, map, 4)){q++; continue;}
                    if(check(readyQuestionsList, map, 3)){q++; continue;}
                }
            }
        }
        else /*if(status == L1_TO_L10)*/
        {
            // same idea is implemented here
        }
        return questions;
    }
    
    private boolean check(List<Question> readyQuestionsList, Map<Integer, List<Question>> map, int level)
    {
        if(map.get(level).size() > 0 && map.get(level).get(0) != null)
        {
            readyQuestionsList.add(map.get(level).remove(0));
            return true;
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a simple quiz app on the iphone in the
I have 6 months experience with Android, developing simple UI-based applications. Now I want
i am developing very simple quiz app In viewDidLoad i am adding objects in
I'm developing a simple Qt 4 app and making my own dialog. I subclassed
Im developing a simple app (1 page) and I'm running into an interesting snag.
I'm developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding)
I am developing simple travel agent android application. When application starts it loads list
I am developing a simple app for blacberry with eclipse. I have just set
I'm developing a simple Blogging/Bookmarking platform and I'm trying to add a tags-explorer/drill-down feature
I am developing a simple application for Android in which I am using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.