1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lyrx [107]
2 years ago
14

Using above information, Write a prolog program to answer the following queries. Please note that you cannot simply answer these

queries with only facts, you should answer then using facts and rules
Computers and Technology
1 answer:
vampirchik [111]2 years ago
7 0

Using the computational knowledge in python it is possible to write a code that uses the functions to make a  a prolog program to answer the following queries

<h3>Writting the code in python:</h3>

<em>valid([]).</em>

<em>valid([Head|Tail]) :-</em>

<em>fd_all_different(Head),</em>

<em>valid(Tail).</em>

<em />

<em>sudoku(Puzzle, Solution) :-</em>

<em>Solution = Puzzle,</em>

<em>Puzzle = [S11, S12, S13, S14,</em>

<em>S21, S22, S23, S24,</em>

<em>S31, S32, S33, S34,</em>

<em>S41, S42, S43, S44],</em>

<em />

<em>fd_domain(Solution, 1, 4),</em>

<em />

<em>Row1 = [S11, S12, S13, S14],</em>

<em>Row2 = [S21, S22, S23, S24],</em>

<em>Row3 = [S31, S32, S33, S34],</em>

<em>Row4 = [S41, S42, S43, S44],</em>

<em />

<em>Col1 = [S11, S21, S31, S41],</em>

<em>Col2 = [S12, S22, S32, S42],</em>

<em>Col3 = [S13, S23, S33, S43],</em>

<em>Col4 = [S14, S24, S34, S44],</em>

<em />

<em>Square1 = [S11, S12, S21, S22],</em>

<em>Square2 = [S13, S14, S23, S24],</em>

<em>Square3 = [S31, S32, S41, S42],</em>

<em>Square4 = [S33, S34, S43, S44],</em>

<em />

<em>valid([Row1, Row2, Row3, Row4,</em>

<em>Col1, Col2, Col3, Col4,</em>

<em>Square1, Square2, Square3, Square4]).</em>

<em />

<em>| ?- sudoku([_, 4, 3, 2,</em>

<em>3, _, _, _,</em>

<em>4, 1, _, _,</em>

<em>_, _, 4, 1],</em>

<em>Solution).</em>

<em>Solution = [1,4,3,2,3,2,1,4,4,1,2,3,2,3,4,1]</em>

<em>yes</em>

See more about python at brainly.com/question/18502436

#SPJ1

You might be interested in
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
Gekata [30.6K]

Answer:

# include <iostream>

#include<stdio.h>

using namespace std;

bool IsLeapYear(int y)

int main()

{

int y;

cout<<"Enter the Year to check Leap or Not"<<endl;

cin>>y;

IsLeapYear(int y);

getch();

}

bool IsLeapYear(int y)

{

if (y%4==0)

{

   if (y%100==0)

    {

         if (y%400==0 )

         {

          cout<"The year is leap Year";

         }

         else

         {

         cout<<" The year is not Leap Year";

         }

     }

     else

     {

     cout<<"The year is Leap Year" ;

     }

}    

else

{

cout<<"The year is not Leap Year";

}    

}

Explanation:

In this program a function has been defined named as IfLeapYear, to check that whether the entered year is leap year or not. An year taken as integer data type named as y to enter the year to check. If the year is divisible by 4 but not divisible by 100 is the leap year. If the year is divisible by 4, divisible by 100 and also divisible by 400 is the century year and is also the leap year.

To check all the statements, Nested if-else conditions has been used to check multiple requirements of the leap year.

6 0
3 years ago
Read 2 more answers
Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End each line with a newline.
Hatshy [7]

Answer:

Hi there! This is a good question to grasp the concepts of object-oriented classes, encapsulation and abstraction of classes and their properties in Java. Please find the details below.

Explanation:

You can implement the solution by calling the getNumKids() function of the personInfo object or directly using the personKid input from the user to display the initial number of kids for the user. Then, calling the incNumKids() increases the kids count. Finally, displaying the new number of kids is done by invoking the getNumKids() method of the PersonInfo object that returns the private property of numKids to the user. The user cannot access this property without the get and set methods.

CallPersonInfo.java =====

import java.util.Scanner;

public class CallPersonInfo {

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

PersonInfo person1 = new PersonInfo();

int personsKid;

personsKid = scnr.nextInt();

person1.setNumKids(personsKid);

System.out.println("Kids: " + personKid); // or person1.getNumKids();

   person1.incNumKids();

   System.out.println("New baby, kids now: " + personInfoObject.getNumKids());

 

}

}

You can also write the code in the same file as PersonInfo.java as below.

import java.util.Scanner;

class PersonInfo {

 private int numKids;

 public void setNumKids(int setPersonsKids) {

   numKids = setPersonsKids;

 }

 public void incNumKids() {

   numKids = numKids + 1;

 }

 public int getNumKids() {

   return numKids;

 }

 public static void main(String args[]) {

   System.out.println("Enter number of kids: ");

   Scanner scan = new Scanner(System.in);

   int num_kids = scan.nextInt();

   PersonInfo personInfoObject = new PersonInfo();

   personInfoObject.setNumKids(num_kids);

   System.out.println("Kids: " + num_kids);

   personInfoObject.incNumKids();

   System.out.println("New baby, kids now: " + personInfoObject.getNumKids());

 }

}

5 0
3 years ago
We have an array of Rectangles called rectangleArray and a function updateRectangle(rect) that takes a single rectangle as a par
Naddika [18.5K]

Answer:

Following are the code  

for(var k = 0; k< rectangleArray.length; k++) // iterting the loop

{

updateRectangle(rectangleArray[k]); // update the rectangle color

}  

Explanation:

  • In the given answer we have iterate over the loop will iterated until the length of rectangle array size-1
  • In every value of k, we have called the update rectangle function which changes the color of the rectangle of a rectangle class
4 0
3 years ago
Which of the following is an example of a law that governs the information IT workers may have access to in the course of their
Anit [1.1K]

Answer:

HIPAA

Explanation:

The Health Insurance Portability and Accountability Act of 1996 is a United States federal statute enacted by the 104th United States Congress and signed into law by President Bill Clinton on August 21, 1996.

6 0
3 years ago
Install hardware, install software, and convert data are the three steps found in the _____. Select one:
aev [14]

Answer:b)Conversion plan.

Explanation:Conversion plan is type of plan in which the the technique is followed by converting the data from the present system to another system's hardware and software surroundings.

The technique follows three basic steps in the conversion plan is software installation plan, hardware installation plan and conversion of data. Thus the correct option is option(b).

3 0
4 years ago
Other questions:
  • When typing in a spreadsheet cell, hitting the Tab key will bring which result?
    6·1 answer
  • Which internet site end in .com​
    10·2 answers
  • A __________ network is good for connecting computers over boundaries.
    6·2 answers
  • Help me 28pts to anyone who answer this
    5·2 answers
  • The blue bar across the top of the screen informs you of the Screen Title, or what step you are on.
    5·1 answer
  • In 4-bit two's complement representation, what is the binary encoding of the number -5?
    8·1 answer
  • What the best option if you cant show your PowerPoint presentation at all
    6·2 answers
  • Suppose the following groups are defined to shorten a system’s access control lists: – Group1: Alice, Bob, Cynthia, David, Eve –
    12·1 answer
  • E-commerce is the demand of modern society both in terms of time and money​
    7·1 answer
  • Who used the term" software" first?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!