Size: a a a

2020 October 22

MG

Matthew Good in pro.algorithms
hmm ok
источник

AM

Azure Mynn in pro.algorithms
And if they're the same height, I think just diving the total height by the line height is enough, that way you get the exact number of lines that can fit on a screen at once and then do min(line_count, max_lines) to find out the number of lines to draw
источник

MG

Matthew Good in pro.algorithms
welp i figured it out :)


boolean hitBottom = false;

public void setOffsetY(int y) {
   LineStats lineStats = textStats.lines.get(textStats.lineCount-1);
   if (y <= (lineStats.yOffset + y)) {
       float offset = y;
       float heightOffset = lineStats.maxHeightF + offset;
       boolean bottom = lineStats.bounds.bottom <= heightOffset;
       if (!bottom) {
           Log.d(TAG, "setOffsetY() called with: y = [" + y + "]");
           offset_y = y;
           hitBottom = false;
       } else {
           if (!hitBottom) {
               Log.d(TAG, "setOffsetY() called with: y = [" + y + "]");
               offset_y = y;
               hitBottom = true;
           }
       }
   }
}
источник

AM

Azure Mynn in pro.algorithms
Aight
источник

MG

Matthew Good in pro.algorithms
only problem now is i can still go a bit past the actual bottom

eg if i recieve a y that is greater than what i would normally need to detect the bottom due to y being updated faster than it can track it

for example, flinging across the screen instead of normally scrolling
источник

MG

Matthew Good in pro.algorithms
doing

offset_y = lineStats.bounds.bottom - lineStats.maxHeight;
hitBottom = true;


seems to fix this
источник

MG

Matthew Good in pro.algorithms
ok now i feel stupid because i can change all this to

public void setOffsetY(int y) {
   LineStats lineStats = textStats.lines.get(textStats.lineCount-1);
   offset_y = Math.min(y, lineStats.bounds.bottom - lineStats.maxHeight);
}
источник

MG

Matthew Good in pro.algorithms
and account...

for negatives

for X in the case of non word wrapping

for nulls in the case of there being no lines actually present (empty text)

for our line dimensions being smaller than our screen height

and vola

public void setOffsetX(int x) {
   if (x < 0) {
       offset_x = 0;
   } else {
       // to deal with x, we need only obtain the line with the longest width
       LineStats lineStats = textStats.getLineWithLongestWidth();
       if (lineStats != null) {
           // our line's width may be smaller than our screen screen width
           if (lineStats.bounds.right > lineStats.maxWidth) {
               offset_x = Math.min(x, lineStats.bounds.right - lineStats.maxWidth);
           } else {
               offset_x = Math.min(x, lineStats.bounds.right);
           }
       }
   }
}

public void setOffsetY(int y) {
   if (y < 0) {
       offset_y = 0;
   } else {
       // to deal with y, we need only obtain the line with the longest total height
       // this is always the last line
       LineStats lineStats = textStats.getLastLine();
       if (lineStats != null) {
           // our line's height may be smaller than our screen screen height
           if (lineStats.bounds.bottom > lineStats.maxHeight) {
               offset_y = Math.min(y, lineStats.bounds.bottom - lineStats.maxHeight);
           } else {
               offset_x = Math.min(y, lineStats.bounds.bottom);
           }
       }
   }
}
источник

Ш

ШаХа in pro.algorithms
Всем привет, столкнулся с задачей по теор вер.
В общем задача такая. У вас сначала есть пустая строка, на каждой итерации вы можете поставить букву 'a' с вероятностью pa / (pa + pb), а так же поставить букву 'b' с вероятность pb / (pa + pb). Вы завершите тогда когда у вас в строке есть хотя бы k подпоследовательности 'ab'.

Найти мат ожидания количество подпоследовательности 'ab' в конечной строке
источник

Ш

ШаХа in pro.algorithms
k <= 1000
источник

Ш

ШаХа in pro.algorithms
ну тут получается можно написать dp
источник

Ш

ШаХа in pro.algorithms
но я не понимаю что делать в ситуациях
Допустим k = 1 и у нас бесконечная последовательность
ab
aab
aaab
..........
то есть мы должны просуммировать такую вещь
(pa / (pa + pb)) ^ i * pb / (pa + pb) * i
источник

Ш

ШаХа in pro.algorithms
Пример
k = 1, pa = 1, pb = 1
мат ожидания 2
кто то может объяснить ? плз
источник

CD

Constantine Drozdov in pro.algorithms
В чем вопрос? Как найти среднее геометрического распределения?
источник

Ш

ШаХа in pro.algorithms
Constantine Drozdov
В чем вопрос? Как найти среднее геометрического распределения?
почитал сейчас про геометрическое распределения и понял что тут это и используют
источник

Ш

ШаХа in pro.algorithms
спасибо
источник

CD

Constantine Drozdov in pro.algorithms
ШаХа
почитал сейчас про геометрическое распределения и понял что тут это и используют
Про производящие функции ещё почитайте
источник

Ш

ШаХа in pro.algorithms
хорошо
источник

DK

Dmitry Kozyrev in pro.algorithms
ШаХа
Всем привет, столкнулся с задачей по теор вер.
В общем задача такая. У вас сначала есть пустая строка, на каждой итерации вы можете поставить букву 'a' с вероятностью pa / (pa + pb), а так же поставить букву 'b' с вероятность pb / (pa + pb). Вы завершите тогда когда у вас в строке есть хотя бы k подпоследовательности 'ab'.

Найти мат ожидания количество подпоследовательности 'ab' в конечной строке
вы уверены, что именно это нужно найти? Ответ всегда равен k
источник

DK

Dmitry Kozyrev in pro.algorithms
>> Вы завершите тогда когда у вас в строке есть хотя бы k подпоследовательности 'ab'.
>> Найти мат ожидания количество подпоследовательности 'ab' в конечной строке
ответ: k
источник