
- •1.1 Знакомство с интерпретатором Hugs.
- •1.2 Выполнение математических операций в интерпретаторе.
- •1.3. Простейшие генераторы списков.
- •1.4 Логические функции, функции сравнения, функции работы с перечислимыми типами данных.
- •1.5 Простейшие списочные и кортежные функции.
- •Задание на лабораторную работу №1.
- •Вариант 1.
- •Вариант 2.
- •Вариант 3.
- •Вариант 4.
- •Вариант 5.
- •Вариант 6.
- •Вариант 7.
- •Вариант 8.
- •Вариант 9.
- •Вариант 10.
- •Пример выполнения лабораторной работы 1.
- •Лабораторная работа 2. Создание простейших рекурсивных программ. Функции работы со строками и множествами. Сообщения об ошибках и преобразования типов.
- •2.1 Создание простейших рекурсивных программ.
- •2.2 Функции работы со строками и множествами.
- •2.3 Сообщения об ошибках и преобразования типов
- •Задание на лабораторную работу 2.
- •Вариант 1.
- •Вариант 2.
- •Вариант 3.
- •Вариант 4.
- •Вариант 5.
- •Вариант 6.
- •Вариант 7.
- •Вариант 8.
- •Вариант 9.
- •Вариант 10.
- •Пример выполнения работы
- •Лабораторная работа 3. Функции высших порядков.
- •Задание на лабораторную работу 3.
- •Вариант 1.
- •Вариант 2.
- •Вариант 3.
- •Вариант 4.
- •Вариант 5.
- •Вариант 6.
- •Вариант 7.
- •Вариант 8.
- •Вариант 9.
- •Вариант 10.
- •Лабораторная работа 4. Текстовые файлы. Факторизация, простые числа, разные задачи.
- •4. 1 Работа с текстовыми файлами в Haskell
- •Задание на лабораторную работу 4.
- •Вариант 1.
- •Вариант 2.
- •Вариант 3.
- •Вариант 4.
- •Вариант 5.
- •Вариант 6.
- •Вариант 7.
- •Вариант 8.
- •Вариант 9.
- •Вариант 10.
- •Лабораторная работа 5. Управление выводом в Прологе. Простейшие рекурсивные программы.
- •5.1 Факты и правила. База знаний. Запросы.
- •5.2 Управление выводом.
- •5.3 Рекурсия
- •Задание на лабораторную работу 5.
- •Вариант 1
- •Вариант 2
- •Вариант 3
- •Вариант 4
- •Вариант 5
- •Вариант 6
- •Вариант 7
- •Вариант 8
- •Вариант 9
- •Вариант 10
- •Лабораторная работа №6. Работа со списками в Прологе.
- •6.1 Списки в Прологе.
- •6.2 Алгоритмы обработки списков
- •6.3 Алгоритмы сортировки
- •Лабораторная работа № 7. Решение логических задач на Прологе.
- •Пример выполнения работы.
- •Лабораторная работа № 8.
Вариант 2.
1. Строки исходного файла, содержащие заданное слово.
2. (50) The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953.
Which prime, below one-million, can be written as the sum of the most consecutive primes?
3. (171) For a positive integer n, let f(n) be the sum of the squares of the digits (in base 10) of n, e.g.
f(3) = 32 = 9,
f(25) = 22 + 52 = 4 + 25 = 29,
f(442) = 42 + 42 + 22 = 16 + 16 + 4 = 36
Find the last nine digits of the sum of all n, 0 < n < 1020, such that f(n) is a perfect square.
Вариант 3.
1. Строки исходного файла, выровненные справа.
2. (21) Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
Evaluate the sum of all the amicable numbers under 10000.
3. (200) We shall define a sqube to be a number of the form, p2q3, where p and q are distinct primes.
For example, 200 = 5223 or 120072949 = 232613.
The first five squbes are 72, 108, 200, 392, and 500.
Interestingly, 200 is also the first number for which you cannot change any single digit to make a prime; we shall call such numbers, prime-proof. The next prime-proof sqube which contains the contiguous sub-string "200" is 1992008.
Find the 200th prime-proof sqube containing the contiguous sub-string "200".
Вариант 4.
1. Строки исходного файла, из которых удалены все символы-цифры.
2. (32)We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital. HINT: Some products can be obtained in more than one way so be sure to only include it once in your sum.
3. (73). Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 7/8
It can be seen that there are 3 fractions between 1/3 and 1/2.
How many fractions lie between 1/3 and 1/2 in the sorted set of reduced proper fractions for d ≤ 12,000?
Вариант 5.
1. Слова исходного файла, не начинающиеся с заглавной буквы и не повторяющиеся.
2. (20). n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
3. (303)
For a positive integer n, define f(n) as the least positive multiple of n that, written in base 10, uses only digits ≤ 2.
Thus f(2)=2, f(3)=12, f(7)=21, f(42)=210, f(89)=1121222.
Also,
.
Find
.