Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

0
votes
0answers
6 views

Super-minimal implementation for inference only of fully a connected neural network in Python + Numpy

There are a lot of Neural Networks Frameworks available but in order to understand how things work internally reimplementing can be a good exercise In this case the goal is to develop a super-...
3
votes
1answer
34 views

Iterative version of a permutations algorithm

For learning purposes, I've written an iterative version of a recursive algorithm for generating the set of permutations for a given set of unique integers. Can I make any improvements to increase ...
9
votes
0answers
67 views

Implementation of std::any

Today, I decided to implement std::any using the cppreference page. I've never actually used std::any before and after seeing ...
5
votes
2answers
327 views

Compute all the permutations for a given vector of integers

The task is to compute all the permutations for a given vector of integers (but of course the specific integer type is not relevant for the solution) The strategy is based on recursion + iterations ...
2
votes
0answers
20 views

Removing duplicate field entries from sorted csv data

Given the following input (cat i.txt), I want to remove duplicate field entries in each of the first three columns and none of the others. ...
6
votes
1answer
94 views

C++17 <span> implementation

C++20 added the span library under the header <span>. As voluntary exercise (not homework!), I spent approximately 1.5 ...
2
votes
1answer
97 views

Game to shuffle and guess a word

I'm new to C++ and while learning, I wrote a simple program that asks for a word, shuffle sthe characters and then asks another person to find the original word, given the shuffled letters. I would ...
4
votes
1answer
48 views

Bar graph of Easter date distribution

Computing Easter for a given year is a classic computational problem. It is also one of the few cases when code seems to just have to live with magic numbers. Alternative to magic numbers: Decoding ...
2
votes
0answers
39 views

A C++17 `std::allocator` implementation

This is an implementation of C++17 std::allocator under the name my_std::allocator, with deprecated stuff omitted for simplicity....
8
votes
1answer
143 views

myUTF-8 small lib (validate UTF-8, guess language, count chars)

I'm new to C language and never got my self into the details of UTF-8, and after reading some articles about it, I wanted to try and play with UTF-8 with C language for both fun and practicing ...
3
votes
4answers
95 views

Linux wc command in C

I'm working on my implementaion of the linux wc command. I finally have something that is working properly (with no options yet) but i think it needs a lot of "cleaning". I mean, i highly disrespect ...
6
votes
2answers
748 views

Intersection of two sorted vectors in C++

Intersection of two sorted vectors in C++ - can this be written any better? ...
1
vote
0answers
47 views

`std::optional` under C++14 v1

This is a first version of an implementation of std::optional it is supposed to compile under C++14. The public interface of the class is complete, but there are ...
4
votes
2answers
109 views

Custom Hashset in Java

I have written this custom hashset and though it isn't completed yet, I would like to know if there is anything I am overlooking in terms of clean code conventions. My aim was also to apply generics ...
3
votes
1answer
57 views

Optimizing quicksort

I created simple quicksort algorithm using iterators. I'm happy with implementation but not with its speed. Profiler tells me that the slowest operation here is ...
2
votes
2answers
76 views

Generic Singly-Linked List implementation

I'm looking for some feedback regarding my implementation of a generic singly-linked list in C#. I'm also looking for some tips on how to implement other techniques such as using ...
5
votes
2answers
68 views

Python AES-CBC implementation using AES-ECB

I am looking for ways to make this code more "pythonic" and any issues with my implementation. This was designed to solve Crytopal's Challenge 10. This challenge requires recreating the AES-CBC cipher ...
3
votes
2answers
140 views

Implement Immutable Collection in C#

I would like to define some constant sequences (of bytes, specifically) in my C# library/API. Both length and content should not vary, preferably by any means (barring reflection). To this end, a <...
7
votes
0answers
92 views

Binary Search Tree Implementation in C++17

I am a hobbyist computer programmer trying to learn modern C++ (in this case C++17). I thought it might be an interesting challenge to write a Binary Search Tree similar to ...
6
votes
0answers
45 views

Extract principal components

First, I am aware that this can be done in sklearn - I'm intentionally trying to do it myself. I am trying to extract the eigenvectors from np.linalg.eig to form ...
9
votes
1answer
71 views

HashTable using C

Introduction This is my first attempt to mess with memory allocation using C and create something close to a python dictionary. Coming from a high level programming language like Python or Java, I am ...
2
votes
1answer
87 views

Simple pattern matching between two string inputs using Java (Google interview challenge)

The interview question is: Write a function isMatch (without using java.util.Regex) that takes two strings as arguments: ...
1
vote
2answers
73 views

Pretty print an object - JavaScript

I've written a function to prettify a json object, as if it were using JSON.stringify. I'm only focused on strings and other objects, nothing else. Is there a better way of doing this? perhaps using ...
5
votes
1answer
59 views

Define a range based on passed arguments

