All Questions
77,242
questions
2
votes
2
answers
165
views
Design decisions for an efficient OrderBook
I am designing code for OrderBook based in C++, based on STL library. Note that there is a related question here, however it is more simple - it does not support deletion of orders, and I intend to ...
2
votes
2
answers
151
views
Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values
Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
1
vote
0
answers
60
views
Buddy - Algorithm in Rust
I wrote my first code in Rust and decided to recall the buddy algorithm, which I suggested at work for our embedded software.
I hope you can give me some advise on things like:
How to make it safe (...
3
votes
2
answers
159
views
String partial implementation using a vector
I saw few similar solutions, but they all relied on C-style arrays and str utils, so I thought I would write a higher level C++ only implementation with a vector as an exercise. I have not implemented ...
6
votes
4
answers
965
views
Filter: BMP Image Filtering Tool
Filter is a C program that allows you to apply filters to BMP images.
Usage:
Usage: filter [OPTIONS] <infile> <outfile>
Review Goals:
General coding ...
0
votes
0
answers
16
views
Login panel .feature (gherkin) file
I think many days ago, I randomly got introduced to cucumber developement, And it seemed like a conventional and interesting principle of software development.
At this very time, I'm concentrating on ...
1
vote
2
answers
63
views
Script to prevent nested root shells (POSIX)
Script to prevent nested root shells shall do exactly as said, plus some niceties like an error message when someone runs it with some argument/option.
...
1
vote
1
answer
84
views
Code that performs 2500 simulations by running a regression after randomly assigning 10 friends to each observation in a data took 20 days to run
I am running the following code to conduct a simulation. I have a dataset of around 100K observations. The simulation does the following:
It randomly assign 10 "friends" to each observation
...
1
vote
0
answers
79
views
Electro-thermal simulation
I'm working on an electro-thermal simulation with variable parameters.
Model require the calculation of all the electrical and thermal quantities at each time step, between a starting and ending time. ...
1
vote
1
answer
53
views
Gracefully shutdown http.Server{}
Good day, everyone!
I want to learn the proper way to gracefully shutdown a http.Server{}. Some answers I found would not handle ...
0
votes
0
answers
17
views
Object-based Radix Sort via an Iteratee
I recently finished implementing a radix sort for objects where either one of the keys is numeric, or can be expressed numerically via an iteratee.
...
4
votes
0
answers
123
views
Find the longest "common sequence" in two lists
In short, the algorithm must find the longest sequence that joins together common sequences from two lists (a more formal specification is given in the code's header).
The lists are assumed to contain ...
1
vote
0
answers
45
views
Is this how you do Spring Cloud Gateway?
I'm new to Spring's reactive Gateway. Here's the code that other collaborator and I wrote (the enum is one of my ideas):
...
1
vote
1
answer
180
views
Python3 currency abstract class (without the permission to be instantiated directly)
I'm a newbie python developer who accidentally studied the concept of
Abstract classes
and I found it pretty much helpful to implement due to the SOLID principles.
At the very moment of testing and ...
2
votes
2
answers
137
views
Thread safe accessing memory cache using semaphore
I have a Web API and for some requests we are sending requests to a third party API that requires request authentication. It's a simple bearer token, which I'd like to reuse across requests, because ...
2
votes
0
answers
120
views
GUI Tic-Tac-Toe game with AI, part 3: control and logic
This is the last part of the series of posts about my GUI Tic Tac Toe game, the previous two question are GUI Tic-Tac-Toe game with six AI players - part 1: the UI and GUI Tic-Tac-Toe game with six AI ...
3
votes
1
answer
71
views
Logging activity traces with custom APIs
I've got this idea (based on experience) that logging plain messages isn't just enough to monitor an application so I built an abstraction layer on top of the built-in ...
4
votes
2
answers
2k
views
Linked list and array list performance comparison in C
After watching Stroustrup's presentation on performance comparison between vectors and linked lists (https://youtu.be/YQs6IC-vgmo?si=9r5wXqnwkmN29xqn), I've decided it would be a good problem to get a ...
2
votes
0
answers
52
views
GUI Tic-Tac-Toe game with six AI players - part 2: the styling
This question is part of a series of posts about my massive Tic Tac Toe game with AI players, the previous question is: GUI Tic-Tac-Toe game with six AI players - part 1: the UI. This question ...
0
votes
1
answer
22
views
MVC Pattern - Need to include services file or not?
I am refactoring an old project, made in Nodejs with Express, applying the MVC pattern, today it is a fairly simple project: handling of the FCM and Remote Config tools from Firebase.
Would it be ...
5
votes
0
answers
220
views
GUI Tic-Tac-Toe game with six AI players - part 1: the UI
This is a huge project that I have worked on for the past few months, it contains 16 scripts, one of the scripts is used to analyze the other scripts. There are 111004 characters in all the script ...
1
vote
1
answer
74
views
An Updated recursive_reduce_string Template Function Implementation in C++
This is a follow-up question for A recursive_reduce Template Function with Unwrap Level Implementation in C++ and A recursive_reduce_string Template Function Implementation in C++. Considering the ...
3
votes
1
answer
59
views
Solve the snake cube puzzle
I wrote a solver for the snake cube puzzle. The solver can be easily adapted to arbitrary snakes.
Since the program takes only a few seconds to run, I didn't care to optimize for speed, instead I ...
2
votes
1
answer
39
views
Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?
We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
2
votes
1
answer
51
views
"2048" game in JavaFX
I wrote my first code in Java and I need constructive criticism and code review.
This is an implementation of the well-known "2048" sliding-blocks game.
...
5
votes
2
answers
314
views
Wordle50 - A Command-Line Word Game
"Wordle50" is a command-line-based adaptation of the popular Wordle daily word game. In this word-guessing game, players aim to decipher a randomly selected word with lengths varying from 5 ...
1
vote
1
answer
79
views
ROM memory in SystemVerilog and cocotb
The Verilog module describes a ROM memory. An initialization file is needed for the INIT_FILE parameter.
Below are Makefile, gtkwave.tcl to launch gtkwave, ...
1
vote
1
answer
85
views
Two versions of user-specified exception filters that log a different message on match
I'd like to show you two versions of my two functions that support my logging tools. Their purpose is to log a different message (here abort) when an error occured ...
0
votes
2
answers
82
views
Refactoring duplicated installation code
I have the following classes:
...
3
votes
1
answer
84
views
parsing json file with potential corrupted record and sorting by id to output first n lines - cleaner logic
messy json file is parsed and should output the N highest
record IDs & scores by score in descending order, highest score first.
the code works but i wonder if there is better readability, help me ...
3
votes
2
answers
111
views
The core of the assembler (the part of the assembler that actually converts mnemonics to opcodes) is hard to follow due to many if-branchings
For my Bachelor thesis, I made a PicoBlaze Assembler and Emulator in JavaScript. I've discussed it on many Internet forums, and quite a few people have complained that the core of my assembler is hard-...
2
votes
0
answers
29
views
Inputting a list of unique numbers in Scratch
So I am working on recreating a hidden minigame from PvZ Brutal Mode EX+/Unnamed Mod in Scratch for fun here. While I am making some considerable progress on it, I'm having trouble simplifying the ...
17
votes
5
answers
5k
views
malloc() and free() implementation
I'm looking for a code review of my custom memory allocation library (written for educational purposes), which includes malloc(), ...
4
votes
1
answer
1k
views
Determine if it is EU summer time in Java
I wanted to write a utility method for learning purposes to determine if a given date (year, month and day) falls within EU summer time or not, without using any of the Java library methods. Is here ...
2
votes
0
answers
55
views
Flutter Cubit: 2 Screens and Listview
I try to program a small app to track my cost spendings. As state management I use Cubit. As I am a flutter beginner, I wanted to verify if I implemented it correctly.
The UI consists of 2 screens: 1 ...
2
votes
1
answer
90
views
Create a String from the part of the vector
I want to create a String from the part of the vector.
My code:
...
2
votes
1
answer
106
views
PHP CSV Parser: Separation of concerns and SOLID principles
I implemented a CSV Parser with Separation of concerns and SOLID principles in mind.
Does that code match the principles?
Here a sample data (CSV):
...
5
votes
3
answers
768
views
Implementation of recursive `ls` utility
Recently I wrote my own implementation of a utility for recursive output of the directories' contents, kind of similar to the ls Linux utility with the ...
1
vote
0
answers
37
views
Trait to extend std::io::Read and std::io::Write
While implementing a proprietary networking protocol, I found myself instantiating buffers of different sizes all the time, reading from a std::io::Reader into it ...
2
votes
2
answers
58
views
French Republican Calendar Converter (Romme Rule)
This is a French Republican Calendar / Gregorian Calendar converter I've written; it returns an accurate date for all the dates I've tested (mostly dates in the present age, although it also lines up ...
3
votes
3
answers
192
views
Extracting records from a 2D List of strings
Recently I had an interview question about extracting records that matched certain criteria from a 2D List of strings. The premise was a CSV file was parsed into a ...
3
votes
1
answer
93
views
HTTP Request-Line parser
I am trying to write an HTTP/1.0 (RFC 1945) parser in C, so I started with the Request-Line. Ideally, the parser should return one of the three:
The request is valid.
The request is malformed, but ...
5
votes
1
answer
126
views
Recreated Snake in Rust
This is my first ever program in Rust. I've made it using only the book, the reference, and any documentation about the crates/functions I was using on the official rust lang website.
I have the ...
9
votes
3
answers
3k
views
Recreating Minesweeper
First, I have to say that this game lacks 5 features that I don't care:
Flags
Chording
Timer
Actual mouse movement
Good graphics
When starting the program, the player is meeted with a "Choose ...
1
vote
1
answer
79
views
mySQL adjacency list model : Always retrieve parent and children/siblings
I’m using mySQL to create and adjacency list model type of table. I have only one level, that is a parent with children, like this:
...
6
votes
1
answer
135
views
Exponentiation in Scratch
This was back when I was new to coding on Scratch (as in the case of coding projects entirely from scratch) around 7-8 months ago with my Cookie Clicker in Scratch project that I made pretty much ...
2
votes
1
answer
137
views
Recursively load all navigation properties of an entity
I have a table representing a class hierarchy using the TPH model.
Some of those sub classes have navigation properties (collections and/or references).
I'm trying to preload them as I know I will ...
1
vote
1
answer
134
views
Interview task model implementation(Event Source Java)
I've got a task to implement simple event source and i did: project
Events structure
...
4
votes
1
answer
329
views
Porting xoroshiro1024** from C to C#, and seeding it
I require a PRNG which:
Has repeatable results from a given state.
Is both seeded from and has a state containing a sufficiently large amount of data (somewhere in the region of 700 bits or more) to ...
3
votes
1
answer
155
views
Yet another CLI Hangman game
...with properly packaged/type-hinted code, automated testing, and no dependencies. Do note that this package requires Python 3.12 or later.
Only pyproject.toml and ...