instruction stringlengths 71 95.1k |
|---|
I have a main() function in my Python program which calls another function which in turn calls yet another function. There are certain conditions in those functions when the program has to call sys.exit(). One approach is to call the sys.exit() directly from the functions like this:
#!/usr/bin/env python3
import sys
i... |
I took one of my old university exercises for another language and re-solved it in c++. It consists of several higher order functions for vectors. I hope the comments are self-documenting enough.
I am mainly concerned about not utilizing "modern" c++ features enough and generally writing bad c++, but feedback of any ki... |
I've been working with Sanic as my default web framework, but coming from Flask, I had some issue with how to handle the database connection.
So I built an asynchronous wrapper around it.
I've also added an option to post process callbacks only when the whole process was successful (didn't thrown an error) and handling... |
I have some functions which update records in some database tables.
When I run each function I want to know the number of records affected by each.
I'm wondering what the most elegant way of returning this information is.
Do I return it directly from the functions as an integer like this?
$result1 = $records->create();... |
I made my first program in Python using PySimpleGUI. The project turns a YouTube video into an mp3 file and stores it in folder for Spotify to access. I found this idea somewhere and just wanted to give it a go. However since it's my first program, I felt like I should try and get feedback to try and stray away from po... |
How my method works is by sorting the list of numbers from least to greatest, finds the length of the list, then pick the first and last index integers. In the python world is this efficient or is there a better faster way; speed-wise?
list = [11,2,343,32324,324,23456,437575,23534654,34624,236543,45464,549874984,4654 ... |
The question is about nodejs module pattern code structure.
My goal is to initialise the module at one time and export the module using module.export
so that, it's available in other files.
I took Twilio for explaining.
Here I want to initialize twilo using credentials and export it as twilioClient, which I can reuse w... |
I solved a question on Codewars about creating a phone number:
Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.
Example
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
The returned format must... |
I am a student I am new to python, This is my first code, any one help me to simplify this code.
A=[5,"c","d"]
total=0
for item in A:
if (item == 5):
total= item
if (item == "c"):
total= total-1
if (item == "d"):
total= total*2
print("total",total)
my requi... |
I've written a parser to scrape data from Canadian Statistics Bureau.
import re
import pandas as pd
import requests
from bs4 import BeautifulSoup
def get_number_of_sources() -> int:
'''
Retrieves Number of STATCAN Sources
Returns
-------
int
Number of STATCAN Sources.
'''
URL = 'ht... |
When scraping and saving data into a file, Which method is more efficient when saving scraped data to a file?
open the file first, scrape, and save the data all while the file is opened, or
store the data into a dictionary and then save it to the file?
For example, the following two scripts scrape data from Yahoo Fin... |
Dynamic Type - [ int, char, bool, ... => dtype ]
Dynamic Type in C, A project that I had been thinking of for a while and made it.
How it works ?
Dtype currently is same as char, when doing dtype var[size]; size bytes are reserved for var as normal char would do. The actual working of dtype is that it stores the type o... |
I'm creating a method that expands a sequence.
This is a sample of how it works:
Input: {1, 2, 3}
Output: {1}, {1, 2}, {1,2,3}
So far, I've been able to solve the algorithm using 2 different approaches:
Approach 1
public IEnumerable<IEnumerable<T>> Expand<T>(IEnumerable<T> sequence)
{
return sequence.Select((x, i)... |
I've been working on this project for my organization for a few months now, and am looking for ways to increase performance on this macro.
I work for an insurance company as a claims auditor. I get a report daily of claims that were ran the day before and look for abnormalities to audit. The below macro compares the dr... |
My code takes 3 images taken with a polarising filter rotated 45° between them and transform them into a single image encoding the polarization parameters as HSV. what can be improved?
import cv2
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from IPython.display import Image
%matplotlib inli... |
Recently starting to learn programming, I'm looking to move to making larger projects and am just picking up the basics now. I have a feeling this code sort of missed the point? Am looking for feedback for better/ more efficient practices to make it more functional/clean.
The following was the prompt:
1. Simple ATM Sof... |
I am new to Rust and specially new to FFI programming, and I am porting a macOS specific C library called librazermacos to Rust.
While writing some public APIs I came up with my first two methods which, incidentally, are the ones I needed to write to check my mouse battery and build some kind of proactive monitoring of... |
I wanted a readfile with 304 Not Modified and 206 Partial Content support, I think i got right, but probably spent way more effort on error-checking than worthwhile.. Also I didn't develop it by reading the specs, but instead studying how Nginx handles Range requests:
<?php
function httpreadfile(string $path): void
{
... |
I'm implementing a queue to update leaderboards when score data changes in the background. Updating the leaderboard is a relatively expensive operation, so if we say "Update leaderboard 5" and then immediately say "Update leaderboard 5" again before the first one is finished, we should just update leaderboard 5 one ti... |
For readability sake, is it better to use optionals or write my code in an iterative manner?
Here's a route I'm working on, does this look readable do you?
@PostMapping("/verify-email")
public ResponseEntity<String> verifyAccount(@RequestBody String email) {
Optional<AppUser> optionalUser = appUserService.findByEma... |
Working on creating new tower defense in JS. May be port to React.
How to improve? Only made enemies and path so far.
In below demo, path is white background and enemy is red circles and green squares. Enemy may have different type: triangle or different speed.
"use strict";
// https://stackoverflow.com/a/15313435
f... |
There is a tree of start folder, it's subfolders, their subfolders, etc. In each folder, subfolder, etc. there are the same structured XML files stored.
books.xml
<xml>
<book>
<author>Isak Azimov</author>
<name>End of spirit</name>
</book>
<book>
<author>熱い</author>
<name>Happiness of plants</name>
</bo... |
I am really new at JavaScript and now i'm kinda struggling with this problem... My JavaScript code is really repetitive and i would like to make it shorter and more readible... (I heard that using a loop could shorten my code but i don't really know how to do that...) could you help with me that ??
The goal is that i w... |
I programmed a little sorting visualizer a while back and I have been meaning to get some feedback on the overall implementation and on what I could do better to have cleaner code or a "best practice" version.
I did my best to use OOP programming.
I have done some projects in the past so this is not my first one and I ... |
I'm a hobby programer and I had an idea for pixelating images and I wrote it.
I was wondering how would a better programer write the same function.
I want to learn and I think that this would help me a lot to see how code is supposed to be written. Also my code is quite slow and I would like to make it quicker.
I use P... |
[Edited] formatting and Flake8 linter corrections
Four days ago I posted my first object oriented programming project.
Everything I have learned to date is self-taught and posting project to receive criticism is the best mentor I currently have.
The feedback on posts like this is integral to me, so please use a fine-to... |
I was solving the lunch boxes problem on HackerEarth but as I submitted my solution most of the test cases were passed and the rest showed 'Time Limit Exceeded'. I would be very grateful if you could help me improve the algorithm of my code to reduce the runtime.
Following is the Problem
Alice works as a restaurant man... |
I have a problem. In my project the user can copy a menu for a specific day or for a specific week. The value that will be sent to the back-end will be something like:
2022-10-07 or 2022-W43
Depending on the selection of the user. But now in the back-end I need to query those items using the given date, but I am not a... |
I made a generic interpolator for Unity objects, but the way it functions makes me question if there's a better way to approach this problem.
I want the logic inside of the Tween<T> function to be the same for every type. I don't want to create many overrides for unique types because that would cause a lot of pointless... |
I was working on Jump Game problem on leetcode
Question
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.
Return true if you can reach the last index, or false otherwise.
Example 1:
Input: num... |
I am working on a project in which an array can easily grow beyond 50M in length. It's an array holding only boolean (0/1) values. Using Uint8Array is just fine and it's very performant compared normal arrays. Still I just wanted to try implementing a BitArray by extending DataView object. BitArray enormously reduces t... |
As the input you get the flight schedule as an array, each element of which is the price of a direct flight between 2 cities (an array of 3 elements - 2 city names as a string, and a flight price).
Planes fly in both directions and the price in both directions is the same. There is a possibility that there are no dire... |
Hello i build project Slot Machine this project was inspired by Tech with Tim here's his code from this project how he implement that --> https://github.com/techwithtim/Python-Slot-Machine/blob/main/main.py .I changed the code of the project on my way but something is same but most of the things i tried to change to ch... |
I want to serialize a class Mango recursively.
Mango Class
class Mango
{
public:
const MangoType &getMangoType() const { return typeMan; }
MangoType &getMangoType() { return typeMan; }
private:
// There are many members of different types : I just mention one.
MangoType typeMan;
};
Data type classes
... |
I've been working on my first python program for a few weeks now and I feel like the program is at a decent stage to begin sharing. The premise was to create a file explorer that eases the use of rsync. The reason I've chosen rsync over ssh/sftp is due to my current location and extremely limited internet connectivity/... |
I would really appriciate if someone could review my code and give me feedback. This was my first multi file project.
Main:
#include <iostream>
#include <vector>
#include "Pad.h"
#include <conio.h>
#include <Windows.h>
#include <iostream>
#include "Ball.h"
#include"consoleFunctions.h"
int main()
{
Map map{};
B... |
Builder pattern separates object construction from its representation
I have to generate username and password for the Account class. Since this operation is a bit more complex, I decided to wrap it into a Builder pattern because it allows me to create an object step by step using methods.
FirstName and LastName are... |
public ResponseEntity<Map<String, String>> resetPassword(@RequestBody String email) {
// Create password token and send by email, if email doesn't exist, don't send it
Optional<AppUser> optionalUser = appUserService.findByEmail(email);
if (optionalUser.isEmpty()) {
throw new VerificationTokenExcepti... |
The struct below parses full name into first name, middle name, last name and suffix.
Perhaps Builder pattern is more appropriate here? I remember there was a principle referring to the number of constructor parameters which Builder solves.
record vs struct? Records inherit from IEquatable. https://sharplab.io/#v2:CYL... |
To avoid a code dump I have removed most of the code and left the first few lines of constructors and methods and anything relevant. Full code at the bottom.
The purpose of this code is to use threads to process the application. Each of the following components needs to run on separate threads: a current time stamp in ... |
Now I have this portable, parallel MSD radix sort for unsigned keys. It exhibits linear speedup on small values of \$P\$ and has a running time of
$$
\Theta(N/P + P),
$$
where \$P\$ is the number of processors available.
What comes to portability, my implementation runs on Windows, Linux and macOSX.
The entire project ... |
Here's my solution to the first challenge of the Cryptopals Crypto Challanges (https://cryptopals.com/sets/1/challenges/1).
I decided to use a cargo workspace to structure my project with the library crates inside the crates/ directory and the binary crates (the solutions to the challenges) inside the challenges/ direc... |
The method is fully functional and creates an excel as expected.
What I would like to know, is if can be made more functional and better written for maintainability.
For example, how can I put the headers of the columns in that way to be separated to allow better readability and in this case be able to manipulate singl... |
The following code is my solution to a LeetCode question - find the longest palindromic substring. My code is 100% correct, it passed once but it took too long, and in most of the reruns I hit a "time limit exceeded" error.
I would appreciate any suggestions on why it's taking too long and how to improve the performanc... |
I recently started TS.
I was looking for feedback on my below function (for example maybe it can be written in shorter way). Let's assume we still use the reduce function.
The function description:
Write a function which takes object, and another object which contains
validators for each of the fields of the main obje... |
Blackjack card game with hit and stand.
Wasn't allowed to use functions outside of classes in code.
Had some difficulty with __str__ dunder method on Dealer and Player classes (got weird solutions for the time-being)
Would appreciate any feedback on how to improve readability and make code more efficient.
Code
#Blackja... |
I made this pretty simple content loop-carousel component, but
the code seems too "Iffy" but Im not sure how I could make it better.
I tried to use the Switch expression, which makes it a bit more readable, but
I dont like the breaks in them.
here is the relevant js code:
data() {
return {
...
currentC... |
I am an amateur. I have been coding for 3 months now.
If you have any comments,suggestion or critics about my code please feel free to speak up(i am urging you to).
I want to be a really good engineer.
This is my header file:
#ifndef BANKSYS_H
#define BANKSYS_H
#include <iostream>
#include <string>
using namespace st... |
If this code is written correctly, it will block undefined behavior from happening in the case of signed overflow (guaranteeing that the program halts instead), and also guarantee that the program halts in the case of unsigned overflow/wraparound.
//overflow.h
#define err exit(1)
//overflow blocking code based on detai... |
This is a toy problem. I want to try using Rust for numerical modeling, but I found zero tutorials for this kind of stuff.
I also just started learning Rust yesterday, so please bear with me.
Usually when I'm doing an ODE solver, I create a grid array, then values array, define initial conditions and other parameters, ... |
I am reading chapter 29 of OS: the three easy pieces, which is about concurrent data structures. The first example these is an approximate counter. This data structure increments numbers by using a global Mutex and several local Mutexes with local counters. When a local counter hits a threshold, it grabs the global mut... |
I have a file with content:
4;10;3;6;10
6;9;1;3;5
3;2;1;1;2,65
I need to split each line of the file into an fractional (double) array with elements as these numbers. I was able to do this and the task works correctly. But the code looks cumbersome. Is there any way to optimize it?
string[] readText = File.ReadAllLine... |
Variables:
conf of type struct Conf whose details are not relevant to this review stores the configuration data being read.
str is a string containing the path of the directory the app uses to save data.
Code:
bool exist = 0;
if ((mkdir(str, 0755) && !(exist = errno == EEXIST)) || (Dir = open(str, O_DIRECTORY)) == -1... |
I have made a couple modifications to the switch/rotate routine for the classic Marbles game. The modifications are
Using a random_select method that can help pick either switch or rotate
Create a method called first_two that rotates l[0] and l[1] and avoids the switch as that would be counter productive
With these t... |
I designed the following DataBaseBuffer class, to be used by different threads that generate queries and need to send them to the database. It was inspired by producer–consumer problem solution.
#include <nanodbc/nanodbc.h>
#include <queue>
#include <string>
#include <mutex>
#include <thread>
#include <algorithm>
clas... |
Here's a link
Given a string s, return the longest palindromic substring in s. A string is called a palindrome string if the reverse of that string is the same as the original string.
Example 1:
Input: s = "babad"
Output: "bab"
Explanation: "aba" is also a valid answer.
Example 2:
Input: s = "cbbd"
Output: "bb"
... |
I am making several dropdowns dependent on each other.
Data used to form dropdowns:
const data = {
size: [
{ id: "s1", value: "009" },
{ id: "s2", value: "012" },
{ id: "s3", value: "041", configId: ["c2"], dischargeId: ["d3"] },
],
config: [
{ id: "c1", value: "Horizontal", sizeId:... |
I have a function and am wondering whether I have written it the most performant way by using multiple guard clauses in the code above some of the variable declaraciont.
Here is my code:
// option 1 - most efficient?
const checker = (
hasBingoLoan = false,
options,
udlViewGrid,
notifications
): EligibilityResul... |
As always, I am looking for as much criticism as possible. Forums and exchanges like this are where I have received my most solid feedback.
Enjoy!
Github hangman repository
The code that I import is below:
from enum import Enum
from dataclasses import dataclass
import random
class Letters(Enum):
a = ('', 'A')
... |
The project outline:
Write a program that walks through a folder tree and searches for
files with a certain file extension (such as .pdf or .jpg). Copy these
files from whatever location they are in to a new folder.
My solution:
import os, shutil
from pathlib import Path
def copy_extension(basedir, newdir, extension... |
I am working on this function here and it produces the desired output. I just want to make sure I'm going about things in a smart way.
It effectively just sorts through the data, with consideration to the fact that campaigns may be created by different firms. Then it aggregates the data.
from collections import default... |
How can I improve this code? I wanted to have a separate method for "isdigit" but when I tried making it, I kept getting the error: "non-void function does not return a value in all control paths [-Werror,-Wreturn-type] }"
I also don't fully understand how I pulled of this part, the more I look at it the less it makes ... |
I'm in the process of familiarizing myself with Rust. In order to get some practice, I decided to make a program that generates images of the Mandelbrot set.
The function I use to generate the image is included below. I'm specifically interested in feedback regarding my use (or lack thereof) of Rust idioms, as well as ... |
The code will create a new Movie class and then with the response of the API call, will render html using the data.
Although the code works, I imagine it will get quite convoluted, now that everything after the new class is created, has to be nested into the event listener. There must be a more correct way to do this. ... |
The project outline:
It’s not uncommon for a few unneeded but humongous files or folders to
take up the bulk of the space on your hard drive. If you’re trying to
free up room on your computer, you’ll get the most bang for your buck
by deleting the most massive of the unwanted files. But first you have
to find them.
Wr... |
I wanted to have a simple way to capture all sysout for a block of code. Ended up with this:
fun captureSysOut(block: () -> Any?): String {
val originalSysOut = System.out
val out = ByteArrayOutputStream(2048)
System.setOut(PrintStream(out))
return try {
block()
String(out.toByteArray())... |
I created a function using requestAnimationFrame loop that works pretty much like the plain JS setTimeout function (except that a custom starting time can be optionally given for the duration, and it returns the finish time). I wonder whether this is an ideal way of writing it. In particular, I had some issues with sel... |
Edit: This question is dead, so I am making an edit in hopes that someone who does have the time to look over my code sees it. If you have any way for me to improve this question/ask some other community/have some recommendations on how I might get an answer (sadly cannot set a bounty due to my points) please tell me. ... |
This is another solution to a previously asked question.
The project outline:
It’s not uncommon for a few unneeded but humongous files or folders to
take up the bulk of the space on your hard drive. If you’re trying to
free up room on your computer, you’ll get the most bang for your buck
by deleting the most massive o... |
Background
The typing module supports subscriptable types. Here is an example use case:
from typing import List
def foo(bar: List[int]):
pass
However, when you try to use this with isinstance, it fails:
>>> from typing import List
>>> my_list = [1, 2, 3]
>>> isinstance(my_list, List[int])
Traceback (most recent c... |
Code for grammar
grammar EpicLang;
Break : 'break';
Do : 'do';
Continue : 'continue';
Else : 'else';
Func : 'func';
For : 'for';
If : 'if';
Then : 'then';
Len : 'len';
NoneObj : 'none';
Print : 'print';
Return : 'return';
While : 'while';
TrueLiteral : 'true';
FalseLiteral : 'false';
// Lexer rules
LINE_COMMENT
... |
I was solving a question in a competition I joined that asked for a program that calculates how many numbers are less than \$q\$. I solved the question but didn't get the full mark because the code was too slow.
The input is 4 lines, the 1st contains \$n\$ (the length of the array), the second contains the elements of... |
I created and finished a Snake using pygame (in Python) utilising feedback I had from a previous code review a year or two ago. I'm pretty happy with the current state and havn't identified any bugs but would love any feedback on this, in terms of logic, coding principals, best practice, or anything else etc.
import p... |
I am bulk recompiling edits to a c-like language which uses an external compiler.exe. The compiler takes the file paths as arguments and does the processing, nothing needs to be synchronized simply speed up the de/compilation of multiple files by using workers, when a worker finishes it should be recycled and the execu... |
This post is a second part of my original post, Add two huge base-10 numbers, which deals with adding two huge base-10 numbers. However, in this case, I'm multiplying two non-negative whole numbers. In both cases, the input and output are represented as null-terminated ASCII strings, with digits in big-endian order. I ... |
I have as input a potentially large CSV file (gzip compressed) with a known structure. I don't know in advance the size of this file, but let's say it can't fit in memory. The rows in this CSV are ordered like the following:
key1, …other fields
key1,
key1,
key1,
key2,
key2,
key3,
key4,
key4,
⋮
They are ordered by the ... |
This is one of my school assignments and I just wanted to ask if there are some obvious mistakes or things I could maybe improve in this code.
Thank you for any suggestions.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class... |
The code combines data from two Ballerina table data structures.
The program prints the following expected and correct results (edited for readability):
[
{"fooId":1,"barId":2,"data":"foo 1;bar 2"},
{"fooId":1,"barId":4,"data":"foo 1;bar 4"},
{"fooId":3,"barId":4,"data":"foo 3;bar 4"},
{"fooId":3,"barId":6,"dat... |
I have the following code which collects gaps in a number sequence into a separate vec.
There will never be a case, iterating over a Vec<i32> where .windows(2) will yield a window with None values. So I want to simplify things by transforming each window into a Gap with first and last i32 values wherever the gap betwee... |
Is there any improvement that can be made to the following code, written to simulate the harmonic oscillator in the path integral formulation with Monte Carlo methods?
#STRAIGHT-LINE INITIALIZATION
def cold_path(N):
return np.zeros(N)
#RANDOM PATH INITIALIZATION
def hot_path(N):
return np.random.uniform(... |
I have this script and I want to ask if it's good/optimal and if it's not how should I change it?
What it's doing is when the website loads music, it starts to play when the user clicks prevent play() not running because user didn't interact) from an array of music and when a music stops a new one plays.
In the future ... |
I want to serialize a C++ class Ramdomclass . Below is the serialization function.
std::vector<uint8_t> Serialize(Ramdomclass &Ramdom)
{
// First encode the dom content
std::vector<uint8_t> Buf;
// First Part
// Name: vec(byte)
// vec(byte): size:u32, bytes
auto EncodedSize = EncodeU32(Ramdom.... |
I am trying to get the value from the from and and pass it to the API and output the result to the DOM. The code works fine but I am 1000% sure there is a better way to write THIS. Thanks for the help and I am new so trying to learn.
JS CODE
const textInput = document.querySelector(`#search__box`);
const btn = docume... |
How can I refactor the calculation() function I have used react class-based component for example extracting to separate individual function such as: addition() {return this.a + this.b;} subtraction() {return this.a - this.b;}
export default class Calculation {
constructor(expression) {
this.expression = ex... |
I devised a tiny pseudo-random engine and I wondered if it would be considered decent or even good.
It is based on a SHA256 implementation and uses a single 32-bytes state variable.
On seeding, the seed is hashed and that's the initial state of the engine. Then, for each new pseudo-random number, the state is hashed, i... |
I am looking for as much criticism as possible. Specifically I am trying to institute BEST PRACTICES for OOP and game design. Enjoy!
Github hangman repository
Each Class is in a separate file and imported.
BASIC LETTERS CLASS
from enum import Enum
class Letters(Enum):
a = ('', 'A')
b = ('', 'B')
c = ('',... |
Intro
I want to visit the value held by a class, which could be of multiple types. This class is very similar to a std::any, so I will be using this in this question.
I wanted to create a reusable solution that accesses the value efficiently (without recursion, or unnecessary calls), that worked similarly to how std::v... |
I've written a lot of (await SomeTask).AsList(); in my project, and it's kind of annoying to keep wrapping it.
To fix this I've written a little extension method on Task<IEnumerable<T>> to be able to do this for me.
The code is like this:
/// <summary>
/// Awaits the Task and returns the result as Task as List<T>.
/// ... |
Is this code well written? I'm not doing much, just rendering my battery status for my status bar but the code seems pretty long. I am new to Bash and Linux, so I thought this code could be improved somewhere.
#!/bin/bash
# Send a notification if battery is low, change status in info file accordingly
notify-low () {
... |
I would love to know your opinion about this algorithm that we wrote in class. I was thinking about how I can optimize it (in terms of size of code/complexity) without using library functions (besides <iostream> for reading and writing).
Assignment (translated):
Gregorian calendar rule about leap years was introduced... |
I've written a code reading csv file using fold expressions.
The only thing that should be defined is columns types and file name:
template <typename ...T, std::size_t... Is>
void parseLineToTuple(std::tuple<T...>& empty, const std::string& line, std::index_sequence<Is...>)
{
std::stringstream ss(line);
(ss >> ... |
I wrote a terrible function to map E.161 keys to letter strings.
I think the logic could be simplified using a recursive function; however I have never been good at recursive methods. Any suggestions are welcomed.
My Code:
#LINQPad optimize+
void Main()
{
var summary = BenchmarkRunner.Run<MyClass>();
summary.Du... |
Im wondering if there is a better way to write these expressions in Angular 13, They dont fit most of my more senior compatriots code, And i'd like to not add messy conditionals if not needed. They seem long winded as if I could handle this with far less characers.
if(this.gkhead.height > 1000){
th... |
I have a Python script that given some configuration, generates a random CSV file that can be used for testing purposes.
I want to know if it adheres to the best Python and coding practices. It works for cases where I need upwards of 10K+ rows fast enough for my requirements, so I am not too worried about performance a... |
The problem
The partition function for the quantum harmonic oscillator can be written in the path integral formulation as
$$Z\propto\int Dx(\tau)\exp\left(-\frac{S_E}{\hbar}\right)=\int Dx(\tau)\exp\left(-\frac{\int_0^{\beta \hbar}d\tau\left(\frac{1}{2}m\dot x^2(\tau)+\frac{1}{2}m\omega^2 x^2(\tau)\right)}{\hbar}\right... |
Coming from a Javascript background, and just now getting into c++. Want to know if im doing the builder pattern correctly in C++, and also what could improve on ?
PongObject.cpp
using namespace std;
class PongObject{
private:
int objectHeight;
int objectWidth;
int offset;
int object... |
I forgot the password to my pdf. I remembered a few characters, so I made a simple password-cracker program in Python. Is the document lost now given the number of combinations? Out of curiosity, how could I speed up this program as much as possible?
from pikepdf import open
from itertools import product
from math imp... |
The elevator system has the following functions:
There is one building, and the number of elevators can be set arbitrarily.
Requests can be sent from outside the elevators, in this case the request will have its original floor, and also the direction (going up or down). Requests of this kind are first sent to a "centr... |
While running unit tests (most of them integration tests) with Python I create some directories. They need to be deleted after the test or when the test fails. The execution of the cleanup code need to be guaranteed.
A fake or virtual filesystem (e.g. pyfakefs) or isn't a solution my situation because my unit tests ca... |
I've been self-studying HTML/CSS/JS. I read about Wa-tor. It's a population dynamics simulation which simulates fish and sharks breeding and predating. This seemed cool so I decided to implement it. I don't know much about javascript, my background is mostly in python and R.
Here's my implementation. Just hit Play... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.