Questions tagged [reinventing-the-wheel]

For when you know you are reinventing the wheel, but are doing it anyways. Questions with this tag involve code that is already fully implemented (such as from a library).

Filter by
Sorted by
Tagged with
10 votes
4 answers
2k views

Number to text in Python

I'm kind of new to programming and I would need a suggestion whether there is a better way to solve this exercise. I need to write a function dict_of_numbers() that ...
fraber's user avatar
  • 101
5 votes
1 answer
383 views

Simple malloc and free implementation

I am trying to implement a simple malloc and free. The buffer is a char array. Each chunk's address is calculated using the size of the previous chunk. ...
user3280530's user avatar
2 votes
1 answer
51 views

Shared_ptr Implementation with Derived class Awareness

Another shared_ptr implementation. My main idea was to write it in a way you could do: ...
KimGiacinto's user avatar
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 ...
KimGiacinto's user avatar
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 ...
Tobias Grothe's user avatar
0 votes
1 answer
172 views

WordPress Plugin for WebP/AVIF Image Conversion

I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance. The plugin has the following ...
KermitTheFrog's user avatar
8 votes
3 answers
2k views

C++ std::optional implementation

Took a shot at implementing a subset of std::optional functionality. A lot of core features are there but some things like converting constructors, etc are missing ...
jdav22's user avatar
  • 319
3 votes
2 answers
987 views

C++ std::any Implementation

Took a shot at implementing std::any. I think this should cover a majority of the functionality of the standard version, except there may be some missing auxiliary ...
jdav22's user avatar
  • 319
2 votes
2 answers
216 views

C++ std::shared_ptr implementation

Took a shot at implementing std::shared_ptr, with a thread-safe refcount and weak count. Didn't do weak_ptr, I'm doing this for ...
jdav22's user avatar
  • 319
4 votes
3 answers
315 views

C++ custom string class implementation

I recently had an interview where I was tasked with implementing a custom C++ string class without using the STL. The interviewer provided the function signatures and variable declarations, specifying ...
Jacob's user avatar
  • 111
4 votes
1 answer
105 views

C++ custom vector class implementation

I've developed a custom vector class in C++, complete with functionalities like assignment, push_back(), emplace_back(), pop_back(), clear(), and size(). I would greatly appreciate any feedback on ...
Jacob's user avatar
  • 111
1 vote
2 answers
75 views

2D Point subclass of complex builtin

I'm writing a pure-python geometry tool for technical drawings / computational geometry (not a solver, as a solver has to work with constraints). I've already mentioned a previous version on code ...
ToAskOrNotToAsk's user avatar
2 votes
1 answer
81 views

Non-recursive topological ordering, starting from given nodes, for Guava graphs

This method returns the topological ordering of a Guava graph starting from a given set of nodes. It's from my personal project github.com/jbduncan/guava-graph-utils, where I'm exploring utilities for ...
jbduncan's user avatar
  • 141
2 votes
2 answers
76 views

Binary search tree with Iterators

One more BST implementation with iterators added. Did not manage to find another implementation with iterators and it is my first attempt at implementing them so thought to check on your opinion: <...
acd's user avatar
  • 107
1 vote
1 answer
75 views

Implemented a basic dictionary in python using lists as linked list and murmur hash as a hash function

...
piepi's user avatar
  • 823
2 votes
1 answer
76 views

Yet another std::unique_ptr implementation

I know I haven't implemented many methods, and haven't specialized it for T[], but I just want to see if what I coded is good or bad. ...
jamesee's user avatar
  • 21
5 votes
2 answers
178 views

C++ UniquePtr Implementation

Took a shot at implementing std::unique_ptr. Code: ...
jdav22's user avatar
  • 319
8 votes
2 answers
256 views

C++ std::vector Implementation

Implementation of the vector class in C++ for learning purposes. Tried to implement interesting parts from the API shown on cppreference.com, but some elements like ...
jdav22's user avatar
  • 319
7 votes
2 answers
167 views

