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 635453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:24:23+00:00 2026-05-13T20:24:23+00:00

For example, in the following layout: . 8 * * * . * *

  • 0

For example, in the following layout:

.    8 * * *

.    * * * *

.    * 8 * *

.    * * * *

All of the cards that are face down are indicated by a *. The pairs of 8 which are face up are at coordinates (1,1) and (2,3).

I have done my 2D array and now i’m stuck in printing the *. The one i’ve done is only printing * * * *. i have no idea how to print the 8 inside the array.

Any help?

public static void Shuffles(){

    int[][]a = new int[4][4];
    for (int i =0; i<4;i++){
        for (int j=0;j<4;j++){

            System.out.print("*");
            System.out.print(" ");
        }
        System.out.println("");
        System.out.println("");
    }


}

public static void main(String[] args) {

    List<Integer> randoms = new ArrayList<Integer>();
    Random randomizer = new Random();
    int [][] memory = new int[4][4];

    for(int i = 0; i < 8; ) {
      int r = randomizer.nextInt(8)+1;
      if(!randoms.contains(r)) {
        randoms.add(r);
        ++i;
      }
    }

    List<Integer> clonedList = new ArrayList<Integer>();
    clonedList.addAll(randoms);
    Collections.shuffle(clonedList);
    randoms.addAll(clonedList);

    for(int i=0; i < 4; i++){
            memory[0][i] = randoms.get(i);
            memory[1][i] = randoms.get(i+4);
            memory[2][i] = randoms.get(i+8);
            memory[3][i] = randoms.get(i+12);
    }

    for (int i =0; i<4;i++){
        for (int j=0;j<4;j++){

            System.out.print(memory[i][j]);
            System.out.print(" ");
        }
        System.out.println("");
        System.out.println("");
    }


    int x1,y1,x2,y2;
    Scanner input = new Scanner(System.in);

    System.out.print("Please enter the coordinate [x1] : ");
    x1 = input.nextInt();
    while((x1<1) || (x1>4)){
        System.out.print("Invalid coordinate!! Re-enter [x1] : ");
        x1 = input.nextInt();
    }

    System.out.print("Please enter the coordinate [y1] : ");
    y1 = input.nextInt();
    while((y1<1) || (y1>4)){
        System.out.print("Invalid coordinate!! Re-enter [y1] : ");
        y1 = input.nextInt();
    }

    System.out.print("Please enter the coordinate [x2] : ");
    x2 = input.nextInt();
    while((x2<1) || (x2>4)){
        System.out.print("Invalid coordinate!! Re-enter [x2] : ");
        x2 = input.nextInt();
    }

    System.out.print("Please enter the coordinate [y2] : ");
    y2 = input.nextInt();
    while((y2<1) || (y2>4)){
        System.out.print("Invalid coordinate!! Re-enter [y2] : ");
        y2 = input.nextInt();
    }

    x1=x1-1;
    y1=y1-1;
    x2=x2-1;
    y2=y2-1;

    if(memory[x1][y1] != memory[x2][y2]){
        Shuffles();
    }

}
}

this is wad i’ve done so far…

  • 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-05-13T20:24:23+00:00Added an answer on May 13, 2026 at 8:24 pm

    Are you looking for this?

    
    // k is the number to display
    //a[][] is the array

    public static void Shuffles(int k, int[][]a)
    {
    for (int i =0; i<4;i++)
    {
    for (int j=0;j<4;j++)
    {
    if(a[i][j] == k)
    {
    System.out.print(a[i][j]);
    }
    else
    {
    System.out.print("*");
    }
    System.out.print(" ");
    }
    System.out.println("");
    System.out.println("");
    }
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi All I have followed the following example http://www.google.com/codesearch#search/&q=NumberFormattingTextWatcher&exact_package=android&type=cs I have CurrencyTextWatcher as a
I have the following svn layout: org.example -- trunk ---- org.example.core ---- org.example.test ----
First of all, have a look at this example of the layout I'm trying
If you have the following example, how can you query out all the strings
JSFIDDLE EXAMPLE BELOW I want to make the following CSS layout and currently im
Example: Suppose in the following example I want to match strings that do not
In the following example, I have a custom JComponent being drawn on green background,
Take the following example, I have a class public class SomeItem { public string
I have the following basic layout: <div id=sidebar style=float: left; width: 250px; display block;></div>
Given the following example layout: test/ test.py formats/ __init__.py format_a.py format_b.py What I try

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.