mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-22 08:13:57 +00:00
fix of
This commit is contained in:
parent
4e70f449e4
commit
4e7580bb57
@ -10,33 +10,67 @@ private fun Int.toDigits(): List<Byte> {
|
|||||||
return "$this".map { "$it".toByte() }
|
return "$this".map { "$it".toByte() }
|
||||||
}
|
}
|
||||||
|
|
||||||
val UPPER_DIAG_MATRIX_INDEX = 0 to 3
|
val UPPER_DIAG_MATRIX_INDEX = 3 to 0
|
||||||
val DOWN_DIAG_MATRIX_INDEX = 4 to 3
|
val DOWN_DIAG_MATRIX_INDEX = 3 to 4
|
||||||
|
|
||||||
val FIRST_ROW_SUM_MATRIX_INDEX = 1 to 3
|
val FIRST_ROW_SUM_MATRIX_INDEX = 3 to 1
|
||||||
val SECOND_ROW_SUM_MATRIX_INDEX = 2 to 3
|
val SECOND_ROW_SUM_MATRIX_INDEX = 3 to 2
|
||||||
val THIRD_ROW_SUM_MATRIX_INDEX = 3 to 3
|
val THIRD_ROW_SUM_MATRIX_INDEX = 3 to 3
|
||||||
|
|
||||||
val FIRST_COLUMN_SUM_MATRIX_INDEX = 3 to 1
|
val FIRST_COLUMN_SUM_MATRIX_INDEX = 0 to 4
|
||||||
val SECOND_COLUMN_SUM_MATRIX_INDEX = 3 to 2
|
val SECOND_COLUMN_SUM_MATRIX_INDEX = 1 to 4
|
||||||
val THIRD_COLUMN_SUM_MATRIX_INDEX = 3 to 3
|
val THIRD_COLUMN_SUM_MATRIX_INDEX = 2 to 4
|
||||||
|
|
||||||
val EMPTY_CEILS_OF_MATRIX = (0 until 3).map { 0 to it }
|
val EMPTY_CEILS_OF_MATRIX = (0 until 3).map { it to 0 }
|
||||||
|
|
||||||
open class Psychomatrix(val date: DateTime) {
|
open class Psychomatrix(val date: DateTime) {
|
||||||
protected open val numbers: ByteArray = ByteArray(10)
|
protected open val numbers: ByteArray = ByteArray(10)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always array 4*5 of values. In rows was put columns (
|
* Always array 4*5 of values. In rows was put columns
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
val asMatrix: Array<Array<Byte>>
|
val asMatrix: Array<Array<PsychomatrixCeilInfo>>
|
||||||
get() = arrayOf(
|
get() = arrayOf(
|
||||||
arrayOf(-1, -1, -1, getUpperDiagSum()),
|
arrayOf(
|
||||||
arrayOf(numbers[1], numbers[4], numbers[7], getRowSum(0)),
|
null,
|
||||||
arrayOf(numbers[2], numbers[5], numbers[8], getRowSum(1)),
|
numbers[0],
|
||||||
arrayOf(numbers[3], numbers[6], numbers[9], getRowSum(2)),
|
numbers[1],
|
||||||
arrayOf(getColumnSum(0), getColumnSum(1), getColumnSum(2), getDownDiagSum())
|
numbers[2],
|
||||||
)
|
getColumnSum(0)
|
||||||
|
),
|
||||||
|
arrayOf(
|
||||||
|
null,
|
||||||
|
numbers[3],
|
||||||
|
numbers[4],
|
||||||
|
numbers[5],
|
||||||
|
getColumnSum(1)
|
||||||
|
),
|
||||||
|
arrayOf(
|
||||||
|
null,
|
||||||
|
numbers[6],
|
||||||
|
numbers[7],
|
||||||
|
numbers[8],
|
||||||
|
getColumnSum(2)
|
||||||
|
),
|
||||||
|
arrayOf(
|
||||||
|
getUpperDiagSum(),
|
||||||
|
getRowSum(0),
|
||||||
|
getRowSum(1),
|
||||||
|
getRowSum(2),
|
||||||
|
getDownDiagSum()
|
||||||
|
)
|
||||||
|
).mapIndexed {
|
||||||
|
x, yArray ->
|
||||||
|
yArray.mapIndexed {
|
||||||
|
y, value ->
|
||||||
|
PsychomatrixCeilInfo(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
value ?.toInt()
|
||||||
|
)
|
||||||
|
}.toTypedArray()
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val dateDigits = dateFormat.print(date).map { "$it".toByte() }.toMutableList()
|
val dateDigits = dateFormat.print(date).map { "$it".toByte() }.toMutableList()
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.github.insanusmokrassar.PsychomatrixBase.domain.entities
|
||||||
|
|
||||||
|
data class PsychomatrixCeilInfo(
|
||||||
|
val x: Int,
|
||||||
|
val y: Int,
|
||||||
|
val count: Int?
|
||||||
|
) {
|
||||||
|
val ceilCoordsAsPair = x to y
|
||||||
|
val isUpperDiag = ceilCoordsAsPair == UPPER_DIAG_MATRIX_INDEX
|
||||||
|
val isDownDiag = ceilCoordsAsPair == DOWN_DIAG_MATRIX_INDEX
|
||||||
|
|
||||||
|
val isFirstRowSum = ceilCoordsAsPair == FIRST_ROW_SUM_MATRIX_INDEX
|
||||||
|
val isSecondRowSum = ceilCoordsAsPair == SECOND_ROW_SUM_MATRIX_INDEX
|
||||||
|
val isThirdRowSum = ceilCoordsAsPair == THIRD_ROW_SUM_MATRIX_INDEX
|
||||||
|
|
||||||
|
val isFirstColumnSum = ceilCoordsAsPair == FIRST_COLUMN_SUM_MATRIX_INDEX
|
||||||
|
val isSecondColumnSum = ceilCoordsAsPair == SECOND_COLUMN_SUM_MATRIX_INDEX
|
||||||
|
val isThirdColumnSum = ceilCoordsAsPair == THIRD_COLUMN_SUM_MATRIX_INDEX
|
||||||
|
|
||||||
|
val isCalculated =
|
||||||
|
ceilCoordsAsPair in EMPTY_CEILS_OF_MATRIX
|
||||||
|
|| isUpperDiag || isDownDiag
|
||||||
|
|| isFirstRowSum || isSecondRowSum || isThirdRowSum
|
||||||
|
|| isFirstColumnSum || isSecondColumnSum || isThirdColumnSum
|
||||||
|
|
||||||
|
val numberOfCharacteristic: Byte? = if (
|
||||||
|
isCalculated
|
||||||
|
) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
(x * 3 + y).toByte()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user