unit test: how do sites like LeetCode and HackerRank prove the correctness of their code?

I'm not sure if this question belongs here, but I've always wondered how exactly sites like Leetcode and HackerRank test their code. Let's say you code in Java for a question like,

Find all duplicates in an array

After clicking submit, the code is sent as part of a POST request to the backend and then, what is the most likely action that occurs there?

As a student yet, my guess is that if the code is compiled successfully, then it is tested against a specific set of tests for Java (I imagine a lot of JUnit hahaha tests). Perhaps it is a separate microservice that handles the tests and keeps track of the metrics (such as memory usage, how many test cases passed, etc.)?

If so, this would mean that each Leetcode question has multiple sets of tests, and each of them tests the same test cases but is only written in different languages ​​(i.e., JUnit tests for Java, unit test for Python, etc. .). I haven't thought much about this, but I have the impression that this could job. However, would this be the correct way to solve this type of software engineering problem?

Edit: not specifically asking about Leetcode / HackerRank, but from a general software engineering point of view, if it is possible to test in an agnostic language instead of writing separate test suites for different languages.

arduino – Central heating control. 2 DHT sensors, 3 control relays. Code issues

First of all, thank all those who spend a little time helping me.

The issue is that some time ago I started to mount a thermostat with arduino starting from scratch, and in a few months I got it, it must be said that programming is wrong, and electronics something better, I finally managed to manufacture my PCB, upload all the code to a NODEMCU and manage the boiler from the mobile phone, an achievement for me.

But of course, I was excited and taking advantage of the fact that we bought a flat, because with a couple of eggs …. I wired the whole house and now I want to manage the heating in a zoned way. I thought it was going to cost me much less the subject of the program, but with each step I take, the more lost I go.

I comment, I intend to control 3 relays with 2 DHT22 sensors, one for each zone.

• Problem 1. I can't figure out how to do so that when a radiator demands heat, the rest of the radiator relays are on, the boiler relay remains ON.

• Problem 2. When I do a GET 192.168.30 / temp Desired Dispatch 40 I get the NODEMCU to see it, I activate the relay of the radiator of the Dispatch, I activate the relay of the Boiler, but when I do a GET 192.168.1.30/temp Desired Despacho00, I get that the radiator relay is deactivated, but not the boiler relay.
• Nor do I get GETs to be reflected correctly in the web browser.

#include 
#include  
#include "ThingSpeak.h" 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define DHTTYPE DHT11
#define DHTTYPE DHT22
#include 
#include 
#include  
#define DRD_TIMEOUT 10
#define DRD_ADDRESS 0

#define DHTPINDespacho 10 //_____________________________________________PONER PATILLA
#define DHTPINSalon  4//_________________________________________________PONER PATILLA


const int releCaldera = 2; //Pin al que está conectado el rele de salida (PINOUT)

const int releDespacho = 12; //Pin al que está conectado el rele de salida del radiador del Despacho (PINOUT)
const int releSalon = 15; //Pin al que está conectado el rele de salida del radiador del Salon (PINOUT)



float histeresis = 1;
static unsigned long last_loop;

unsigned long int anteriorRefreshDatosDespacho = 0;
unsigned long int anteriorRefreshDatosSalon = 0;


float tempDespacho= 0;
float tempSalon= 0;

float tempDeseadaDespacho = 00;
float tempDeseadaSalon = 00;


int calderaHabilitada;
int estadoRele = 0;
int contconexion = 0;
bool shouldSaveConfig = false;
bool initialConfig = false;


DoubleResetDetector drd(DRD_TIMEOUT, DRD_ADDRESS); //Función de doble reset para configurar NODEMCU

LiquidCrystal_I2C lcd(0x27, 16, 2);


DHT dhtDespacho(DHTPINDespacho, DHT22);
DHT dhtSalon(DHTPINSalon, DHT22);


WiFiClient client;
WiFiServer server(80);

//Parámetros de Thingspeak

const char* serverThingspeak = "api.thingspeak.com";
char  myWriteAPIKey(17) = "0WU6GVSSUPYI8EED";
char  myChannelNumber(11) = "888615";

