SlideShare a Scribd company logo
1 of 3
Download to read offline
German University in Cairo
Faculty of Media Engineering and Technology
Dr. Nada Sharaf
Concepts of Programming Languages, Spring 2019
The Helsinki Puzzle
Deadline: 22/3/2019
Project Description
Given a square grid of size N, where the horizontal rows are numbered 1 to N from
top to bottom and the vertical columns are numbered 1 to N from left to right.
You must place a number in each cell of the N by N grid such that :-
• Each row is unique.
• Each row is exactly equal to one of the columns, however, it must not be
the column with the same index as the row.
• If X is the largest number you place in the grid, then you must also place
1,2,...,X-1, where the condition X ≤ N is satisfied.
Examples
For a 3 × 3 grid, you may have the following matrix
c1 c2 c3
r1 2 1 2
r2 2 2 1
r3 1 2 2
defined by the following equalities


c1 = r2
c2 = r3
c3 = r1


For a 4 × 4 grid, you may have the following matrix
c1 c2 c3 c4
r1 1 2 3 1
r2 3 4 4 2
r3 2 4 4 3
r4 1 3 2 1
defined by the following equalities




c1 = r4
c2 = r3
c3 = r2
c4 = r1




1
German University in Cairo
Faculty of Media Engineering and Technology
Dr. Nada Sharaf
Predicates to be added
You are going to solve this puzzle purely through Prolog. This means that you are
not allowed to use any clpfd libaries. Your solution must utilize both tech-
niques, unification and generate-and-test. You should implement all of the
following predicates.
grid_build/2
The predicate grid_build(N,M) should succeed only if M represents a grid that is
N by N such that each cell in M contains an unbound variable.
Hint: length(L,3) produces a list of 3 unbound variables.
grid_gen/2
The predicate grid_gen(N,M) should succeed only if M represents a grid that is N
by N such that each cell in M contains a value from the valid range 1 .. N.
num_gen/3
The predicate num_gen(F,L,R) should succeed only if R represents a list of con-
secutive numbers starting from F until L.
Hint: numGen(1,3,R) succeeds when R = 1,2,3 .
check_num_grid/1
The predicate check_num_grid(G) succeeds if G does not contain a number X
unless all the numbers 1 .. X-1 are there.
acceptable_permutation/2
The predicate acceptable_permutation(L,R) should succeed only if R represents
an acceptable permutation of the list L.
Hint: 2,1,3 is not an acceptable permutation of the list 1,2,3 because 3 did not
change it’s position.
2
German University in Cairo
Faculty of Media Engineering and Technology
Dr. Nada Sharaf
acceptable_distribution/1
The predicate acceptable_distribution(G) should succeed only if no row is
placed in a column with the same index and no column is placed in a row with
the same index.
row_col_match/1
The predicate row_col_match(M) should succeed only if each row is equal to a
column with a different index and each column is equal to a row with a different
index.
trans/2
The predicate trans(M,M1) should succeed only if M1 represents a transposed ver-
sion of the matrix M.
Hint: This needs to be approached through rows and columns.
distinct_rows/1
The predicate distinct_rows(M) should succeed only if M represents a matrix M
where all rows are unique.
distinct_columns/1
The predicate distinct_columns(M) should succeed only if M represents a matrix
M where all columns are unique.
helsinki/2
The predicate helsinki(N,G) should succeed only if G is a square grid of size N*N
that satisfies all the helsinki puzzle properties.
3

More Related Content

What's hot

Matrices And Application Of Matrices
Matrices And Application Of MatricesMatrices And Application Of Matrices
Matrices And Application Of Matricesmailrenuka
 
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)954 Sukatan Pelajaran Matematik (T) STPM (Baharu)
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)RAMLAH BINTI A. RANI
 
Quadratic functions power point
Quadratic functions power pointQuadratic functions power point
Quadratic functions power pointtongj
 
Poster on Graph Terminologies
Poster on Graph TerminologiesPoster on Graph Terminologies
Poster on Graph TerminologiesDeepak Tathe
 
Matrix and it's Application
Matrix and it's ApplicationMatrix and it's Application
Matrix and it's ApplicationMahmudle Hassan
 
11.6 graphing linear inequalities in two variables
11.6 graphing linear inequalities in two variables11.6 graphing linear inequalities in two variables
11.6 graphing linear inequalities in two variablesGlenSchlee
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homographyShih-Hsiang Lin
 
Presentation on inverse matrix
Presentation on inverse matrixPresentation on inverse matrix
Presentation on inverse matrixSyed Ahmed Zaki
 
Graphing Linear Inequalities
Graphing Linear InequalitiesGraphing Linear Inequalities
Graphing Linear Inequalitiesinderjyot
 
Planar graph( Algorithm and Application )
Planar graph( Algorithm and Application )Planar graph( Algorithm and Application )
Planar graph( Algorithm and Application )Abdullah Moin
 
6 4 Point Slope Form
6 4 Point Slope Form6 4 Point Slope Form
6 4 Point Slope FormKathy Favazza
 
