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
6
votes
0answers
290 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 ...
4
votes
1answer
609 views

Basic Implementation of Hash Table in Python

Basic impl of hash_table in python. Supports set, get, and delete. Uses open addressing with linear probing function. Any ideas would be greatly appreciated! Thanks! ...
9
votes
1answer
6k views

Self-contained SHA-256 implementation in C

I have been looking for a SHA-256 implementation in C with no dependencies (preferably self-contained in a single C-file) with a permissive license but found none to my liking. Since the Wikipedia ...
5
votes
1answer
114 views

iterative binary_search Python implementation

I did a Python implementation of binary search implementation iteratively. It passes all of the test and I was wondering if I can get any feedback. ...
3
votes
1answer
604 views

Python Hash Table and insertion

I'm attempting to implement a basic hash table in Python using linked lists. Any tips would be appreciated (including better hash functions). I intend this to handle collisions with separate chaining. ...
5
votes
3answers
1k views

Binary Search Tree BFS iteratively

I was given this coding question for a technical interview: Given a binary tree, implement a method to populate the list level_ordered_list with the data of the nodes traversed level-order, ...
3
votes
3answers
165 views

A “templated” doubly-linked list implementation in plain C

I've attempted to make something similar to C++ and D templated lists in plain C. In this gist there's the full code of the header file and test driver I'm using. I'll post some excerpts from the ...
0
votes
2answers
396 views

Python generate custom combinations of sub lists

I'm generating a custom combination of sub lists without using itertools. Here's what I've come up with: ...
2
votes
1answer
105 views

Python implementation for Set

I wanted to ask for a code review for my implementation of Set: ...
2
votes
1answer
103 views

DoublyLinkedList python implementation and unit testing

I wanted to ask for code review for DoublyLinkedList. Especially my insert, find, replace, <...
5
votes
1answer
900 views

Base conversion: decode and encode base to integer

I encountered this question as I am preparing for my code interview. I was implementing a base function that can decode and encode any bases from base 2 to base 36. I think my ...
9
votes
3answers
676 views

indexOf Boyer-Moore String Search algorithm

This is an implementation of Boyer-Moore string search algorithm index_of for a pattern in text. I was challenged to implement it by my friend. This Python ...
3
votes
2answers
80 views

Python implementation for contains pattern in text

This is an implementation of contains, which returns a boolean indicating whether a pattern occurs in text. I encountered this question while I was implementing ...
10
votes
2answers
225 views

Python implementation of find_all_indexes

I got asked this question before in an interview. For example, find_all_indexes('ababc', 'abc') returns 2. This Python function ...
0
votes
1answer
648 views

Python's str.isAlpha(), reimplemented without Unicode support

I've created an alphabet checker that is similar to str.isAlpha(). I know that python has its built-in function. str.isalpha()...
3
votes
1answer
41 views

Class to unit-test functions, with rudimentary support for testing multi-parameter functions

Recently I read about test-driven-design and decided to try to create a simple unit testing class to begin using this approach. I have not been programming in Python for very long so forgive my ...
5
votes
3answers
1k views

Fastest FIFO with macros for use embedded devices

UPDATE (a year later) Since this post the code has turned into a small library called fifofast and is hosted on github under the MIT License. This note is meant for anyone who stumbled across this ...
5
votes
3answers
116 views

Reimplementation of Python's deque

It has been a while since taking the class Algorithms and Data Structures, so the following module was written as an exercise for implementing Python's ...
3
votes
0answers
219 views

ECDH implementation in python (part 3)

After the first and second part, the primary feedback I got was to rename a lot of my variables as I used the same name for different local variables which is really confusing. I tried to hotfix that, ...
0
votes
1answer
141 views

ECDH implementation in python (part 2)

I worked a while on my code I posted here to make it more flexible and hopefully a little bit more secure. My goal is to implement a secure library for elliptic curve cryptography. ...
1
vote
1answer
166 views

Array Wrapper Class

I’ve wrote a small array wrapper class which mimics the built-in Collection for adding and retrieving items. Once the object is created, you set the array capacity and that would not change. ...
2
votes
3answers
9k views

Generate all permutations of a list in Python

This is my solution to the "Permutations" problem from Leetcode: Given a collection of distinct numbers, return all possible permutations. I know this is a common routine that can be done much ...
5
votes
0answers
3k views

Java AES-256 GCM file encryption

I wrote my first file encryption program, that encrypts a file with AES-256 GCM and stores IV and salt prepended to the file content, so it's likely that I did something worse than possible. I ...
2
votes
1answer
69 views

Mean of integers, ignoring the largest and smallest values

The code returns the mean of a list of integers, except ignoring the largest and smallest values in the list. If there are multiple copies of the smallest value, ignore just one copy, and likewise for ...
11
votes
2answers
3k views

Reimplementing Python's enum.auto() for compatibility

In Python >= 3.6 there is an enum.auto() function. The auto() function can be used like this: ...
1
vote
0answers
345 views

