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
24
votes
7answers
5k views

Python program to calculate GCD

...
15
votes
2answers
220 views

Re-implementation of `std::tuple` for MCUs

Background I'm writing code for an 8-bit MCU with very limited RAM (1KiB) and program flash space (64KiB). I have a C++14 capable compiler with no standard library implementation available. This is a ...
4
votes
1answer
376 views

Stack implementation with singly linked list

The following is my implementation of a stack using a linked list. ...
1
vote
1answer
59 views

Algorithmic complexity of this algorithm to find all ordered permutations of length X

I have written a recursive function to generate the list of all ordered permutations of length X for a list of chars. For instance: ['a', 'b', 'c', 'd'] with X=2 will give [['a', 'a'], ['a', 'b'], ['...
6
votes
5answers
3k views

String to double without std::stod

I encountered a pesky error in Code::Blocks: the conversions functions (stod, stof, stoi, ......
2
votes
0answers
475 views

Iterator for custom List class

I have extended a custom list class I have been working on with a Iterator class. I have not used std::iterator as a base class as it will be deprecated in C++17. ...
2
votes
3answers
504 views

A Stack Template

Why you're here: Today I bring you a simple Stack Machine and a Lot of questions. I am trying to gain a little bit more understanding of pointers, memory management and templates and thought a Stack ...
8
votes
3answers
3k views

Convert binary string to decimal number

I'm finishing the book C Primer Plus by Stephen Prata and I wrote as a part of the homework program to convert binary string to decimal number: ...
5
votes
4answers
142 views

Yet another doubly linked list (follow-up)

I've integrated the feedback from my previous question "Yet another doubly linked list". In addition to that the list now uses the copy and swap idiom. It also has a very simple iterator to enable it ...
6
votes
2answers
523 views

Custom variadic min/max/sum functions

I have decided to write my own min max sum functions. I really don't like the ones provided ...
11
votes
1answer
675 views

std::string implementation attempt

The following is my attempt at a string class that behaves like std::string. Any feedback would be appreciated. my_string.h ...
3
votes
2answers
118 views

List implementation

Appreciate your thoughts and feedback on my simple list implementation. I have the code on github with list and some googletests here (not sure why github changes the spacing to be so big) Some ...
4
votes
1answer
88 views

Yet another doubly linked list

This is a working but very simple doubly linked list. I wrote it to get more familiar with certain language concepts and because I've never made one in C++. (For convenience reasons this is not split ...
4
votes
1answer
2k views

Moving objects on a grid in C++

I have a code that works but is very badly written. The main is very verbose, it is just to test the class. I want to make objects move on a chessboard (a coordinate grid). I've defined these object ...
5
votes
1answer
78 views

A minimal wc for stdin

This is a minimal reimplemtation of wc. It supports only stdin at the moment and no command line arguments, that's for a later version. This is my first complete ...
4
votes
1answer
135 views

Button click logic with SFML

I wrote some functionality that works as intended in order to create functional clickable rectangles. I inherit from RectangleShape in SFML and I have several objects (not just buttons) that inherit ...
5
votes
3answers
365 views

Self-made string class

Since I've been working with C strings these days, I decided to make a string class from the ground-up just to see how it would go. I wrote all labels in Spanish (my mother language) just for the sake ...
5
votes
2answers
142 views

Queue Implementation in C++ [closed]

When reviewing my code, please consider these questions too: Any way to avoid using new/delete? Or are data structures like that normally and can't really use smart pointers? I was thinking of using ...
5
votes
1answer
189 views

Binary Search Tree C++

Appreciate your thoughts and feedback... BST.h ...
3
votes
0answers
67 views

Huffman encoding in Rust

An implementation of Huffman encoding / decoding as a learning exercise. I'm still new to Rust, so any tips about making things more natural for the language are appreciated. ...
2
votes
1answer
317 views

operations with complex numbers in C++

...
11
votes
5answers
4k views

Stopwatch class

I am learning C# and I have an exercise: Design a class called Stopwatch. The job of this class is to simulate a stopwatch. It should provide two methods: Start and Stop. We call the start ...
14
votes
3answers
1k views

Stack Implementation in C++ with Exceptions

Appreciate your thoughts and feedback... Stack.h ...
0
votes
2answers
112 views

C++ Stack implementation with linked-list

It's proving difficult to find implementations of a Stack with linked list and Im trying to figure out if my implementation is correct/not missing anything obvious. ...
1
vote
0answers
218 views

Permutation of a given set

A simple aspect of brute forcing certain problems is that you may have to do a large numbers of tasks in large numbers of possible orders, as such an algorithm for calculating all these possible ...
1
vote
2answers
515 views

Simple String class with operators

Any input is appreciated! And can I get some advice on how to properly delete the dynamically allocated memory with the destructor? My professor said we have to delete each individual element of an ...
10
votes
2answers
4k views

Yet another implementation of malloc() in C

I'm really curious to know someone else's opinion on this implementation. Specifically, I would be interested to know the way you would have implemented it. Here the list of issues I've found with in ...
4
votes
3answers
235 views

Find substrings in string

I'm self-learning C now, and I want to find out if my code is good and clean or kinda messy. For this exercise, the program tells if the text which was inserted has the keyword "asd", without using ...
5
votes
1answer
1k views

C++ RSA Implementation

A while ago I wrote an implementation of RSA with C++, that takes in a simple string,encrypts and then decrypts it. It's pretty much the only substantial thing I have written in C++ and while it works ...
3
votes
1answer
322 views

C# basic dictionary (hash) implementation

I have implemented a very basic hash data structure with basic set/retrieve methods. A good example of use of this implementation would be a phone-book. I have used as underneath storage structure an ...
1
vote
1answer
64 views

Object formatter using reflection

I am making an object formatter for use when debugging. Formatted class: ...
4
votes
1answer
175 views

Two-way data binding

Why reinvent the wheel? I personally like to implement all of my JS from scratch, I try to stay away from using the likes of jQuery or any external sources/libraries/frameworks as much as possible. ...
13
votes
1answer
185 views

Logging library

Due to several limitations of the standard library's logging module, I wrote my own. Below are the most important parts. You can find the whole library here. Any feedback is welcome. ...
7
votes
2answers
2k views

Echo implemented in Java

I implemented a simple version of echo(1) command utility. The program works as described in the man page: it writes to the standard output all command line arguments, separated by a whitespace and ...
28
votes
5answers
4k views

C++ Vector Clone

I'm learning C++, so I decided to make a simpler clone of std::vector. Concerns: I have seen people defining methods outside of the class, and only prototyping ...
10
votes
1answer
1k views

Merge n sorted iterators

Over the weekend I was curious about efficiently merging multiple sorted iterators together, and for them to be in sorted order. This is quite like a challenge on HackerRank: You’re given the ...
1
vote
1answer
77 views

Fortune of Unix V7 implemented in Java

I'm learning Java recently, this is one of my first program written in this language. I reimplemented a basic version of Fortune. This version prints to the standard output a randomly chosen line ...
4
votes
2answers
374 views

Custom maximumBy and minimumBy in Haskell

Going through the magnificent Haskell Programming from first principles, I'm currently reimplementing functions from standard libraries such as maximumBy and ...
2
votes
1answer
297 views

Optimisation suggestions for Min Heap

Can someone please optimisations for my implementation of min heap.Its performance is poor compared to the heapq module in python. My use case for the MinHeap class is 'N' insertions and extractions ...
2
votes
1answer
385 views

Home-grown encryption/decryption function

I know what you are thinking, it's never a good idea to roll your own encryption functions, but I'm doing this for fun and self-learning. I created a function that allows you to send a string as a ...
2
votes
3answers
106 views

Quick sort with a predicate

I want to pass a predicate into quick sort. The issue I'm running into is that the predicate must have two arguments, the pivot and the element of the list's tail. As far as I know though, predicates ...
0
votes
1answer
1k views

Generate a set of combinations

For one of my personal projects, I needed an algorithm to generate a set of combinations. I've finally successfully written one. The problem is that this algorithm uses two recursive calls to ...
2
votes
1answer
257 views

StopWatch for users C#

I have tried to create a stopwatch and I have done but I don't know how to improve it, and I want the user control the stopwatch whether it (Start) or (Stop), I'll be thankful if you tell me what I ...
2
votes
1answer
57 views

Stack implementation in python using jupyter

This is my first program in Python: a stack implementation. ...
6
votes
2answers
139 views

Permutations II from leetcode solution

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [[1,1,2], [1,2,1], [2,1,1]] ...
5
votes
2answers
1k views

Recursive sorting algorithm

I wrote a recursive sorting algorithm and was wondering what would be the run time complexity of this. The bulk of the work is done in the push_up function, which I ...
10
votes
2answers
2k views

Heap allocated std::array

I have created a heap allocated equivalent of std::array simply because I needed a lightweight fixed-size container that isn't known at compile time. Neither ...
2
votes
1answer
40 views

C - non-recursive mergesort on lists

Continuing my foray into classic structures and algorithms, I've tried to implement merge sort for doubly-linked lists. From my (limited) testing it seems the thing I've concocted works, but several ...
6
votes
2answers
100 views

is_subset Python implementation

I wanted to ask for a code review for my implementation of Set: ...
6
votes
0answers
289 views

C - fully threaded binary search trees

For learning purposes, I've decided to implement several classic data structures, starting with binary search trees. The entire code can be seen here, in a frozen branch ...