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
1
vote
1answer
40 views

"filter" function in Scheme

I know this is a bit elementary, but I am highly uncomfortable writing Scheme code, and I want to make sure that what I'm doing is good practice. I know mutation is frowned upon in Scheme. I have no ...
4
votes
1answer
50 views

Locale-independent float print function

The objective was to write a locale-independent function that prints floating-point numbers (i.e. one that always uses . as a decimal point regardless of the locale)...
2
votes
0answers
103 views

Improving constexpr invoke function C++17, alternative to std::invoke

I've learned that in C++17, std::invoke isn't constexpr. To make a constexpr version, I could copy the implementation provided here: https://en.cppreference.com/w/cpp/utility/functional/invoke , OR I ...
4
votes
1answer
99 views

Python: Matrix Manipulation module

I made a module called "matrix-py" in python to add, subtract, multiply, transpose matrices I want to know how to improve the code quality and if there's something wrong about my code here's ...
2
votes
2answers
125 views

My own function for copying memory in C

I have written a function that copies memory from one destination to another. I would like you to view my code and tell me if I have to fix something. That's the code: ...
2
votes
2answers
255 views

C++ overloading += operator in custom string class better implementation

I am trying to learn C++, so I started coding a custom string class (using only c-style strings) to get familiar with concepts like operator overloading etc. in the case we have a pointer attribute. I ...
6
votes
1answer
87 views

Writing a thread-safe ring queue in C++17

I tried implementing a thread-safe ring queue in C++. I'm totally new to move semantics and C++11/14/17 in general. ...
3
votes
1answer
77 views

Date program for xv6- improvement and testing

This is my first post on this forum. I have read the guidelines and will try to adhere to them, but I apologize if I miss something. The code I am posting is intended to duplicate the output of &...
1
vote
1answer
77 views

Check if two types are the same without template instantiations

Below is my attempt to check if two types are the same without template instantiations. ...
2
votes
1answer
104 views

Improving an itoa function

I wrote an itoa function yesterday, which based on feedback I am now working on improving. How does the below look? Are there any ways in which I can improve it? ...
2
votes
1answer
68 views

Pseudo-random number generator & password generator

I've started learning Rust and decided to implement something on my own from scratch. I've implemented a PRNG and I use it to generate random passwords. Project tree: ...
2
votes
1answer
41 views

Doing a string replace

How does the following look for doing a string replace in C? Is this approach more common than allocating memory within the function and returning a new string pointer, or is the bring-your-own-buffer ...
1
vote
1answer
56 views

A better implementation of the `execvp` call: the code implements `execvp`

I'm trying to implement execvp () using execv (). I don't know if the code is the best implementation. my code: ...
1
vote
1answer
87 views

String tokenizer

Objective: Create a function called wordsAndSpaces that splits a string on groups of spaces, preserving each group of space characters as a single token. Example: <...
8
votes
2answers
155 views

re-implementation of std::vector

I've implemented a simple vector-like structure. I would appreciate all criticism relevant to code. I have also published code under github. Here is the link to source code + unit test for most ...
1
vote
0answers
131 views

Binary to hex in ARM64 SIMD assembly

As an exercise in learning ARM64 assembly (aka AArch64), I wrote this function to convert 64-bit binary to hexadecimal with SIMD instructions. I'm most interested in feedback on the algorithm, ...
5
votes
1answer
69 views

Pipeviewer: A small "pv" Rewrite

If you ever had to pipe a large amount of data from some program foo into another program bar, you're probably familiar with the ...
3
votes
1answer
80 views

A byte endian swapper

There are both a simple byte endian (little and big) order swapper and its testbench. A data stream inputs to the module and is converted to the other endianness by computational logic. ...
1
vote
3answers
79 views

c - memcopy for embedded system

I just implemented my memcpy function without any previous lookup. ...
1
vote
1answer
79 views

A Tiny Image Tagger Implementation in C#

I am trying to implement a tiny image tagger with customized tag options in C#. The main window is as follows. The left block is a picture box MainPictureBox and ...
1
vote
1answer
80 views

initialize 2d array using 12 tone algorithm with Rust

a rust exercise in initalizing a 12x12 array based on the algorithm for twelve tone matrix described here: https://www.instructables.com/Create-a-Twelve-Tone-melody-with-a-Twelve-Tone-Mat/ i copy ...
2
votes
0answers
30 views

gpuIncreaseOne Function Implementation in CUDA

I am trying to perform the basic operations + with CUDA for GPU computation. The function vectorIncreaseOne is the instance for ...
2
votes
1answer
73 views

Pulse-width modulation module

Module for generating a PWM signal. The req_value_i input gets a duration value of the signal. Furthermore, the module can be stopped by deassertion of the enable_i input. ...
1
vote
1answer
145 views

Snake game in C++17 with SDL2

I implemented a simple snake clone in C++, using SDL2 for the graphics part. Gameplay-wise, its pretty much classic snake: The player is able to control the snake with "WASD", food gets ...
1
vote
1answer
100 views

Company database REPL program in Rust for Chapter 8 of The Book

Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the ...
7
votes
2answers
326 views

Idiomatic use of `Option` and `unwrap` in mean, median and mode Rust program for Chapter 8 of The Book

I've recently finished Chapter 8 of The Book and have started doing the exercises at the end of the chapter. This post pertains to the first exercise which involves writing a program to output the ...
3
votes
4answers
227 views

A simplified regular expression matcher

I am working my way through some code challenges — partly to improve my problem solving, but also to improve my code quality. I think my current (fully-functional) solution to a challenge is pretty ...
0
votes
1answer
184 views

Generic Meyers Singleton implementation in C++

Is this a correct implementation of a generic Meyers Singleton in C++17? Any tips appreciated. Singleton.h ...
0
votes
0answers
55 views

Convert hex to base64 and then fixed XOR

I've seen on the site questions where too simple tasks can be grouped into one. Here are Challenge 1 & 2 from Crypto Challenge Set 1 in Python. Any suggestions? ...
2
votes
2answers
109 views

A postfix (a.k.a. Reverse-Polish Notation - RPN) calculator

As an exercise, I put together a postfix calculator using modern Fortran. Language apart, I am interested in knowing your take on the algorithm. As far as I remember from my freshman year (chemistry - ...
4
votes
2answers
92 views

Implementing dynamic array without STL

For my game engine that I'm trying to write without using STL I implemented dynamic array class(some kind of std::vector). I would like to know whether this code suits best practices. I'm also not ...
6
votes
3answers
338 views

Beginner C fgetline() implementation

I am doing C coding practice by reinventing a getline function that works with any streams. Any comments on the overall code quality, including correctness, style ...
1
vote
2answers
404 views

C++ Shared_Ptr implementation

I reinvented a c++ smart pointer, shared_ptr to be precise. It is meant for practice purpose and does not attempt to replace the standard implementation. To the ...
2
votes
1answer
79 views

An Implementation of Two Dimensional Plane as Monochromic Image Container with std::unique_ptr in C++

I am trying to implement a monochromic image container with std::unique_ptr. The example usages The example usages is as below. ...
6
votes
1answer
449 views

Parsing a JSON one line at a time in Python

happy 2021 everyone! I started coding some months ago for fun and recently I challenged myself to build a JSON parser in Python (v3.8). The basic idea was to avoid loading the whole file at once, ...
2
votes
2answers
85 views

Unsigned integer power with overflow detection

An unsigned integer version of pow() is fairly easy to code, yet I also wanted: overflow detection portability only modest performance impact due to overflow ...
2
votes
1answer
75 views

PHP JWT management base library for inclusion in larger projects

Edit: this is a base library for including in larger projects for the overall management of JSON Web Tokens (JWT) that should be compatible with other JWT libraries that share an encryption secret - ...
2
votes
2answers
222 views

My String Class

Here's my very basic String class. This is my first attempt, to try to design and write a basic String class in C++, without using the absolute new features provided by newer C++. ...
6
votes
2answers
907 views

AES implementation in python

For educational purposes, I have implemented the AES block cipher in python. I decided to follow the interface for block cipher modules as defined in PEP 272. The implementation consists of two python ...
2
votes
3answers
317 views

A Merge Sort implementation for efficiency

This is my version of mergesort. ...
2
votes
1answer
278 views

C++: swapping bytes of an uint64_t

This question is about swapping bytes of an uint64_t value, or in other words, about converting between endianness of an integer value: ...
2
votes
1answer
83 views

C++ implementation of a Stack with dynamic C-style array

I implemented a Stack in C++ using a dynamic C-style array. I tried sticking to the most important functions a Stack has to have to be usable. This is meant to only be for integers. I appreciate any ...
4
votes
0answers
147 views

Sorting Algorithm (from scratch) in Python

Updated (at the bottom) I am attempting to write a Python program where I have to create a sorting algorithm without the assistance of the built-ins (like the sort()...
5
votes
1answer
81 views

Matrix template Class

This is my 2nd shot at dynamic memory allocation. This project is for practice purposes. So many things were considered whilst writing this minimal project. I considered using placement new to ...
7
votes
2answers
378 views

Doubly Linked List Data Structure ADT in C++

I'm trying to implement a Doubly Linked List data structure in C++. Please give me suggestions on how this code can be improved. Try to remain in C++11 because that's what I know atm. ...
6
votes
2answers
302 views

Custom STL Vector container Implementation

For practice purposes, I reimplemented a STL Vector container. This container has most/all of the capabilities of STL vector.In my previous post, the reviewers made critical and concised observations ...
3
votes
2answers
356 views

Linked List Queue Implementation

I implemented a Queue using linked list data structure. This is also my first time using templates in C++. OVERVIEW Queue is a data-structure that supports only ...
7
votes
3answers
1k views

Implementation of Singly Linked List (C++)

I tried to implement a singly linked list myself, sorry it is not commented but I think it should be pretty self-explanatory, if not feel free to comment. I know that using namespace std; is not ...
4
votes
4answers
550 views

Convert Integer to Binary String

This code takes a user input number which is a positive integer, and outputs a string representation of the number in binary. For example, input 2 outputs ...
11
votes
3answers
416 views

FASTA-to-tsv conversion script

I worked on a script that takes as input a multi-sequence .fasta file and outputs the number of each aminoacid/sequence in a .tsv...

1
2
3 4 5
18