void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
  }


void setup() {



dhtDespacho.begin();
dhtSalon.begin();

delay(10);

Serial.begin(115200);
Serial.println();


//Aqui decimos que el rele de la caldera este desconectado
pinMode(releCaldera, OUTPUT);
digitalWrite(releCaldera, LOW);

pinMode(releDespacho, OUTPUT);
pinMode(releSalon, OUTPUT);
pinMode(DHTPINDespacho, INPUT);
pinMode(DHTPINSalon, INPUT);



Serial.println();

if (WiFi.SSID()==""){
    Serial.println("We haven't got any access point credentials, so get them now");   
    initialConfig = true;
    }
    if (drd.detectDoubleReset()) {
    Serial.println("Doble reset detectado");
    initialConfig = true;
      }
      if (initialConfig) {
      Serial.println("Starting configuration portal.");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("INTRODUCIR");
          lcd.setCursor(0,1);
          lcd.print("USUARIO Y PASS");
      WiFiManager wifiManager;
      wifiManager.resetSettings();
      }
    
  //Leer configuración de Json
  
  Serial.println("mounting FS...");

  if (SPIFFS.begin()) {
    Serial.println("mounted file system");
    if (SPIFFS.exists("/config.json")) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open("/config.json", "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr buf(new char(size));

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("nparsed json");

          strcpy(myWriteAPIKey, json("myWriteAPIKey"));
          } else {
          Serial.println("failed to load json config");
        }
      }
    }
  } 

WiFiManagerParameter custom_myWriteAPIKey("API-Key", "myWriteAPIKey", myWriteAPIKey, 17);

WiFiManager wifiManager;

//Establecer configuración guardada

wifiManager.setSaveConfigCallback(saveConfigCallback);

    IPAddress _ip = IPAddress(192, 168, 1, 30);
    IPAddress _gw = IPAddress(192, 168, 1, 1);
    IPAddress _sn = IPAddress(255, 255, 255, 0);
    wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);

    wifiManager.addParameter(&custom_myWriteAPIKey);
  
  if (!wifiManager.autoConnect()) {
      Serial.println("failed to connect and hit timeout");
      delay(10);
      
      ESP.reset();
      delay(10);
      }

  //Si has llegado aquí estás conectado a una WIFI
  Serial.println("Conectado a una Wifi");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("CONECTANDO...");
          delay(20);

  //Leer parámetros actualizados
  
  strcpy(myWriteAPIKey, custom_myWriteAPIKey.getValue());
  

  //Guardar los parámetros en FS
  
  if (shouldSaveConfig) {
      Serial.println("saving config");
      DynamicJsonBuffer jsonBuffer;
      JsonObject& json = jsonBuffer.createObject();
      json("myWriteAPIKey") = myWriteAPIKey;
    
      File configFile = SPIFFS.open("/config.json", "w");
          if (!configFile) {
          Serial.println("failed to open config file for writing");
            }
      json.printTo(Serial);
      json.printTo(configFile);
      configFile.close();
    //Guardado finalizado
    }
  Serial.println();
  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  delay(10);}
    
