# codeforces A – I Wanna Be the Guy wrong answer in testcase 27

I am practicing problem solving by solving on Codeforces, but in problem "A-I Wanna Be the Guy". Here is the link for the problem. My code gets rejected at testcase 27 which has input: 3 1 2 2 2 3 Here is my code: #include <bits/stdc++.h> using namespace std; int main() { int n, x;… Read More codeforces A – I Wanna Be the Guy wrong answer in testcase 27

# Make a loop to find the distance between stations in R

I have made this code to find the distance between stations but in the output, there is only one value. Can you find the error? df <- data.frame( station = rep(c("A", "B", "C", "D"), each = 20), temperature = rnorm(80), latitude = c(40.7128, 34.0522, 41.8781, 39.9526), longitude = c(-74.0060, -118.2437, -87.6298, -75.1652) ) stations <-… Read More Make a loop to find the distance between stations in R

# python def create_file_if_not_exist(file_name: str): SyntaxError: invalid syntax near colon

File "report.py", line 17 12:05:47 def create_file_if_not_exist(file_name: str): 12:05:47 ^ 12:05:47 SyntaxError: invalid syntax I’m getting this error when I run python report.py Can someone help me find out what m i doing wrong I tried removing : str from "def create_file_if_not_exist(file_name: str)"but the error passes to next line def set_logging(): logging.basicConfig( level=logging.INFO, format=’%(asctime)s %(levelname)s… Read More python def create_file_if_not_exist(file_name: str): SyntaxError: invalid syntax near colon

# Array Changes When A Function is Called (Debugging)

console.clear(); function hori_resolveOverlaps(lines) { if (lines.length <= 1) return lines; // Sort the lines ascending by start value lines.sort((a, b) => a[0][0] – b[0][0]); let outLines = [lines[0]]; let last = outLines[0]; // Iterate over the lines, skipping the first one lines.slice(1).forEach((line) => { // There’s an overlap, so extend the current segment’s end if… Read More Array Changes When A Function is Called (Debugging)

# Using map to convert pandas dataframe to list

I am using map to convert some columns in a dataframe to list of dicts. Here is a MWE illustrating my question. import pandas as pd df = pd.DataFrame() df[‘Col1’] = [197, 1600, 1200] df[‘Col2’] = [297, 2600, 2200] df[‘Col1_a’] = [198, 1599, 1199] df[‘Col2_a’] = [296, 2599, 2199] print(df) The output is Col1 Col2… Read More Using map to convert pandas dataframe to list

# Substracting Date in java return bad result

Hi I’ve tried to substract hour from a Date using Date.getTime() – (time in ms ) but the result is not correct , there is always a slight gap compared to the good result, any idea ? if(hoursToBeSubstracted<1) { float toMinute = hoursToBeSubstracted*60; return new Date((long)(d1.getTime()-toMinute*60000)); } return new Date((long)(d1.getTime() – 3600 * hoursToBeSubstracted *… Read More Substracting Date in java return bad result

# Substracting Date in java return bad result

Hi I’ve tried to substract hour from a Date using Date.getTime() – (time in ms ) but the result is not correct , there is always a slight gap compared to the good result, any idea ? if(hoursToBeSubstracted<1) { float toMinute = hoursToBeSubstracted*60; return new Date((long)(d1.getTime()-toMinute*60000)); } return new Date((long)(d1.getTime() – 3600 * hoursToBeSubstracted *… Read More Substracting Date in java return bad result

# Why is the placement of variable declaration giving diffrent results?

#include <stdio.h> int order = 3; int wt[10] = {2,1,3}; int price [10] = {100,50,150}; int maxW = 5; void fracK() { int curr_weight, i, max_i; // <<<< float tot_price; // <<<< int used[10]; // <<<< //inititialising all used elements to 0 for (i = 0; i < order; ++i) { used[i] = 0; }… Read More Why is the placement of variable declaration giving diffrent results?

# moved the css code to its own file using href="" (almost all symbols like < , : , and > are underlined red

However when i move my css code back into the body in the html file (not using href="") the edits like padding, and color got applies to the frontend, here is my css code. .subscribe-button { background-color: rgb(204, 0, 0); color:white; border: none; padding-top: 10px; padding-left: 16px; padding-right: 16px; padding-bottom: 10px; border-radius: 2px; cursor: pointer;… Read More moved the css code to its own file using href="" (almost all symbols like < , : , and > are underlined red

# Throwing error while creating tables in SQL

I am currently executing a code, trying to create tables: cur.executescript(”’ CREATE TABLE User( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE , name TEXT, email_id TEXT); CREATE TABLE Courses( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, course_name TEXT); CREATE TABLE Member( user_id INTEGER, course_id INTEGER, role INTEGER)/*student-0 teacher 1*/ PRIMARY KEY(user_id, course_id); ”’)… Read More Throwing error while creating tables in SQL