## algorithms – Determining number of \$j\$ such that \$b_j le c_i\$ and \$a_j le b_i\$ in time \$O(log n)\$

I have an array $$A$$ of length $$n$$, containing triplets (think of it as a $$3times n$$ matrix). Can I re-order the array (without reordering a triplet’s inner values) in time $$O(nlog n)$$ so that it is possible to answer the following query in $$O(log n)$$? Given $$i$$, determine the number of $$j$$ such that $$A_{2,j} le A_{3,i}$$ and $$A_{1,j} le A_{2,i}$$.

Posted on

## color – How did WCAG come up with the constants used in determining luminance

If you follow some of the links further you will get to the page about the information on the Standard Default Color Space for the Internet – sRGB. There are a number of definitions described in more detail (example in screenshot). However, I am curious as to why you are interested in finding out the constants because the calculations are done by tools which are standard in the industry. Wherever possible, it is certainly easier to use standard tools rather than trying to do the calculations yourself.

Posted on

## Algorithm for determining if two fundamental domains give the same Coxeter group

If I have the fundamental domains of two polytopes, how do I determine whether they have the same symmetry group?

Posted on

## linux – Efficient way of determining whether 2 directories have ANY difference?

I’d like to recursively compare two directory trees that are expected to be identical, but I don’t want a full comparison which would take forever. I’d like to do an efficient comparison so that as soon as 1 difference is detected, the command stops and returns, and tell me which file was different.

What I consider to be a difference:

• two files have different content (different timestamps doesn’t matter)
• a file was found in one directory but not the other (at the exact same path, of course)

Notes:

• I don’t need to know the actual differences within the file, just the filepath is enough
• I tried diff 3.7 on Ubuntu 20.04, it doesn’t have a “stop on difference” option that I could see
• The files are a mix of text and binary
Posted on

## real analysis – Determining compactness of the set \$S={frac{1}{m}+frac{1}{n}:min mathbb N, nin mathbb N}cup {0}\$ in metric space \$mathbb R\$

Given a set $$S={frac{1}{m}+frac{1}{n}:min mathbb N, nin mathbb N}cup {0}$$.
My attempt:
Claim $$1:0$$ is a limit point of set $$S$$.

Proof: Given any $$epsilon gt 0, exists N_epsilon in mathbb N: frac1{N_epsilon}lt epsilon/2$$. Choosing $$m,n ge N_epsilon$$,we have $$frac1{n}le frac1{N_epsilon}lt epsilon/2$$ and $$frac1{m}le frac1{N_epsilon}lt epsilon/2$$. Thus $$0ltfrac{1}{m}+frac{1}{n}lt epsilon$$. Since $$epsilon gt 0$$ is arbitrary, we conclude that $$0$$ is a limit point of $$S$$.

Claim $$2$$: All elements of set $$T={1/n: nin mathbb N}$$ are also limit points of $$S$$.

Proof: Given any $$epsilon gt 0, exists M_epsilon in mathbb N: frac1{M_epsilon}lt epsilonimplies frac1{m}lt epsilon ;;forall mge M_epsilonimplies -epsilonlt frac1{m}lt epsilon$$. Hence for any $$frac1{n}in T$$, we have $$frac 1{n}-epsilonlt frac 1{n}+ frac1{m}lt frac1{n}+epsilon$$. Just as previosuly, it follows that all elements of $$T$$ are limit points of $$S$$.

Heine-Borel theorem states that a set $$S$$ in $$R$$ is compact $$iff S$$ is closed and bounded. Indeed, in the present case, $$S$$ is bounded as $$2$$ is one upper bound.
Since, $$1/n notin S$$ for any $$nin mathbb N$$, $$S$$ is not closed and therefore, $$S$$ can’t be compact.

Is my conclusion correct? Thanks.

Posted on

## mobile application – Determining Information Priority using digital Survey

I would like to understand users information priority when it comes to planing trips, browsing and booking events/activities using mobile applications in general.

I’m currently limited to researching by conducting a (single page) digital survey (instead of in person interviews which I’d prefer).

Any tip on how to approach this or links to similar research are welcome. What’s your opinion about this type of questions:

“You are performing a task of planning your trip 2 weeks ahead/ looking for events to attend in your free time tomorrow.”

List of all Offers
List of all Vendors
Offer Categories (Music & Culture, Sport& Outdoor Activities, Shopping, Mobility)

Ticket Price
Date & Time
Location
Event Description
Vendor Contact
How many people have booked so far (how many still can)
Corona related information

“You have chosen an Event you want to book. Rank how important finding this information is to you:”
Payment options
Whether I have to sign up to pay
Can I return a ticket
Can I pay in cash on the spot
Can I save event to mobile phone calendar
Can I share on social media that I’ll be attending

Posted on

## calculus – Determining instantaneous rates of changes for quartic functions

I have 5 quartic functions that were found with quartic regression. Each function models a country’s relationship with rotavirus vaccination rates (x) against years (y, years are integers and not real values, ex. year 1 -> x=1, etc.)