void refreshDatosDespacho(){

if (millis() > anteriorRefreshDatosDespacho + 20000){
    anteriorRefreshDatosDespacho = millis();
    float tempDespacho = dhtDespacho.readTemperature();
    float humiDespacho = dhtDespacho.readHumidity();
      if (isnan(tempDespacho) || isnan(humiDespacho)){ 
      Serial.println("Fallo en lectura de temperatura y humedad del Despacho");
      return;}
        if (calderaHabilitada = 1){
          if (tempDespacho + histeresis >= tempDeseadaDespacho && tempDespacho > 0)  digitalWrite(releDespacho, LOW);
        else if (tempDespacho < tempDeseadaDespacho && tempDespacho > 0){ 
        digitalWrite(releDespacho, HIGH);
        digitalWrite(releCaldera, HIGH);}
      else digitalWrite(releDespacho, LOW); 
      }              
      Serial.println();
      Serial.println("Leyendo datos....");
      Serial.print("Temperatura deseada: ");
      Serial.println(tempDeseadaDespacho); 
      Serial.print("Temperatura Despacho: ");
      Serial.println(tempDespacho);
      Serial.print("Humedad Despacho: ");
      Serial.println(humiDespacho);
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Temp Despacho: ");
            lcd.print(tempDespacho);
            lcd.print(" ");
            lcd.print((char)223);
            lcd.print("C");
            lcd.setCursor(0,1);
            lcd.print("Hum Despacho:  ");
            lcd.print(humiDespacho);
            lcd.print(" %");
            int estadoRele = digitalRead(releCaldera);
      if (estadoRele == LOW){
          Serial.print("Estado relé caldera: ");  
          Serial.println("LOW");
          lcd.setCursor(15,0);
          lcd.print(" ");        
            } else {
                    Serial.print("Estado relé caldera: ");  
                    Serial.println("HIGH");
                    lcd.setCursor(15,0);
                    lcd.print("C");
                    } 
                    
 // Start the server
    ThingSpeak.begin(client);
    Serial.println("Cliente thingspeak iniciado");
    server.begin();
    Serial.println("Server iniciado");
    Serial.println(myWriteAPIKey);
    Serial.println("local ip");
    Serial.println(WiFi.localIP());
    delay(10);
    ThingSpeak.setField(1, tempDespacho);
    //ThingSpeak.setField(2, humiPasillo); 
    ThingSpeak.setField(6, estadoRele);
    //ThingSpeak.setField(4, tempDeseadaDespacho);
    ThingSpeak.writeFields(String(myChannelNumber).toInt(), myWriteAPIKey);   
    delay(100);
    Serial.println("Enviando datos...");
    Serial.println();
    
            }
         }

         void refreshDatosSalon(){

  if (millis() > anteriorRefreshDatosSalon + 20000){
      anteriorRefreshDatosSalon = millis();
      float tempSalon = dhtSalon.readTemperature();
      float humiSalon = dhtSalon.readHumidity();
      if (isnan(tempSalon) || isnan(humiSalon)){ 
      Serial.println("Fallo en lectura de temperatura y humedad del Salon");
       return;}
        if (calderaHabilitada = 1){
          if (tempSalon + histeresis >= tempDeseadaSalon && tempSalon > 0)  digitalWrite(releSalon, LOW);
        else if (tempSalon < tempDeseadaSalon && tempSalon > 0){ 
        digitalWrite(releSalon, HIGH);
        digitalWrite(releCaldera, HIGH);}
      else digitalWrite(releSalon, LOW); 
      }         
      Serial.println();
      Serial.println("Leyendo datos....");
      Serial.print("Temperatura deseada: ");
      Serial.println(tempDeseadaSalon); 
      Serial.print("Temperatura Salon: ");
      Serial.println(tempSalon);
      Serial.print("Humedad Salon: ");
      Serial.println(humiSalon);
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Temp Salon: ");
            lcd.print(tempSalon);
            lcd.print(" ");
            lcd.print((char)223);
            lcd.print("C");
            lcd.setCursor(0,1);
            lcd.print("Hum Salon:  ");
            lcd.print(humiSalon);
            lcd.print(" %");
            int estadoRele = digitalRead(releCaldera);
      if (estadoRele == LOW){
          Serial.print("Estado relé caldera: ");  
          Serial.println("LOW");
          lcd.setCursor(15,0);
          lcd.print(" ");        
            } else {
                    Serial.print("Estado relé caldera: ");  
                    Serial.println("HIGH");
                    lcd.setCursor(15,0);
                    lcd.print("C");
                    } 
 // Start the server
    ThingSpeak.begin(client);
    Serial.println("Cliente thingspeak iniciado");
    server.begin();
    Serial.println("Server iniciado");
    Serial.println(myWriteAPIKey);
    Serial.println("local ip");
    Serial.println(WiFi.localIP());
    delay(10);
    ThingSpeak.setField(3, tempSalon);
    //ThingSpeak.setField(2, humiSalon); 
    //ThingSpeak.setField(3, estadoRele);
    //ThingSpeak.setField(4, tempDeseadaSalon);
    ThingSpeak.writeFields(String(myChannelNumber).toInt(), myWriteAPIKey);   
    delay(100);
    Serial.println("Enviando datos...");
    Serial.println();
    
            }
         }


