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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:34:07+00:00 2026-05-18T20:34:07+00:00

i have a square with start and finish points, also places where i can’t

  • 0

i have a square with start and finish points, also places where i can’t go. And my program must find a way to reach finish:

ar_galima([], _, _):-!.
ar_galima([Prad|Galas],Kelias, X) :- not(Prad == X), not(member(X, Kelias)), ar_galima(Galas, Kelias, X). 

gener(Stac_M, Stac_K, k(A,B), k(Y,B)) :-  Y is A + 1, Y > 0, Y =< Stac_M, B =< Stac_K.
gener(Stac_M, Stac_K, k(A,B), k(Y,B)) :-  Y is A - 1, Y > 0, Y =< Stac_M, B =< Stac_K.
gener(Stac_M, Stac_K, k(A,B), k(A,Y)) :-  Y is B + 1, Y > 0, Y =< Stac_K, A =< Stac_M.
gener(Stac_M, Stac_K, k(A,B), k(A,Y)) :-  Y is B - 1, Y > 0, Y =< Stac_K, A =< Stac_M.

paieska(_, _,_,Tikslas,Tikslas,[], _):-!.
paieska(Stac_M, Stac_K, Draudziama, Prad, Tikslas, [K|Kelias], Kelias2) :- 
      gener(Stac_M, Stac_K, Prad, K), ar_galima(Draudziama, Kelias2, K), 
      paieska(Stac_M, Stac_K, Draudziama, K, Tikslas, Kelias, [K|Kelias2]).

trasa(Ilgis, Aukstis, Draudziama, k(X,Y), Tikslas, Kelias) :-
      paieska(Ilgis,Aukstis, Draudziama, k(X,Y), Tikslas,Kelias, []).

i find routes to finish and now i’m stuck outputing the route (a list) into 2 dimension table in terminal (well, a simple graphic show of the route).

example of list to output:X = [k(2, 1), k(3, 1), k(4, 1), k(4, 2), k(4, 3), k(4, 4)] ;

Could someone suggesst me how should i output a 2 dimension table into terminal?

EDIT:

X should be printed:

 + + + *
 + + + *
 + + + *
 + * * *

print perdicate could look like this:

printTable(N, M, X) :- …

where N is number of rows, M is number of columns and X is list of coordinates.

  • 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-18T20:34:08+00:00Added an answer on May 18, 2026 at 8:34 pm

    You can do it with something like this:

    print_table(H, W, L):-
      succ(W, W1),
      print_table(4, 1, H, W1, L).
    
    print_table(1, W, _, W, _):- !.
    print_table(Y, W, H, W, L):-
      succ(NY, Y),
      nl,
      !,
      print_table(NY, 1, H, W, L).
    print_table(Y, X, H, W, L):-
      (member(k(X, Y), L)->C='* ';C='+ '),
      write(C),
      succ(X, NX),
      !,
      print_table(Y, NX, H, W, L).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a square with start and finish points, also places where i can't
I have a square div (called square) and trying to put another div (caption)
I have a square 400 x 400 with a plane projection attached to it
I have 3 square. smallest square s3 is inside s2. s2 is in side
Lets say I have a non-square image.. If I increment the width and I
I have such a grid square disk. Every grid represents a pixel. My aim
I have created an array square(40) as picturebox. I have to assign 40 picture
I have text next to a image (red square for now). When i make
I have a MKMapView with a square overlay described as: CLLocationCoordinate2D coordsBg[5]={ CLLocationCoordinate2DMake(31.750865,35.180882), CLLocationCoordinate2DMake(31.740331,35.180882),
I have this code and I want to have my button as a square,

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.