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

  • Home
  • SEARCH
  • 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 7759599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:40:16+00:00 2026-06-01T13:40:16+00:00

I am trying to write a prolog program that can find the tiles that

  • 0

I am trying to write a prolog program that can find the tiles that are completely surrounded by b or w in a 2D-array.

For example, given a dataset like this:

[
    [b, w, +, +],
    [w, +, w, b],
    [+, w, b, +],
    [+, +, +, b],
]

It would return another Variable containing:

[
    [-, -, -, -],
    [-, w, -, -],
    [-, -, -, b],
    [-, -, -, -],
]

That is, it replaced all the + which were completely surrounded with b with a b, and the same for those surrounded by a w, and replaced everything else with a -.

Can anyone give any ideas on how to build a program to do this?

  • 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-01T13:40:18+00:00Added an answer on June 1, 2026 at 1:40 pm

    This might help: it takes the representation you gave, and gives back a list whose elements are each of the form [ColumnIndex, RowIndex, Value]. You can then use member to find an element at a particular row/column.

    encodearray( A, AA ) :- ( A, 0, 0, AA ).
    encodearray( [], _, _, [] ).
    encodearray( [[]|A], _, R, AA ) :- R1 is R+1, encodeArray( A, 0, R1, AA ).
    encodearray( [[A|B]|X], C, R, [[C,R,A]|AA] ) :- C1 is C+1, encodeArray( [B|X], C1, R, AA ).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a Prolog program that will print out the male
I'm trying to write a prolog program that behaves in the following fashion: it
I'm trying to make program in prolog that will do something like this: diffSet([a,b,c,d],
I'm trying write a C program that sends an UDP packet to a given
I'm trying to write a program in Prolog, which will insert an element into
Trying to write a chat, like on facebook, I wondered if two clients can
I'm trying to write a program that converts from Mayan to Arabic numerals and
I'm trying write a code that can the set property value through the lambda
I'm trying to write a simple maze search program in prolog, before I add
I was trying this palindrome program in prolog, the logic works but write operation

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.