Shared_Ptr Implementation

I have tried to Implement Shared_Ptr and learned a lot while Implementing it. So guys please review my Implementation. Any Suggestions,Feed backs are highly appreciated. and Thanks in Advance. Asad. ...
4
votes
1answer
605 views

Unique_Ptr Implementation

I have Implemented Unique_Ptr with move semantics for the sake of Learning. Any suggestions, feed backs are highly appreciated. ...
8
votes
4answers
3k views

Generating Permutations in Python

To brush up my Python knowledge I an algorithm to generate permutations in lexicographic order. I ended up with the following code: ...
3
votes
1answer
265 views

HashMap in Javascript

I began working on a Javascript project, and the first fundamental building block is a data structure that mimics Java's java.util.HashMap, since Javascript ...
3
votes
1answer
408 views

C++ STD Thread Pool

I wanted to try implementing my own version of a C++ Thread Pool (I know there are lots of them..). I was hoping that someone could tell if I did it okay. Tasker.h: ...
4
votes
1answer
143 views

Implementation of an intrusive SmartPointer

Here is my implementation of SmartPointer. It is intrusive and tiny. How can I improve it? For example, constexpr, ...
2
votes
1answer
488 views

Check if a string ends with a given suffix, without using .endswith()

I figured out how to do this assignment, but now that I have, I'd like to know if there is a cleaner way to do it. Below is what was required of the assignment, below that is my working function that ...
12
votes
2answers
2k views

Implementation of memmove

Here is my implementation of memmove; where can I improve? ...
15
votes
2answers
1k views

ECDH implementation in python

I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: ...
4
votes
2answers
153 views

Develop custom Hash Map

I've got a task to implement custom hash map with only get, put, size functions without remove and implementing base Map interface in Java. I've made one but not sure if it is good one. Can You check ...
11
votes
3answers
7k views

Return characters in a string in alphabetical order

Problem Take a string and return all input characters in alphabetical order Assume that no numbers or punctuation will be used For the same character, uppercase characters should be returned ...
2
votes
3answers
381 views

Naive, bubble, insert and quick sort in C

I've created a program that shows the time needed to sort a random array of integers. An example is: ...
2
votes
2answers
73 views

Binary Search, using .remove

I'm aware that a function in the standard library exists. Please give me feedback regarding good coding conventions and standards. ...
4
votes
0answers
155 views

Character-based transitions (part of a lexer)

As part of my prep for the Code Rreview community-challenge (which looks like it will be Write your own programming language), I've been working on an LL(1) lexer generator in Rust. Yes, lexer ...
6
votes
3answers
11k views

Merge sort implementation with vectors

I'm new to algorithms. To be honest I am not really sure if my implementation is right. However, the output is sorted correctly in ascending order so perhaps it's correct. Please feel free to give ...
4
votes
1answer
220 views

Sorting algorithm, possibly a new one [closed]

I'm a beginner who has never seen a sorting algorithm's implementation and have decided to try make one on my own (can someone tell me if this has been already used?). The fact is I have never used ...
8
votes
1answer
2k views

Library, that finds the derivative of a function

I've written a small library, that provides a way to store mathematical expressions in a tree-like structure, and provides a method, that finds the first derivative of a function. I know, that there ...
7
votes
3answers
3k views

Custom std::shared_ptr<T> implementation

I'd like to get a few pointers about my code. I know that shared_ptr is up and running, and I'm reinventing the wheel but you can't say no to the school assignment. ...
6
votes
1answer
442 views

My lru_cache implementation

This code is intended to function exactly like functools.lru_cache. Is there anything I could improve in design, implementation, style, or any other area? (Python ...
24
votes
6answers
5k views

C++ string operators

I'm trying to practice my C++ on my own; At the moment I'm trying to implement the concept of operator overloading making my own string class/function. I think I handled this correctly; the code ...
2
votes
1answer
70 views

PHP 7.0 - 'INIController' - A set of classes for reading, parsing, and editing .ini files directly or in memory (Second version)

This is the second review of this particular project, after I've made changes based on feedback I received on my last post on code review, which you can take a look at here. Yes, I copy pasted some ...
3
votes
4answers
839 views

String class in C++

I was writing simple String class implementation (and it is quite ordinary), but I had found out that constructors, destructors and operator = are the most ...
1
vote
2answers
513 views

Re-implementing Javascript's String.prototype.indexOf

I had this idea of trying to re-implement the function String.prototype.indexOf in a way that could potentially be faster than the native function. With some ...
16
votes
4answers
2k views

String Queue implementation

Is the implementation clean enough & can be used in production? I tried to write clean & bug-free code. It looks good to me. I would appreciate any improvement suggestions. One question I ...
4
votes
1answer
4k views

My implementation for std::unique_ptr

I just finished learning about move semantics and realized that a nice practical example for this concept is unique_ptr (it cannot be copied, only moved). For ...