## bitcoin core: how to worry about the specific unspent spending (coin selection algorithm) from the list of unused in a wallet to calculate the size of the transaction

I have a problem calculating dynamic transaction fees. The problem I face is to calculate the size of the transaction.
When I have one not spent in my wallet, it is too easy to calculate the size of the transaction. But when there are multiple unspent in the wallet, I think there is an algorithm for selecting coins to calculate the best not spent or combination of not spent.
I have compiled the document
document that explains this problem completely.

I need an opinion on the way I want to move. If you develop your own currency selection algorithm or are there other options?

## Does homomorphic encryption hide the algorithm itself?

The question is quite simple, but finding resources and answers is quite complicated. Homomorphic encryption should allow us to calculate on encrypted data. What if the algorithm for computing should also be kept secret? Since we have a functioning homomorphic encryption, is the algorithm that applies to the input data also safe?

Is it possible for an intruder to understand how the data is calculated and learn about the algorithm, since the intruder has access to the program that performs the calculation?

## Algorithm – How did they get the ball moving in Puzz Loop games?

I would like to ask if anyone knows how they achieved the movement of the ball in the game Puzz Loop 2.

The goal is to clear all the balls that move on a rail, with which it is behind pushing all the others.

You can watch a video for a better illustration, here.

The game was running on a CP System II, powered by a Motorola 68000 @ 16 Mhz. Question

How could you replicate the same ball game mechanics that move along a rail?

## Algorithm for multiplication tables – Computer Science Stack Exchange

Thank you for contributing a response to Computer Science Stack Exchange!

But avoid

• Make statements based on opinion; Support them with references or personal experience.

Use MathJax to format equations. MathJax reference.

## algorithm – Stack data structure in python 3

I have implemented a stack. It works well. But if you think something needs to be improved, say so. You would love to check my code.

class Stack:

def __init__(self):
self.stack = ()

def isEmpty(self):
return self.stack == ()

def push(self, data):
self.stack.append(data)

def pop(self):
data = self.stack(-1)
del self.stack(-1)
return data

def peek(self):
return self.stack(-1)

def sizeStack(self):
return len(self.stack)

stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
print(stack.sizeStack())
print("Popped: ", stack.pop())
print("Popped: ", stack.pop())
print(stack.sizeStack())
print("Peek:", stack.peek())
print(stack.sizeStack())


## Kotlin algorithm translation in Java code

I'm quite new to programming and I'm struggling to implement the cameraX analyzer https://codelabs.developers.google.com/codelabs/camerax-getting-started/#7.

Can anyone help convert this line of code? val pixels = data.map { it.toInt() and 0xFF } to Java

P.S. Variable data is an array of bytes.

## c ++ – Prim algorithm – Minimum expansion tree

I have implemented the Prim algorithm of Introduction to algorithms. I have observed that the code is similar to the Dijkstra Algorithm, so I have used the implementation of my Dijkstra Algorithm.

Review this code and suggest improvements.

To compile on Linux: g++ -std=c++14 prims.cpp

#include
#include
#include
#include
#include

class Graph
{

struct Vertex
{
std::size_t id;
int distance = std::numeric_limits::max();
Vertex * parent = nullptr;

Vertex(std::size_t id) : id(id) {}
};

using pair_ = std::pair;
std::vector vertices = {};

//adjacency list , store src, dest, and weight
//to store unprocessed vertex min-priority queue
std::priority_queue< pair_, std::vector,
std::greater > unprocessed;

public:
Graph(std::size_t size);
void add_edge(std::size_t src, std::size_t dest, int weight);
void prim(std::size_t vertex);
std::size_t  minimum_cost() ;
};

Graph::Graph(std::size_t size)
{
vertices.reserve(size);
for (int i = 0; i < size; i++)
{
vertices.emplace_back(i);
}
}

void Graph::add_edge(std::size_t src , std::size_t dest, int weight)
{
if(weight >= 0)
{
if (src == dest)
{
throw std::logic_error("Source and destination vertices are same");
}

if (src < 0 || vertices.size() <= src)
{
throw std::out_of_range("Enter correct source vertex");
}

if (dest < 0 || vertices.size() <= dest)
{
throw std::out_of_range("Enter correct destination vertex");
}

int flag = 0, i = src;
{
if (it.first == dest)
{
flag = 1;
break;
}
}
if (flag == 0)
{
}
else
{
throw std::logic_error("Existing edge");
}

}
else
{
std::cerr << "Negative weightn";
}
}