TL;DR I'm self teaching VBA, learning about functions and passing arguments from a subroutine into the function and want to know if my very basic function to define a range is optimal and follows ...
3
votes
0answers
57 views

Naive Implementation of A Least Recently Used (LRU) Cache Memoiser

I wrote code to (naively) perform lru memoisation. I tried to write it in a functional programming style, and so did not make use of any global variables. My Code ...
3
votes
1answer
80 views

C++ String class implementation

I wrote a simple String class implementation using unique_ptr and move semantics. Is my implementation good enough in terms of design and efficiency? Stringy.h <...
5
votes
3answers
97 views

My own getline function for reading strings from files

I am a newbie to C++ and I want to do some cool stuff with it. Here I have implemented my own getline function which reads from a file. so what do you think of this getline function? ...
0
votes
0answers
28 views

Mutex implementation using Windows APC

I just wrote this now and didn't test it much. This isn't a replacement for std::mutex, but for something like fun. I may develop it to make it shared across processes by storing the counters in a ...
7
votes
0answers
89 views

C++17 is_integral trait implementation

This is a C++17 is_integral trait implementation. Most implementations exhaust all integral types: bool ...
4
votes
3answers
327 views

LRU implementation in C++ using a LinkedList

Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition ...
1
vote
2answers
53 views
6
votes
3answers
140 views

C++14 std::array implementation

I invested an hour or so to reimplement the C++ header <array>. Most stuff is in the namespace my_std, but ...
0
votes
2answers
71 views

Convert number to X base

As an educational exercise, I would like to make this code more efficient, with fewer lines, without using other standard functions. The goal here is to convert a number to X base and display it, (...
4
votes
0answers
94 views

Quicksort template (for sorting corresponding arrays)

I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays! The really "metaprogrammy" way to do it would be to use ...
9
votes
1answer
456 views

Simple LinkedList

I guess this has been made a couple of times by now, but i wanted to take my chance on creating a simple generic linked list in c#. What do you think ? This is the main class. ...
6
votes
1answer
118 views

unique_ptr basic implementation for single objects

This is an implementation to simulate the basic functionality of unique_ptr. This doesn't provide features like custom deleter and ...
5
votes
2answers
111 views

C++ Maybe<T> implementation

In order to improve my understanding of C++ template meta-programming, SFINAE, references, and overall class design, I've tried to implement a Maybe<T> class ...
2
votes
1answer
59 views

Python implementation of Conway's chained arrow notation

A year ago, I implemented an evaluation algorithm for Conway's chained arrow notation in Python. I'd like to get a review on my code, especially about readability and if it is pythonic. I'd also like ...
9
votes
3answers
732 views

Simple re-implementation of std::vector

Here is a simple reimplementation of most of std::vector. I want to check if I implement it correctly but the standard libraries source code is not very readable ...
3
votes
0answers
89 views

C++ program that processes unique markup language similar to HTML

I have solved a task which takes input in a unique markup language. In this language each element consists of a starting and closing tag. Only starting tags can have attributes. Each attribute has a ...
4
votes
1answer
144 views

Sorting an array in C++

This started as a simple exercise in sorting an array. I wanted to make it a bit more complex which is why I made it a 2D array. I then noticed that each pass that checked and swapped values, it was ...
5
votes
8answers
320 views

List implementation in C

I tried to implement a Python-esque list in C. Having not really used C in anger, I'd like some pointers on style and error handling in particular. Header ...
2
votes
1answer
71 views

C++ template-based dimension-tagged type

I'm writing a small C++14 library for myself that allows me to decorate a type with dimensionality information, so that I can leverage the template/type system to avoid mistakes such as adding ...
4
votes
3answers
216 views

strlen and strcmp implementation in x86 FASM assembly

I wrote my own implementation of strlen and strcmp from C in x86 FASM and I would like to know is there anything that should be changed or improved. strlen needs string in eax and is returning length ...
6
votes
2answers
152 views

RSA c implementation

This is my first attempt to implement a crypto algorithm. I am using C and gmp to interact with big numbers. Here is my code; you can run it after having linked with the ...
1
vote
0answers
27 views

Custom Vector and Matrix classes in python for machine learning

I am creating a machine learning tool set from scratch in python. I have never done something of this kind and I don't usually use python but I thought it would be good to expand my horizons. I am ...
1
vote
1answer
65 views

Quicksort in C with unit testing framework

This is my quicksort There are many like it but This quicksort is mine. So, quicksort, in C, with a big framework to test it six ways from Sunday. Passed the tests nicely, but there may be warts, or ...
3
votes
2answers
283 views

Verify a subnet mask for validity in Python

I've written a small Python function to check whether a string is a valid IPv4 subnet mask. It works but maybe it's too convoluted and terse? Or maybe it could be improved / optimised / rewritten in ...
0
votes
1answer
83 views

Implementation of a Hash Map in C++

I created a templated Hash Map class in C++, which supports most of the basic C++ types (e.g. int, float, ...