instruction stringlengths 71 95.1k |
|---|
I'm working on my first real Elixir application, after dabbling for a few years. In my elixir/phoenix application I have to work with data over an external REST API. For my purposes, I can tolerate some staleness in the data so I would like to cache the data from the external system and consult the cache during request... |
I'm writing a piece table library in Rust with the structures:
#[derive(Default)]
struct Piece {
additional: bool,
offset: usize,
length: usize,
}
and
/// PieceTable contains the additional, original buffers and a vector of pieces.
/// It also maintains a length variable.
pub struct PieceTable {
table:... |
Background:
I have close to 50 excel files - I cannot change the data source - and I steadily get more.
My task is to make sense of all that data and, lo an behold, save that as another excel file (I asked if I should put it in a local database, but no, I should not).
Asking on SO lead me here, as I thought it might be... |
I just finished writing an ncurses-based Tetris clone in C. It's only my second project of this size, the first being a Snake clone. I would really appreciate any and all suggestions/improvements as I'm relatively new to C and I would like to improve.
As this is a 300-plus-line codebase, anything I can add to this ques... |
Link to problem: https://www.codewars.com/kata/5539fecef69c483c5a000015/train/powershell
I have a working solution in Codewars but my solution is slow for some reason and I need to improve the efficiency.
Please look over my solution and offer any suggestions on things I could do to improve what I have.
Instructions fo... |
Im trying to get more grip of Classes and also calling different classes to each other which will be more understandable when showing code before:
Utils.py
from proxymanager import ProxyManager # https://pypi.org/project/proxy-manager/
class ProxyServer:
def __init__(self):
self.proxy_manager_test = ProxyM... |
I have a program that should read and process about 500,000 files in the format hdf5, each of them containing about 400 data points representing the coordinates of carbon atoms in a sheet of graphene. Since I have an HDD, the process of reading is slow and as such I don't want to delay the reading process as it waits f... |
I have been tasked to make an array without duplicated values from another existing array.
So I did it, but I want to know is there some other better way to do that.
Example input/output
Input: 1, 15, 1, 5, 1, 3
Output: 1, 15, 5, 3
My code
#include <stdio.h>
int main(void) {
const int ARRAY_SIZE = 5;
int m[ARRAY_... |
I write protocol messages encoder/decoder for my project.
All messages have 2-bytes header (1 byte - message type, 1 byte message sub-type) and body.
There are two types of messages:
Plain message - no encoding
Encoded message - AES encoding
I would like to get your feedback on:
Overall design and coding style
Prop... |
I wrote a code for sticky/fixed table header. I am bit confused with my coding, though it does my job. I know there are many jQuery codes available online. But I wanted to do it in plain JS with IE support. Now I want to see is there anything wrong/abuse of language in my code.
Here my code:
/* Sticky table header st... |
The code was written to generate the factorisation of numbers into primes in ascending order. E.g 3! ='2 * 3', 4!='2^3 * 3'. When I have huge numbers such as 100!, the run time becomes a problem. I want to have a code which will run in less time.
from math import floor,sqrt,factorial
from decimal import Decimal
def pri... |
I recently just stumbled upon a post regarding Google Foobar Level 2 and decided to try it out myself but starting from Level 1. The description and code are shown below.
Write a function called answer(data, n) that takes in a list of less
than 100 integers and a number n, and returns that same list but with all of th... |
I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Bootstrap 4. I have decided to add themes to it. The application is not HMVC, only MVC.
I thought it was a good idea to use the Twig template engine to the theme(s). For this purpose, I use CodeIgniter Simple and Secure Twig.
The theme's... |
This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and the previous questions about recursive functions, including A Summation Function For Arbitrary Nested Vector Implementation In C++, A recursive_count_if Function For Various Type Arbi... |
I have code in Python 3 where I fetch data from the GitHub API, and I want some advice on the architecture of this code.
import urllib.request, urllib.parse, urllib.error
import json
import sys
from collections import Counter
from datetime import datetime, timedelta, date
from tabulate import tabulate
from LanguagesRep... |
This is a depth-first search Kings Tour. I call it like this because the king must pass by all coordinates only touching them once (like a knights tour).
How could I improve?
Thank You
# author @reivaJ
from collections import defaultdict
from itertools import product
import sys
import numpy as np
from random impor... |
I'm trying to code a simple game called 'Atom'. The game is like this: At the start, you press 'Play' and one of the three boards (5x5, 6x6 or 7x7) are generated. There you have to guess where the hidden Atoms are through clicking on the squares on the left, right, top and bottom.
After pressing one of the squares a "l... |
I have tried to implement the following challenge:
Personal Web Page Generator
Write a program that asks the user for his or her name, then asks the user to enter a sentence that describes himself or herself. Here is an example of the program's screen:
Enter your name: Julie TaylorEnter
Describe yourself: I am a compu... |
https://leetcode.com/problems/stone-game/
Alex and Lee play a game with piles of stones. There are an even
number of piles arranged in a row, and each pile has a positive
integer number of stones piles[i].
The objective of the game is to end with the most stones. The total
number of stones is odd, so there are no ti... |
This is a small frontend frame for a React app that is built then served statically.
Because the app uses React-Router for browser-based routing but the server doesn't know anything about the app I added some code to the backend that reads the list of routes the app uses from a json file and creates dummy handlers for ... |
I was wondering if it is possible to speed up this script? The source file has 90,000 rows, and it has to create a separate forecast for 1200 unique dealers using fbprophet. I'm new to python so I'm not sure if there is something obvious I'm missing, or if it's just going to have to take a really long time. If any sees... |
I'm making a bot for PlayStation 5.
And restock is coming soon so I want to make my bot faster.
The approximate duration is 4.90 seconds.
Is there any way to make this faster?
I found that I should write this in C or C ++ for better results.
#startup
chrome_options = Options()
chrome_options.add_argument("--headless")... |
I have a dataset ('sample_data.csv') of the form below:
timestamp,cell_id,crnti,enodeb_id,uplane_downlink.cqi_wideband_mean,uplane_downlink.distance_initial_km,uplane_downlink.non_gbr_dl_bytes,time_sec,timestamp_y,uplane_uplink.non_gbr_ul_bytes
1606208553171,1,1487,1002107,7,27,134,1606208553,1606208553256,146
16062085... |
This code is a revised version of the implementation which asked for an advice on improvement. Original post here: Counting unival subtrees
Credits to: [Deduplicator], [Reinderien], [Toby Speight], [chux].
The revised version was applied following changes:
Merge insertRight(), insertLeft() function into createNode fun... |
Link here
I'll include a solution in Python and C++ and you can review one. I'm mostly interested in reviewing the C++ code which is a thing I recently started learning; those who don't know C++ can review the Python code. Both solutions share similar logic, so the review will apply to any.
Problem statement
Given a ... |
Is there a neater way of handling the option response from req.cookie() in this code block (line 3 onwards)? Id like to avoid the nested if statements, and multiple returns if at all possible. req.cookie() returns an Option<Cookie> and the Cookie struct has a value function. If the cookie is present but has the wrong v... |
I made a snake game in HTML/CSS/JavaScript. I want to make my code better and shorter.
Here is my codes:
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Snake Game</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<p class="score" draggable="true"></p>
<canvas class="canvas" height=... |
I write a function using PHP and MySQL, to get PDO connection, query and array of placeholders to execute query and return result.
I test this function and it has good response when result for SELECT has empty result or has error; do you see any problems, or have tips to say about this?
Do you have any tips about this ... |
I have a main-class that takes a list of sources and returns two objects for each source; one with the required data and one analytics tool.
The Analytics-class has different methods depending on what source it is. The Data-class extracts data from different paths and cleans the data in different ways depending on the ... |
I wrote this code to speed up my daily work. I want to ask for help on how to further accelerate this code.
Operation of the code
It copies 1-1 worksheets from 3 different workbooks to 3 worksheets of the new workbook. Inserts, copies, and formats different columns. Then, by examining different criteria on a worksheet ... |
It should return true, if there is no element that follow or the following elements are greater than their predecessors.
public class Element {
private int value;
private Element next;
public boolean isSorted(){
if (this.next == null)
return true;
else return (this.value < thi... |
I have been trying to code something simple where I call a class with different functions to different paths,
if I call etc:
from lib.utils import GetAllPaths
path = GetAllPaths()
path.test()
with following code:
class GetAllPaths:
"""
Return file and paths directions
"""
if platform == "win32":
... |
I created an app which counts days, hours, minutes and seconds until some event.
I learned a lot while creating it and as always I would love some feedback from you guys to improve my code by learning from mistakes and maybe implement a better solution. In particular, I am not very proud of the way my startTimer() work... |
What is your opinion on my solution for Rock Paper Scissors game logic in Java?
Round outcome enum class
public enum Winer
{
DRAW,
PLAYER,
COMPUTER;
}
Played moves enum class
public enum PlayedMove
{
ROCK,
PAPER,
SCISSORS;
}
Game logic class
public class GameLogic
{
public static Winer get... |
I've created a .py utility file, which specifies the learning rate policy for the neural network in PyTorch. The program in prior reads a json and creates a dict, called here is cfg.
So far, I have implemented 3 kinds of learning policies - steps, exp, cos, and for each of them I've created a separate class with the __... |
I've been quite annoyed lately by the fact that the CopyMemory API (RtlMoveMemory on Windows and MemMove on Mac) is running much slower than it used to, on certain computers. For example on one of my machines (x64 Windows and x32 Office) the CopyMemory API is running about 600 times slower than a month ago. I did do a ... |
I am using following script to plot cluster populations using two lists contained x and y data
# calculate clusters using encore method
cluster = encore.cluster(u, select="all", superposition=False, method=encore.DBSCAN(eps=1))
# make list of population of each cluster;
cluster_sizes= [len(c) for c in cluster.clusters... |
I have a list of N integers and I iteratively take two integers at random, which are not at the same position in the list and uniformly recombine their binary representation, e.g. in intList = [1,4,1,5] (N=4) the number on the second and third position is chosen, aka 4 & 1, and their binary represenations 4=100 & 1=001... |
I have a function that gets a string and prints it as a message. Then, it reads the text from stdin, saves it in a pointer and sends it back:
char *getString(char *queryText){
char buffer[BUFFERSIZE];
char *temp;
printf("%s", queryText);
fgets(buffer, BUFFERSIZE, stdin);
//clears \n at the end of the line
if ((strlen... |
I have two integer values and would like to obtain their quotient which should be a fractional number, in this example 37/2=18.5. I usually do this:
uint16_t dividend=37;
uint16_t divisor=2;
auto quotient=dividend/double(divisor);
In python3 there are division / and truncation division // which result in respective q... |
Initially, I posted this question on StackOverflow. I wanted to know if there's an existing library that implements the concept I have in mind, which is the following.
I want to define a hierarchy/tree, e.g.:
Commit
/ | \
Feature Fix Refactoring
/ \
... |
I'm a beginner to python and as part of my course I'm instructed to create a simple tic tac toe game.
I'd be very appreciative and interested of any insight, criticism, instructions, best practices or code readability and tips.
Are my comments descriptive, repetitive and useful enough?
Any inputs and tips would be grea... |
I'd like to get a review for the function that cd into the git tree root or does nothing if we are outside of the repository.
reviewed version:
# cd to the root of the current git directory
# If $PWD is submodule, will cd to the root of the top ancestor
# It requires to stay in the current directory, if the root is . o... |
I was extremely annoyed by the lengthy, edge-case-galore explanation of integer version of C++ standard library mindpoint implementation here, so I made my own simple 2's complement version. I present it for your judgement.
The general idea is to carry out a + (b-a)/2 in a wider signed integer that won't ever overflow.... |
I'm new to both Python and socket programming and figured setting up a simple chat server would be good practice. In addition to general critiques of the code, I have specific questions:
What are the best practices for network programming in Python? Is the object-oriented style I went with advisable or should I struct... |
The program is meant to collect from the user:
The function under which to calculate the area
The left and right boundaries of the region
The amount and position of rectangles to use to approximate the area
Then run the calculation. Finally, the user is given the option to do another calculation.
import re
print('Th... |
I was asked to write chess simulation of pieces as a take home interview question and was given this spec.
This is what I came up with:
ChessGenerator.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
public class ChessGenerator {
... |
I am writing a pong game in Python that uses voice input to move the paddles.
I have implemented multithreading so that the google speech recognition module can always run in a separate thread from the main game. However, it doesn't seem to be running on the separate thread and I have no way of finding out how. I want ... |
I have completed my lab assignment for class, but I'm still wondering if there's any ways I could better optimize my code. specifically my methods isSeatAvailable and reserveSeat.
Here is my problem: Write a program that displays, examines and manipulates a two dimensional array
representing plane seats for a plane wit... |
I'd like some feedback/suggestions on how to improve the following. Specifically I want to know if what I'm doing is reliable and fast, or if there is a better way to accomplish this.
The problem:
I have some dataset containing counts of sales made at different times throughout the day, across different locations/shops... |
I have been trying to improve python combined with Postgres.
At this moment im only sending two values to database which are etc:
link = "https://www.mathem.se/varor/vegetarisk-fars/vegofars-fairtrade-1000g-anamma"
store = "mathem"
and I do have few options that I want to be able to do with Postgres and that is to fe... |
I recently came across a coding challenge on some sort of technological basket weaving forum, where you had to pick 2 cards from a shuffled deck. I believe the challenge can be interpreted 2 ways:
Generate random deck, pick first 2
Generate sequential (or any) deck, pick 2 random cards
I went for option one. I believ... |
I studied segment tree recently and I made this code of segment tree and its queries. Is my code correct in terms of time complexity?
class segmentTree{
private:
vector<int> mini;
vector<int> tree;
vector<int> maxi;
int n;
Here in the constructor I passed the dynamic array.
public:
segmentTree(vec... |
for a thesis I am creating a program that constructs curling sequences.
The curling number of a sequence is defined as 'the largest frequency of any period at the end of the sequence'. (For example, 11232323 has curling number 3, because 23 is repeated three times)
Currently, I am mostly interested in the appearance of... |
I'd like, from a DataFrame, to retrieve a Series which contains the index of the minimal value per row (so axis=1). From the documentation it seems idxmin may be useful
Let' take
import pandas as pd
import numpy as np
df = pd.DataFrame({
'col1': [0, 10, 2, 30, 4],
'col2': [2, 3, 4, 5, 6],
'col3': [9, 7, ... |
I am new to Python but I aspire to become a 'proper' Python coder, (maybe even one day help the noobs on CodeReview :)
Therefore I want to get into good habits early, and would really appreciate some feedback on my first mini-project.
Notes
The code deals cards for a simple board game. If you are interested, this is ... |
I've learn to code almost alone, so I really need some ideas/advice, as it started to get really difficult to advance.
Because this is mostly server side, I can't provide a running snippet, but yet it's a short snippet.
Code
When I press a UI button, it fetches a resource, and this should create a set of list items. Si... |
I want to use structs as a container for data packets for asynchronous networking in C#. Found out that you can create a union style struct without the need to mark the struct itself as unsafe--instead marking the field as unsafe.
Example:
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi, Size = 8, Pack = 4)]
... |
This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A Summation Function For Boost.MultiArray in C++. I am trying to implement an arithmetic_mean template function for calculating the arithmetic mean value of various type arbitrary nested iter... |
I am working on a project where I need to work with http apis and call them using Python language. Below is what I need to do:
Take few input parameters like - environmentName, instanceName, configName.
Call get API on a service. Get the JSON data and compare the configName it already has vs what you want to update fr... |
I've been programming in C++ for over a decade and am thinking of learning Rust. Finding a number whose square is the sum of three different positive squares in at least two disjoint ways, which I used in test code in a C++ program, I wrote a Rust program to find out what other numbers' squares can be written as the su... |
Write a bash script for an ABC organization fulfilling the following requirements:
Takes an Employee's Name, designation, age, years of service and salary, extra working hours as an input.
Calculates remaining years of service. An Employee retires at the age of 60.
Check if the Employee is valid for salary appraisal.... |
I am practicing programing in Java. I have started to make a Xs and Os (Tic-Tac-Toe) game and I began with baseline logic of the game. I would appreciate any advice on my programming style, what am I doing wrong and what is good about my code.
Combinations class
public class Combinations
{
public static Map<Field, ... |
I am using 2 functions written in Python to convert a DLG file to PDB energies:
import glob
import os
import subprocess
import numpy as np
from vmd import vmdnumpy as vnp
from vmd import Molecule
from vmd import atomsel
def dlg_to_multiframepdb(fname):
inputstrings = subprocess.check_output("grep \"DOCKED:\" %... |
This program converts legacy markup in the form seen in the tests to the resulting markdown seen in the test's respective comment.
The full program is as uploaded as a snippet, or you may see below
let tests = [
"OneMatch$$$TwoMatch" // [One Match](OneMatch)[Two Match](TwoMatch)
, "OneMatch$$$TwoMatc... |
I've never messed with batch really so I'm trying to introduce myself. I made this to back up all registry data and organize it like this:
RegBackup
November
11-27-2020
[Registry Files]
11-28-2020
[Registry Files]
Backup.bat
The script is:
@echo off
Rem set bat location as CD
cd /D "%~dp0"
Rem open explo... |
I've written a little clock implementation in Java Swing. It now seems to work flawlessly after having terrible Swing specific timing problems. Please indicate if this is the way to draw the clock and if the passive / active combination (i.e. drawing from timer and drawing from e.g. paintComponent) has been programmed ... |
Hey I wrote a struct in C++ trying to represent a Pixel Component of a color
Here it is
template<typename T, T min, T max>
struct PixelComponent {
static constexpr T MIN = min;
static constexpr T MAX = max;
T value;
PixelComponent() = default;
PixelComponent(T value) : value(value) {}
inline ... |
My express.js application uses a lot of promises for interacting with a variety of services. Instead of including try/catch with each one, I've setup a fail safe factory method for all my express controllers. This should only be called when an unexpected error occurred. For example, 404 when trying a public API. I'm sk... |
I've been tinkering with python for quite a while but have never taken on a challenge like this - I'm trying to write a collectd plugin to scrape metrics from prometheus endpoints.
My goals are to make it as stable as possible - i'd like to put this into production when i am happy with it. There are a couple of items t... |
I'm trying to write a minor lib that would enable me to measure average time measured when using struct timespec. Since C doesn't allow operator overloading, I'm forced to build functions. I am aware that checks like end_time < start_time are not done, but I've left them out to achieve some kind of shortness in the cod... |
I created a JS script for a friend's website to allow the visitors to choose the date and time of their delivery.
I'm new in web-development and I will appreciate a feedback from professionals like you.
The script doesn't have an UI at the moment ,so for settings just need to change the shippingDateTime.
The script aut... |
I am designing a Stock Currency application and for that, I created a database.
I searched for my question here first but the answerer told me to ask the same question here.
flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Stock_Data(db.Model):
__tablename__ = 'stock_datas'
# Column names start wi... |
Module: https://amueller.github.io/word_cloud/
I really enjoyed the python WordCloud module, so I wanted to give it a GUI so I could share it with family and friends. I also wanted a platform where one could generate their own WordClouds within their own pictures, without word limitations (like many of the online wordc... |
This is my working template file which I manually edit to create new properly formatted webpages for my personal website.
I am interested in what advantages if any could be realized by placing the CSS in this file into an external file before modifying this file to work as a Django template.
Should I just leave it the ... |
I am attempting to complete the coin flip streaks problem from automate the boring stuff with python.
My code works fine but my only concern is the phrasing of the task.
Does the question want us to find the number of samples (100 flips) that contain at least one streak and divide that by the total number of samples (1... |
I did an OOP to make 2048 using Matplotlib visualization. The color dictionary is for setting different colors to each number in the game.
There are two classes written here: App2048, through which we add interactivity and we run the app, and CellObject, which is for the cell/square that will have a value/number. objec... |
I was solving the following problem on HackerRank.
Here's my solution -
from itertools import combinations
a = input()
ls = list(map(str, a.split()))
for i in range(1, int(ls[1])+1):
ls2 = []
ls2 = list(map("".join, combinations(ls[0], i)))
for elem in ls2:
ls2[ls2.index(elem)] = "".join(sorted(elem... |
I have following component
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { filterTransactionsByDates } from 'Utils/functions';
import {ReactComponent as BilanceIcon} from 'as... |
The problem says:
You are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q).
Let's sort p in non-decreasing order, and q in non-increasing order, we can denote the sorted vers... |
I need to write a maximum function so that it finds that longest word in the Ternary Search Tree and prints it.
This is what I have done so far. I have words in the tree such as "canvas", "cats" "van" but it prints None any way.
def maximum(self):
if self.root == None:
return 0
ptr = self.root
self.... |
Problem Statement
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
Example 1:
Input... |
I am new to programming / R and new to writing functions. I am working through the book R for Data Science and am on the following exercise:
Implement your own version of every() using a for loop.
In case you're unaware, the every function from purrr does the following:
Do every element of a list satisfy a predicate?
H... |
I am trying to implement the Euler–Maruyama method and use it to solve the Ornstein–Uhlenbeck process. I am basing my code on the wikipedia page where a python implementation is shown. More generally I'm trying to get to grips with stochastic differential equations in c++.
This is my code
#include <iostream>
#include <... |
I am trying to get a signal name to print when getting a signal number.
I actually have :
char* getsig(int sig){
switch (sig)
{
case SIGKILL:
return "SIGKILL";
case SIGSTOP:
return "SIGSTOP";
case SIGTERM:
return "SIGTERM";
case SIGTRAP:
return "SIGTRAP";
case... |
Here is some code I wrote to add, remove, and change user names and passwords in .htpasswd with PHP:
function adduser($user, $pass) {
try {
$htpasswd = '.htpasswd';
//$hash = '{SHA}'.crypt($pass, base64_encode($pass));
$hash = crypt_apr1_md5($pass); //APR1-MD5
$contents = $user ... |
Assume we are given a number and a prime p. The goal is to count all subnumbers of number that are divisible by p. A subnumber of number is formed of any number of consecutive digits in the decimal representation of number. Here is my solution:
number = input()
p = int(input())
print([int(number[i : j]) % p for i in ra... |
What are the pros and cons of each option, considering long-term implications (increasing the number of functions / parameters, other developers taking over, etc.)?
Option 1: removes the need to pass foo and bar to each method, but will create nested functions that are hard to follow.
const myFunction = ({foo, bar}) =>... |
I am learning python from CS106. Please review my code for Khan Sole Academy, I think my code not efficient. Please add critique and advice for beginner like me.
About Code
Generate 2 random numbers and add those numbers. If the user supplied answer is correct, row will increase by 1, goal is 3. If answer is false, row... |
The code bellow is code of "Hello" message handler. It works, but I really don't like as it looks.
The "hello" protocol contains three messages:
client -> server: diffie-hellman client public parameters
server -> client: diffie-hellman server public parameters
client -> server: used data
Could you please review the c... |
I have created a test, also the interfaces to be implemented for each test case based on user's role because I think it would make it easier to understand what the test case will and should do, also forces each test that has similar requirements to have consistent method naming. I want to make sure what I did is a best... |
I created an algorithm that helps me merging a payload into a given fixed object, in other words
this payload
const requestPayload = {
"customer_email": "me@domain.com",
"customer_name": "unit test",
"customer_firstname": "unit",
"customer_lastname": "test",
"customer_phone": "123456789",
"custo... |
My code is structured so that I create an ellipse through my first three points of data. Then I go through each next row, and if the point falls outside the ellipse, I record the minimum distance between the point and ellipse. These points have datetime associated with it so I can only keep points 10 minutes old in my ... |
here's the updated version of the code for being reviewed. Fixes:
"private" _cg function
functions definition as cg() {}
general clean-up
#!/bin/bash
# cd to the root of the current git directory
# If $PWD is submodule, will cd to the root of the top ancestor
# It requires to stay in the current directory, if the ro... |
I have been building an API in Go, which I want to link to a Postgres SQL table. I have always used NoSQL previously but thought it would be good to try a SQL database.
Here are my structs
type Activity struct {
Activity string `json:"activity"`
Payload Payload `json:"payload"`
}
type Payload struct {
Use... |
I am trying to resolve following problem. Please advice which part of the code can be improved.
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
Example:
Given the below binary tree and sum = 22,
5
/ \
4 ... |
I know my solution works, but I would like to know if the function can be simplified so that the loop is not called twice. Is there a way to pass the properties to be run through as parameters in the function?
My given data structure looks like (in which totalQuantities and typeQuantities might contain an uncertain amo... |
I was working on new function with Pandas DataFrame. It's meant to sort values by column name but exclude specific rows from sorting and return sorted dataframe with that has rows with preserved positions.
E.g. I have a DataFrame
Name marks
rank1 Tom 10
rank2 Jack 30
rank3 nick 50
rank4 jul... |
I've been learning C++ for a while. I wrote this app sometimes ago. The feedback that I got for that app was quite helpful. Now I rewrote the app using the new knowledge that I acquired while learning. This app has been complied with MSVC std-c++14. I want to learn writing efficient code with as little memory usage as ... |
I am solving the following HackerRank problem:
Consider a list (list = []). You can perform the following commands:
insert i e: Insert integer e at position i.
print: Print the list.
remove e: Delete the first occurrence of integer e.
append e: Insert integer e at the end of the list.
sort: Sort the list.
pop: Pop th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.