instruction stringlengths 71 95.1k |
|---|
Is there any way to reduce this code? It repeats itself, but I cannot find any way to reduce it because it is only repeating inside one elif. Sorry I'm a beginner my code is quite bad
It repeats here:
onze(joueurs)
print("joueur", a + 1, "a", joueurs[a])
time.sleep(1)
while s... |
Apologies for the cryptic title, but the problem really is rather simple.
I have a 64 bit integer which I interpret as 16 4 bit nibbles, or a nibble array if you wish, and I needed generate a mask covering the nibbles which are zero, or the inverse.
I have already come up with a solution, but it seems to me that there ... |
Standard code review, tell me what's good, what's bad, and how to improve. Critical suggestions welcomed. This is a content aggregator using bs4 and requests. I did not use any tutorials or help.
import requests
from bs4 import BeautifulSoup as bs
topic = input('Enter the topic: ').lower()
print()
def getdata(url, hea... |
I wrote a fileupload function for my application. Basically the application is a web based folder structure, which has files included.
I don't know, but I am not happy with it. Is it too long? Can I do some parts easier? Is the logging ok? So many questions... The FileModel is inerhiting from ParentModel.
public Act... |
Just want you guys to review my python 3 IRC bot code, it is actually a fork of https://github.com/Orderchaos/LinuxAcademy-IRC-Bot
You can see the source code at github
I also have questions:
I really can't find out how to change the ident for the bot, can I change the ident?
Can I change the ident by modifying the us... |
I originally wrote a rough C++ wrapper of the sqlite3 c library which did not use prepared statements. This code is my attempt at using prepared statements. I have attempted to make the wrapper as generic as possible so can be used in a wide range of applications.
How easy to use do you think this C++ class is?
Any b... |
Hello everyone!
In this task I had to create docstring generator. I'm just wondering how you see this problem, I have to "take data" from the dictionary
{'Args': None, 'Returns': None, 'Raises': None, 'Attributes': None, 'Summary': None, 'Description': None}
and then generate docstring in the correct order.
This is my... |
What do you think about this read only table design, regarding performance?
package jsql
Main.java
package jsql;
public class Main {
public static void main(String[] args) {
Record head = new Record("given name", "family name", "street", "postal code", "city");
Record jimmy = new Record("James", "B... |
I have the following code that makes a call to an external API, processes the response and returns a string. The problem is it is taking a very long time to process. I can't do anything to the API, but I was just wondering if there is a better way of doing the rest of the code.
foreach(var item in products)
{
item.... |
I've made a splitString() function which receives a character and a string and returns a vector<string> containing all the string split by a character in the input string:
vector<string> splitString(string input, char separator) {
size_t pos;
vector<string> text;
while (!input.empty()) {
pos = in... |
So I have recently written a bubble sort in java and was wondering if the code is correct and if there was any way to make it even more efficient.
Here is my code:
void bubbleSort(int array[], int num){
if(num == 1)
return;
for(int i = 0; i < num - 1; i++){
if(array[i] > array[i+... |
I'm writing this simple program for school, and using NumberFormat on all the variables seems very repetitive (Note that we were asked to use the NumberFormat method). Is there any way to clean this code so it doesn't look so cluttered?
import java.util.Scanner;
import java.text.NumberFormat;
public class CarPrice {
... |
I am working on the improvement of the bash-awk workflow designed for the analysis of data in multiple-colums format. The script uses AWK code (which extract numbers from selected columns of the input.csv as well as does some basic stat calculations) integrated into bash script (which operates with the input files loca... |
After quite some time away from Haskell I am trying to brush up. To do so I am writing some basic linear regression functionality.
The code produces the output expected. In essence I am trying to duplicate the functionality of R's lm() function using matrix algebra in Haskell. I appreciate that there is much more to do... |
The rationale behind this code is to implement a runtime-safe number conversions in situations when precision loss is possible, but is not expected. Example: passing a size_t value from a 64-bit code to a library (filesystem, database, etc.) which uses 32-bit type for size, assuming you will never pass more than 4Gb of... |
My C++20 N-dimensional matrix project now supports basic linear algebra operations: https://github.com/frozenca/Ndim-Matrix
Today I want to get some reviews on computing eigenvalues and eigenvectors.
In particular, I don't like so much duplicate codes. I think other parts are okay.. (hope?)
There are two functions: Com... |
Description
This is a simple (and hopefully) RESTful API in Golang that uses Redis. I have next to no prior experience in Golang and absolutely no prior experience with Redis. The API is a simple counter service with the feature of disabling "public" updates (cannot create new counter, and cannot increment existing cou... |
I have created the following function which filters a linked list in place
(here it removes all instances of the element k), but it could easily be modified to take a function pointer as an argument and filter on something else.
Any ideas on how to improve the code?
typedef struct list_integer {
type value;
str... |
I recently decided to learn how to multithread Java programs, so I made a small program to compare the performance of serial and multithreaded programs that perform the same task.
I created a serial program that calculates the number of primes from 1 to 10 million, and timed it 50 times using a test program. Here's the... |
I have this function called error, which estimates value based on previous value and rewards in trials. The difference between the estimated value and true value is then calculated, giving the error. I need to run this code 1000 times with different lists of trials, but currently it runs too slowly. How would I optimiz... |
We have a large set of projects at work. It's very important we keep track of those and every so often we need to run a full back-up that's unrelated to the 'normal' back-ups IT is running (snapshots every day, week, month, etc.). Recently we had a big migration on all of the older projects. To make sure nothing is irr... |
I have tried to embody some basic ATM operations in a Object Oriented manner for practice. Would love some review pointers from structure, Object Oriented principles point of view. Also what should be my next steps in order to get good at OO design(I would like to read more code not books/videos, have pushed my mind ou... |
Inspired by this question, here's some C code to check if a point is "inside" of a shape on a simple black and white bitmap.
For this exercise:
Set bits form the "outlines" of a shape (and are never inside).
Unset bits may be inside or outside of a shape.
Unset bits with a path to the edge of the bitmap are "outside".... |
I would be grateful for a code review of my first "real" C# project (https://github.com/michaeljsiena/RockPaperScissors). It's a basic rock, paper, scissors console game. It's probably quite over-engineered for what it is, but I wanted to try applying some aspects of object-oriented design I've been learing in a simple... |
I have a dataframe with a column composed by date object and a column composed by time object.
I have to merge the two columns.
Personally, I think it is so ugly the following solution.
Why I have to cast to str?
I crafted my solution based on this answer
#importing all the necessary libraries
import pandas as pd
imp... |
I previously posted a question for codereview:
Python Autoclicker
And I received some great feedback and changes to do in the code.
I have done many of the changes mentioned in the answers and here is the final code:
from pynput.keyboard import Controller
from time import sleep
def auto_click(key: str, n_clicks: int,... |
I recently needed to detect agents within a certain-field of view and came across this question in gamedev stack exchange. To learn how it works, I followed the first answer's guidance and decided to make a program that demonstrates how a "a field of view like collision detection" is done. But throughout the process, I... |
I'm working on an implementation of Monte Carlo Tree Search in Swift.
It's not bad, but it could be better! I'm principally interested in making my algorithm:
faster (more iterations/second)
prioritize moves that prevent instant losses (you'll see...)
Here is the main driver:
final class MonteCarloTreeSearch {
va... |
I've been learning React for about a month now. I wrote a small interactive calculator to show the effects of time dilation under special relativity. It's Node/React/Razzle(for SSR)/Typescript/Javascript.
Here are the issues I have run into and would like help with:
I feel like I'm abusing state. You change one parame... |
I am trying to learn how to correctly implement an iterator (and its corresponding const variant) using a single template, so I would appreciate any criticism to the following code. It's an forward iterator for a cv::Mat wrapper (a class from OpenCV that stores an image).
Edit: Its behavior must be equivalent to a pair... |
I am writng a JUnit test case for the below methods :
public final class LoggerService implements ILoggerService {
private Logger logger;
private <T> LoggerService(T type){
logger = LoggerFactory.getLogger((Class<?>) type);
}
public static <T> LoggerService getLoggerService(T type){
return new Logg... |
I've built a login panel, which will submit an email and password via fetch/POST. And I wanted to know the best way to handle network status errors?
Reason being, as I want to inject error messages into my login panel for each state/status code.
I've written the code below, which works. But I wondered if there is a bet... |
A few days ago I posted a previous version of my first bash script here to get few tips and reviews so I could improve it. So now it is improved a bit. I also shellchecked it and fixed the warnings. I would love to hear more tips from you guys.
Here is the code:
#!/usr/bin/env bash
declare -r CONF_DIR_PATH="$HOME/.con... |
I recently put up my C++ class to wrap the sqlite3 c library here:
Thin C++ wrapper for sqlite3 C library
One of the suggestions was rather than to specify a vector for arguments to functions instead specify iterators so users can use whatever collection they see fit.
Not being that familiar with adding such iterator f... |
I read some answers here on stack exchange, but none really "hits the nail on the head" about where to throw exceptions, where I shouldn't and where to catch them.
the idea that an exception should be thrown in exceptional cases is very vague, for example, if I can't find a user in my data source (repository) I can't c... |
I wanted to write a program in python which it scans the RAM of a computer, by displaying the services and the executables.
import psutil
import wmi
from time import sleep
from progress.bar import Bar
# Connecting
c = wmi.WMI()
# stock here Process Id
proc = []
# function to get the Size
def get_size(bytes, suffix="B... |
I want to have dynamic continuous block of memory for different types, that inherit from single base class. I've written structure for that purpose. I know I play with a fire here, but I would like to know how dangerous it is to use this structure.
Each element stored in DynamicPool must inherit from Base to support co... |
I was working on an Limit Order Book structure in JS and came up with this algorithm. I am pretty sure this must have already been implemented but couldn't even find a clue over the web.
The thing is, it's very fast especially when you have an array of many duplicate items. However the real beauty is, after inserting k... |
Hello I don't have any specific problem but I'm just interested how someone who is experienced in JavaScript would write this small toy program. it's a simple Todo List app, there are many approaches to writing something like this but I'm not sure if the way I wrote it is the most optimal.
I want to see how others woul... |
I have an IoT device with accelerating and gyroscope sensors.
before my device can be used it needs to be calibrated.
Basically, it means that I do measures for XYZ axes and for the gyro movements and save the findings in
JSON file.
With this script, I want to assure the calibration process has occurred and that the va... |
There are things that I am not 100% sure.
Is it possible that dangling references can be create in add_task method?
Is it possible that this implementation will deadlock?
I had to use shared_ptr in order to store packaged_task in the queue. Is there a better way to do it?
class ThreadPool {
public:
ThreadPool(int n... |
I'm new to Go and I completed the first challenge from Gophercises. Any feedback would be highly appreciated.
There are some things that I am unsure of if they are made in an optimal way.
Github repo
Goroutines and channels in the quizList loop
Better error logging for the cli portion
The Shuffle function only works... |
I am trying to optimise my remove-erase functions by using some attributes of C++ containers. This function should delete all indices defined in std::set form given vector. I am pretty sure that algorithm is functionality-wise working, but every time I see STL implementation or any code using STL I see a lot of checks ... |
For the real time control software I need square root calculation. I have heard that the sqrt function from the standard library isn't good choice due to the unpredictable number of iterations used during calculation. Based on that information I have decided to implement the sqrt function in my own based on the Newton ... |
I am learning C from C Primer Plus, and am still a beginner. I have been introduced to only two functions for input, scanf() and getchar().
According to me, when stdin is associated with input from a keyboard, there are 4 possibilities for user input in this program:
User provides valid input and presses enter.
User p... |
This is intended as a simple layout for an auto showroom site:
Disclaimer Details changed from original for privacy
body {
font-family: Helvetica, sans-serif;
background-color: #B2BEB5;
}
b {
font-family: Helvetica, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, sans-serif;
}
header.brandname {
bac... |
I am attempting to build an Android APP with the ability to connect specified FTP server in Java. The connection operation has been performed in FTPconnection class and the network call of FTP has been separated from main thread via java.util.concurrent.Executors.
The experimental implementation
Project name: FTPConne... |
I want to use only one for Loop for this code. Is this possible? If not then how can I optimise my code further?
It works well for the constraint 1 ≤ T ≤ 10, 2 ≤ N ≤ 10^3, 1 ≤ M ≤ 10^5,
but I am getting time limit exceeded for 1 ≤ T ≤ 100, 2 ≤ N ≤ 10^5, 1 ≤ M ≤ 10^5.
#include <iostream>
using namespace std;
#include <v... |
I've added some methods to a basic BST implementation for integers - if anyone can point out some ways that this could be written in a more efficient or clean manner, please let me know.
public class BST {
/*
* 1) Node inner class
*/
private class Node {
int data;
N... |
I was given a spreadsheet of data that I turned into a CSV file and then converted it into a JSON file.
I threw it into my application and I am processing it in the following manner:
const fs = require("fs");
class DataRepository {
constructor(filename) {
if (!filename) {
throw new Error("Creating a reposi... |
I'm starting out with Rust and decided to implement a game of Hangman. Can you please provide general feedback on the code?
I've already identified some lines (see comments [A], [B], [C]) where I cannot find a better way; feedback regarding these would be much appreciated as well.
use rand::seq::SliceRandom;
use std::i... |
I have made an AVL tree in C and coded the basic functionality of insertion, deletion, and search. I would love some criticism on my implementation especially on the insertion and deletion section of the code. Furthermore I think I could have used one less variable in the Node structure as you do not need a height for ... |
This is my implementation of an AStar-like algorithm for maze solving.
A quick summary of the problem I am trying to solve with my algorithm might be:
A simple binary maze is given to you to solve, you may only go in the standard cardinal directions: north, east, west and south. There is a twist, however: You may also... |
This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4.
It supports 12 conversions, it can convert number from each type to the other three type, it can convert:
binary to decimal | binary to hexadecimal | ... |
Here's the Rabin-Karp implementation that I've written in Python:
from functools import lru_cache
from itertools import islice
from typing import List, Optional
BASE = 139
MOD = 2 ** 31 - 1
@lru_cache(maxsize=None)
def char_to_int(c: str) -> int:
return ord(c) + 1
def calculate_hash(s: str, length: Optional[in... |
I want to improve performance for api. I design cache in dao layer. I use caffine cache. Basic code is:
CacheConfig.java
@Configuration
public class CacheConfig {
@Autowired
private AppDao appDao;
@Bean(value = "appCache")
public LoadingCache<String, App> appCache() {
return Caffeine.newBuilde... |
I wrote two template functions to serialize and deserialize structs representing messages to be sent and received via a TCP socket:
/*
* Convert a byte string into a packet.
*/
template <typename PacketType>
PacketType deserialize(std::string &buf, bool partialProcessing = false)
{
PacketType packet;
size_t b... |
I need to iterate over a list of IP addresses, to check if the elements inside are subnets/supernets between them, for this I use the IP-address library.
Currently I have the following problem: my second iterator (which I use to iterate over the rest of the list) always starts at 0 and therefore compares each element ... |
I'm trying to build a response cache with custom key values (from headers and cookies). Here's the code I have so far, and it kinda works, but I need a second opinion or suggestions for improvements.
Are there any possible errors, faster key generation methods etc.
Here's the code for middleware and cache key building:... |
This is an Relative Strength Index algorithm able to buy and sell stock based on values from basic stock CSVs. It works correctly and well, but I'm not sure if it can be better optimized as it basically repeats itself twice to operate on the two stock values it's given. I can only use python itself, no numpy or anythin... |
I'm trying to design a chain of responsibility pattern.
It slightly differ from traditional way when handler does only one action on a request, f.e. handles http response considering status code.
But my handlers have to do two actions. Below is an (dummy) example where handler asks a question first and then writes the ... |
I am looking to improve the performance of my code through best practices and cleaner code.
My goal here is just to perform a conversion whenever there is a keyup.
But I noticed that my code looks very repetitive. In your view, what should I do to simplify it?
window.oninput = function(event) {
var campo = event.ta... |
I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.
I want to refactor my renderPriceChange function since it's using the same pattern.
const renderPriceChange = (price) => {
if (price > 0) {
return (
<Text style... |
Description of the App:-
A React app that shows the public Github repositories of a user.
The app shows an input field where we can enter a Github username and a submit button. {It provides users the feedback while getting the data in the background.}
The repositories are shown as a list and for each repo, the followi... |
Hello everyone!
Here is the thing. So I wanted at first to create Robot class, I want him to move around some board. Maybe 10x10 or something like that, then i wanted to invent a Robot fights class, I want to add class players (becuase i want to play between player 1 and player 2) but here it is what I have so much.
Le... |
I am trying to sort an associative array by following this scheme:
Sort by 'qt': positives first, non-positives after. Magnitude does not matter, only sign.
In positive part: sort by sa DESC
In negative part: sort by sa DESC
I managed to have the desired result but by tinkering :
$array = [
[
"id" => 1,
... |
This is a challenge from CodeSignal.
For
image = [[1, 1, 1],
[1, 7, 1],
[1, 1, 1]]
the output should be boxBlur(image) = [[1]].
To get the value of the middle pixel in the input 3 × 3 square: (1 + 1 + 1 + 1 + 7 + 1 + 1 + 1 + 1) = 15 / 9 = 1.66666 = 1. The border pixels are cropped from the final re... |
I am trying to translate the book Game Coding Complete by Mike McShaffry 4E to modern C++17 standard and faced with the code of Mersenne Twister by Takuji Nishimura and Makoto Matsumoto.
Is it right to convert random generator code from book like that:
from:
#include <ctime>
#define CMATH_N 624
#define CMATH_M 397
#def... |
Im planning to use Strategy design pattern to put it in
ScheduledExecutorService.scheduleAtFixedRate. I can use create as many scheduleAtFixedrate depends on the data to be pulled. Will this cause a race condition?
public abstract class DefaultStrategy {
protected Map<String, String> transactionMap;
... |
I have been writing a discord.py bot, running on replit.com. I gotten to the music bot part after finishing the queue part. My code is logically correct; however, the code is way too inefficient causing the bot to crash when someone adds another song to the queue. How can I program my bot to be more efficient? If my co... |
Im fairly new to Golang and I appreciate any feedback about how to make the code cleaner.
The code is called by go-routine and should update status (fail/success etc) of several installation process.
package avss
import (
"context"
"sync"
"helm.sh/helm/v3/pkg/release"
"sigs.k8s.io/controller-runtime/... |
I have a situation where I've used the strategy pattern but got many different strategies that are available to the client code that needs to select the appropriate strategy, this is because there's a lot of different usages to the strategy depending on the machine that's being calculated, because of the domain it's be... |
As you may know, C++20 has added std::atomic<std::shared_ptr<T>> specialization to the standard, but sadly, most compilers have not implemented it yet. So I decided to implement it myself.
I want to know if I can improve this code or not. In addition, I'm not sure if my implementations of wait(), notify_one() and notif... |
I have a function that sums two arrays element-wise and stops if the sum at a certain index is greater strictly than 1. This function is called lot of times (15817145 times for a small simulation and expects to grow a lot more as the simulation size grows). Profiling my code shows that it is among the five most consumi... |
-I have a ListView, and its SelectedItem property is bound to EmployeeModel SelectedEmployee in my VM, and it implements the Set method from MVVM Light. (Basically, OnPropertyChanged, but the MVVM Light version.)
-I have three more ListViews (more, but for simplicity's sake, we'll say three.) They are bound to the fo... |
I have a medium sized project that uses a class hierarchy that essentially boils down to:
class Mach
{
public:
virtual ~Mach();
//...
virtual void common_action() =0;
//... A lot of common actions
//...
};
class MachStrato : public Mach
{
public: //...
// ...Implementation of the common inter... |
As some part of my application needs connection to database I wanted to create tests that use mocks to avoid running special instance of database just for testing. That gave me a glimpse of how can I use mocks and I played with them a bit.
I wanted to test express router:
UserRouter.post("/users", async ({ body }: Requ... |
Made a console game in C++ called "Epic dungeon", which my friend did a year ago in JS. I decided to do it in order to gain experience (in fact, I did it because I would have stopped learning C++ if I hadn't done something, because studying for so long and not doing anything can quickly get boring) I did it without usi... |
I had a piece of code that solved really simple problem - it formated two dates to look better on a webpage. It looked like this:
function formatDateRange(
days: { firstDay: string, lastDay: string }
): string {
let first, last;
first = dayjs(days.firstDay); //dayjs parses string that formatted like this "YYYY-... |
This question is a follow up of Header only bigint library written in c++20.
I've made all (or almost all) the corrections suggested in the answers, plus some minor change here and there and a modification in the division algorithm. Instead of a lot of constructors, now there are only two template construcors, limited ... |
How are you doing? I have to make a script to parse an xml input file to a json file. I tried to do my best, but it will be nice if you could check it and help me to improve it. The idea is that I don't have use objectify of libraries that converts files directly. I have to write this scritps with at least this propert... |
Here is a python function I have for a neural network I have implemented. I feel it become a bit cumbersome. The intention is to weight positive labels in channels 1:end higher than background pixels. Hence the distinction between foreground and background.
def loss_function(
self,
x: torch.tensor,
... |
I have following code:
public class Worker : BackgroundService
{
public Worker()
{
}
protected async override Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
var task1 = Task.Run(() =>
MethodOneAsync(... |
I'm trying to implement a sql-like in-memory database.
Here is my code:
#[derive(Debug)]
enum DataPoint {
Int(i32),
Float(f64),
Text(String),
Null,
}
#[derive(Debug)]
struct Table {
name: String,
rows: Vec<Vec<DataPoint>>,
cols: Vec<(String, DataPoint)>,
}
impl Table {
//insert a row i... |
I've been learning C as my first language and recently I decided to learn how to create Win32 apps written in C. I Quickly realized, though, that my biggest challenge wasn't writing the Win32 app itself, but more how to implement logic and design into the program.
I would therefore really appreciate any feedback about ... |
I am a beginner programmer ( just recently picked it up ). I just completed my first ever project, that is creating a Blackjack game in Python. I would like to know your opinions about it and how it can be improved! Thanks in advance. This code is original and I made it myself without any external assistance.
import ra... |
I'm getting started with Python and one of the beginner projects to learn the language was a password generator (one of the dozens already in CodeReview). I have a C# and JS background so I want to make sure I'm doing things the Python way.
Technically the include_punctuation and include_digits properties could be omit... |
I'm trying to write code that reads data from a CSV and pushes it to a Salesforce application using the API. My code processes the data in a for loop, but it takes a long time (3 hours) to run the function. What can I do to optimize my code to run faster?
Here's an example of my code which reads Patient Diagnosis data ... |
I created a class in a separate .h and .cpp file with the idea of having an array of 3 monsters with each monster having different stats( name; health; damage). The problem is that the constructor should change the properties but when I try to call them in the main file only the 3rd monster's properties are changed.
ma... |
I've watched a talk by Fedor Pikus on design patterns held at CppCon 2019. Motivated by this, I wrote my own visitor implementation and some helpers which allow me to create a visitor from a couple of lambdas.
My goal is to reduce the amount of boilerplate code but still use the classical visitor pattern (I know about ... |
When one writes C++ code to manipulate LinkedLists, Trees, etc. one creates a tmp pointer that points to the start/root and changes that pointer as one traverses along.
What would be the equivalent way of doing that in smart pointers?
Here, I wrote a Trie code using std::unique_ptr to understand how to pass pointers ar... |
I was curious on how I could create a random string and have it have a set prefix. Lets say, as an example, 3456. This question is more referring to how I would join two strings together, my prefix and my random string.
To give a more comprehensive exmaple of what i'm looking for, let's say I generate the string "ab8... |
I know this has been done many times before, but this is my existing code taken from a sample I found to async process a list of tasks. I've seen Task.Run in use before in many examples, but I'm assuming that in most cases, the workload will be IO bound and therefore the Task scheduler is not clever enough to know whet... |
Related: Find all distinct subsets that sum to a given number
This code is supposed to efficiently generate all subsets of a list such that the subset's values sum to a particular target value. For example, given the input list [5, 3, 2, 1] and the target 8, it should produce [5, 3] and [5, 2, 1]. Given the same input ... |
I'm doing a hobby project for fun recently, it's a GitHub webpage using Jekyll.
One of the main component of my site is displaying Chinese characters with their Sino-Vietnamese pronunciation. I use <ruby> elements to render these texts, for those who don't know, you can read its MDN docs
The problem with that is word s... |
This playbook aims to verify if a specific file exists in a specific directory and, if not, to create it.
Neither the file nor the directory may exist before the verification.
After the process is finished, I would like to have a statement that ell me that the file exists.
See what I came up with and please give me fee... |
I am trying to solve a set of differential equations in x,y,z, I have made simple kutta 2 code in python before but not with 3 variables. I am not sure if what i have done is an acceptable way to adjust for 3.
Here is what i have so far: (i have not entered the exact solution as i do not know it)
import numpy as np
imp... |
My code does a DFS on the given graph and prints all possible paths for a given start and end node. My question is how can this be improved?
Can some form of memoization be used here? There are cases where a path from a certain source - destination is already found and will be an intermediate path for a different sour... |
I currently I have this code
if (this.showAllOnlineFriends === false) {
this.showAllOnlineFriends = true;
} else {
this.showAllOnlineFriends = false;
}
When you press a button, it will toggle a boolean on or off. Is there a more readable way to write this?
|
Recently I had to do an IKM C++ assessment to qualify for a job. Some of the questions seemed strange to me, so I'll be doing a few posts here to discuss.
The first one is related to use of std::unordered_set. From what I remember it went something like:
A programmer is using a struct to contain some data. The struct ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.