All Questions
75,873
questions
0
votes
0
answers
2
views
I wrote a simple time measurement library in C++
welcome everybody
I wrote a simple code to measure time easily
Features
Easy include and just call timeit()
Fast It just calculates the average time in the loop
...
-1
votes
0
answers
5
views
unexpected indent error in while loop ( in python) [closed]
hi I am writing a code to integrate schrodinger equation using Numerov method, how ever in one code block I am having "IndentationError" which says 'unexpected indent'.
here is my code below,...
0
votes
0
answers
9
views
LeetCode - LRU Cache by rodde
I have solved this LeetCode problem. Depending (perhaps) on the server load, I once scored the following performance figures:
My code follows:
...
2
votes
1
answer
7
views
C generic dynamic array (using preprocessor)
I wrote a generic dynamic array using the preprocessor. My use case for it is a compiler I'm writing that uses dynamic arrays a lot, and my current void pointer implementation is becoming a bit hard ...
2
votes
1
answer
14
views
the mini js tool library
hello everyone i am a newbie js "developer" and for practice i created a super mini (8 methods) javascript tool library. I need you to give me feedback "should I keep expanding my ...
1
vote
0
answers
19
views
Simple diff utility in Java using OOP
(Previous and initial iteration lives here.)
Now I was able to spare some lines by putting diff related state in an object. Also, I relied on Files.readAllLines, as ...
0
votes
0
answers
13
views
Singleton Design pattern: what is the best implementation
I can write the 2 following implementations but was wondering what is the best implementation: the first one require class methods and class variables (common to the instances which are the same).
<...
0
votes
1
answer
7
views
Improving multiple FirstOrDefault statements on same collection
I'm having multiple FirstOrDefault() statements, in this case 2, on a collection.
...
2
votes
1
answer
10
views
TFunction: std::function replacement for event system
I've been trying to implement delegate for my event system. I thought that maybe std::function can do the trick for me, but it turned out to be not comparable, so what i have end up doing is this, std:...
-1
votes
0
answers
11
views
Please correct any misunderstandings ive made when commenting what this code does [closed]
Hi im studing zed shaws learn python the hardway, he says i must go and read other peoples code and comment what i think it does
please can someone review it for me and tell me if i've misunderstood ...
2
votes
1
answer
24
views
Find perfect squares within a given range
I managed to make this work without breaking the program if you enter some weird numbers in the range. The thing is I know this could have been done simpler and smarter. I can't really see how right ...
1
vote
0
answers
44
views
C++: STL-like AVL Tree (+ benchmark vs. my red-black tree and std::set)
AVL trees and red-black trees are most famous balanced binary search trees.
I've always wondered "Why do all major C++ standard library implementations use red-black trees as their ordered ...
0
votes
1
answer
17
views
An algorithm that minimizes the number of ingredients necessary
I am working on a code that will minimize the number of ingredients necessary to make some dishes.
Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. ...
1
vote
0
answers
26
views
Integration loop over multiple doping and temperature levels
I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out ...
1
vote
0
answers
17
views
Python - dictionaries and making a list of student enrollments
I'm new at Python and I have to make a list of student enrollments and use dictionaries within a class.
I want to manage a list of exam enrollments. To do this, it is necessary to create the ...
1
vote
0
answers
20
views
Maze generator in C (part 2)
Maze generator in C. This is part 2 of this
I changed everything I was told I should in the part 1 of the review.
I also added functionality to be able to step through the generation of the maze, or ...
0
votes
0
answers
14
views
An OpenGL backend for displaying a framebuffer of an emulator
Motivation
I'm making an emulator. It has its own software framebuffer of size 320x240. Each frame is prepared internally from the emulator, and I just need a way to display it on a window, scaled to ...
1
vote
0
answers
10
views
Recursive path drawing in Latex
I have some diagrams I'm drawing using tikz and I'd like to make a macro to draw them for me.
I will describe it fully but here are some examples so you can follow along:
The diagram has a number of ...
0
votes
1
answer
15
views
Treat a list by generating a dataframe and sending the data to function via multiprocessing
To collect the list with the data from an API, I need to do these steps:
...
5
votes
2
answers
520
views
Simple diff utility in Java
(See the next and second iteration here.)
I have this toy implementation of the diff utility in Java:
...
2
votes
1
answer
21
views
A simple logging library in C
I've created a simple logging library in C which I can use in my other projects. I wanted to get started in software development using the C language, and this is my first attempt at writing something ...
0
votes
0
answers
12
views
Perform data cleansing on objects that pass through a data pipeline
I have a data pipeline where I need to perform data cleansing on objects that pass through the pipeline. As a simplified MRE, the code below creates an example object and then simulates a data ...
2
votes
1
answer
33
views
Download and print a CSV report based on user input
I'm learning Java and I did one exercise that consists in reading the input of the user (name of the network and date of the report) and return the csv that was inputed by the user. I know that the ...
4
votes
1
answer
160
views
Converts image from one type to another
This script first looks through a specified folder path for image files that have a given extension and removes any periods that might be in those file names. It also adds those sanitized file names ...
-1
votes
0
answers
21
views
Perfect forwarding Constructor for class with 2 strings using c++20 concepts [closed]
CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++" did this with std::enable_if at the end of the talk (hopefully the link will remain ...
1
vote
0
answers
14
views
Database Repository Class Using the Decorator Pattern
I have a base repository class that's using AWS DynamoDB,
and I have also implemented a class named StocksRepository
I'm wondering if I should create a StocksRepositoryWithLogs and
...
3
votes
1
answer
43
views
Fast way to compute a^d mod n
For a Miller-Rabin primality test I need a fast way to compute a^d mod n.
Where a is one of 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...
0
votes
2
answers
24
views
Decrement from an array of integers equally for all elements > 0
There are x distribution centers each with y number of products. Each day only an equal amount from all x distribution centers with remaining product can be shipped. Calculate how many days it would ...
3
votes
1
answer
271
views
Maze generator in C
Iterative dfs Maze generation program in C.
Details about the algorithm:
Example run of the program:
In my implementation:
Each cell has:
4 neighbors [left, right, top, bottom]
2 walls [right, top]
...
0
votes
1
answer
10
views
How to speed up truncating text to specific word count in nim?
I have a web application, as part of it I regularly have to send out "overviews" of records in a database, which contain shortened excerpts of a description-text of that record.
What the ...
1
vote
1
answer
39
views
Is there a better way to traverse a list of tree nodes efficiently
I am wondering if there is a better way to traverse a list of trees.
Here is my current algorithm:
Collect the parent IDs in a Map
Traverse all the groups and find ones where their ID is not in the ...
2
votes
2
answers
43
views
Internet Protocol Version 4 Datagram - Checksum Calculator
I could not find an implementation of the IPv4 header checksum calculation. So, I decided to made one as defined in RFC 791.
I made use of the "newer" ...
2
votes
1
answer
32
views
Find the column number in a spreadsheet according to the letter that identifies it
Google Sheets maintains an identity for each column that follows this pattern:
col 1 = A
col 26 = Z
col 27 = AA
col 52 = AZ
To know the column number according to ...
0
votes
1
answer
25
views
Google App Script Automation for User Onboarding
Background
I am a relatively new developer(> 2 years coding) working as an intern for a smaller company, as part of a now 4 person team. We had two other team members, one our system admin and the ...
1
vote
1
answer
41
views
JS function to check if a date is in the correct format
I wrote the following JS function to check if a date comes in the right format and can be used further down in the application
...
0
votes
0
answers
13
views
first React project - Lights Out game
I am working my way through a React tutorial on Scrimba (I am not finished yet). I got to a certain part that inspired me to try a project on my own. I made a game of Lights Out. If you've never heard ...
5
votes
1
answer
160
views
Evaluating math terms as nested lambdas instead of expression tree
I need to store some math terms. Originally I would use a tree to do it, especially if parsing strings was involved. However, since the expressions are built within the code and need not be parsed, I ...
1
vote
2
answers
40
views
How to implement a daily streak counter in JavaScript?
I want to implement this in a SQL database schema, but am doing it in JavaScript first to make sure I have the logic right. Basically, I would like to track "actions" a user performs. If ...
1
vote
1
answer
67
views
A C++ Job Manager Class (Rev 1)
This is a revised version of the JobManager class originally posted here. The revisions made were centered around:
Encapsulating the ...
0
votes
0
answers
42
views
Is the given code optimized ? Can it be optimized? [closed]
I have a dashboard where I have to show the
Charts and graphs for weekly sales(7 days before including today) , monthly sales(12 months before including this month) and profit/loss got in 7 days with ...
0
votes
0
answers
10
views
Unit test for a React click-counting component
Take this basic component using state:
...
0
votes
0
answers
41
views
Best way validate object in c# with "Manager" class [closed]
In my project I have an class named Precatorio
...
1
vote
2
answers
40
views
Check if a new movie session can be inserted
I have this function in my code, this way I validate if a new movie session can be inserted, it works, but I wanted to find a better way to do it.
...
1
vote
1
answer
45
views
Is this PDO query okay to use in PHP OOP?
Im new in PHP OOP so if anything is wrong I apologize.
If I want to do a simple SQL query, do you think this code is good? Is it safe to use? Or am i doing something wrong?
...
1
vote
0
answers
32
views
Program for monitoring file in Combined Log Format
After encountering a suggestion that monitoring a log file for a webserver could allow for the implementation of automatically analyzing and handling of certain events (that might require altering ...
1
vote
2
answers
27
views
Function that get 3 word for strings, than combine them to 1 string and finally print the string in reverse
I'm learning C and I got a task to make 3 function.
The first get 3 addresses of string, get 3 words from the user, and enter into the addresses.
The second get the 3 addresses of string and combine ...
2
votes
1
answer
63
views
Commented Parser Combinators in Lisp-style C
I've attempted to remedy the issues outlined in the answer to my previous question. I've added several hundred blank lines to better illustrate the grouping of functions and generally make things look ...
0
votes
1
answer
35
views
Common interface for fixed-length and variable-length lists in C#
I am working on library project in which I am reading and writing binary files that have own file format structure. In that structure there are variable-length and fixed-length elements. My approach ...
1
vote
0
answers
57
views
Smallest interval whose sum exceeds a threshold
In a non-negative 1D array x, we wish to find the shortest slice such that x[start:end] > threshold, with constraint that <...
1
vote
0
answers
16
views
Nodejs - Javascript buffer that takes in uint64, enum and string data as input
I am writing a nodejs program that adds some data into a buffer, before it is streamed. The data types are listed in the comments of the code, and there are fixed places in the buffer that these data-...