Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

Prolog yardım (10 TL ödüllü :P)


BioHazarD

Öne çıkan mesajlar

logic ve türevi derslerde nefret etmiştim zaten bu dönem bi ai dersinde prolog verdiler ingilizceden anlamayan mal böyle sanki herşeyi zaten biliyomuşuz gibi anlatan bi hoca geldi. şu soruların cevaplarını 25ine kadar yollamam lazım ama hiç ilgilenmedim dersle anca 1. soruyu yapabildim ben :P doğru çözen ilk kişinin banka hesabına 10 tl atıcam :D

sorular

1. Write programs that implement the following operations on lists:
(a) Double a list, that is:
[1; 2; 3] --> [1; 2; 3; 1; 2; 3]:
(b) Duplicate the elements of a list:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:
(c) Erase all occurrences of 5 from a list:
[1; 2; 5; 3; 5] -->[1; 2; 3]:
(d) Duplicate all occurrences of 5 in a list:
[1; 2; 5; 3; 5] -->[1; 2; 5; 5; 3; 5; 5]:

2. Let w be an arbitrary list of integers and (wR) be the reverse list for w. In the
problems below de—ne operations on lists acting as prescribed.
(a) Given w let listop1(w) = w(wR) w.
(b) Given w let listop2(w) = (wR) w(wR)
(c) Given w let listop3(w) = ww(wR) .
(d) Given w let listop4(w) = w(wR)(wR) .

3. Calculate the following values provided the lists given are all lists of non-negative
integers.
(a) The sum of odd elements of a list.
(b) Decide the sum of the elements of a list divisible by 4. E.g.: sum4([1,5,4,8,3,2])=12.
(c) The sum of squares in a list. E.g.: sumsq([1,4,7,9,12])=14.
(d) The sum of elements of a list giving remainder 1 divided by 6. E.g.: rem6([1,5,7,10,19])=26.

4. Calculate the following values provided the lists given are all lists of non-negative
integers.
(a) Find the length and starting position of the longest sequence of 1s in a given
list. E.g.: oneslh([1,2,11,1,1,3,2])=2, onesat([1,2,11,1,1,3,2])=4.
(b) Find the 6th maximal element of a list. Its value should be the minimum of
the list of it consists of less than six elements. Try to generalize the problem
for the kth maximal element for an arbitrary k.
(c) Find the greatest common divisor of a list of integers consisting at least two
elements.
(d) Find the least common multiplier of a list of integers consisting at least two
elements.

5. Decide the values of the following functions.
(a) Determine the greatest proper divisor of a number n. A divisor of n is proper
if it differs from n and 1.
(b) Determine the greatest square dividing n. E.g. 36 is the greatest square which
divides 108.
(c) Decide of the number n whether it is perfect or not. The number n is perfect
if it is the sum of its divisors less than n. E.g.: 6=1+2+3, hence 6 is perfect.
(d) Given a non-negative n write n as the sum of four squares. E.g. 28=25+1+1+1,
9=4+4+1+0. Is this representation unique?

6. Determine the following values.
(a) Give the sum of the numbers between 100 and 1000 (the endpoints included)
which are the multitudes of 3 or 5. All values should occur at most once.
E.g.: 15 could be counted by 3 as well as by 5, but it should occur once in the
formation of the sum.
(b) Find the smallest positive value divisible by 1, 2, ..., 20.
(c) Find the greatest palindrome number emerging as the product of n and m
where 100 · n;m · 999. A number is called palindrome if it remains the same
when read backwards. E.g. 12721 is a palindrome.
(d) Determine the list of the powers of two ending by 6 and not greater than 10000.
E.g.: 16, 256, etc.

Link to comment
Sosyal ağlarda paylaş

1. Write programs that implement the following operations on lists:
(a) Double a list, that is:
[1; 2; 3] --> [1; 2; 3; 1; 2; 3]:
(b) Duplicate the elements of a list:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:
(c) Erase all occurrences of 5 from a list:
[1; 2; 5; 3; 5] -->[1; 2; 3]:
(d) Duplicate all occurrences of 5 in a list:
[1; 2; 5; 3; 5] -->[1; 2; 5; 5; 3; 5; 5]:


(a) Double a list, that is:
[1; 2; 3] --> [1; 2; 3; 1; 2; 3]:
[1; 2; 3] --> [1; 2; 3; 1; 2; 3]:

(b) Duplicate the elements of a list:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:
[1; 2; 3] -->[1; 1; 2; 2; 3; 3]:

(c) Erase all occurrences of 5 from a list:



Link to comment
Sosyal ağlarda paylaş

×
×
  • Yeni Oluştur...