Application of matrices in Daily life
Application of matrices in Daily lifeApplication of matrices in Daily life
Application of matrices in Daily lifeshubham mishra
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksJinTaek Seo
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Entrust Datacard
 
2.5 Equations of Lines
2.5 Equations of Lines2.5 Equations of Lines
2.5 Equations of Linessmiller5
 

What's hot (20)

Ds lec 5_chap4
Ds lec 5_chap4Ds lec 5_chap4
Ds lec 5_chap4
 
Matrices And Application Of Matrices
Matrices And Application Of MatricesMatrices And Application Of Matrices
Matrices And Application Of Matrices
 
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)954 Sukatan Pelajaran Matematik (T) STPM (Baharu)
954 Sukatan Pelajaran Matematik (T) STPM (Baharu)
 
Quadratic functions power point
Quadratic functions power pointQuadratic functions power point
Quadratic functions power point
 
Poster on Graph Terminologies
Poster on Graph TerminologiesPoster on Graph Terminologies
Poster on Graph Terminologies
 
Matrix and it's Application
Matrix and it's ApplicationMatrix and it's Application
Matrix and it's Application
 
11.6 graphing linear inequalities in two variables
11.6 graphing linear inequalities in two variables11.6 graphing linear inequalities in two variables
11.6 graphing linear inequalities in two variables
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homography
 
matrices and function ( matrix)
matrices and function ( matrix)matrices and function ( matrix)
matrices and function ( matrix)
 
Presentation on inverse matrix
Presentation on inverse matrixPresentation on inverse matrix
Presentation on inverse matrix
 
Graphing Linear Inequalities
Graphing Linear InequalitiesGraphing Linear Inequalities
Graphing Linear Inequalities
 
Planar graph( Algorithm and Application )
Planar graph( Algorithm and Application )Planar graph( Algorithm and Application )
Planar graph( Algorithm and Application )
 
6 4 Point Slope Form
6 4 Point Slope Form6 4 Point Slope Form
6 4 Point Slope Form
 
Goldbach and Chandra
Goldbach and ChandraGoldbach and Chandra
Goldbach and Chandra
 
Application of matrices in Daily life
Application of matrices in Daily lifeApplication of matrices in Daily life
Application of matrices in Daily life
 
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeksBeginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
 
Math 116 pres. 5
Math 116 pres. 5Math 116 pres. 5
Math 116 pres. 5
 
Matrix in software engineering
Matrix in software engineeringMatrix in software engineering
Matrix in software engineering
 
2.5 Equations of Lines
2.5 Equations of Lines2.5 Equations of Lines
2.5 Equations of Lines
 

Similar to Project descr updated_28714

ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRY
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRYON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRY
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRYFransiskeran
 
On algorithmic problems concerning graphs of higher degree of symmetry
On algorithmic problems concerning graphs of higher degree of symmetryOn algorithmic problems concerning graphs of higher degree of symmetry
On algorithmic problems concerning graphs of higher degree of symmetrygraphhoc
 
Nbhm m. a. and m.sc. scholarship test 2012 with answer key
Nbhm m. a. and m.sc. scholarship test 2012 with answer keyNbhm m. a. and m.sc. scholarship test 2012 with answer key
Nbhm m. a. and m.sc. scholarship test 2012 with answer keyMD Kutubuddin Sardar
 
Exact Matrix Completion via Convex Optimization Slide (PPT)
Exact Matrix Completion via Convex Optimization Slide (PPT)Exact Matrix Completion via Convex Optimization Slide (PPT)
Exact Matrix Completion via Convex Optimization Slide (PPT)Joonyoung Yi
 
Propagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionPropagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionMohammad
 
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...cseiitgn
 
Nbhm m. a. and m.sc. scholarship test 2010
Nbhm m. a. and m.sc. scholarship test 2010Nbhm m. a. and m.sc. scholarship test 2010
Nbhm m. a. and m.sc. scholarship test 2010MD Kutubuddin Sardar
 
Genetic operators
Genetic operatorsGenetic operators
Genetic operatorsDEEPIKA T
 
Analysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topologyAnalysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topologyAmir Masoud Sefidian
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyappasami
 
Master of Computer Application (MCA) – Semester 4 MC0079
Master of Computer Application (MCA) – Semester 4  MC0079Master of Computer Application (MCA) – Semester 4  MC0079
Master of Computer Application (MCA) – Semester 4 MC0079Aravind NC
 

Similar to Project descr updated_28714 (20)

Fx3111501156
Fx3111501156Fx3111501156
Fx3111501156
 
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRY
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRYON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRY
ON ALGORITHMIC PROBLEMS CONCERNING GRAPHS OF HIGHER DEGREE OF SYMMETRY
 
On algorithmic problems concerning graphs of higher degree of symmetry
On algorithmic problems concerning graphs of higher degree of symmetryOn algorithmic problems concerning graphs of higher degree of symmetry
On algorithmic problems concerning graphs of higher degree of symmetry
 
Nbhm m. a. and m.sc. scholarship test 2012 with answer key
Nbhm m. a. and m.sc. scholarship test 2012 with answer keyNbhm m. a. and m.sc. scholarship test 2012 with answer key
Nbhm m. a. and m.sc. scholarship test 2012 with answer key
 