f(x) = ax4 + bx3 + cx2 + dx + e Domain and Range
Morocco y = -0.220x⁴ + 5.44x³ – 47.3x² + 171x – 123 {x | 1≤x≤10} {y | 5.92 ≤y≤97}
Sudan y = -0.199x⁴ + 5.27x³ – 50.1x² + 205x – 220 {x | 2≤x≤10} {y | 28.6≤y≤100}
Rwanda y = -0.318x⁴ + 9.12x³ – 95.1x² + 426x – 592 {x | 3≤x≤10} {y | 50.6≤y≤98}
Ghana y = -0.290x⁴ + 8.20x³ – 84.6x² + 377x – 518 {x | 3≤x≤10} {y | 49.5≤y≤ 92}
Botswana y = -0.034x⁴ + 1.28x³ – 16.8x² + 90.2x – 78.3 {x | 3≤x≤10} {y | 72.9≤y≤83.7}

I’m now trying to find instantaneous rates of change for each country. I want to find instantaneous rates for each integer x value within a country’s domain. so for Rwanda, it’d be instantaneous rates of change for x=3,4,5,6,7,8,9,10. I’m super new to calculus so I’m not sure how I’d go about finding the derivative of my quartic functions to calculate instantaneous rates of change – if someone could help me through this and possibly show a sample calculation for one instantaneous rate of change for one of my countries, that’d be really appreciated!!

PS: my goal afterwards is to graph each country’s instantaneous rates of change values (y) over time (x) and perform linear regression each. and then, whichever country (instantaneous rate of change linear graph) has the highest slope value = increased the most in vaccination rates over x many years. please let me know if you think this makes sense if you can!

Posted on

## java – Determining winning line in TicTacToe game

I am trying to write code to determine a win in tic-tac-toe game. In this question, I am not focusing on the whole game, I am only interested in the question of how to determine that the game ended with the victory of one of the players. So I made a synthetic example to test different approaches.

My guess is that a winning line on the board can only appear after the current player has made his move. Therefore, it makes no sense to check all the lines on the board. I only consider those that include the last move made. I assume that the board can be of any size (but only square) and the winning line has the same size. Thus, it is one of the rows, or one of the columns, or one of the two diagonals.

After several attempts, I ended up with the code below:

``````import java.util.List;
import java.util.function.Predicate;

enum Cell {
X,
O,
B // blank cell
}

public class Board {

private final int size = 3;
private final Cell()() board;

public Board(Cell()() board) {
this.board = board;
}

private boolean isLineCompleted(Predicate<Integer> predicate) {
boolean result = true;
int i = 0;
while (result && i < size) {
result = predicate.test(i);
i++;
}
return result;
}

public boolean hasWinningLine(int row, int col) {
if (board(row)(col) == Cell.B) return false;

Cell base = board(row)(col);
List<Predicate<Integer>> checks = List.of(
i -> board(row)(i) == base, //columns
i -> board(i)(col) == base, //rows
i -> board(i)(i) == base,   //top-down diagonal
i -> board(size - i - 1)(i) == base //down-top diagonal
);

boolean lineCompleted = false;
for (var check : checks) {
if (!lineCompleted) {
lineCompleted = isLineCompleted(check);
}
}

return lineCompleted;
}
}
``````

And I wrote some tests that use this code something like this:

``````Cell()() xWins = {
{Cell.X, Cell.O, Cell.X},
{Cell.O, Cell.X, Cell.O},
{Cell.X, Cell.B, Cell.B}};

board = new Board(xWins);
AssertTrue(board.hasWinningLine(0, 2));
``````

I have several questions:

1. How easy is this code to read and understand? How can you improve it in this sense?

2. I try not to make unnecessary checks. The algorithm should return false as soon as it finds an unsuitable cell. Should I handle the loop like this

``````for (var check : checks) {
if (!lineCompleted) {
lineCompleted = isLineCompleted(check);
} else break; // That's better?
}
``````

Is it possible to rewrite this code using a stream API?

1. When checking each line, this code can compare the cell to itself. How can i avoid this without complicating the code? Should I even think about it?

I am new to programming and would appreciate any advice that would help me code better.

Posted on

## encryption – Hill Cipher: Determining the number of bad keys

Find the number of matrices whose determinant is a multiple of 13 where the first column is not a multiple of 13 but the second column is a multiple of the first modulo 13

But here’s what I did:
The number of combinations when the first column is not multiple of 13 is (26^2-2^2) = 2^2×(13^2-1)
The number of combinations when the second column is multiple of 13 is 2^2
Thus, the total combinations: 2^4 × (13^2 – 1)

The solution given is: 2^4 × (13^2 – 1) x 13

Please advise!

Posted on

## transactions – What literal thing is determining the price of Cryptos / stocks?

The “current Bitcoin price” from an exchange like Coinbase is simply the last price at which a buyer and seller agreed to trade Bitcoin at that exchange, also known as the “last price”. Every time a new trade takes place on that exchange, the price is updated.

The current price from sites that aren’t exchanges themselves, like Robinhood or Preev, are generally taken as the averages of the prices of all of the exchanges they connect to. Sometimes these averages are weighted, so that the price from exchanges with higher trade volume is weighted more heavily than the price from a very small exchange.

Posted on