Skip to content
This repository was archived by the owner on Sep 6, 2018. It is now read-only.

Conversation

SeveNChaK
Copy link

No description provided.

@ice-phoenix
Copy link
Contributor

recheck all

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 9 / 12

Example: 4 / 4
Trivial: 2 / 4
Easy: 3 / 4

Succeeded:

  • [Example] lesson1.task1/sqr
  • [Trivial] lesson1.task1/seconds
  • [Trivial] lesson1.task1/lengthInMeters
  • [Example] lesson1.task1/sqRoot
  • [Easy] lesson1.task1/thirdDigit
  • [Easy] lesson1.task1/travelMinutes
  • [Example] lesson1.task1/discriminant
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/numberRevert

Failed:

  • [Trivial] lesson1.task1/trackLength
    • Expected: Infinity
    • Actual: Infinity
    • Inputs:
      • x1 -> 0.3366168539395701
      • y1 -> -1.7976931348623157E308
      • x2 -> -1.7976931348623157E308
      • y2 -> 0.10008622359980968
    • Exception: null

Seed: -7606361675669160907

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 1 / 7

Example: 1 / 1
Easy: 0 / 5
Normal: 0 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot

Failed:

  • [Easy] lesson2.task1/timeForHalfWay
    • Expected: NaN
    • Actual: NaN
    • Inputs:
      • t1 -> 9.316666666666666
      • v1 -> 0.0
      • t2 -> 0.0
      • v2 -> 9.0
      • t3 -> 0.016666666666666666
      • v3 -> 0.0
    • Exception: null
  • [Normal] lesson2.task1/segmentLength
    • Expected: -1
    • Actual: -2147483648
    • Inputs:
      • a -> 0
      • b -> 0
      • c -> -2147483648
      • d -> -2147483648
    • Exception: null

Seed: -7606361675669160907

owner

SeveNChaK []

@ice-phoenix
Copy link
Contributor

recheck all

*/
fun seconds(hours: Int, minutes: Int, seconds: Int): Int = TODO()
fun seconds(hours: Int, minutes: Int, seconds: Int): Int {
val x1 = hours * 60 * 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переменным лучше давать осмысленные имена

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/seconds
  • [Trivial] lesson1.task1/lengthInMeters
  • [Example] lesson1.task1/sqr
  • [Example] lesson1.task1/discriminant
  • [Easy] lesson1.task1/thirdDigit
  • [Example] lesson1.task1/sqRoot
  • [Trivial] lesson1.task1/trackLength
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/travelMinutes
  • [Easy] lesson1.task1/numberRevert

Seed: -3955448798949467784

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 2 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 0 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay

Failed:

  • [Normal] lesson2.task1/segmentLength
    • Expected: -1
    • Actual: -2147483647
    • Inputs:
      • a -> 1
      • b -> 1
      • c -> -2147483648
      • d -> 0
    • Exception: null

Seed: -3955448798949467784

owner

SeveNChaK []

* Например, 100 рублей под 10% годовых превратятся в 133.1 рубля
*/
fun accountInThreeYears(initial: Int, percent: Int): Double = TODO()
fun accountInThreeYears(initial: Int, percent: Int): Double = TODO()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В коммитах лучше избегать ненужных изменений, так как они усложняют объединение наборов изменений от разных разработчиков

@ice-phoenix
Copy link
Contributor

recheck all

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/trackLength
  • [Trivial] lesson1.task1/seconds
  • [Example] lesson1.task1/sqRoot
  • [Trivial] lesson1.task1/lengthInMeters
  • [Easy] lesson1.task1/travelMinutes
  • [Example] lesson1.task1/sqr
  • [Example] lesson1.task1/discriminant
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/thirdDigit
  • [Easy] lesson1.task1/numberRevert

Seed: -2773410453390593234

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 3 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 1 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay
  • [Normal] lesson2.task1/segmentLength

Seed: -2773410453390593234

owner

SeveNChaK []

@SeveNChaK
Copy link
Author

SeveNChaK commented Sep 12, 2016

Изначально что-то не прошло, а в сообщение позже уже все нормально. Как это понимать? Подскажите, пожалуйста.

@ice-phoenix
Copy link
Contributor

Проверяющая система использует случайное тестирование, и на разных запусках может проверять ваш код на разных входных значениях. В вашем коде все еще есть ошибка, найденная при первом запуске.

@mglukhikh
Copy link
Contributor

Автору PR: вы отстаёте от графика. Вам следует исправить имеющиеся замечания, закончить с заданиями 2-го урока и перейти к решению задач 3-го урока.

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 14 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 1 / 2

Succeeded:

  • [Easy] lesson3.task1/lcm
  • [Example] lesson3.task1/factorial
  • [Normal] lesson3.task1/isPalindrome
  • [Easy] lesson3.task1/maxDivisor
  • [Example] lesson3.task1/isPrime
  • [Trivial] lesson3.task1/digitNumber
  • [Example] lesson3.task1/isPerfect
  • [Easy] lesson3.task1/isCoPrime
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/minDivisor
  • [Normal] lesson3.task1/revert
  • [Example] lesson3.task1/digitCountInNumber
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Hard] lesson3.task1/squareSequenceDigit