Linear algebra havard university
Linear algebra havard universityLinear algebra havard university
Linear algebra havard university
 
algo1
algo1algo1
algo1
 
Exact Matrix Completion via Convex Optimization Slide (PPT)
Exact Matrix Completion via Convex Optimization Slide (PPT)Exact Matrix Completion via Convex Optimization Slide (PPT)
Exact Matrix Completion via Convex Optimization Slide (PPT)
 
COCOON14
COCOON14COCOON14
COCOON14
 
Propagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionPropagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace Reduction
 
Unit 1. day 3review
Unit 1. day 3reviewUnit 1. day 3review
Unit 1. day 3review
 
Modeling the dynamics of molecular concentration during the diffusion procedure
Modeling the dynamics of molecular concentration during the  diffusion procedureModeling the dynamics of molecular concentration during the  diffusion procedure
Modeling the dynamics of molecular concentration during the diffusion procedure
 
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
 
Nbhm m. a. and m.sc. scholarship test 2010
Nbhm m. a. and m.sc. scholarship test 2010Nbhm m. a. and m.sc. scholarship test 2010
Nbhm m. a. and m.sc. scholarship test 2010
 
Genetic operators
Genetic operatorsGenetic operators
Genetic operators
 
Analysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topologyAnalysis and design of a half hypercube interconnection network topology
Analysis and design of a half hypercube interconnection network topology
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
Ou3425912596
Ou3425912596Ou3425912596
Ou3425912596
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Master of Computer Application (MCA) – Semester 4 MC0079
Master of Computer Application (MCA) – Semester 4  MC0079Master of Computer Application (MCA) – Semester 4  MC0079
Master of Computer Application (MCA) – Semester 4 MC0079
 

Recently uploaded

247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Project descr updated_28714

  • 1. German University in Cairo Faculty of Media Engineering and Technology Dr. Nada Sharaf Concepts of Programming Languages, Spring 2019 The Helsinki Puzzle Deadline: 22/3/2019 Project Description Given a square grid of size N, where the horizontal rows are numbered 1 to N from top to bottom and the vertical columns are numbered 1 to N from left to right. You must place a number in each cell of the N by N grid such that :- • Each row is unique. • Each row is exactly equal to one of the columns, however, it must not be the column with the same index as the row. • If X is the largest number you place in the grid, then you must also place 1,2,...,X-1, where the condition X ≤ N is satisfied. Examples For a 3 × 3 grid, you may have the following matrix c1 c2 c3 r1 2 1 2 r2 2 2 1 r3 1 2 2 defined by the following equalities   c1 = r2 c2 = r3 c3 = r1   For a 4 × 4 grid, you may have the following matrix c1 c2 c3 c4 r1 1 2 3 1 r2 3 4 4 2 r3 2 4 4 3 r4 1 3 2 1 defined by the following equalities     c1 = r4 c2 = r3 c3 = r2 c4 = r1     1
  • 2. German University in Cairo Faculty of Media Engineering and Technology Dr. Nada Sharaf Predicates to be added You are going to solve this puzzle purely through Prolog. This means that you are not allowed to use any clpfd libaries. Your solution must utilize both tech- niques, unification and generate-and-test. You should implement all of the following predicates. grid_build/2 The predicate grid_build(N,M) should succeed only if M represents a grid that is N by N such that each cell in M contains an unbound variable. Hint: length(L,3) produces a list of 3 unbound variables. grid_gen/2 The predicate grid_gen(N,M) should succeed only if M represents a grid that is N by N such that each cell in M contains a value from the valid range 1 .. N. num_gen/3 The predicate num_gen(F,L,R) should succeed only if R represents a list of con- secutive numbers starting from F until L. Hint: numGen(1,3,R) succeeds when R = 1,2,3 . check_num_grid/1 The predicate check_num_grid(G) succeeds if G does not contain a number X unless all the numbers 1 .. X-1 are there. acceptable_permutation/2 The predicate acceptable_permutation(L,R) should succeed only if R represents an acceptable permutation of the list L. Hint: 2,1,3 is not an acceptable permutation of the list 1,2,3 because 3 did not change it’s position. 2
  • 3. German University in Cairo Faculty of Media Engineering and Technology Dr. Nada Sharaf acceptable_distribution/1 The predicate acceptable_distribution(G) should succeed only if no row is placed in a column with the same index and no column is placed in a row with the same index. row_col_match/1 The predicate row_col_match(M) should succeed only if each row is equal to a column with a different index and each column is equal to a row with a different index. trans/2 The predicate trans(M,M1) should succeed only if M1 represents a transposed ver- sion of the matrix M. Hint: This needs to be approached through rows and columns. distinct_rows/1 The predicate distinct_rows(M) should succeed only if M represents a matrix M where all rows are unique. distinct_columns/1 The predicate distinct_columns(M) should succeed only if M represents a matrix M where all columns are unique. helsinki/2 The predicate helsinki(N,G) should succeed only if G is a square grid of size N*N that satisfies all the helsinki puzzle properties. 3