## c – Determine if a point is inside or ouside of an irregular shape on a bitmap

You are given an irregular shape on a bitmap. How do you determine if
a point is inside or ousdie of the shape?

We are allowed to assume that `helper functions` are already available for us and we don’t need to write them as well.

So I decided that I can use a function that returns me the status of a given bit on that bitmap.

``````int IsBitIsOn(bitmap_ty *bitmap, size_t x, size_t y);
``````

We also can assume that the given point won’t be a point on the outline of the shape. Which means the given X,Y coordinates must be either inside or outside the shape and not on one of the outlines.

And here is my full code of the task,
I wrote it as a bitmap that every `ON(==1)` bit tells me that I’m on an outline, while `0 bit` tells me i’m either `inside` or `outside` the shape.

``````int IsInTheShape(bitmap_ty *bitmap, size_t x, size_t y)
{
int IsIn = 0; /* flag of whether the given point is inside the shape    */

int ComeFromAbove = 0;

int start_sequal = 1;

size_t curr_row = y;
size_t curr_column = 0;

while (x != curr_column)
{
if (IsBitIsOn(bitmap, curr_column, curr_row))
{
IsIn = !IsIn;

/* starts a sequal of bits that are ON  */
while (IsBitIsOn(bitmap, curr_column + 1, curr_row))
{
/* checks the source direction of the first bit in the sequal */
if (start_sequal &&
IsBitOn(bitmap, curr_column, curr_row - 1) ||
isBitOn(bitmap, curr_column - 1, curr_row - 1) ||
isBitOn(bitmap, curr_column + 1, curr_row - 1))
{
ComeFromAbove = 1;
start_sequal = 0;
}
++curr_column;
}
/*  checks the source direction of the last bit in the sequal,
so if it cuts the direction of the first bit, it means
the next points are out of the shape    */
if (ComeFromAbove)
{
if (!IsBitOn(bitmap, curr_column, curr_row + 1) &&
!isBitOn(bitmap, curr_column - 1, curr_row + 1) &&
!isBitOn(bitmap, curr_column + 1, curr_row + 1))
{
ComeFromAbove = 0;
IsIn = !IsIn;
}
}
}
++curr_column;
}

return (IsIn);
}
``````

I draw the following shapes find the problematic points and shapes: Posted on

## whois – How to determine, who to contact for transferring my Domain

My client’s domain, `www.daccusa.org`, is hosted at `inmotionhosting.com`. They tell me though, that the domain itself, is not.

I’ve spoken with two different customer supports at `inmotionhosting.com` and they both tell me two different things. One says “I have to get in touch with `www.joker.com`” and the other one tells me that “I have to get in touch with `webhosting.dk`“.

According to my whois search, the registrar is Joker and the name-server is Webhosting, and according to the control-panel over at `joker.com`, I don’t have any domain registered, but I can however login with my information (e-mail and re-generated password).

(WHOIS)

I want my domain transferred to `inmotionhosting.com` – which one (Joker/*Webhosting*) should I ask for the transfer?

Posted on

## Determine a formula involving a binomial coefficient for the nth term of the sequence

The first few terms are
a] 1,4,10,20,35,56,84,120
b] 1,3,15,84,495,3003,18564,116280,735471,4686825

Posted on

## How to determine offset bits when addressing CPU cache?

I know that the offset is based off of the line size for a cache. I have seen the example: "32-btye line size would use the last 5-bits (i.e. 25) off the address as the offset into the line" but I do not understand the process used to determine this.

Posted on

## cryptography – How to determine what type of encoding/encryption has been used?

This is very weak security on all fronts! The plaintext is P4\$\$w0rdP4\$\$w0rd and it’s encrypted using XOR encryption, with the key CdZ4MLMPgYtAE9gQ80gMtg==. This produces the ciphertext posted by the OP above, WeJcFMQ/8+8QJ/w0hHh+0g==.

To verify:

First, use xxd to get the underlying binary of the plaintext:

``````echo -n 'P4\$\$w0rdP4\$\$w0rd' | xxd -b -c16
``````

This produces:

``````01010000 00110100 00100100 00100100 01110111 00110000 01110010 01100100 01010000 00110100 00100100 00100100 01110111 00110000 01110010 01100100
``````

Next, base64-decode the key and use xxd to get the underlying binary of the key:

``````echo -n 'CdZ4MLMPgYtAE9gQ80gMtg==' | base64 -d | xxd -b -c16
``````

This produces:

``````00001001 11010110 01111000 00110000 10110011 00001111 10000001 10001011 01000000 00010011 11011000 00010000 11110011 01001000 00001100 10110110
``````

Now, XOR the two binary strings:

``````01010000 00110100 00100100 00100100 01110111 00110000 01110010 01100100 01010000 00110100 00100100 00100100 01110111 00110000 01110010 01100100  (plaintext)
(XOR)
00001001 11010110 01111000 00110000 10110011 00001111 10000001 10001011 01000000 00010011 11011000 00010000 11110011 01001000 00001100 10110110  (key)
-----------------------------------------------------------------------------------------------------------------------------------------------
01011001 11100010 01011100 00010100 11000100 00111111 11110011 11101111 00010000 00100111 11111100 00110100 10000100 01111000 01111110 11010010  (ciphertext)
``````

Finally, use bc, xxd, and base64 to convert the binary ciphertext to base64:

``````echo "obase=16; ibase=2; 01011001111000100101110000010100110001000011111111110011111011110001000000100111111111000011010010000100011110000111111011010010" | bc | xxd -p -r | base64
``````

This produces WeJcFMQ/8+8QJ/w0hHh+0g==, which is the ciphertext posted by the OP in the question above.

I apologize if this answer seems contrived. Admittedly, it is. Questions similar to this, where the poster provides only some ciphertext, and asks for some insight as to how that ciphertext could have been produced, seem come up quite frequently on security.stackexchange.com; and this question is often referenced as a duplicate to those. The point of this answer is to illustrate that questions of this nature are unanswerable, because there are infinite solutions to these types of questions.

Posted on

## linear algebra – Determine smallest k, such that \$rank(A^m)=rank(A^k)\$, for all m>k

Let $$A∈mathbb{C}^{nxn}$$. Determine the smallest number $$k∈mathbb{N}$$, dependent on matrix A, such that $$rank(A^{m})=rank(A^{k})$$ for all m>k.

I know what the rank means and I know that the matrices having the same rank means they should be similar. Through googling I found some info on the Drazin index, ind(A), which resembles this exercise but I still found too little material to get a clear answer. I don’t know how to concretely describe this k.

Posted on

## 8 – How to determine if {{user_picture}} is not empty in the comment.html.tpl template

Trying to determine if {{user_picture}} is not empty in the comment.html.twig template.

`{{user_picture}}` refers to the Compact display mode for a User Entity.

The below code doesn’t work.

``````{% if user_picture is not empty %}
{{ user_picture }}
{% else %}
<img src="images/default_image" width="42" height="42">
{% endif %}
``````

Also tried this with no success…

``````{% if user_picture|render is not empty %}
``````

Researched a bunch, and couldn’t find any problems/solutions with this use case. What am I missing?

Posted on

## rest – How to determine user logged in and session not expired in SharePoint using JavaScript

I created a clientside application for SharePoint using javascript and jquery.
We use Rest API for CURD operation on SharePoint Data and config Idle Session Timeout for the inactive user.
After a user session expired all rest request, return Access denied Error:

Access denied. You do not have permission to perform this action or access this resource.

How to determine user logged in and session not expired (before sending rest request and reloading page) only using javascript and jquery?
Is FedAuth cookie useful for this problem and how?

Posted on

## machine learning – How do I express the neural network f as function of \$d_1\$ and determine the value of \$d_1\$

$$f$$ is a neural network described by $$f in N_2(1,d_1,1;Relu,Id)$$, how should I express the network $$f$$ as a function of $$d_1$$? I could only write $$f$$ as $$sigma_r circ L_r circ ^….circ sigma_1 circ L_1$$, shall I write $$L_i(x) = W^ix+b^i$$ and $$sigma_i(x)=(g(x_1+,…,g(x_{d_i}))$$?
And I am also very confused that how I could find the value of $$d_1$$ if $$f(x)=|x|$$?

Posted on

## optimization – Determine whether \$f\$ is coercive or not.

I have difficulty in determine whether those functions are coercive or not. This is part of an exercise in Amir Beck’s book “Introduction to Nonlinear Optimization”.

a) $$f(x_1,x_2)=2x_1^2-8x_1x_2+x_2^2$$.

b) $$f(x_1,x_2)=4x_1^2+2x_1x_2+2x^2_2$$.

C) $$f(x_1,x_2)=x_1^3+x_2^3+x_3^3$$.

I’m trying to estimate $$f(x,y)$$ to the norm $$|x|$$.

For the definition of coercice function, the following is known

Let $$f : mathbb{R}^n to mathbb{R}$$ is continuous function. The function f is called coercive if $$limlimits_{|x| to infty} f(x) = infty$$.

Posted on