Failed:

  • [Hard] lesson3.task1/fibSequenceDigit
    • Expected:
      9
    • Actual:
    • Inputs:
      • n ->
        219
    • Exception: java.util.concurrent.TimeoutException: executable timed out after 10000 ms

Seed: -5620831687848804632

owner

SeveNChaK []

@maximpetrov
Copy link
Contributor

recheck all

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/seconds
  • [Example] lesson1.task1/sqRoot
  • [Trivial] lesson1.task1/trackLength
  • [Example] lesson1.task1/sqr
  • [Example] lesson1.task1/discriminant
  • [Trivial] lesson1.task1/lengthInMeters
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/numberRevert
  • [Easy] lesson1.task1/thirdDigit
  • [Easy] lesson1.task1/travelMinutes

Seed: -6777597016495018913

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 2 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 0 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay

Failed:

  • [Normal] lesson2.task1/segmentLength
    • Expected:
      -1
    • Actual:
      1482573
    • Inputs:
      • a ->
        482574
      • b ->
        482574
      • c ->
        -999999
      • d ->
        -791059
    • Exception: null

Seed: -6777597016495018913

lesson2.task2

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 4 / 5

Example: 1 / 1
Easy: 2 / 2
Normal: 1 / 2

Succeeded:

  • [Example] lesson2.task2/pointInsideCircle
  • [Easy] lesson2.task2/isNumberHappy
  • [Easy] lesson2.task2/queenThreatens
  • [Normal] lesson2.task2/circleInside

Failed:

  • [Normal] lesson2.task2/brickPasses
    • Expected:
      false
    • Actual:
      true
    • Inputs:
      • a ->
        874
      • b ->
        727
      • c ->
        204
      • r ->
        648
      • s ->
        648
    • Exception: null

Seed: -6777597016495018913

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 14 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 1 / 2

Succeeded:

  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/lcm
  • [Easy] lesson3.task1/minDivisor
  • [Example] lesson3.task1/factorial
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/isPerfect
  • [Example] lesson3.task1/digitCountInNumber
  • [Trivial] lesson3.task1/digitNumber
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Normal] lesson3.task1/isPalindrome
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Hard] lesson3.task1/squareSequenceDigit

Failed:

  • [Hard] lesson3.task1/fibSequenceDigit
    • Expected:
      0
    • Actual:
    • Inputs:
      • n ->
        233
    • Exception: java.util.concurrent.TimeoutException: executable timed out after 10000 ms

Seed: -6777597016495018913

owner

SeveNChaK []

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 15 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 2 / 2

Succeeded:

  • [Normal] lesson3.task1/isPalindrome
  • [Trivial] lesson3.task1/digitNumber
  • [Example] lesson3.task1/isPerfect
  • [Easy] lesson3.task1/minDivisor
  • [Easy] lesson3.task1/lcm
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/factorial
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Hard] lesson3.task1/fibSequenceDigit
  • [Example] lesson3.task1/digitCountInNumber
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Hard] lesson3.task1/squareSequenceDigit

Seed: -6331706759773008094

owner

SeveNChaK []

@mglukhikh mglukhikh removed the stale label Oct 16, 2016
Copy link
Contributor

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дальнейшие задачи будут проверяться только после исправления имеющихся замечаний

