-
Notifications
You must be signed in to change notification settings - Fork 102
Lessons 1-5 Копылов М. #57
Conversation
* Человек положил в банк сумму в s рублей под p% годовых (проценты начисляются в конце года). | ||
* Сколько денег будет на счету через 3 года (с учётом сложных процентов)? | ||
* Например, 100 рублей под 10% годовых превратятся в 133.1 рубля | ||
* Например, 100 рублей под 10% годовых превратятся в 133.1 рубл |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В коммитах лучше избегать изменений, не относящихся к решаемой задаче.
Название PR |
Автору PR: вы уже довольно сильно отстаёте от графика. Вам следует исправить замечания в этом PR и перейти к решению задач из 2-го и 3-го урока, в противном случае вы рискуете получить неудовлетворительную оценку за октябрь. |
Название пулл реквеста все еще не соответствует его содержанию. Если вы его не поправите к концу октября, вместо зачета по предмету вы получите парочку мемосов и представление к отчислению. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ваши следующие задачи не будут проверяться до тех пор, пока вы не исправите все имеющиеся замечания к урокам 1-3.
src/lesson2/task1/IfElse.kt
Outdated
fun ageDescription(age: Int): String { | ||
var sAge = "$age" | ||
val ageL=age%10 | ||
if (age%100 in 10..20) sAge+=" лет" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все это выражение лучше оформить как один плоский when
src/lesson2/task1/IfElse.kt
Outdated
*/ | ||
fun ageDescription(age: Int): String = TODO() | ||
fun ageDescription(age: Int): String { | ||
var sAge = "$age" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вместо отдельной переменной лучше возвращать результаты работы вашей функции прямо по месту в виде "$age лет"
src/lesson2/task1/IfElse.kt
Outdated
rookX2: Int, rookY2: Int): Int = TODO() | ||
rookX2: Int, rookY2: Int): Int { | ||
val threat: Int | ||
if ((kingX == rookX1 && rookX2 == kingX) || (kingY == rookY1 && rookY2 == kingY) || (kingY == rookY1 && rookX2 == kingX) || (kingX == rookX1 && rookY2 == kingY)) threat = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выражения, отвечающие за факт атаки короля той или иной ладьей, следует вынести в отдельные переменные
src/lesson2/task1/IfElse.kt
Outdated
bishopX: Int, bishopY: Int): Int = TODO() | ||
bishopX: Int, bishopY: Int): Int { | ||
val threat:Int | ||
if ((Math.abs(bishopX-kingX)==Math.abs(bishopY-kingY)) && (rookX==kingX || rookY==kingY)) threat=3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выражения, отвечающие за факт атаки короля ладьей или слоном, следует вынести в отдельные переменные
src/lesson2/task1/IfElse.kt
Outdated
fun triangleKind(a: Double, b: Double, c: Double): Int = TODO() | ||
fun triangleKind(a: Double, b: Double, c: Double): Int { | ||
val kind:Int | ||
if (a+b<c || c+a<b || b+c<a) kind=-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше сперва найти максимальную сторону, а потом все один раз посчитать относительно нее
src/lesson3/task1/Loop.kt
Outdated
fun revert(n: Int): Int { | ||
if (n<10) return n | ||
var nn=n | ||
var result:Int=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Система типов Котлина выведет тип переменной автоматически
src/lesson3/task1/Loop.kt
Outdated
var nn=n | ||
var result:Int=0 | ||
var ext:Int=1 | ||
var count=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет ли у вас готовой функции, которая считает количество цифр в числе?
src/lesson3/task1/Loop.kt
Outdated
} | ||
nn=n | ||
for (i in count downTo 1){ | ||
for (j in 1..i-1) {ext*=10} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Напишите функцию fun pow(Int, Int): Int
src/lesson3/task1/Loop.kt
Outdated
nn/=10 | ||
ext=1 | ||
} | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пожалуйста, форматируйте ваш код так, как будто его будет читать психопат-перфекционист с педантичной любовью к каждому пробелу и каждому переносу строки, у которого есть топор и который знает, где вы живете
src/lesson3/task1/Loop.kt
Outdated
else return true | ||
nn/=10 | ||
} | ||
if (test==1) return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В каком случае вы можете оказаться здесь, а переменная test
не равна 1???
А можно мне просто мемосов без отчисления? :D |
Второй "Исправленный Lesson 2 Task 1" - это "Исправленный Lesson 3", когда коммитил забыл переименовать |
src/lesson1/task1/Simple.kt
Outdated
* Например, расстояние между (3, 0) и (0, 4) равно 5 | ||
*/ | ||
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double = TODO() | ||
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double = sqrt(sqr(abs(x1 - x2)) + sqr(abs(y1 - y2))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем брать модуль перед возведением числа в квадрат?
src/lesson1/task1/Simple.kt
Outdated
* Определите время поезда в пути в минутах (в данном случае 216). | ||
*/ | ||
fun travelMinutes(hoursDepart: Int, minutesDepart: Int, hoursArrive: Int, minutesArrive: Int): Int = TODO() | ||
fun travelMinutes(hoursDepart: Int, minutesDepart: Int, hoursArrive: Int, minutesArrive: Int): Int = (minutesArrive - minutesDepart) + 60 * (hoursArrive - hoursDepart) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Длинные строки принято разбивать на несколько более коротких, в данном случае, например, после знака =
в объявлении функции
src/lesson1/task1/Simple.kt
Outdated
fun accountInThreeYears(initial: Int, percent: Int): Double = TODO() | ||
|
||
fun accountInThreeYears(initial: Int, percent: Int): Double { | ||
val perc = percent.toDouble() / 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вместо явного вызова toDouble()
при floating-point операциях, включающих константы, обычно эти самые константы делают типа Double
--- percent / 100.0
src/lesson1/task1/Simple.kt
Outdated
fun accountInThreeYears(initial: Int, percent: Int): Double { | ||
val perc = percent.toDouble() / 100 | ||
val inperc = perc * initial | ||
return initial + inperc + (initial + inperc) * perc + (initial + inperc + (initial + inperc) * perc) * perc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Формулу можно упростить, если воспользоваться математическими правилами
src/lesson1/task1/Simple.kt
Outdated
*/ | ||
fun numberRevert(number: Int): Int = TODO() | ||
fun numberRevert(number: Int): Int { | ||
val n1:Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему вы разделили определение и объявление переменной?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще актуально
src/lesson3/task1/Loop.kt
Outdated
fun squareBetweenExists(m: Int, n: Int): Boolean = TODO() | ||
fun squareBetweenExists(m: Int, n: Int): Boolean { | ||
val sqroot = Math.sqrt(m.toDouble()).toInt() | ||
return (sqroot * sqroot >= m && sqroot * sqroot <= n) || ((sqroot + 1) * (sqroot + 1) <= n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если вы примените правильную функцию округления, данную проверку можно будет упростить
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще актуально
src/lesson3/task1/Loop.kt
Outdated
fun revert(n: Int): Int { | ||
if (n < 10) return n | ||
var nn = n | ||
var result: Int = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Система типов Котлина выведет тип переменной автоматически
src/lesson3/task1/Loop.kt
Outdated
if (n < 10) return n | ||
var nn = n | ||
var result: Int = 0 | ||
var ext: Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему эта переменная объявлена здесь, а не ниже прямо при использовании?
src/lesson3/task1/Loop.kt
Outdated
val count = digitNumber(n) | ||
|
||
for (i in count downTo 1) { | ||
ext = pow(10, i - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно ли перестроить ваш алгоритм так, чтобы не было необходимости на каждой итерации цикла возводить 10 в требуемую степень?
src/lesson3/task1/Loop.kt
Outdated
fun hasDifferentDigits(n: Int): Boolean = TODO() | ||
fun hasDifferentDigits(n: Int): Boolean { | ||
if (n < 10) return false | ||
val samenum: Int = n % 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Переменным лучше давать осмысленные имена, соответствующие их назначению в коде
- Система типов Котлина выведет тип переменной автоматически
4 урок будет проверен после того, как вы исправите замечания к предыдущим урокам |
Вы довольно сильно отстаёте от графика. Вам следует продолжать решать задачи учебного проекта. |
src/lesson1/task1/Simple.kt
Outdated
fun accountInThreeYears(initial: Int, percent: Int): Double { | ||
val perc = percent / 100.0 | ||
val inperc = perc * initial | ||
return initial + inperc + (initial + inperc) * perc + (initial + inperc + (initial + inperc) * perc) * perc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Данное выражение можно очень сильно упростить, если вспомнить о некоторых математических свойствах умножения и сложения
src/lesson1/task1/Simple.kt
Outdated
*/ | ||
fun numberRevert(number: Int): Int = TODO() | ||
fun numberRevert(number: Int): Int { | ||
val n1:Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще актуально
src/lesson2/task1/IfElse.kt
Outdated
val r1Threat = (kingX == rookX1) || (kingY == rookY1) | ||
val r2Threat = (kingX == rookX2) || (kingY == rookY2) | ||
|
||
if (r1Threat && r2Threat) return 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще актуально
src/lesson2/task1/IfElse.kt
Outdated
val rThreat: Boolean = (kingX == rookX) || (kingY == rookY) | ||
val bThreat: Boolean = Math.abs(bishopX - kingX) == Math.abs(bishopY - kingY) | ||
|
||
if ((bThreat) && (rThreat)) return 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все еще актуально
src/lesson2/task1/IfElse.kt
Outdated
val side1: Double | ||
val side2: Double | ||
|
||
if (a > b && a>c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Форматирование кода
for (i in list.size - 1 downTo 1) { | ||
for (j in i downTo 1) { | ||
list[i] += list[j - 1] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Подумайте, нужен ли вообще этот цикл?
nn /= base | ||
} | ||
list.reverse() | ||
return list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше как list.reversed()
src/lesson4/task1/List.kt
Outdated
*/ | ||
fun convertToString(n: Int, base: Int): String = TODO() | ||
fun convertToString(n: Int, base: Int): String { | ||
var result: String = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Во первых, можно не указывать тип. Во вторых, для подобных операций лучше использовать список строк или StringBuilder
.
src/lesson4/task1/List.kt
Outdated
var result: String = "" | ||
val list = convert(n, base) | ||
for (element in list){ | ||
if (element > 9) result += ('a'.toInt() + element - 10).toChar() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем toInt()
?
src/lesson4/task1/List.kt
Outdated
fun decimal(digits: List<Int>, base: Int): Int { | ||
var result = 0 | ||
var iDigit = 1 | ||
for (i in digits.size-1 downTo 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Форматирование кода
Довольно много замечаний еще не исправлены. Новые уроки не будут проверены, пока вы не исправите предыдущие. |
recheck all |
authorRainbowDev [diablo3355@gmail.com] lesson1.task1Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 12 / 12 Example: 4 / 4 Succeeded:
Seed: -8748346597584261012 lesson2.task1Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 5 / 7 Example: 1 / 1 Succeeded:
Seed: -8748346597584261012 lesson2.task2Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 3 / 5 Example: 1 / 1 Succeeded:
Failed:
Seed: -8748346597584261012 lesson3.task1Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 12 / 18 Example: 4 / 4 Succeeded:
Failed:
Seed: -8748346597584261012 lesson4.task1Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 16 / 21 Example: 7 / 7 Succeeded:
Failed:
Seed: -8748346597584261012 lesson5.task1Author: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 4 / 12 Example: 2 / 2 Succeeded:
Failed:
Seed: -8748346597584261012 ownerRainbowDev [] totalAuthor: RainbowDev [diablo3355@gmail.com] Owner: RainbowDev [] Total: 61 / 136 Example: 28 / 30 |
Поздравляем, у вас зачет! До встречи на экзамене! |
No description provided.