void loop() {


  

  
  drd.loop();
  refreshDatosDespacho();
  refreshDatosSalon();

  
 
   WiFiClient client = server.available();
    if (!client) {
        return;    
        }
  
  // Read the first line of the request
  String req = client.readStringUntil('r');
  Serial.println(req);
  client.flush();

   int  val;
  
      int  valDespacho;

      if (req.indexOf("/tempDeseadaDespacho40") != -1){
      tempDeseadaDespacho = 40;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho40") != -1){
      tempDeseadaDespacho = 22;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho23") != -1){
      tempDeseadaDespacho = 23;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho24") != -1){
      tempDeseadaDespacho = 24;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho25") != -1){
      tempDeseadaDespacho = 25;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho26") != -1){
      tempDeseadaDespacho = 26;
      valDespacho = 1;
      } else if (req.indexOf("/tempDeseadaDespacho00") != -1){
      tempDeseadaDespacho = 00;
      valDespacho = 0;

      } else {
      Serial.println("peticion invalida");
      client.stop();
      return;      
      }


      int  valSalon;

      if (req.indexOf("/tempDeseadaSalon40") != -1){
      tempDeseadaSalon = 40;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon22") != -1){
      tempDeseadaSalon = 22;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon23") != -1){
      tempDeseadaSalon = 23;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon24") != -1){
      tempDeseadaSalon = 24;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon25") != -1){
      tempDeseadaSalon = 25;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon26") != -1){
      tempDeseadaSalon = 26;
      valSalon = 1;
      } else if (req.indexOf("/tempDeseadaSalon00") != -1){
      tempDeseadaSalon = 00;
      valSalon = 0;

      } else {
      Serial.println("peticion invalida");
      client.stop();
      return;      
      }

      calderaHabilitada = val;
      client.flush();

  // Prepara la respuesta web

  
  String sDespacho = "HTTP/1.1 200 OKrnContent-Type: text/htmlrnrnrnrnGPIO is now ";
  sDespacho += (valDespacho)?"high":"low";
  sDespacho += "n";
  
  
   String sSalon = "HTTP/1.1 200 OKrnContent-Type: text/htmlrnrnrnrnGPIO is now ";
  sSalon += (valSalon)?"high":"low";
  sSalon += "n";


  // Send the response to the client
  client.print(sDespacho);
  client.print(sSalon);
  delay(1);
  client.stop();
  Serial.println("Client disonnected");
  }



           
     
    
   



  

Physical: Why is my plastic credit card and activation code sent separately?

A much People get a credit card and leave it in the envelope for a considerable time.

In addition, separating data greatly complicates the life of a mail thief. Snatching a piece of mail is a crime of opportunity. But snatching two on separate days requires a real stalking. Having obtained a piece, the thief must now return to the crime scene often. That greatly increases exposure, both for persistence and for repeated visits.

In addition, it is likely that the correspondence is obviously not marked with a sender, so the thief does not know what mail to steal, and should steal a lot. This greatly increases the possibility of the owner noticing that his email is being lost, which would void the entire exercise since the owner would cancel the card.

And after all that there is a good chance that the piece that the thief raised was the second arrive… In which case the other half of the puzzle Never Appear. The thief could check for weeks and never get it. When to give up

python – VS Code Remote does not pick up .bash_profile in ssh

I was using Python to execute a bash script after writing several commands in it.
These commands are mainly Python scripts:

#!/bin/bash
./xmlchange JOB_WALLCLOCK_TIME=30:00:00
./xmlchange NTASKS=40
./case.setup
cp ../something ./something  
./xmlchange something
./case.build
./case.submit

The Python call is:

os.chmod("./run.sh", stat.S_IRWXU )
subprocess.call("./run.sh")

However, one of the commands, the last one (./case.submit), always behaves differently. This command is used to send a SLURM job to a queue. If I ran this bash script directly from Python, the job always failed almost immediately due to a memory problem.