shared_ptr implementation code - first cut

I've written an implementation of shared_ptr. It doesn't support weak_ptr (yet) but below is the code. I'd appreciate any feedback, comments. ...
Greg's user avatar
  • 71
4 votes
1 answer
155 views

Set implementation

I believe reinventing the wheel is in fact a good learning exercise. How can I improve my Set implementation without just copying ...
Sergey's user avatar
  • 401
1 vote
1 answer
105 views

Implement the Swift pow(base, exp)-function yourself

Task: Implement a function, which accepts two integers and results the first number raised to the power of the second number. Both numbers have to be positive. Examples: The arguments 4 and 3 shall ...
michael.zech's user avatar
  • 4,232
3 votes
1 answer
102 views

std::list reimplementation for practice

I used cppreference list to implement this simplified std::list. The CXX_STANDARD is 11. My questions are the usual: Is the ...
Abner's user avatar
  • 39
4 votes
2 answers
550 views

Constexpr flat_multimap

About the Reasoning I wrote a flat_multimap because it was slightly more efficient to read/write from disk (contiguous memory block) and because it would keep the logarithmic efficiency from a tree (...
FreezePhoenix's user avatar
7 votes
3 answers
174 views

C++ String Class Reimplementation

I started learning C++ about a week ago and I was hoping somebody can critique my code. I decided to implement my own basic String class just for the sake of applying all that I've learned about ...
Janriz Libres's user avatar
6 votes
3 answers
233 views

Unit testing a Linked List implementation in C++

Recently I wanted to use the gtest library to unit test my program but for some reason, it's incredibly hard to make it work and configure (at least for me it was), ...
I_throw_but_dont_catch's user avatar
2 votes
0 answers
120 views

Minimal Chess Web GUI with Flask

Being a big chess fan, I finally started developing my own chess tool, however I'm already quite dissatisfied with where it's going... folder structure: ...
Mantas Kandratavičius's user avatar
2 votes
1 answer
316 views

Find all permutations of string using recursion

Background: I am somewhat new to programming and only two weeks into learning Python. Currently trying to improve my understanding of recursion, which has been a tough concept for me to implement. ...
b-mitch's user avatar
  • 21
8 votes
1 answer
173 views

Lightweight general-purpose graph library in C++

As a personal side project I started building a graph library in C++ (I know, very original). The code is open source, but for the purpose of this question I will provide the relevant details and the ...
Bobray's user avatar
  • 81
1 vote
3 answers
115 views

C++ getline implementation for custom stdlib

I'm writing my own "standard library". It relies on nothing but syscalls, so I've had to make my own implementations of everything, including getline (...
Fuzzy Muffin's user avatar
2 votes
2 answers
103 views

Python Logger Implementation

I have developed an implementation of a logger in Python. I know that Python already has a built-in logger, my goal with this is to get feedback and suggestions for improvement, particularly about ...
nabla-f's user avatar
  • 163
6 votes
3 answers
1k views

Implementation of a shared pointer constructors and destructor

I am writing my simple shared pointer. I am asking to review existing functions (understand that my implementations is not full, e.g now operator*) Review please ...
mascai's user avatar
  • 397
7 votes
1 answer
294 views

C++ mutex-like class using std::condition_variable

On a project I'm working on, I have a need for a mutual-exclusion primitive behaving like std::mutex or std::recursive_mutex, ...
Macmade's user avatar
  • 171
6 votes
2 answers
267 views

A selection sort implemented in Python

I'm not proficient at Python. My question is twofold: whether this selection sort algorithm implementation for number lists could be considered clean code (in the sense of being modular and ...
Piovezan's user avatar
  • 257
2 votes
1 answer
113 views

Comparator aware `flat_set` implementation

I am currently implementing a flat_map like container in C++, and had problems with the comparator used. Thus, I reduced it to the bare minimum which I will present here. (In particular, my code here ...
tommsch's user avatar
  • 243
3 votes
1 answer
150 views

Optimizing my sorting function

I created my own list sorting function with Python: ...
U13-Forward's user avatar
11 votes
5 answers
2k views

Portable Object-Oriented WC (Linux Utility word Count) C++ 20, Counts Lines, Words Bytes

This question Code lines counter prompted me to write my own line counting program. I program on both Windows and Linux and I know about the Linux utility wc. The command line and output format are ...
pacmaninbw's user avatar
  • 23.5k
1 vote
0 answers
140 views

Priority Queue implementation using a Heap [closed]

I'm working on a custom implementation of A-Star and so I had to also create a Priority Queue and so I had to create a Heap. I'm quite happy with my Heap but I'm a bit worried about my Priority Queue: ...
Caïn's user avatar
  • 111
2 votes
4 answers
109 views

Find the modal value of a sample of numbers

I am currently interested in implementing statistical measures. Other measures like mean, variance, and covariance are easy, but the mode feels harder than I thought. Is this good enough? Note: ...
soupless's user avatar
  • 185
2 votes
1 answer
105 views

Linked list in rust, Needed optimization

I've implemented constructor, push , pop, drop and some macro. I need to know if the drop implementation is correct and is drop is really necessary? Meanwhile I still didn't check about ...
Nithin Gowda's user avatar
1 vote
1 answer
64 views

Mapping various input values to a data accumulation class

This function takes inputs from multiple different controls on a form, and maps them to values in a data accumulation class. This code was written specifically to keep logic, data, and display ...
EvilPCDiva's user avatar
2 votes
1 answer
287 views

Generic insertion sort

I implemented a generic insertion sort routine that can sort an array of any type. It's similar to the qsort function from the standard library. My goal it to optimize the code for readability above ...
Panic's user avatar
  • 287
2 votes
1 answer
192 views

Reimplementing Alias method in C++

In the following I reimplement the Walker-Vose Alias method for sampling from nonuniform, discrete probability distributions. I am well aware that there is https://en.cppreference.com/w/cpp/numeric/...
mcocdawc's user avatar
  • 944
3 votes
2 answers
313 views

Add two numbers represented as digit strings

This algorithm adds two numbers digit by digit using their string representations. I am wondering what the time and space complexities of the following algorithm are. In particular, I am wondering ...
MadPhysicist's user avatar
0 votes
1 answer
79 views

Creating custom setTimout function using requestAnimationFrame loop

I created a function using requestAnimationFrame loop that works pretty much like the plain JS setTimeout function (except that ...
gaspar's user avatar
  • 153
1 vote
2 answers
174 views

Several container functions rewritten as an excercise

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 ...
Phil's user avatar
  • 11
2 votes
1 answer
350 views

C++ std::string implementation

Following is my simple implementation of the std string class. Please review my code and offer some advice. I want to figure out is there anything wrong with my code or is there anything I can improve ...
Jacob's user avatar
  • 111
1 vote
1 answer
72 views

General purpose 2D grid

I am developing (WIP) a mine sweeping game to get more familiar with Rust. I decided to represent the mine field as a 2D grid. While developing I realized that this grid can be outsourced as a general ...
Richard Neumann's user avatar
2 votes
1 answer
73 views

Quadratic equation solver using ABC and PQ formula

Getting my feet wet with Rust, I implemented a solver for quadratic equations. I implemented both, ABC and PQ formula solvers, to challenge myself with branch conditions. ...
Richard Neumann's user avatar
2 votes
1 answer
97 views

Derivative calculator simplifier using python

I am newbie in the field of programming, but I have tried to make relatively "huge" project. My "app" would derivate a mathematical expression, after that simplify the output ...
dobok's user avatar
  • 21
8 votes
1 answer
391 views

Improving the speed of an MD5 implementation from scratch in C++

I wrote an implementation of the MD5 hashing algorithm from scratch in C++, following the original RFC: https://www.ietf.org/rfc/rfc1321.txt . It works as expected, and the outputs match all the test ...
Prashant Sinha's user avatar

1
2 3 4 5
20