instruction
stringlengths
71
71.9k
Could you guys please review the Graph Library I developed in C? It's also on GitHub #include "graph.h" /*Function: * Graph_node_in_adjacency * * In this function we verify whether the node is * present in adjacency List of a vertex * * Input: * Graph_edges_t * vertex_number_t * * Output: * b...
Over on Stack Overflow, someone asked a simple Haskell question: how to test whether there is exactly one distinct vowel in a given string. To clarify, there can be any number of non-vowel characters, and the vowel may be repeated any number of times (at least once!), but no other vowels may occur. I proposed the below...
How should one break this component down to better perform unit test on its behaviors? Issues: Authentication middleware component makes external request. Must recognize preflight and final flight. (Exceptions) Must verify path. Only want to expose crossOriginRequest. Please criticize anything you see wrong in logic...
I'm learning C and decided to write my first major project in C. I was bored and wanted to play blackjack so I decided to create my own game. My program starts the user off with 500 credits and continues playing until the user runs out of credits or quits, at which point they can start again by typing play. The main in...
I am using the following VBA code to replace accented letters with regular letters in a spreadsheet. This is necessary because these spreadsheets have to be uploaded to an import tool that does not allow foreign characters. Function RemoveAccentsFromForeignLetters() StartNewTask ("Removing accents from foreign let...
I'm trying to figure out if there's a better way to run the code below. Basically Course is an association of Student and courses_needed is an array of Course where I have many Students have and need many Courses and I'm trying to figure out the demand. I've came up with the following code and it runs, which is fine, b...
I'm making an image viewer and before I continue development I want to make sure I haven't done anything bad. In particular, I was wondering if my error handling is sane. Most of the code is OpenGL/glfw boilerplate, so far all that happens is the creation of an OpenGL context and then I use stb_image to load the image ...
In preparing this answer, one of the components was an algorithm to rearrange a sorted array in a particular way. To put it succinctly, here's the problem description: Given an array \$A\$ with \$n\$ elements \$A = \{ A_1, A_2, A_3, \dots , A_{n-2}, A_{n-1}, A_{n} \}\$ rearrange the contents such that the resulting a...
Today I coded a class to get settings from a file and to load them in to a dictionary. Please post and feedback, improvements and changes, no matter how big or small, as long as they are actual improvement and not disadvantages. using log4net; using System; using System.Collections.Generic; using System.IO; using Syste...
I am coding an interview question from Yahoo Software Engineer Intern Interview. Given an unordered list of numbers, find all pairs that add up to x. I have a working solution in Java: public static void main (String args[]){ int[] numbers = new int[]{2, 5, 7, 3, 9, 4, 1, 8}; //input array int x =...
I created an helper method to return a List of UIElements where the returned elements have to match with one of the Types which I pass to the method. First I used this method to get all the children of one type: public static IEnumerable<T> FindVisualChildren<T>(DependencyObject dependencyObj) where T : DependencyObj...
I implemented a function for pager link creation, it looks like this: function createPagerObject(pageUri, page, totPages) { const MAX_PAGES_IN_PAGER = 6; // for the first three pages the starting would be 1 let pageNumber = Math.sign(page - 3) > 0 ? page - 3 : 1; let pager = []; for(let i = 0; i <...
I have this little function to validate e-mail. It's a little piece of code to search major mistakes in e-mail input and it's part of a bigger program I have to complete as a school assignment. Is there a better way to do it in C? I'd like to do it in regex but if I have understood correctly, C under Windows doesn't ...
(See the previous (and initial) iteration.) Compared to the previous iteration, I have added more methods that maintain the invariant required for constant time rotations, such as bulk add/remove, iterators, dumping contents to array. I have more progress on java.util.ArrayList subclass that supports rotations in const...
Want to brush up my rusty web dev skills. I want to call the twitch API for several channels and eventually call a callback function when all results are in without using a sync call. I didn't work with JavaScript for a long time, so I'm not sure if my solution is a good way, especially how I figure out if the callback...
source : https://github.com/Zakisu/QB_Mysql/blob/master/mysql/Mysql.php please review mycode read the docs about the usage <?php /** * Mysql Class * * @category Database Access * @package Mysql * @author Muhammad Zaki Sulistya <zaki.sulistya@gmail.com> * @copyright Copyright (c) 2016 */ class QB_Mysql { ...
Following task: You've got an array which contains parts. Parts can contain subparts. Subparts can contain further subparts and so on. For example: computer cpu hardDisc graphicsCard graphicsCardCpu graphicsCardRam Let's suppose I have a correct structure where every part has a unique id. Su...
I'm trying to find the shortest and best way to achieve the following: Given input integer $N, get the following output: n = 0, output = 0 n = 1, output = 0 n = 2, output = 10 n = 3, output = 100 n = 4, output = 1000 n = 5, output = 10000 I do this with the following code, but there must be a better option to do...
What is a cleaner and/or clearer way of writing the following method def disbursements @invoice = Invoice.find(params[:id]) utc_time = Time.parse.now.utc #check if invoice_id is not nil if @invoice.invoice_id == nil @invoice.errors[:invoice_id] << "invoice_id can not be blank" end #check if trip date is no...
I am a Laravel newbie so please forgive me for my code... I have a method, in a Laravel controller, that updates the current logged user profile (postProfileGeneral()). Logged user can upload a profile picture, and I manipulate the uploaded file (i.e. remove spaces, create unique name, etc.); since I'd like to reuse th...
I've never been into web a lot, but I really want to. I started from simple things. I have some experience in .NET and c#. But the world of javascript is completely new for me. I wrote simple calculator just to try js. Maybe there are some ridiculous things in my code that I want to know. I'm not really interested...
This is my first SFML game. There are 2 players: the red circle and the yellow circle. The red circle is controlled by Up,down,left and right keys, the yellow one is controlled by WASD keys. The players are supposed to keep on trying to get behind each other in order to move them and get them inside the black circle, t...
This is a class similar to std::pair and std::tuple inspired by Alexandresku's Expected<T>. Let me know if this class can be helpful for simple error handling. template<class E, class T> class CheckValue{ public: template<class UT> CheckValue(const E &e, UT &&t) : e(e), t(std::forward<UT>(t)){} operator E(...
I am building an iOS SDK to be consumed by apps. I am building an object that represents a physical place. The interface looks like so: @interface RDPlace : NSObject @property (nonatomic, strong, readonly) NSString *city; @property (nonatomic, strong, readonly) NSString *country; @property (nonatomic, strong, readon...
I know there is a balance to be struck between writing dry code and damp code but I have the feeling that this is a bit too repeative. Is there a terse yet self explainatory way to rewrite these tests? class TripTest < ActiveSupport::TestCase def setup @trip = trips(:one) @invoice = invoices(:one) end t...
Working codepen: http://codepen.io/leongaban/pen/oxwLzE?editors=1010 The function below takes in user entered text through the cli: V=patch gulp build It then checks for the last version of the build folder, then iterates the appropriate version number. Hoping to condense all the if/else into more functional code. last...
I am new to AngularJS and I thought of trying something simple: a notification factory that is useful for displaying actions alert messages like "Save successfully!" or "Validation errors: ...". The factory - first thing I have tried is to define a container to hold all UI element data and use it for binding. Basically...
I thought about using a macro to auto close FILE pointers at the end of a block. My solution so far is: FILE *fopen_safe(const char *filename, const char *mode) { FILE *fp = fopen(filename, mode); if (!fp) { perror("fopen"); exit(EXIT_FAILURE); } return fp; } #define with_fopen(fp, fi...
I'm interested in receiving some feedback regarding an Event system that I wrote. Both in style and implementation, but also in overall design and the design decisions that I made. It is intended to be used as part of a game (hobby project of mine) and is intended to be used on a single thread. While receivers will alw...
This is a working linked list that will be used as a vector. Instead of using dynamic arrays, I am using a linked list. I would like to see a more concise solution without utilizing the STL. SimpleVector.h class SimpleVector { public: SimpleVector(){ head = nullptr; } SimpleVector(const SimpleVect...
This is my second SFML game, which is Pong. Please tell me what you think. #include <iostream> #include <SFML/Graphics.hpp> int player1score = 0; int player2score = 0; bool intersects(sf::CircleShape& c1, sf::RectangleShape& rect2){ sf::FloatRect circle = c1.getGlobalBounds(); sf::FloatRect rectangle = rect2.getGlob...
I implemented the DFS and BFS. Please offer improvements. #!/usr/bin/python # coding=utf-8 # Para poder poner acentos en comentarios # Alberto Penhos # A01018426 # # Se hizo con listas, ahí se guardan los valores en el siguiente formato: # Posición de la lista: # 0 3 6 # 1 4 7 # 2 5 8 # # La meta es el estado...
Continuing on my VB.NET quest, I came across this slightly more challenging problem. You are given a 2D matrix, a, of dimension \$M\$x\$N\$ and a positive integer \$R\$. You have to rotate the matrix \$R\$ times and print the resultant matrix. Rotation should be in anti-clockwise direction. Rotation of a 4x5 matri...
I implemented a fixed-length stack in Java for use in my fractal generator program, an RPN calculator and my esolang interpreter. This is a generic stack, and goes over and above the call of duty in places to supply my esolang interpreter with some essential methods (the initStack(),dumpStack() and ...N() methods, as w...
I started a project the other day and started going down the path of using async and await as I have never used it before and it seems like a good match. The app that I'm making is a WPF solution using MVVM. It is going to read from a smart card and show the information that was saved to the card. It is part of a demo/...
I changed the program to use a dynamic array instead of a vector or storing the integers. This program works without bugs and executes relatively fast. The only doubt Istill have is how to fill the dynamic array in am ore elegant fashion (I couldn't get array={0} or array.fil(0) to work. At this point, there's to asses...
I have this background service, which runs continuously even when the application closed (Paused or Stopped). The service is to retrieve the user location and post it to server. public class LocationUpdaterService extends Service { public static final int TWO_MINUTES = 120000; // 120 seconds public static Boole...
I have written a safe read function for haskell (for education!). I think this is fairly idiomatic haskell code, but I'd like to know for sure. If you see anything else that could be improved, please let me know in your answer. module ReadNum (readNum) where main = print $ readNum "87k7" readNum :: String -> Maybe I...
I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an unnecessary mov in another project. Problem 1: "If—else (34 points): Write a program that asks the user to enter a single d...
Create a class diagram and Java code for the following system and scenario, taking into account the possibility of future extensions. The system is a command line utility that prints a short 'quote of the day' on the user's terminal when run. To begin with the quote is selected randomly from a set of hard-coded st...
I've grown tired of typing my password back and forth to all the hosts you connect to, i want to be able to jump to every single user on all the hosts with ease. So i've made this script with a quite messy oneliner at the end of it. The script first reads user input where to connect to. remote_user, remote_host and re...
I have written a very basic paint program in java using AWT and Swing. I have separated the program into two different class files; one of them holds the JFrame and adds a custom panel (this custom panel being the second class file, extending JPanel). In my first try, I tried using Timer and an ActionListener with repa...
private void loadTabsIfGPSAndInternetAvailable() { final Utils utils = new Utils(this); final LocationClient locationClient = new LocationClient(this); if (!utils.isConnected()) { utils.generateNoConnectivityAlert(); } else if (!locationClient.hasGPS()) ...
EDIT: Version 2 is now available here I am just getting to grips with ReactJs using es2015 classes, i have just converted a simple portion of an app i maintain into react code and tried a few things out, this displays a list of customers with a sub-list of the animals that they own. Am i utilising es2015 features corre...
Initial stage of implementation of the polynomial class. Essentially I need to implement the basic mathematical operations. Right now I have implemented just addition. Was wondering if this is a good way to proceed. I also want to be sure if the move constructor would be called during the addition operation. poly.h /* ...
I wrote a Java program with a Swing UI that calculates prime numbers. The primes are displayed into a listbox. I used a few optimizations to generate the primes faster. I’m using the NetBeans IDE, so there’s a lot of generated Swing code. Currently, the program finds as many primes as the user has input into a spinner ...
I have a system that outputs a comma separated string into a single column. I need to grab the individual values out of that list. The list could have random spaces and commas that need to be accounted for. I'm new to MySQL and I have a working example that just seems rather long. I'm wondering if there is a simple...
I am trying to write code to calcultate ex using: $$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots $$ This is the code I have, which works for small values of x. Please do not pay attention to the variable e, specifically to the fact that user enters it. #inc...
I wrote this implementation of quicksort as a bit of practice and review for myself. I did not base my algorithm on anything more than my own understanding of quicksort and working through a couple of examples myself on paper, so please let me know of any improvements or optimizations that I could make! import java.ut...
I'm just starting out with Java, and trying to make a method to get a positive integer input from the console. My currently working implementation is this: public static Scanner sc = new Scanner(System.in); public static int getPositiveIntInput(String message) { int n; String error_message = "Error: input mu...
I made a merge sort implementation in C++, which I have tested with the values: 6, 38, 27, 7, 12, 58, 92, 43, 3, 9, 82, 10 producing the correct output of: 3 6 7 9 10 12 27 38 43 58 82 92 However, when running my program, it seemed pretty slow, and I was wondering if there were any places in my code where there is an...
I'm trying to improve my limited knowledge in PHP (7) and I wrote these two simple classes as a proof of concept. They both have just one (private) property ->email and they run validation before setting a value for it (unless it's null). They are both supposed to run at business-tier GtokenA uses magic methods and is...
After posting my original address book program I took the responses and edited my code. I have used every suggestion given, the code works great, and now I am looking for further review and suggestions from the Code Review community. Parent class (Person): //parent class #ifndef PERSON #define PERSON #pragma once #inc...
I'm pretty new with programming in general. I'm using Python 2 right now as it seems most of the courses are teaching Python 2 and not 3. I built this area calculator that will calculate square, rectangle, triangle, circle or trapezoid. I'm a little concerned about how I used the functions as well as my else stateme...
I recently posted an earlier version of this code on Code Review, and now with the given suggestions and many other improvements, I am back. I included the description of exactly what Cyther is supposed to do inside of my source code. Cyther's repo can be found here. My objective is to make sure that this code is as cr...
I am new to C++, learning from the book primer C++ The exercise: Write a program to read strings from standard input looking for duplicated words. The program should find places in the input where one word is followed immediately by itself. Keep track of the largest number of times a single repetition occurs and whi...
The problem statement is here. Problem Description The task is to rank the contestants in the contest based on following criteria Contestants are ranked first by the number of problems solved (the more the better) then by decreasing amounts of penalty time If two or more contestants are tied in both problems solved an...
I'm creating a console app that has the purpose to teach you how to use C# bitwise operators. I have several classes which contain info about the different operators and I instantiate/add them in the main class like this: var trainingDefinitions = new TrainingDefinitions(); var generalDefinitions = new GeneralDefinitio...
I've been writing basic Python scripts for a while now to help process data or automate some task but I've decided I should start picking up unit testing and objective orientated programming (the vast majority of my scripts so far have been procedural). As a starter I decided to follow along with Uncle Bob's bowling sc...
Question: Need to create three classes. Number Fraction Integer Requirements The first class should support “display”, “==”, and “+”. "Display" : This operation displays the Number itself in its original form. "+" : This operation adds the number itself with another number and returns a third number whose numeric va...
I want to ask the user about whether he wants to continue playing or not. For this I have used, char choice; do { System.out.println("Would you like to continue?(y/n)"); choice=sc.nextLine().charAt(0); if (choice!='y' && choice!='n') { System.out.println("Invalid Entry"); } }whi...
In my program below I am getting the parent node game 1 and then removing one of the two child nodes, depending on which one is clicked. I currently have two event listeners, with two separate functions for removing one child vs the other. It doesn't feel very dry to me, and I think I could benefit from having someone ...
Since I use C++ mainly to do physical calculations, I often come across the problem that I forget which units a certain variable is in, e.g. radian or degree, or meter vs. millimeter. For this reason, I started using a custom header file defining my units, which is posted below. The basic idea is that I never create so...
The following code fetches trending topics from Twitter's API using a WOEID. It caches the response, loading from this cache the next time if its relatively fresh (generated within the last 15 minutes) to avoid returning a "Rate limit exceeded" message from Twitter. A 'force-refresh' flag can be passed to skip the cach...
I have some code that reads a file and then does some parallel processing of the data. There are millions of lines in the file and this section of the code is the bottleneck in my program. Any information on how to improve processing times or any other suggestions to improve the code (e.g. error processing, string mani...
I am working on a generic repository. And I wondered if anyone could give some feedback on it. Interface for DbContext: public interface IDbContext { IDbSet<T> Set<T>() where T : class; DbEntityEntry Entry<T>(T entity) where T : class; void SaveChanges(); } Context class public class BookContext : DbContex...
Here's my lock-free channel impl lfchan, I didn't want to copy/paste the code here since it is multiple files. I'm trying to get an idea of what can be improved or if there are any bugs in it. chan.go type innerChan struct { q []aValue sendIdx uint32 recvIdx uint32 slen uint32 rlen uint3...
The goal of following MVC controller code is to achieve following workflow: User exports catalog (either with items of type Spread or of type Consumables) to Excel; User makes changes in exported Excel file; User uploads catalog to web; User preview his changes before committing to database. Because catalog can b...
I have been working on a Scrabble Word Finder for a couple of days now and have it working pretty much but would love to improve the efficiency. The code is made up of 2 classes: one for creating and managing a pool of letter tiles and another for iterating over a word dictionary (from a .txt file) to check/score word ...
I've recently started learning Rust, and I've managed to whip up this function, which reads and parses a thing from stdin. I don't like it though, and I feel it could be further simplified. What do you think? fn read_thing<T: str::FromStr>() -> Result<T, &'static str> { let mut buffer = String::new(); match io:...
I'm writing a binary PowerShell module and have recently started to add wildcard support to some cmdlets. I'm not sure if I'm using an efficient way of creating the final collection of objects to write back to the pipeline. I'm wondering if it might be slightly more efficient to use a HashSet<T> rather than a List<T> i...
I have managed to build an inheritance hierarchy for shape class object and I am wondering if there is a better solution to combine the following 2 hierarchies. To begin, I have a 4 shapes classes triangle, line, oval and square which 3 of (line, oval and square) inherit from abstract class SimpleTwoPointShape and this...
I've been out of working in Java for quite some time now (almost two years), so I've been working on a fun side project just to get back into the swing of things. Essentially, in the long term, the goal of this will to be to compile a library that can be used in to create basic platform-like 2D games. I'm never dealt w...
Microsoft Excel cells basically have two values: the formatted value that is shown to the user, and the actual value of the cell. These two values can be extremely different when the cell has certain formatting types such as date, datetime, currency, numbers with commas, etc. I am writing a script that cleans up databa...
I'm starting to play with F# to do some data parsing and I was able to create a function to group an array of string into sub groups. The code looks like this: let breakBy lines pattern = let rec breakByRec lines pattern acc = match lines with | [] -> acc | head::tail -> match ...
This is a program which computes the circumference of two circles and gives some information such as the difference between circumferences. I want to know whether the method declarations and method calling in my code is correct. I didn't face any errors. import java.text.*; import javax.swing.*; class Q5Main{ pub...
I'm currently learning Swift by following the Stanford developing iOS app 2015 lecture series. I have completed assignment 1 but am wondering if there is any improvement can be made to my code. Also, I have not been able to complete extra credit no. 4, so I would appreciate if someone could offer me a hint. import UIKi...
Checking if some port is up on the network is a very common task when working with remote services. A common way to check is using telnet, but I have two practical issues with that: telnet is not available in all systems, for example in recent versions of Windows. When connection is successful with telnet, an interact...
Is my algorithm slow because it has problems? Or, is any bitwise common prefix solution not going to give me the performance I'm looking for? After profiling my algorithm, I found that over 60% of the time was spent on one line len(os.path.commonprefix((item1, item2))). I'm only looking for the length of the prefix To...
I've created a function to return all the indices where an element is to be found in an array. If it occurs twice or more, all the respective indices will be returned, for now it returns them in natural counting (1,2,3...) and not how the computer sees them (0,1,2,...). #include <iostream> #include <vector> using names...
HRESULTs are the common way for Microsoft technologies like COM and Win32 to return either an error code or messages that mean a specific type of success. They are usually returned as the result of a function. They have various pieces of information encoded in their bits, such as the OS facility that erred, the error...
Before starting I would like to say that I just made this program after studying python for 5 hours for the first time so I am totally new to this programming language. This program tries to create 4X4 board denoting it with 0 everywhere. Now to deploy treasure, it randomly selects 9 position and deploy them on the boa...
I was given the task of making a grid peg solitaire puzzle. Here are the programs, the basic puzzle file, and the actual grid solitaire puzzle: The puzzle software class Puzzle: """" Snapshot of a full-information puzzle, which may be solved, unsolved, or even unsolvable. """ def fail_fast(self): ...
This is the first mini-project I have completed by myself with Python 2.7. I wrote a simple program that calculates the area of different two-dimensional shapes and it works. I want to know what you think of it and also want to know how it can be improved and if I did something wrong, so this is my code: def circle(pi...
The foreach loop seems ridiculously lengthy and I am trying to get rid of it altogether is possible. But there are a lot of things happening in there which I need to know in order to update the UI and create other values. For examples, variables mappedRuntimeName, mappedDeviceName are used for updating the UI and also ...
I've been learning more programming in the past few years (C, Java, Arduino) for my hobbies. I read the "C for Dummies" book and found that it was good, but did not cover much - especially pointers... One of my friends from college (CS major) suggested a simple program exercise to see if I could figure out how to use p...
I just finish coding this code which use for control robot using compass sensor with PID control to control motors. Trying to make javascript object for necessary job. Please guide me for a better code. Watch Video to get how it works I use johnny-five package for control Arduino and pid-controller for PID control. var...
Here is is a fixed code, taking in to account Spurious wakeup issue.Thanks to Costa for bringing that up. ISemaphore: package edu.vandy.utils; /** * This interface provides a simple counting semaphore to manage * concurrent access to a set of resources. A semaphore may implement * "Fair" or "U...
Let L be the language defined as follows: The words are made up of strings of a’s followed by b’s. The number of a’s is always equal to the number of b’s. Examples of words that belong to L are: ab, aabb, aaabbb etc... One way to test if a word w belong to this language is to use a stack to check if the number of a’...
I have a table in pandas that has two columns, QuarterHourDimID and StartDateDimID ; these columns give me an ID for each date / quarter hour pairing. For instance for January 1st, 2015, at 12:15PM the StartDateDimID would equal 1097 and QuarterHourDimID would equal 26. This is how the data I'm reading is organized. It...
I am experimenting with performance evaluation. From the hardware architecture point of view, two main factors are cache misses and incorrect prediction of conditional branches which can degrade the performance of an application. I have considered a small application for each case: Cache Misses: In this application, ...
I have created this ViewController using Swift. Its job is to track geolocation and draw a line on a map and save it to core data object. I just want some advice on improving the geolocation tracking using core location and storing information using core data. import CoreLocation import MapKit import UIKit import CoreD...
I'm not really sure if the following solution is the best fit, and I would like to know best practices when manipulating state and/or Ajax isomorphic fetch requests, in this case, in intervals. Users Module import { createAction, handleActions } from 'redux-actions' import { api } from '../utils/api' export const RE...
I have developed the following method for each as a replacement for $.each, and I am considering using it in my personal lightweight js library called LIBJS. The final version will be part of a javascript class as opposed to a stand alone function. /** * * @method each * @param {Object} obj ...
I have this method in C# that could be refactored. Should I use a design pattern? I see too much repetition and it gets worse if more conditionals are added. Should I change it to a method call? public void CreateOrUpdateReportDefinition(ReportGroupSubReport reportGroupSubReport, bool isNew, int report) { if (repo...
I only need three random numbers within the range of 1-54 (deck of cards) and none of the three numbers can be a duplicate. I cannot use an ArrayList; I must use a standard array. Is the method I chose to check for duplicates good enough? public class Test { public static int genRandom() { // generate random int ...
The diabolical Professor Boolean has captured you and a group of your hapless rabbit kin as test subjects for his terrible experiments! You're not sure what his real plans are, but currently it seems he's trying to make everyone faster and smarter? He's exposing rabbit test subjects to novel chemicals, genetic...
I have started to interest myself in artificial intelligence a while ago, especially within the game industry. I have started with state machines moved on to fuzzy logic and now I want to learn and implement a neural network which will also work for games. However to not overwhelm my tiny little head I wanted to start ...
I broke my server into two classes, a general server class and a client session class. I know the code isn't documented in the header, but I am more interested in the design of the server/session model and whether or not responsibility is correctly broken up between the modules. Also, whether or not the callbacks for s...
I'm comparing my algorithms, slice_prefix and bit_prefix, with existing ones to find the common prefix length of 2 strings as fast as possible. Another program I'm working with spends most of its time on one line len(os.path.commonprefix((item1, item2))). I've searched for other algorithms in Python and created my own...