But if I executed the last command from my terminal, the job worked fine.

Therefore, I wonder if the environment is the same in the VS Code session with the default login session. Because at least the interface of the "Terminal" tab is not the same, it does not load the .bash_profile.

Does anyone have any experience in this?

How to implement python decorators to reuse the code of a function?

Guys, I'm trying to learn about decorators to help automate some repetitive routines.

Initially, I have several functions that read files and convert each line of them into a Pyhton list depending on the content of the file, for example:
There is the user archive that contains the username and full name:
jcalo-José Carlos
mxferr-Max Ferreira
… In the end, the result should be a list of tuples (("jcalo", "José Carlos), (" mxferr "," Max Ferreira ")). There is also a product list file
products
bread
the milk
Expected result ("bread", "milk")

The common procedure is to read the files and generate the list. Based on this, I already made the following code, with read_list with common steps to read each file:

def read_list(funcao):
def warapper_function(*args, **kwargs)
if intens_delimiter == 'n':
lista = open("file", 'r').readlines()
else:
lista = open('file', r)
lista = list(servers).split(servers_delimiter)
lista.close()
lista = list(map(lambda x : x.strip(), servers))
lista = (x for x in servers if x != "")
return lista
return warapper_function

@read_list
def read_produtos_list():
file = "produtos.txt"

@read_list
def read_users_list():
file = "usuários.txt"

Does anyone know how I keep writing code to use decorators?
My goal is to take advantage of reading the file and generate the list and modify the functions to obtain the correct return according to the type of file to read.

Gremlin code to find 1 vertex with specific property

I want to return a node where the node has a property as a specific uuid and I just want to return one of them (there could be several matches).

g.V().where('application_uuid', eq(application_uuid).next()

Would the previous query return all nodes? How did I just return 1?

I also want to get the property map of this node. How would I do this?

redirection – Can I use KernelEvents :: EXCEPTION to make exceptions for my own code?

I have written code for a custom module in my .MODULE file that looks like this.

function cookie_authentication_node_access(NodeInterface $node, $op, AccountInterface $account) {
  if ($account->isAnonymous() && $node->gettype() == 'page') {
    return AccessResult::forbidden()->cachePerPermissions();
  }

return AccessResult::neutral(); 

}

Basically, using an EventSubscriber, I want to create an exception for my own rule that I did earlier (allow anonymous users to access a certain page) …

Would it be the KernelEvent & # 39; EXCEPTION & # 39; the right way, or is it only for real exceptions not detected?

sql server – Remove error mark in SQL code after applying an Alter to a #temporal table

How can I prevent the SQL Server editor from giving me a field from a temporary table as an error when writing the SELECT statement. I leave the example so you can see:

CREATE TABLE (#Tmp_Oportunidades)
    ((Cliente) Int NULL             
    , (CodigoFiscal) Varchar(255) NULL  
    , (Titulo) Varchar(255) NULL            
    , (Empleado) Int NULL
    , (IdCategoria) Int NULL            
    , (CesionTipo) Varchar(255) NULL    
    , (IdCampaña) Int NULL) 

ALTER TABLE (#Tmp_Oportunidades) ADD (Id) (int) IDENTITY(1,1) NOT NULL, (Fila_Error) NVarchar(4000) NULL` `

INSERT INTO (#Tmp_Oportunidades) ((CesionTipo), (Fila_Error)) values ('N','aaa')

The field (Row_Error) is marked as an error, although running the script works fine. Is there any way to update the Temporary Object in the database from the T-SQL code?

visual study code: HTML Intellisense does not work in VSC

I am trying to get intellisense for html in vsc.

When I create an index.html file, there is no intellisense for any tag.

but if I change the name of the file to index.htm, then I have the intellisense for html

Also, my extensions such as "auto-closing tags," "reaction sinippets," both do not work under the .html extension.

I checked my configuration for html, I can't find anything wrong.

but my icon extension works, the icon shows that it is an html file, but intellisense and the html related extensions don't work

What cloud will be the problem with this? Is there a conflict in my extension or is there a configuration problem that I don't know?

Thank you !

python: collision detection code does not detect the entire collision

I am doing capsule-capsule collision detection. Is not perfect; Let some collisions pass. I'm thinking it may have to do with the floating point error, but I don't know how to correct it. I used this algorithm to find the shortest distance between two 3D line segments: http://geomalgorithms.com/a07-_distance.html#dist3D_Segment_to_Segment
If the shortest distance is less than double the radius of my capsule, a collision is supposed to be detected.
Here is my code:

def check_intersection(particle1,particle2):
    decimal.getcontext().prec = 100
    epsilon = 2**-52 #implement epsilon
    small_num = 0.00000001 #number to check if they're closely parallel
    u = particle1.get_s() #s1
    v = particle2.get_s() #s2
    p0 = particle1.get_p1_position() #P0
    q0 = particle2.get_p1_position() #Q0
    w = np.array((p0(0)-q0(0), p0(1)-q0(1), p0(2)-q0(2)))  #distance from 2 particles from their p1's

    a = np.dot(u, u)
    b = np.dot(u, v)
    c = np.dot(v, v)
    d = np.dot(u, w)
    e = np.dot(v, w)
    D = (a * c) - b ** 2  # always >=0
    '''
    a = u(0)**2 + u(1)**2 + u(2)**2 #dot product of u*u. Always >=0
    b = u(0)*v(0) + u(1)*v(1) + u(2)*v(2) #dot product of u*v.
    c = v(0)**2 + v(1)**2 + v(2)**2 #dot product of v*v. Always >=0
    d = u(0)*w(0) + u(1)*w(1) + u(2)*w(2) #dot product of u*w
    e = v(0)*w(0) + v(1)*w(1) + v(2)*w(2) #dot product of v*w
    D = (a*c)-b**2 #always >=0
    '''
    #Set all to defaults
    sc = sN = sD = D #sc = sN / sD, default sD = D >= 0
    tc = tN = tD = D #tc = tN / tD, default tD = D >= 0
    if D**2 < small_num:  # checks if SCs are parallel
        sN = 0.0  # force using point P0 on segment S1
        sD = 1.0  # to prevent possible division by 0.0 later
        tN = e
        tD = c
    else:  # get the closest points on the infinite lines
        sN = (b * e) - (c * d)
        tN = (a * e) -(b * d)
        if sN < 0.0:
            sN = 0.0
            tN = e
            tD = c
        elif sN > sD:  # sc > 1  => the s=1 edge is visible
            sN = sD
            tN = (e + b)
            tD = c
    if tN < 0.0:  # tc < 0 => the t=0 edge is visible
        tN = 0.0
        # recompute sc for this edge
        if -d < 0.0:
            sN = 0.0
        elif -d > a:
            sN = sD
        else:
            sN = -d
            sD = a
    elif tN > tD:  # tc > 1  => the t=1 edge is visible
        tN = tD
        # recompute sc for this edge
        if (-d + b) < 0.0:
            sN = 0.0
        elif (-d + b) > a:
            sN = sD
        else:
            sN = (-d + b)
            sD = a
    # division to get sc and tc
    if abs(sN) < small_num:
        sc = 0.0
    else:
        sc = sN / sD
    if abs(tN) < small_num:
        tc = 0.0
    else:
        tc = tN / tD
    # difference of 2 closest points
    dP = np.array( (w(0) + (sc * u(0)) - (tc * v(0)), w(1) + (sc * u(1)) - (tc * v(1)), w(2) + (sc * u(2)) - (tc * v(2))) )
    # dP = w + np.multiply(sc,u) - np.multiply(tc,v) #S1(sc) - S2(tc)
    close_d = dP(0) ** 2 + dP(1) ** 2 + dP(2) ** 2 # closest distance b/w 2 lines
    # check if distance <= radius * 2, if so, INTERSECTION!

    if close_d <= (2*S_RADIUS)**2: #used squared distance of twice the radius as cutoff
        return True
    else:
        return False

Here is a visualization of a collision: enter the description of the image here