Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Vít Novotný
pb016-priklady
Commits
6a8842fd
Commit
6a8842fd
authored
Jan 21, 2017
by
Vít Novotný
Browse files
added example 3.6_17
parent
aaca4d6d
Changes
7
Hide whitespace changes
Inline
Side-by-side
3.4_13
-rekurze
.py
→
3.4_13.py
View file @
6a8842fd
File moved
3.4_13
-rekurze
.py.out
→
3.4_13.py.out
View file @
6a8842fd
File moved
3.5_15
-rekurze
.py
→
3.5_15.py
View file @
6a8842fd
File moved
3.5_15
-rekurze
.py.out
→
3.5_15.py.out
View file @
6a8842fd
File moved
3.6_17.pl
0 → 100644
View file @
6a8842fd
% nacteni:
/*
['3.6_17.pl'].
*/
solution
(
Start
,
Solution
)
:-
breadth_first_search
([[
Start
]],
Solution
).
breadth_first_search
([[
Node
|
Path
]|
_
],[
Node
|
Path
])
:-
goal
(
Node
).
breadth_first_search
([[
N
|
Path
]|
Paths
],
Solution
)
:-
bagof
([
M
,
N
|
Path
],(
move
(
N
,
M
),
\
+
member
(
M
,[
N
|
Path
])),
NewPaths
),
NewPaths
\
=
[],
append
(
Paths
,
NewPaths
,
Path1
),
!,
breadth_first_search
(
Path1
,
Solution
);
breadth_first_search
(
Paths
,
Solution
).
3.6_17.py
0 → 100644
View file @
6a8842fd
#!/usr/bin/env python
# encoding=utf-8 (pep 0263)
from
linked_lists
import
LinkedList
,
Cons
,
Nil
def
solution
(
node
):
for
path
in
breadth_first_search
(
LinkedList
(
LinkedList
(
node
))):
yield
path
def
breadth_first_search
(
paths
):
path
=
paths
.
head
node
=
path
.
head
if
is_goal
(
node
):
yield
path
new_paths
=
Nil
for
node1
in
move_anyY
(
node
):
if
not
member
(
node1
,
path
):
new_paths
=
Cons
(
Cons
(
node1
,
path
),
new_paths
)
if
new_paths
!=
Nil
:
paths1
=
append
(
paths
.
tail
,
new_paths
)
else
:
paths1
=
paths
.
tail
for
path
in
breadth_first_search
(
paths1
):
yield
path
def
is_goal
(
_
):
# zavisi na resenem problemu
return
False
def
move_anyY
(
x
):
# zavisi na resenem problemu
yield
x
def
append
(
xs
,
ys
):
if
xs
==
Nil
:
return
ys
else
:
return
Cons
(
xs
.
head
,
append
(
xs
.
tail
,
ys
))
def
member
(
x
,
xs
):
if
xs
==
Nil
:
return
False
if
x
==
xs
.
head
:
return
True
return
member
(
x
,
xs
.
tail
)
3.6_17.py.out
0 → 100644
View file @
6a8842fd
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment