English
Tasks
Complete the task of the chosen difficulty level for your variant number.
Variants
Variant 1. Leap years
1. Initial level. Create a Kotlin console program: read years a,b in 1–9999, a<=b; print the leap years using the Gregorian rule: divisible by 400, or by 4 but not by 100. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read years a,b in 1–9999, a<=b; print the leap years using the Gregorian rule: divisible by 400, or by 4 but not by 100. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read years a,b in 1–9999, a<=b; print the leap years using the Gregorian rule: divisible by 400, or by 4 but not by 100. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 2. Rate plans
1. Initial level. Create a Kotlin console program: read minutes in 0–10000; compare the sample plans A=100+2*m and B=200+m, and print both if they are equal. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read minutes in 0–10000; compare the sample plans A=100+2*m and B=200+m, and print both if they are equal. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read minutes in 0–10000; compare the sample plans A=100+2*m and B=200+m, and print both if they are equal. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 3. Rook
1. Initial level. Create a Kotlin console program: read the coordinates of two different squares in 1–8; check whether a rook can move between them with no other pieces present. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read the coordinates of two different squares in 1–8; check whether a rook can move between them with no other pieces present. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read the coordinates of two different squares in 1–8; check whether a rook can move between them with no other pieces present. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 4. Prime numbers
1. Initial level. Create a Kotlin console program: read a,b in 0–10000, a<=b; print the number of primes in the inclusive range. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read a,b in 0–10000, a<=b; print the number of primes in the inclusive range. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read a,b in 0–10000, a<=b; print the number of primes in the inclusive range. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 5. Banknotes
1. Initial level. Create a Kotlin console program: read an amount in 10–100000 that is a multiple of 10; break it down into unlimited banknotes of 100, 50, 20, and 10, and print the counts. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read an amount in 10–100000 that is a multiple of 10; break it down into unlimited banknotes of 100, 50, 20, and 10, and print the counts. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read an amount in 10–100000 that is a multiple of 10; break it down into unlimited banknotes of 100, 50, 20, and 10, and print the counts. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 6. Date
1. Initial level. Create a Kotlin console program: read a month in 1–12 and a day; validate the date in a common year using the actual length of the month. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read a month in 1–12 and a day; validate the date in a common year using the actual length of the month. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read a month in 1–12 and a day; validate the date in a common year using the actual length of the month. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 7. Guessing
1. Initial level. Create a Kotlin console program: set the secret to 37; read up to 7 integer guesses in 1–100, and print higher/lower/correct and the number of guesses. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: set the secret to 37; read up to 7 integer guesses in 1–100, and print higher/lower/correct and the number of guesses. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: set the secret to 37; read up to 7 integer guesses in 1–100, and print higher/lower/correct and the number of guesses. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 8. Divisors
1. Initial level. Create a Kotlin console program: read n in 1–10000; calculate the sum of its proper positive divisors and classify it relative to n. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–10000; calculate the sum of its proper positive divisors and classify it relative to n. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–10000; calculate the sum of its proper positive divisors and classify it relative to n. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 9. Temperatures
1. Initial level. Create a Kotlin console program: read n in 1–1000 and that many finite temperatures in −50..60; count those below 0, exactly 0, and above 0. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–1000 and that many finite temperatures in −50..60; count those below 0, exactly 0, and above 0. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–1000 and that many finite temperatures in −50..60; count those below 0, exactly 0, and above 0. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 10. Roman numerals
1. Initial level. Create a Kotlin console program: read an integer in 1–10; print the exact representation I, II, III, IV, V, VI, VII, VIII, IX, X using when. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read an integer in 1–10; print the exact representation I, II, III, IV, V, VI, VII, VIII, IX, X using when. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read an integer in 1–10; print the exact representation I, II, III, IV, V, VI, VII, VIII, IX, X using when. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 11. Triangle
1. Initial level. Create a Kotlin console program: read three finite side lengths in 0.1–1000; check the inequalities and classify the triangle as equilateral/isosceles/scalene. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read three finite side lengths in 0.1–1000; check the inequalities and classify the triangle as equilateral/isosceles/scalene. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read three finite side lengths in 0.1–1000; check the inequalities and classify the triangle as equilateral/isosceles/scalene. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 12. GCD
1. Initial level. Create a Kotlin console program: read two numbers in 1–1000000; find their GCD using Euclid's algorithm and print it. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read two numbers in 1–1000000; find their GCD using Euclid's algorithm and print it. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read two numbers in 1–1000000; find their GCD using Euclid's algorithm and print it. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 13. Digits
1. Initial level. Create a Kotlin console program: read n in 0–1000000000; use a loop to find the sum and count of its digits, with a count of 1 for 0. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 0–1000000000; use a loop to find the sum and count of its digits, with a count of 1 for 0. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 0–1000000000; use a loop to find the sum and count of its digits, with a count of 1 for 0. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 14. Numeric palindrome
1. Initial level. Create a Kotlin console program: read n in 0–1000000000; check whether it equals the number with its digits reversed, performing calculations in Long. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 0–1000000000; check whether it equals the number with its digits reversed, performing calculations in Long. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 0–1000000000; check whether it equals the number with its digits reversed, performing calculations in Long. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 15. Factorial
1. Initial level. Create a Kotlin console program: read n in 0–20; calculate its factorial in Long, with 0!=1. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 0–20; calculate its factorial in Long, with 0!=1. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 0–20; calculate its factorial in Long, with 0!=1. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 16. Fibonacci
1. Initial level. Create a Kotlin console program: read n in 0–90; calculate F0=0,F1=1,F(n)=F(n-1)+F(n-2) in Long. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 0–90; calculate F0=0,F1=1,F(n)=F(n-1)+F(n-2) in Long. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 0–90; calculate F0=0,F1=1,F(n)=F(n-1)+F(n-2) in Long. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 17. Scores
1. Initial level. Create a Kotlin console program: read n in 1–100 and scores in 0–100; print the mean and the count >=60. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–100 and scores in 0–100; print the mean and the count >=60. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–100 and scores in 0–100; print the mean and the count >=60. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 18. Discount
1. Initial level. Create a Kotlin console program: read an amount in 0–100000; apply a sample discount of 0% below 1000, 5% from 1000 to 5000, and 10% from 5000 inclusive. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read an amount in 0–100000; apply a sample discount of 0% below 1000, 5% from 1000 to 5000, and 10% from 5000 inclusive. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read an amount in 0–100000; apply a sample discount of 0% below 1000, 5% from 1000 to 5000, and 10% from 5000 inclusive. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 19. Quadratic equation
1. Initial level. Create a Kotlin console program: read integers a,b,c from −100 to 100, a!=0; use the discriminant to print 0, 1, or 2 real roots. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read integers a,b,c from −100 to 100, a!=0; use the discriminant to print 0, 1, or 2 real roots. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read integers a,b,c from −100 to 100, a!=0; use the discriminant to print 0, 1, or 2 real roots. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 20. Calendar days
1. Initial level. Create a Kotlin console program: read a year in 1–9999 and a month in 1–12; print the number of days, accounting for leap years. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read a year in 1–9999 and a month in 1–12; print the number of days, accounting for leap years. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read a year in 1–9999 and a month in 1–12; print the number of days, accounting for leap years. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 21. Parity
1. Initial level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the sums of even and odd numbers separately. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the sums of even and odd numbers separately. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the sums of even and odd numbers separately. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 22. Maximum
1. Initial level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the maximum and the position of its first occurrence, starting from 1. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the maximum and the position of its first occurrence, starting from 1. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–1000 and that many integers in −10000..10000; print the maximum and the position of its first occurrence, starting from 1. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 23. Menu
1. Initial level. Create a Kotlin console program: read commands 1, 2, 0: 1 increments a counter, 2 prints it, and 0 or EOF exits; unknown commands do not change the state. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read commands 1, 2, 0: 1 increments a counter, 2 prints it, and 0 or EOF exits; unknown commands do not change the state. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read commands 1, 2, 0: 1 increments a counter, 2 prints it, and 0 or EOF exits; unknown commands do not change the state. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 24. Pair search
1. Initial level. Create a Kotlin console program: read s in 2–20; find the first pair a,b in 1–10 with sum s, ordered by a and then b. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read s in 2–20; find the first pair a,b in 1–10 with sum s, ordered by a and then b. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read s in 2–20; find the first pair a,b in 1–10 with sum s, ordered by a and then b. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 25. Power
1. Initial level. Create a Kotlin console program: read an integer a in −10..10 and n in 0–10; use a loop to calculate a^n in Long, with a^0=1. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read an integer a in −10..10 and n in 0–10; use a loop to calculate a^n in Long, with a^0=1. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read an integer a in −10..10 and n in 0–10; use a loop to calculate a^n in Long, with a^0=1. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 26. Series
1. Initial level. Create a Kotlin console program: read n in 1–10000; calculate the sum 1+1/2+…+1/n in Double. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–10000; calculate the sum 1+1/2+…+1/n in Double. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–10000; calculate the sum 1+1/2+…+1/n in Double. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 27. Binary digits
1. Initial level. Create a Kotlin console program: read n in 0–1000000; use a loop to count its set bits. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 0–1000000; use a loop to count its set bits. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 0–1000000; use a loop to count its set bits. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 28. Angle
1. Initial level. Create a Kotlin console program: read an integer angle in −1000000..1000000; normalize it to 0–359 and indicate the cardinal direction for 0, 90, 180, 270. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read an integer angle in −1000000..1000000; normalize it to 0–359 and indicate the cardinal direction for 0, 90, 180, 270. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read an integer angle in −1000000..1000000; normalize it to 0–359 and indicate the cardinal direction for 0, 90, 180, 270. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 29. Table
1. Initial level. Create a Kotlin console program: read n in 1–12; print the multiplication table for n times 1–12. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read n in 1–12; print the multiplication table for n times 1–12. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read n in 1–12; print the multiplication table for n times 1–12. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Variant 30. Stream
1. Initial level. Create a Kotlin console program: read at most 1000 integers in −1000..1000 until stop/EOF; skip invalid values, and print the sum and the number accepted. Check types and bounds; for invalid input, print a message and exit.
2. Basic level. Create a Kotlin console program: read at most 1000 integers in −1000..1000 until stop/EOF; skip invalid values, and print the sum and the number accepted. Use nullable conversions without !!, check bounds and EOF, and repeat the prompt after an invalid line. Print a summary only for a valid data set.
3. Advanced level. Create a Kotlin console program: read at most 1000 integers in −1000..1000 until stop/EOF; skip invalid values, and print the sum and the number accepted. Place the entire set of parameters in a repeating menu: calculate a new set or exit. Without !!, check bounds, overflow, and EOF; an invalid set does not change the number of successful calculations. Show this counter and a table of at least five boundary checks. Add CLI arguments in key=value format and --help; with no arguments, read the same fields from the keyboard. Print a labeled tabular report with a summary; send errors to stderr. Exit codes: 0 – success or help, 2 – invalid input, 1 – operational failure.
Procedure
- Define the input contract and the expected result.
- Choose types and check the bounds of intermediate calculations.
- Separate string parsing from checking whether a value is permitted.
- Write down the loop invariant and termination conditions.
- Check every branch, boundaries, null, text, and an empty stream.
- Save the code and test table in a local repository.