mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-14 20:33:57 +00:00
update calculating of numbers
This commit is contained in:
parent
814a43e490
commit
2655b628c5
@ -8,7 +8,7 @@ import kotlinx.coroutines.experimental.async
|
|||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
class MutablePsychomatrix(date: DateTime) : Psychomatrix(date) {
|
class MutablePsychomatrix(date: DateTime) : Psychomatrix(date) {
|
||||||
private var mutableNumbers = super.numbers.toMutableList()
|
private var mutableNumbers = calculateNumbers(date).toMutableList()
|
||||||
|
|
||||||
override val numbers: ByteArray
|
override val numbers: ByteArray
|
||||||
get() = mutableNumbers.toByteArray()
|
get() = mutableNumbers.toByteArray()
|
||||||
|
@ -23,8 +23,39 @@ val THIRD_COLUMN_SUM_MATRIX_INDEX = 2 to 4
|
|||||||
|
|
||||||
val EMPTY_CEILS_OF_MATRIX = (0 until 3).map { it to 0 }
|
val EMPTY_CEILS_OF_MATRIX = (0 until 3).map { it to 0 }
|
||||||
|
|
||||||
|
fun calculateNumbers(dateTime: DateTime): ByteArray {
|
||||||
|
val dateDigits = dateFormat.print(dateTime).map { "$it".toByte() }.toMutableList()
|
||||||
|
|
||||||
|
val firstNumber = dateDigits.sum()
|
||||||
|
val firstNumberDigits = firstNumber.toDigits()
|
||||||
|
|
||||||
|
val secondNumber = firstNumberDigits.sum()
|
||||||
|
val secondNumberDigits = secondNumber.toDigits()
|
||||||
|
|
||||||
|
val thirdNumber = firstNumber - dateDigits[0] * 2
|
||||||
|
val thirdNumberDigits = thirdNumber.toDigits()
|
||||||
|
|
||||||
|
val fourthNumber = thirdNumberDigits.sum()
|
||||||
|
val fourthNumberDigits = fourthNumber.toDigits()
|
||||||
|
|
||||||
|
dateDigits.addAll(firstNumberDigits)
|
||||||
|
dateDigits.addAll(secondNumberDigits)
|
||||||
|
dateDigits.addAll(thirdNumberDigits)
|
||||||
|
dateDigits.addAll(fourthNumberDigits)
|
||||||
|
|
||||||
|
return ByteArray(10).also {
|
||||||
|
numbers ->
|
||||||
|
(0 until numbers.size).forEach {
|
||||||
|
index ->
|
||||||
|
numbers[index] = dateDigits.count {
|
||||||
|
it == index.toByte()
|
||||||
|
}.toByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open class Psychomatrix(val date: DateTime) {
|
open class Psychomatrix(val date: DateTime) {
|
||||||
protected open val numbers: ByteArray = ByteArray(10)
|
protected open val numbers: ByteArray = calculateNumbers(date)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always array 4*5 of values. In rows was put columns
|
* Always array 4*5 of values. In rows was put columns
|
||||||
@ -72,34 +103,6 @@ open class Psychomatrix(val date: DateTime) {
|
|||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
|
|
||||||
init {
|
|
||||||
val dateDigits = dateFormat.print(date).map { "$it".toByte() }.toMutableList()
|
|
||||||
|
|
||||||
val firstNumber = dateDigits.sum()
|
|
||||||
val firstNumberDigits = firstNumber.toDigits()
|
|
||||||
|
|
||||||
val secondNumber = firstNumberDigits.sum()
|
|
||||||
val secondNumberDigits = secondNumber.toDigits()
|
|
||||||
|
|
||||||
val thirdNumber = firstNumber - dateDigits[0] * 2
|
|
||||||
val thirdNumberDigits = thirdNumber.toDigits()
|
|
||||||
|
|
||||||
val fourthNumber = thirdNumberDigits.sum()
|
|
||||||
val fourthNumberDigits = fourthNumber.toDigits()
|
|
||||||
|
|
||||||
dateDigits.addAll(firstNumberDigits)
|
|
||||||
dateDigits.addAll(secondNumberDigits)
|
|
||||||
dateDigits.addAll(thirdNumberDigits)
|
|
||||||
dateDigits.addAll(fourthNumberDigits)
|
|
||||||
|
|
||||||
(0 until numbers.size).forEach {
|
|
||||||
index ->
|
|
||||||
numbers[index] = dateDigits.count {
|
|
||||||
it == index.toByte()
|
|
||||||
}.toByte()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return count of numbers of `i`
|
* @return count of numbers of `i`
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user