void Graph::prim(std::size_t vertex)
{
vertices(vertex).distance = 0;
vertices(vertex).parent = &vertices(vertex);

unprocessed.push( std::make_pair(vertices(vertex).distance, vertex) );
while (!unprocessed.empty())
{
int curr_vertex_dist = unprocessed.top().first;
std::size_t curr_vertex = unprocessed.top().second;
unprocessed.pop();

{
auto& next_dist = vertices(ver.first).distance;
const auto curr_dist = ver.second;
if (curr_dist < next_dist)
{
next_dist = curr_dist;
//make src vertex parent of dest vertex
vertices(ver.first).parent = &vertices(curr_vertex);
unprocessed.push( std::make_pair(next_dist, ver.first));
}
}
}
}

std::size_t  Graph::minimum_cost()
{
std::size_t cost = 0;
for (auto vertex: vertices)
{
cost = cost + vertex.distance;
}
return cost;
}

int main()
{
Graph grp(9);
grp.prim(0);
std::cout << "The total cost is : " << grp.minimum_cost() << "n";
}


## Simple algorithm execution time in image

Let's say we have an algorithm that gives an image and a set of "centers" changes each pixel in the image one by one after calculating which center is closest to our runtime by O (n) or O (cn) where c is the number of centers and if c were a constant fraction of n, would it become O (1)?

## algorithm – Linear discriminant analysis (LDA) – Covariance matrix problem

I am trying to follow this example from this LDA video:

In minute 7 if the video formula is given to calculate the covariance matrix, and the direct output of the covariance matrix is ​​given without explaining the mathematical steps:

 ((1/3 1/6),(1/6 1/3))


I tried to solve the mathematics manually and my problem is if I calculate

(x- means(x)) * (x- means(x))transpose

I do not understand the result. But instead if I use

(x- means(x))transpose * (x- means(x))


I get accurate results.

Please explain what the correct formula is because everywhere it is written as
(x- means(x)) * (x- means(x))transpose

But matrix multiplication is NOT commutative, that is. It is NOT true that AB = BA

## Optimization – How to make a tool algorithm to blur?

I am creating an algorithm for the stain tool, but it has to be done pixel by pixel.

The concept of tool for blurring is simple

onMouseMove – Copy the pixels from the old point to the new one using a brush template I am having problems in bitwise operations. The algorithm is not drawing pixels correctly (I am creating this algorithm from scratch, so there may be some silly errors)

diameter = brush.size;
_bitData = _canvas.bitmapData;
_bitwidth = _bitData.rect.width;//width of canvas

_bitVector = _bitData.getVector();//1d vector of uint

_brushVector = brush.bitmapData.getVector();//1d vector of uint

brushVectorIndex = 0;
for(yIndex = 0; yIndex < diameter; yIndex++)
{
for(xIndex = 0; xIndex < diameter; xIndex++)
{
yCor = yIndex + oldY;
xCor = xIndex + oldX;

if(_bitData.rect.contains(xCor,yCor))
{
bitVectorIndex_old      = (yCor * _bitWidth)        + xCor;
bitVectorIndex_new      = ((Y+yIndex) * _bitWidth)  + X+xIndex;

//Creating alpha map of brush and old mouse point's pixel
brushPixelAlpha = (_brushVector(brushVectorIndex) & _bitVector(bitVectorIndex_old) & 0xFF000000);

//Adding colors to the aplha map according to old mouse point's pixel
brushPixel = brushPixelAlpha | (_bitVector(bitVectorIndex_old) & 0x00FFFFFF);

//Create alpha map for new pixel
pixelAlpha = ((brushPixel | _bitVector(bitVectorIndex_new)) & 0xFF000000)

//Adding color to pixel alpha map using brush's stamp
pixel =  pixelAlpha | (brushPixel & 0x00FFFFFF);

_bitVector(bitVectorIndex_new) = pixel;
}
brushVectorIndex++;
}
}
_bitData.setVector(_bitVector);


If you could suggest how to optimize this code, that will also be useful because this code will run every 10,000 frames each frame.