*/
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double = TODO()
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double {
val s=sagenes*48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Форматирование кода должно быть одинаковым везде --- если вы отделяете знаки операций от операндов пробелами, то делайте это везде. Попробуйте отформатировать ваш код при помощи IntelliJ IDEA и в дальнейшем придерживайтесь такого же стиля кодирования.

*/
fun thirdDigit(number: Int): Int = TODO()
fun thirdDigit(number: Int): Int {
return number%1000/100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функцию с телом в виде одного return expr можно записать как fun foo(...) = expr

t3: Double, v3: Double): Double {
val ps:Double = (t1*v1+t2*v2+t3*v3)/2
var t:Double
if (t1*v1 < ps)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Форматирование кода

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Данное выражение лучше оформить как when

t3: Double, v3: Double): Double = TODO()
t3: Double, v3: Double): Double {
val ps:Double = (t1*v1+t2*v2+t3*v3)/2
var t:Double
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно обойтись без этой переменной, если все возвращать сразу

*/
fun isNumberHappy(number: Int): Boolean = TODO()
fun isNumberHappy(number: Int): Boolean {
val x4:Int = number%10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Система типов Котлина выведет тип переменной автоматически

*/
fun isCoPrime(m: Int, n: Int): Boolean = TODO()
fun isCoPrime(m: Int, n: Int): Boolean {
var a: Int = m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что делает данная функция по сути? Объясните своими словами в комментарии.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Через алгоритм Евклида находит НОД и если он единица, то числа взаимно простые.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Объясните, что делает ваш новый код, в комментарии
  • Нельзя ли вынести часть функциональности вашей функции в отдельную функцию, которая могла бы помочь при решении других задач?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В коде ничего не поменялось в этой задаче, все также алгоритм Евклида

var revertNumber = 0
var number = n
while (k >= 0) {
revertNumber = revertNumber + Math.pow(10.0, k.toDouble()).toInt() * (number % 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Напишите pow, который работает в Int

* 15751 -- палиндром, 3653 -- нет.
*/
fun isPalindrome(n: Int): Boolean = TODO()
fun isPalindrome(n: Int): Boolean = if (revert(n) == n) true else false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выражение if (cond) true else false можно заменить на cond

}
count = sum - n
if (count != 0) {
number = square.toDouble() / Math.pow(10.0, count.toDouble())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow(Int, Int)

}
count = sum - n
if (count != 0) {
number = fibn.toDouble() / Math.pow(10.0, count.toDouble())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow(Int, Int)

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/seconds
  • [Example] lesson1.task1/sqRoot
  • [Example] lesson1.task1/sqr
  • [Easy] lesson1.task1/thirdDigit
  • [Example] lesson1.task1/discriminant
  • [Trivial] lesson1.task1/lengthInMeters
  • [Trivial] lesson1.task1/trackLength
  • [Easy] lesson1.task1/travelMinutes
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/numberRevert

Seed: -6264856230449157656

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 3 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 1 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay
  • [Normal] lesson2.task1/segmentLength

Seed: -6264856230449157656

lesson2.task2

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 3 / 5

Example: 1 / 1
Easy: 1 / 2
Normal: 1 / 2

Succeeded:

  • [Example] lesson2.task2/pointInsideCircle
  • [Easy] lesson2.task2/isNumberHappy
  • [Normal] lesson2.task2/circleInside

Failed:

  • [Easy] lesson2.task2/queenThreatens
    • org.opentest4j.AssertionFailedError :
  • [Easy] lesson2.task2/queenThreatens
    • Expected:
      true
    • Actual:
      false
    • Inputs:
      • x1 ->
        2
      • y1 ->
        7
      • x2 ->
        4
      • y2 ->
        5
    • Exception: null
  • [Normal] lesson2.task2/brickPasses
    • Expected:
      false
    • Actual:
      true
    • Inputs:
      • a ->
        2
      • b ->
        558
      • c ->
        2
      • r ->
        1
      • s ->
        648
    • Exception: null

Seed: -6264856230449157656

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 15 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 2 / 2

Succeeded:

  • [Example] lesson3.task1/factorial
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/isPerfect
  • [Example] lesson3.task1/digitCountInNumber
  • [Trivial] lesson3.task1/digitNumber
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/lcm
  • [Easy] lesson3.task1/minDivisor
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Normal] lesson3.task1/isPalindrome
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Hard] lesson3.task1/squareSequenceDigit
  • [Hard] lesson3.task1/fibSequenceDigit

Seed: -6264856230449157656

owner

SeveNChaK []

@ice-phoenix
Copy link
Contributor

Обратите внимание, что ваш код не проходит один из встроенных в проект тестов. В дальнейшем проверяйте ваш код на работоспособность локально, у себя на машине, при помощи запуска встроенных тестов в IDE.

*/
fun seconds(hours: Int, minutes: Int, seconds: Int): Int = TODO()
fun seconds(hours: Int, minutes: Int, seconds: Int): Int {
val x1 = hours * 60 * 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переменным лучше давать осмысленные имена, соответствующие их назначению в коде

*/
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double = TODO()
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double {
val s = sagenes * 48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переменным лучше давать осмысленные имена, соответствующие их назначению в коде

t2: Double, v2: Double,
t3: Double, v3: Double): Double = TODO()
t3: Double, v3: Double): Double {
val ps = (t1 * v1 + t2 * v2 + t3 * v3) / 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Повторно вычисляемые подвыражения лучше вынести в отдельные переменные

fun segmentLength(a: Int, b: Int, c: Int, d: Int): Int = TODO()
fun segmentLength(a: Int, b: Int, c: Int, d: Int): Int {

if ((c in a..b) && (d in a..b)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Данное выражение лучше оформить как when

package lesson2.task2

import lesson1.task1.sqr
import lesson4.task1.abs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем вам здесь этот импорт?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Никогда не добавлял импорт ни в один урок, он сам

fun lcm(m: Int, n: Int): Int = TODO()
fun lcm(m: Int, n: Int): Int {
var k = Math.min(n, m)
val min = Math.min(m, n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем два раза вызывать min(m, n)?

val min = Math.min(m, n)
while (true) {
if ((k % m == 0) && (k % n == 0)) return k
else k = k + min
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почитайте про более быстрые алгоритмы поиска НОК

*/
fun maxDivisor(n: Int): Int = TODO()
fun maxDivisor(n: Int): Int {
var res = n - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет ли более точной верхней границы для возможных делителей, чем n?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не понял вопроса

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если мы ищем делители числа n, не равные n, какое максимальное значение может принимать любой другой делитель?

*/
fun isCoPrime(m: Int, n: Int): Boolean = TODO()
fun isCoPrime(m: Int, n: Int): Boolean {
var a: Int = m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Объясните, что делает ваш новый код, в комментарии
  • Нельзя ли вынести часть функциональности вашей функции в отдельную функцию, которая могла бы помочь при решении других задач?

var revertNumber = 0
var number = n
while (k >= 0) {
revertNumber = revertNumber + pow(10, k) * (number % 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему бы вместо переменной k и постоянного возведения в степень не начать с требуемой степени десятки и уменьшать ее на 10 каждый раз?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошая идея:)

Copy link
Author

@SeveNChaK SeveNChaK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ничего не менял в той задаче, все также через алгоритм Евклида

*/
fun isCoPrime(m: Int, n: Int): Boolean = TODO()
fun isCoPrime(m: Int, n: Int): Boolean {
var a: Int = m
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Через алгоритм Евклида находит НОД и если он единица, то числа взаимно простые.

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/seconds
  • [Trivial] lesson1.task1/lengthInMeters
  • [Easy] lesson1.task1/numberRevert
  • [Example] lesson1.task1/sqr
  • [Example] lesson1.task1/discriminant
  • [Example] lesson1.task1/sqRoot
  • [Trivial] lesson1.task1/trackLength
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/thirdDigit
  • [Easy] lesson1.task1/travelMinutes

Seed: 4397626888305790086

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 2 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 0 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay

Failed:

  • [Normal] lesson2.task1/segmentLength
    • Expected:
      -1
    • Actual:
      1482575
    • Inputs:
      • a ->
        482575
      • b ->
        482575
      • c ->
        -1000000
      • d ->
        -999999
    • Exception: null

Seed: 4397626888305790086

lesson2.task2

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 5 / 5

Example: 1 / 1
Easy: 2 / 2
Normal: 2 / 2

Succeeded:

  • [Example] lesson2.task2/pointInsideCircle
  • [Easy] lesson2.task2/isNumberHappy
  • [Easy] lesson2.task2/queenThreatens
  • [Normal] lesson2.task2/circleInside
  • [Normal] lesson2.task2/brickPasses

Seed: 4397626888305790086

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 15 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 2 / 2

Succeeded:

  • [Normal] lesson3.task1/isPalindrome
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Example] lesson3.task1/factorial
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/isPerfect
  • [Example] lesson3.task1/digitCountInNumber
  • [Trivial] lesson3.task1/digitNumber
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/lcm
  • [Easy] lesson3.task1/minDivisor
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Hard] lesson3.task1/squareSequenceDigit
  • [Hard] lesson3.task1/fibSequenceDigit

Seed: 4397626888305790086

owner

SeveNChaK []

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 3 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 1 / 1

Succeeded:

  • [Easy] lesson2.task1/timeForHalfWay
  • [Example] lesson2.task1/minBiRoot
  • [Normal] lesson2.task1/segmentLength

Seed: 4580750298525503986

owner

SeveNChaK []

*/
fun seconds(hours: Int, minutes: Int, seconds: Int): Int = TODO()
fun seconds(hours: Int, minutes: Int, seconds: Int): Int {
val hour = hours * 60 * 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переменным лучше давать осмысленные имена, соответствующие их назначению в коде. Это не час, это количество секунд в заданном количестве часов.

*/
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double = TODO()
fun lengthInMeters(sagenes: Int, arshins: Int, vershoks: Int): Double {
val sagene = sagenes * 48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

См. замечание выше

*/
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double = TODO()
fun trackLength(x1: Double, y1: Double, x2: Double, y2: Double): Double {
val sx = abs(x1 - x2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем брать модуль перед возведением в квадрат?

val part2 = t2 * v2
val part3 = t3 * v3
val ps = (part1 + part2 + part3) / 2
when {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вместо when { ... return ... return ... return ... } лучше сделать return when { ... }

(a >= c) && (b <= d) -> return b - a
c in a..b -> return b - c
d in a..b -> return d - a
else -> return -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обратите внимание, что тесты для данной функции не проходят

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проходит, у меня нигде нет сообщения об ошибке. Там два коммита почти сразу было, в первом не правильно, во втором все прошло.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, прошу прощения, не заметил второго коммита

* Вернуть true, если кирпич пройдёт
*/
fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean = TODO()
fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean = ((((a <= r) && (b <= s)) || ((a <= s) && (b <= r))) || (((a <= r) && (c <= s)) || ((a <= s) && (c <= r))) || (((b <= r) && (c <= s)) || ((b <= s) && (c <= r))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такой код лучше форматировать как

a && b
|| c && d
|| e && f
|| ...

return n
}

fun NOD(x: Int, y: Int): Int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Функции в Котлине принято называть camelCase
  • Данную функцию лучше назвать gcd

var f1 = 1
var f2 = 0
var result = 1
if (n < 3) return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сколько раз будет выполнено тело цикла ниже, если n < 3? Имеет ли смысл данная проверка?

*/
fun maxDivisor(n: Int): Int = TODO()
fun maxDivisor(n: Int): Int {
var res = n - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если мы ищем делители числа n, не равные n, какое максимальное значение может принимать любой другой делитель?

sum = sum + digitNumber(square)
}
count = sum - n
if (count != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем эта проверка? Что сделает код ниже, если count == 0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ненужные действия - исправил. В последней задачи тоже надо исправить, но поздно сообразил (после того как уже запушил), не стал лишний раз коммит делать.

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson1.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 10 / 12

Example: 4 / 4
Trivial: 3 / 4
Easy: 3 / 4

Succeeded:

  • [Trivial] lesson1.task1/seconds
  • [Trivial] lesson1.task1/trackLength
  • [Example] lesson1.task1/sqRoot
  • [Trivial] lesson1.task1/lengthInMeters
  • [Example] lesson1.task1/sqr
  • [Example] lesson1.task1/discriminant
  • [Example] lesson1.task1/quadraticRootProduct
  • [Easy] lesson1.task1/numberRevert
  • [Easy] lesson1.task1/thirdDigit
  • [Easy] lesson1.task1/travelMinutes

Seed: 1077813246755573219

lesson2.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 3 / 7

Example: 1 / 1
Easy: 1 / 5
Normal: 1 / 1

Succeeded:

  • [Example] lesson2.task1/minBiRoot
  • [Easy] lesson2.task1/timeForHalfWay
  • [Normal] lesson2.task1/segmentLength

Seed: 1077813246755573219

lesson2.task2

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 5 / 5

Example: 1 / 1
Easy: 2 / 2
Normal: 2 / 2

Succeeded:

  • [Example] lesson2.task2/pointInsideCircle
  • [Easy] lesson2.task2/isNumberHappy
  • [Easy] lesson2.task2/queenThreatens
  • [Normal] lesson2.task2/circleInside
  • [Normal] lesson2.task2/brickPasses

Seed: 1077813246755573219

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 15 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 2 / 2

Succeeded:

  • [Example] lesson3.task1/factorial
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/isPerfect
  • [Trivial] lesson3.task1/digitNumber
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/lcm
  • [Easy] lesson3.task1/minDivisor
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Normal] lesson3.task1/isPalindrome
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Hard] lesson3.task1/squareSequenceDigit
  • [Hard] lesson3.task1/fibSequenceDigit
  • [Example] lesson3.task1/digitCountInNumber

Seed: 1077813246755573219

owner

SeveNChaK []

Copy link
Contributor

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все хорошо, за исключением нескольких замечаний

(a >= c) && (b <= d) -> return b - a
c in a..b -> return b - c
d in a..b -> return d - a
else -> return -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, прошу прощения, не заметил второго коммита

x2: Double, y2: Double, r2: Double): Boolean = TODO()
x2: Double, y2: Double, r2: Double): Boolean {
val r = Math.sqrt(sqr(y1 - y2) + sqr(x1 - x2)) + r1
return (r <= r2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишние скобки вокруг выражения

*/
fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean = TODO()
fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean =
((((a <= r) && (b <= s))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Много лишних скобок, которые можно убрать, если вспомнить о приоритете операций в Котлине

* Например, 25 и 49 взаимно простые, а 6 и 8 -- нет.
*/
fun isCoPrime(m: Int, n: Int): Boolean = TODO()
fun isCoPrime(m: Int, n: Int): Boolean = (gcd(m, n) == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишние скобки

fun revert(n: Int): Int = TODO()
fun revert(n: Int): Int {
var k = pow(10, digitNumber(n) - 1)
var revertNumber = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше revertedNumber

sum = sum + digitNumber(fibn)
}
count = sum - n
if (count != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужна ли эта проверка?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, я вчера заметил, исправлю

@kotlin-polytech-bot
Copy link

author

Alex [korneev.ry@yandex.ru]

lesson2.task2

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 5 / 5

Example: 1 / 1
Easy: 2 / 2
Normal: 2 / 2

Succeeded:

  • [Normal] lesson2.task2/circleInside
  • [Normal] lesson2.task2/brickPasses
  • [Easy] lesson2.task2/isNumberHappy
  • [Easy] lesson2.task2/queenThreatens
  • [Example] lesson2.task2/pointInsideCircle

Seed: 1912800749757994264

lesson3.task1

Author: Alex [korneev.ry@yandex.ru]

Owner: SeveNChaK []

Total: 15 / 18

Example: 4 / 4
Trivial: 1 / 1
Easy: 5 / 8
Normal: 3 / 3
Hard: 2 / 2

Succeeded:

  • [Normal] lesson3.task1/isPalindrome
  • [Normal] lesson3.task1/hasDifferentDigits
  • [Example] lesson3.task1/factorial
  • [Example] lesson3.task1/isPrime
  • [Example] lesson3.task1/isPerfect
  • [Example] lesson3.task1/digitCountInNumber
  • [Trivial] lesson3.task1/digitNumber
  • [Easy] lesson3.task1/fib
  • [Easy] lesson3.task1/lcm
  • [Easy] lesson3.task1/minDivisor
  • [Easy] lesson3.task1/maxDivisor
  • [Easy] lesson3.task1/isCoPrime
  • [Normal] lesson3.task1/revert
  • [Hard] lesson3.task1/squareSequenceDigit
  • [Hard] lesson3.task1/fibSequenceDigit

Seed: 1912800749757994264

owner

SeveNChaK []

@SeveNChaK
Copy link
Author

Готов сдать полностью Lesson 4, как только мы закончим с этим пулл реквестом.27.10.2016, 17:59, "Marat Akhin" notifications@github.com:@ice-phoenix requested changes on this pull request.

Все хорошо, за исключением нескольких замечаний

In src/lesson2/task1/IfElse.kt:

\ No newline at end of file
+fun segmentLength(a: Int, b: Int, c: Int, d: Int): Int {

  • when {
  •    (c >= a) && (d <= b) -> return d - c
    
  •    (a >= c) && (b <= d) -> return b - a
    
  •    c in a..b -> return b - c
    
  •    d in a..b -> return d - a
    
  •    else -> return -1
    

Да, прошу прощения, не заметил второго коммита

In src/lesson2/task2/Logical.kt:

@@ -35,7 +43,10 @@ fun queenThreatens(x1: Int, y1: Int, x2: Int, y2: Int): Boolean = TODO()

  • Вернуть true, если утверждение верно
    */
    fun circleInside(x1: Double, y1: Double, r1: Double,
    •             x2: Double, y2: Double, r2: Double): Boolean = TODO()
      
    •             x2: Double, y2: Double, r2: Double): Boolean {
      
    • val r = Math.sqrt(sqr(y1 - y2) + sqr(x1 - x2)) + r1
    • return (r <= r2)

Лишние скобки вокруг выражения

In src/lesson2/task2/Logical.kt:

@@ -46,4 +57,10 @@ fun circleInside(x1: Double, y1: Double, r1: Double,

  • кирпич 4 х 4 х 4 пройдёт через отверстие 4 х 4.
  • Вернуть true, если кирпич пройдёт
    */
    -fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean = TODO()
    +fun brickPasses(a: Int, b: Int, c: Int, r: Int, s: Int): Boolean =
    •    ((((a <= r) && (b <= s))
      

Много лишних скобок, которые можно убрать, если вспомнить о приоритете операций в Котлине

In src/lesson3/task1/Loop.kt:

@@ -96,7 +137,7 @@ fun maxDivisor(n: Int): Int = TODO()

  • Взаимно простые числа не имеют общих делителей, кроме 1.
  • Например, 25 и 49 взаимно простые, а 6 и 8 -- нет.
    */
    -fun isCoPrime(m: Int, n: Int): Boolean = TODO()
    +fun isCoPrime(m: Int, n: Int): Boolean = (gcd(m, n) == 1)

Лишние скобки

In src/lesson3/task1/Loop.kt:

@@ -131,7 +172,17 @@ fun cos(x: Double, eps: Double): Double = TODO()

  • Поменять порядок цифр заданного числа n на обратный: 13478 -> 87431.
  • Не использовать строки при решении задачи.
    */
    -fun revert(n: Int): Int = TODO()
    +fun revert(n: Int): Int {
    • var k = pow(10, digitNumber(n) - 1)
    • var revertNumber = 0

Лучше revertedNumber

In src/lesson3/task1/Loop.kt:

@@ -166,4 +233,19 @@ fun squareSequenceDigit(n: Int): Int = TODO()

  • 1123581321345589144...
  • Например, 2-я цифра равна 1, 9-я 2, 14-я 5.
    */
    -fun fibSequenceDigit(n: Int): Int = TODO()
    +fun fibSequenceDigit(n: Int): Int {
    • var fibn = 0
    • var sum = 0
    • var count = 1
    • var number = 0
    • while (sum < n) {
    •    fibn = fib(count)
      
    •    count++
      
    •    sum = sum + digitNumber(fibn)
      
    • }
    • count = sum - n
    • if (count != 0) {

Нужна ли эта проверка?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

@ice-phoenix
Copy link
Contributor

Все отлично, можете заливать 4 урок. Этот PR я закрываю, чтобы GitHub'у было попроще =)

@SeveNChaK
Copy link
Author

Ураа:)28.10.2016, 15:39, "Marat Akhin" notifications@github.com:Все отлично, можете заливать 4 урок. Этот PR я закрываю, чтобы GitHub'у было попроще =)

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants