java – Calculate aim angle dead zone range

In my top down 2D shooter game the player has a shoulder mounted gun which rotates and aims automatically at enemies – that part is all working fine. Since the player can rotate as well, the gun is constantly updating it’s angle to keep aim on the enemy.

But this causes a problem where the gun aims at the player’s own head…! It doesn’t have any practical consequences in the game, but obviously looks weird and unrealistic. So I need to create a ‘dead zone’ angle range where the gun cannot aim. It will have to aim as best it can at an enemy up to just before it aims at the player’s head.

It seems tough to calculate since there are two angles in play. The dead zone will have to update itself as the player turns.

enter image description here

Disable dates for a selected range in Reac Sharepoint SPFx

I am new to React Sharepoint online SPFx and want to know how to disable dates in selected range in react-datetime. For now I am using npm-reactdatetime and able to disable dates from current date.
Like if a person is ill in the calendar for like 30th Oct, 2020 he should not be able to select date from 30th Oct to Nov 14, 2020.

sql server – How to delete specific range of data from Service Broker > System Queues data table?

Due to sudden increase of my database .mdf file we found there are 4 internal queue message table are increase unexpectedly. so we decided to delete some range of data from these table.

we try this code:

declare @c uniqueidentifier
while(1=1)
begin
    select top 1 @c = conversation_handle from dbo.queuename
    if (@@ROWCOUNT = 0)
    break
    end conversation @c with cleanup
end  

but its try to delete all data and due to space limitation this query cannot execute.
my internal message queue table :

enter image description here

enter image description here

Range em Python – Números em ordem decrescente

Preciso gerar uma lista com números pares de 0 até N em ordem decrescente.

Eu preciso informar a quantidade de números pares que tenho de informar, e aí, o programa me retornar com tal relação de números pares em ordem decrescente.

Por exemplo, se eu informar 8, tenho que imprimir 0, 2, 4, 6, 8, 10, 12, 14. O meu programa, abaixo, está retornando 9 números, indo até o 16. Onde errei, por gentileza? 🙂

numero = int(input('Informe um número inteiro positivo e par: '))
while numero <= 0 or numero % 2 != 0:
    print('O número não pode ser zero, ímpar ou negativo!')
    numero = int(input('Informe um número inteiro positivo e par: '))
while numero > 0 or numero % 2 == 0:
    for n in range(numero + numero, - 1, - 2):
        print(n)
    break

python – CSES standard solution for range query problem giving TLE

Problem statement is from CSES

This is a standard question where we are given a list of numbers and a number of queries. For each query, you have to give the sum of numbers in the given range.

My implementation in python:

def solve():
    n,q = (int(a) for a in input().split(' '))
    arr = (int(a) for a in input().split(' '))
 
    cumulativeArray = (0) # Initial entry added to make 1 based indexing
    sum = 0
    for i in range(len(arr)):
        sum += arr(i)
        cumulativeArray.append(sum)
 
    for i in range(q):
        x,y = (int(a) for a in input().split(' '))
        print(cumulativeArray(y) - cumulativeArray(x-1))
 
solve()

This gives the required answers correctly for all my custom test cases. But gives TLE for huge test cases.

I believe this is happening due to split() method in my code.
Any leads are welcome.

python – List index out of range, but I tried to debug it and I can’t find any errors

I am making a N-queens algorithm (The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal) and this is the “Outside”, not the algorithm: But it gives me an error (listed after the huge code) and I printed each thing, and 5 is within 8.

a = (0, 0, 0, 0, 0, 0, 0, 0)
b = (0, 0, 0, 0, 0, 0, 0, 0)
c = (0, 0, 0, 0, 0, 0, 0, 0)
d = (0, 0, 0, 0, 0, 0, 0, 0)
e = (0, 0, 0, 0, 0, 0, 0, 0)
f = (0, 0, 0, 0, 0, 0, 0, 0)
g = (0, 0, 0, 0, 0, 0, 0, 0)
h = (0, 0, 0, 0, 0, 0, 0, 0)

board = (a,b,c,d,e,f,g,h)
for row in board:
    for elem in row:
        print(elem, end=' ')
    print()

#ask for first queen position

firstq_x = int(input('What is x of first queen: '))
print(firstq_x)
firstq_y = int(input('What is y of first queen: '))
print(firstq_y)
#board(firstq_y) and board(firstq_y(firstq_x))

y = board(int(firstq_y)-1) # y is the selection of a,b,c,d,e,f,g, or h.
y(int(firstq_x)-1) = 'Q' # y(int(firstq_x)-1) is the selection of 0's based on y.

for row in board:
    for elem in row:
        print(elem, end=' ')
    print()

#horizontal
for floor in range(8):
    if y(floor) == 0:
        y(floor) = "X"
        
#vertical
board = (a,b,c,d,e,f,g,h)

count = 0

for vert in range(len(board)):
    vertical = board(count)
    if vertical(firstq_x-1) == 0:
        vertical(firstq_x-1) = "X"
    count+=1
    
#NW
#find y first
ytofill = 2
yminus1 = board(firstq_y-ytofill)  #this will give us list before current list
#find x next
xtofill = 1
xminus1 = yminus1(firstq_x-xtofill)  #this will give us letter before letter
#execute

if firstq_y>firstq_x:

    for NW in range(firstq_x):
        if yminus1(firstq_x-xtofill) == 0:
            yminus1(firstq_x-xtofill) = 'X'
        yminus1 = board(firstq_y-ytofill)
        xtofill+=1
        ytofill+=1

else:
    
    for NW in range(firstq_y):
        if yminus1(firstq_x-xtofill) == 0:
            yminus1(firstq_x-xtofill) = 'X'
        yminus1 = board(firstq_y-ytofill)
        xtofill+=1
        ytofill+=1

#NE
#find y first
ytofill = 2
yminus1 = board(firstq_y-ytofill)  #this will give us list before current list
#find x next
xtofill = 1
xminus1 = yminus1(firstq_x-xtofill)  #this will give us letter before letter
#execute

if firstq_y>firstq_x:

    for NE in range(firstq_y):
        if yminus1(firstq_x-xtofill) == 0:
            yminus1(firstq_x-xtofill) = 'X'
        yminus1 = board(firstq_y-ytofill)
        xtofill-=1
        ytofill+=1

else:
    
    for NE in range(firstq_x):
        if yminus1(firstq_x-xtofill) == 0:
            yminus1(firstq_x-xtofill) = 'X'
        yminus1 = board(firstq_y-ytofill)
        xtofill-=1
        ytofill+=1

board = (a,b,c,d,e,f,g,h)
for row in board:
    for elem in row:
        print(elem, end=' ')
    print()

However, it gives me the error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-4-cb78dab39eae> in <module>()
     54 
     55     for NE in range(firstq_y):
---> 56         if yminus1(firstq_x-xtofill) == 0:
     57             yminus1(firstq_x-xtofill) = 'X'
     58         yminus1 = board(firstq_y-ytofill)

IndexError: list index out of range
```

docker – openshift is running all containers with uid 101 instead of taking an uid from a project range

Openshift cluster is installed in AWS using this doc: https://docs.openshift.com/container-platform/4.5/installing/installing_aws/installing-aws-default.html

When running a pod in any project – it is always started with the same UID 101:

$  oc run -it -n knative-serving --image busybox test1 sh
If you don't see a command prompt, try pressing enter.
~ $ id
uid=101(101) gid=0(root) groups=1000600000

This is a problem when user 101 already exist in an image – in this case it has a GID 101 as well, which prevents from accessing FS (fs permissions are for GID 0).

Expected behavior is that containers are created with UID from a project’s range and GID 0.

Openshift is updated to the latest version: 4.5.14

Dashboard charts where in some higher is better, others lower is better, and in yet others the values should fall between a range

As the title says, how are people approaching having multiple charts in a dashboard, where in some higher is better vs lower is better vs fits in range? All of these charts would have multiple values.

Consider, for example, a case where you want to show 3 charts side by side: 1] revenue by store [higher is better], 2] bad debts/write-offs [lower is better], and 3] price volatility [should be between upper and lower bounds]

I’ve struggled with this for years, and still haven’t found an elegant solution.

node.js – Counting the amount of numbers that go into a certain range. JavaScript

I’ve generated 20 random numbers into an array, but I want to count the amount of numbers in that array that are in a certain range (1-50). Not sort them into a range, but count how many fit the range.

let randomIntLength = 20;
let randomArray();
for(let i = 0; i<randomIntLength; i++) {
randomArray.push(Math.round(Math.random() * 100 )) + 1;
};

Not sure how to continue after this so any help would be appreciated.

sql server – Find rows with a column value based on a date range and type AND excluding them based on less than 90 days prior for another value from same column

So I am finding all rows within a date range that are of the BLUE type.

SELECT * FROM table
WHERE date_of_service BETWEEN CAST ('2020-01-01' AS DATE) AND  CAST ('2020-09-30' AS DATE)
AND type = 'BLUE'

Then I want to remove rows (based on ID) with a BLUE type that also have a row of another color with the same ID, dated within 90 days previous to the date of the BLUE type. If colors other than BLUE with the same ID are dated more than 90 days previous to the Blue row listing, I want to keep the BLUE type rows or if colors other than BLUE are dated within 90 days previous, remove them.

Any clues to the best approach for this? I guess I am having trouble envisioning the subquery filters. Thank you!

enter image description here