instruction
stringlengths
71
95.1k
I am working on a product-related app where the data model for a product attribute feels too heavy. But I can't split it into several small data models because they are all about goods. At present, my approach is to parse network data directly into a data model. The properties of the data model are readwrite. For exam...
This was a simple game I was making in python. Below is the main class. This is more or less of a prototype for the game. Any criticism or advice is welcome. Source Code import tkinter as tk from threading import Thread from time import time,sleep from random import randint, choice import math from PIL import Image, Im...
I came across this problem while giving a sample test. The problem was that we have given a tree which is undirected. We can start from any node of our choice. Initially we have power "P" and while going from one node to other node we loose some power "X" (consider as cost of travelling) and earn some profit "Y...
I am beginner in C++ and I was given this assignment by my teacher. The assignment is to print the following shape: * * * * * * * * * * * ************* The following is what I have tried and basically it works, but I doubt my code is not simple, there's another way simpler tha...
I am trying to find a maximum sum of elements in a list where the sum of three consecutive elements is not allowed. So, to find the max sum, you'll have to go through each element sequentially from the first element of the list(Must have first element value in max sum output). You can not select more than two elements ...
I was surprised to find that there doesn't seem to be a good "continuous range from start to end" data structure in python. I feel such a structure might be useful. So I made one. Moreover, from my time answering questions on StackOverflow, a use case that I've seen come up repeatedly is to have a program have differin...
A fairly simple program that I tried to write in Common Lisp in order to practice/learn. I'm sure this can be done more elegantly but Lisp's string handling seems to be very werd. (defun d20 () (+ 1 (random 19))) (defun initlist (specs) (let* ((ilist (map 'list #'(lambda (n) `(,(first n) ,(+ (second n) (d20)))) spec...
I'm an absolute beginner in programming, and Today I decided to put my knowledge to the test and create a basic c# calculator. I've Done it, but now I'm looking for ways to Make it more shorter and readible. If you Have any suggestions, please give them! using System; namespace lol {     class Program     {         st...
I have made a simple command line version of connect 4. It is my first time using classes and importing one part of my project into another so any feedback on how I've done and any way it could be changed or improved would be helpful. This code file (connect4.py) contains the basic functions I have made: class connect4...
I have these two macros that are like my Yin & Yang. They turn off and on functions in excel so my macros calculate quicker. I call on in the beginning and one at the end. Is there anything I can do or add to these to make them better? Private Sub TurnOffFunctions() Application.ScreenUpdating = False Applicati...
I need to log the activities of instances of a class. Code that uses the class should be able to disable the default class logger (which, by default, is initialized with a StreamHandler that output log messages to console) and add handlers to it (i.e., to support writing log messages out to a log file). It appears to ...
I am learning C# like 1 or 2 months and I wanted to know if there is any possibility to shorten this code. It is simple. It only changes color of the console text with while loop if you enter wrong input. When you enter it correctly it changes the color + asks you if you want to continue. It looks weird for me when I ...
I am working through Programming Fundamentals with Python on Udacity. The assignment was to create a recursive triangle. I am happy with the output, but I am hoping for feedback on the actual construction of the program. Could I have done this in a more simple and concise way? import turtle def draw_polygon(a_turtle, ...
In my project I have a chain of Fragments where each one gets a bitmap, manipulates it, then sends it to another fragment for more processing. My fragment chain looks like this: CaptureFragment -> RotateFragment -> CropFragment -> ... And here's some of the code: abstract class BaseFragmentInOut<InVM : BitmapViewMode...
Background I transformed a non-trivial JSON response that uses arrays into a nested object eliminating some of the original properties inserting a new summary property that is a unique list of values from the original object I did this with temporary variables, foreach loops and some conditional logic. My first wor...
In the 20×20 grid below, four numbers along a diagonal line have been marked in red. The product of these numbers is 26 × 63 × 78 × 14 = 1788696. What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? Here's my implementation in Python and I...
I was hoping to get some feedback on my basic recreation of the google homepage. Im doing the Odin Project learning course and this was the first project trying to use the basics of HTML/CSS HTML file: <!DOCTYPE html> <html> <head> <title>Google</title> <link rel="stylesheet" href="style.css"> </head> ...
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? from time import time from functools import lru_cache def make_grid(grid_size): """Return a list of lists c...
I've implemented a "Ticket" class which is shared as a shared_ptr between multiple threads. The program flow is like this: parallelQuery() is called to start a new query job. A shared instance of Ticket is created. The query is split into multiple tasks, each task is enqueued on a worker thread (this part is importan...
I have an application where messages are collected and dispatched to various handlers. Messages are derived from the base class MessageBase, handlers derived from HandleBase, so what typically happens is a handler will receive a MessageBase pointer. Now, the handlers need to know the derived type of message to determi...
I have just started learning basic Java. I would like to know what I can do to improve my coding habits in Java and how to code more efficiently. In this code example, I took code from Very simple Hangman game and made some edits. Most noticeably, I created a GUI to display the game. I do not think I am too good with J...
I'm new to JS and wanna know right code style or approach to cod Vanilla JS using ES6. To practice this, I'm using ESLint JS code-style of AirBnb and referencing clean-code-javascript repo. However, I cannot sure it is right style for me because I'm newbie. For this reason, I want to ask code review about my simple Van...
The 'score' of a race is given. We have to calculate the 'bonus points' to be given to the participant. The 'bonus points' are dependent on the relation between product of digits at even places and product of digits at odd places. So essentially I have to find the product of digits at even and odd places. I first count...
I've written some PHP code that connects to a database and saves input entered by the user at our signup page. I would like some feedback before I present this code to my colleagues, as I intend on using this code for our website: Security Use of PDO vs other connection methods Variable Naming PHP Conventions HTML Con...
I am developing a C# Windows forms application. In that, I am reading data from XML which is coming from a web API and storing that XML data into SQL database. I am able to achieve this. But my only concern is, In Production environment, this application will be in service and there will a lot of data to synchronize fr...
This is my implementation class Ch02LinkedLists { void removeDuplicatesInPlace(Node head) { Node anchor = head; Node curr; while ((curr = anchor) != null) { while (curr.next != null) if (curr.next.val == anchor.val) curr.next = curr.next.next;...
I'm a student in my first semester and in my free time and holidays, I do some java training to keep my mind from rusting...so I downloaded this amazing Digital Algorithms practice app and came across the Plus One problem and that inspired me to code the Plus-Target problem: Question Given an Integer Array (non-empty A...
My application will accept textarea content that is submitted by a user, and i would like some people to review my code to make sure there is no security vulnerability such as XSS. My mySQL column that will save this information is a column of type TEXT and is not required and nullable. When storing the data to databa...
I'm trying to Implement a d-ary heap. A d-ary heap is just like a regular heap but instead of two childrens to each element, there are d childrens! d is given when building a heap, either by giving an argument or by passing it while calling init. Here is my Implementation: import math class DHeap: ''' creates d-he...
This is the code I came up with. I added comments to make the solution more verbose. int findComplement(int num) { // b is the answer which will be returned int b = 0; // One bit will be taken at a time from num, will be inverted and stored in n for adding to result int n = 0; // k will be used to...
Challenge Write a function that takes 2 integer operands left and right (both >= 0) and evaluates one of the following basic arithmic operations: addition multiplication exponentation The challenge is you are prohibited from using any built-in operator, except for an incrementation (++ or +1). The entropy is a...
how could I optimize my code, or make it cleaner? See things to avoid. I receive data in my protocol and then analyze it in a message structure. My protocol: {2 octet: Message ID}{? octets: CONTENT}\n #include "pegasus.h" # define ENDL '\n' t_message *create_message(int id, char *content) { t_message *message; ...
I am using SDL2 for window management and rendering, but it can be a little verbose. And because of how SDL2 works under the hood, the SDL_Renderer is tied to image resource loading. So, I am setting out to write a wrapper around the SDL initialization and window/renderer management. The core of it is called SDLConte...
This function checks whether or not a substring needle exists in another string haystack and returns the position if it does or 0 if it doesn't, unless the position is 0 in which case, it won't be located. Looking for ways to improve this code, specifically better error handling. #include <stdio.h> #include <stdlib.h> ...
I am creating an algorithm to find the shortest path between two points in a maze but my current solution is too slow. This is what I did: Helper classes: import { Coord } from "./Coord"; export class MazeResult { position: Coord; path: Array<Coord>; constructor (_position: Coord, _path: Array<Coord>) { ...
I wrote a simple sort algorithm in JavaScript, but code climate is complaining its complexity being too high (currently sitting on 6 instead of 5, which is code climate wants). I personally cannot see how it can be further simplified. Can anyone help? The following algorithm sorts an array of numbers from largest to s...
This class is an Async/Await wrapped Dictionary. Of course it doesn't technically implement IDictionary, but the functionality is basically the same as an IDictionary. It achieves similar functionality to ConcurrentDictionary but with async/await, and is non-blocking. Note: please pay attention to the challenge. The ch...
I wrote a class that generates combinatorial necklaces with fixed content as per Sawada: A fast algorithm to generate necklaces with fixed content. The class is instantiated with an input list that states the occurrence of each value that is to appear in the necklace. The execute method is called to run either Sawada's...
I am making a very simple stopwatch functionality as below. New will start the timer. Pause will suspend the watch. Start will restart again. Session will return the duration. #include<chrono> #include<vector> class Timer { using cppTimer = std::chrono::high_resolution_clock; using seconds = std::chrono::s...
I am trying to write a util that converts an SO URL to revised version, for example, given this url: 'https://stackoverflow.com/q/57449318/10731613' this util returns: 'https://stackoverflow.com/posts/57449318/revisions' here is the code import re url = input() if len(url)<10: url = 'https://stackoverflow.com/q/5...
BookstoreScraper is application based on Spring Boot. It allows to scrape data from two biggest polish online bookstores - EMPIK and MERLIN. You can scrap books within 3 options: bestsellers most precise book (you simply give title and it looks for most precise book) categorized book (currently 5 categories of books a...
I have written a driver in JavaScript that decodes the payload of the sensor which is hexadecimal encoded. It receives the payload and the port details to the pre-defined function 'decode' which is the body of the driver provided by one of the IoT platforms and the driver has to be developed with this as an entry point...
Problem Statement: Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array. Example 1: Input: [1,0,1,0,1] Output: 1 Explanation: There are 3 ways to group all 1's together: [1,1,1,0,0] using 1 swap. [0,1,1,1,0] using 2 swaps. [0,0,...
This method repositions vertices of an object in such a way that the center of the object is at the origin of the coordinate system. The task is the commented part. While my code does the job I feel that it is very basic. I am looking for advice on how to make it faster and more elegant, concise and efficient. Any comm...
This code is applicable to either GLSL or C due to virtually identical syntax. Before GLSL 1.3, bitshift operators were not present and I am aiming for backwards compatibility to GLSL 1.2. float lut[3] = {256,65536,16777216}; vec4 getBytes(float n) { vec4 bytes; bytes.x = floor(n / lut[2]); bytes.y = floor(...
I solved the following problem using backtracking: We are given a list of military units, their weight and their (numerical) strength. We have a number of ships with a limited carrying capacity. Determine how to load ships with military units, so that carrying capacity for each ship is not exceed and so that we ...
Below is my code for the problem 1.4 in CTCI. I would like a review of my code and if my approach to the problem is correct. Problem Statement: Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backw...
I implemented very constrained trivial implementation of sql querries operating on user files (in csv format). Where possible i tried to use modern C++ features. The fancy goal is to serve MySql queries in way user is not aware that no MySql server is instaled. Simply - mock mysql using file system. I splitted a whole ...
I'm writing a simple function that applies a Sepia filter to an image. My function works, but I'm a beginner gopher. So I would like to know if there is a way to improve the code. I usually code in Javascript, so I have troubles with a strong typed language such as go. // Sepia apply a sepia filter to Image. func Sepia...
I have made this class. Not sure if there is anyway to make it better. It seems to work alright half the time, but other times frames jump up higher then the set limit around 30frames more if i set it to 200fps. I'm using it in a hooked directx function to limit games fps. Timer.hpp class Timer { public: Timer(); ...
I am trying to convert a JSON file to CSV format using Python. I am using the JSON.loads() method and then using json_normalize() to flatten the objects. The code is working fine for few input rows. I was wondering if there is better way of doing this. By better I mean: Is it efficient in terms of time and space comple...
We are converting a WinForms application to WPF. so I need to accept the input like WinForms. As I don't want to change the logic of it. Ao I write the class for those its works. But the is not good please take a look at the class once and suggest the edits in this class. public class TreeItem : INotifyPropertyChange...
Setup: I have ~30 parameters (dependent variables) measured simultaneously along a common time axis with ~1Hz resolution (independent variable). I need to calculate bin averages for all parameters, with a bin width of 10 seconds on the time axis. Potentially also other statistical parameters like standard deviation and...
I have been working on writing a script that will allow me (and my wife, as you'll see in some of the text in the code) to switch countries for some streaming services I use. It first checks to see if a certain firewall rule exists and will create it if it doesn't exist. If it does exist, it will toggle the rule on or...
In this article I found this quite elegant looking Elixir code: conn |> put_session(:current_user, user) |> put_resp_header(location, "/") |> put_resp_content_type("text/html") |> send_resp(302, "You are being redirected") It works by using the output of each of the functions as the first argument to the next function...
The class below provides a set of utility methods to access set of currently running processes. It is a wrapper around my own version of UNIX 'ps' command. Please help me improve this. import os import re from constants.common import EMPTY_STRING from util.common import execute_remote_command class ProcessStatus...
I recently had to complete this for a school assignment and I really enjoyed it, but was hoping someone with experience in OO design or maybe just Java in general could have a look and point out anything that's glaringly bad, or give me some pointers; I would appreciate it a lot. I hope it's not too much code. This is ...
I created a simple middleware pipeline builder that I want to use for my frameworks. It is similar to how ASP.NET-Core middleware works and uses the same conventions: A public constructor with a parameter of type RequestDelegate. A public method named Invoke or InvokeAsync. This method must: Return a Task. Acce...
Does this exist already? It's an array (=variable-size list with integer indices) where add/remove/set and get all take \$O(\log\ n)\$ time. I couldn't find this anywhere, so I made up the name "Log-N array" and implemented it in Java. Rationale: The more often you add or remove entries with your ArrayList, the more y...
In my example, I have four models: User, Company, Project, and Plant (though my project technically has more: Plant, Job, Team, etc.). Model User: name, role, company: { id, role }, projects: [ { id, role } ], plants: [ { id, role } ] Model Company: name, members [ ], projects [ ] Model Project: title, members [ ], com...
I'm doing an implementation of HttpClient that is built in a NET Standard project, which will be used as a base to build and process JSON requests/responses for a third part REST API. Client is built in a simple way, as there are two different address for the API, both used under production environment. internal class ...
I wrote a Markov-chain based sentence generator as my first non-trivial Python program. I mainly used C before, so I probably have ignored a lot of Python conventions and features, so any advice would be appreciated. text-gen.py import sys import random class MarkovChain: # Class constant that serves as an initial...
I'm new to coding and C++, this is one of my first pieces of "software". Could anyone give me some constructive criticism? #include <iostream> #include <fstream> #include <string> using namespace std; bool IsLoggedIn() { string user, pass, un, pw; cout << "Username: " << endl; cin >> user; cout << "Pa...
Challenge https://leetcode.com/explore/interview/card/top-interview-questions-easy/93/linked-list/773/ Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If...
I have a Notifications component in my React app, which continuously polls the server for new notifications. The app uses Redux for storing notifications. When a new notification is received, it is shown on screen. Here's what the code looks like: import * as React from 'react' import { connect } from 'react-redux' in...
I'm working on a version of the Unix tail command that works by iterating over a file, pushing line by line into a stack. Finally, the number of desired lines will be popped and printed to the screen. I have used void * (void pointers) as the data field of my stack nodes (the stack is basically a linked list with limit...
Implement a feature for a text editor to find errors in the usage of brackets in the code. Input: sorted(list(zip(a, b)) Output: False Input: ([{}, {}]) Output: True Here's my implementation in Python: class Stack: def __init__(self): self.items = [] def push(self, item): """Push item in stack....
I'm creating an app in C++ designed to run an experiment. The model I created is here: #pragma once #include <iostream> #include <fstream> #include <string> #include <vector> #include <nlohmann/json.hpp> #include <filesystem> namespace Experiment { enum Option { None = 0, Left = 1, Right = 2 }; enum Mode { St...
The objective is to implement basic mySQL and relational principles, like how to handle and query one-to-many and many-to-many relationships. The database consists of 5 tables: car (car_id, model_id, plate) model (model_id, maker_id, name) maker (maker_id, name) feature (feature_id, description) car_feature (car_id,...
I am getting log file which contain other information along with leakage information into following format Log_file <some test1> <some test2> leakage1, leakage2.... til lekage29 (separated by comma) val1, val2, val3............ (separated by comma) #!/usr/bin/env python import argparse import pandas as pd import re ...
I made simple Kruskal/Prim algorithm with a graph constructed by nested Python dictionary. Kruskal parent = {} rank = {} def find(v): if parent[v] != v: parent[v] = find(parent[v]) return parent[v] def union(v, u): root1 = find(v) root2 = find(u) if rank[root1] > rank[root2]: p...
I just want to get some advice about code optimization. How can I make this more OOP? How many class should I have for this kind of task? My code already works but I was told to use OOP in a way that it would make sense using it. import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern...
Today I do something like this, where I get, select and sort some data and pass it on to the view (which loads a partial view) as a list of custom objects Page model public PagesSettings PageSettings { get; set; } public List<Reportage> itemListReportages { get; set; } public void OnGet() { PageSettings = (PagesSe...
I wrote this chip8 emulator as practice recently since my coursework is mostly console programs. I've tested it with roms off Zophar's Domain and it appears to work with my limited testing. I'm hoping for general advice / suggestions about the code structure and the way it's written. main.cpp I think there's too much ...
I'm looking for a good approach to AJAX communication using only pure JS and PHP. I would like it to be as safe as possible and compatible with most modern browsers and IE 10+. I did some research and found some code examples for writing a vanilla JS function to handle AJAX communication, but I was not sure how safe an...
I have a script and I was looking to have it reviewed to see where I should improve it. Our need: We need to backup a folder every day to a specific USB drive. There may be multiple USB drives plugged into the computer. We need to ensure that it is only backing up to a specific drive. Code: function ex{exit} #########...
I am writing some unit tests using XUnit in F# and I am wondering what is the most idiomatic way in the F# sense to write them. Let's start a simple case: BicValidationTests.fs: module Rm.Bai.Domain.BicValidationTests open Rm.Bai.Domain.BicValidation open FsUnit open Xunit let shortValidBic = "MYMB gb 2L" let expec...
The following code allows users to enter multiple optional quantity fields after first filling in a value of the current quantity input. If the input field contains a value it will then display the next quantity field, if not, it will remove/not display it. The code is currently working as intended but I don't believe ...
Is there a shorter / cleaner way of creating a plain object from URLSearchParams than this: const uri = new URL('https://tempuri.org/?token=secret&test=true') const result = {} for (let p of uri.searchParams) { result[p[0]] = p[1] } Expected result: { token: 'secret', test: 'true' }
This is, kind of, my first programming project. It's a small project to complete first year's university programming course. The program allows the user to record his mouse/keyboard/cursor activities and then replay it. It's a mini-bot. I am unsure whether I will continue developing this project, or abandon C and go l...
Doing a challenge to print the number that you would get if you convert a given number to binary, invert its bits, then convert back to decimal. I decided to give it a run in clojurescript (which I don't really know) and while all the below makes sense to me, it has to be possible to do it better and without dropping t...
I'm reimplementing the min() function as an exercise (EDIT: not all the functionality of the python std library function, just the minimum of a list of numbers). Here is my code: def my_min(num_list): minimum = num_list[0] for num in num_list[1:]: if num < minimum: minimum = num ...
I have scripts to display commit statistics and merge statistics of my repos, and they work. I wrote them for my personal usage, and because I was interested in finding trends in my git repos. This script reports statistics about commits (number, average length in words, etc.). Relevant commits can be selected using gi...
I have seen multiple questions on this problem but none seem to answer my specific question. To start, the basic question is asking to find the smallest number that is divisible by numbers 1 to 20. I have written some code that has solved the problem but the runtime is exceptionally too long for my liking. I guess I do...
My aim was to create a function which behaves like the operator . in Haskell. Here is what I made: template <typename F> auto compose(F&& f) { return [a = std::move(f)](auto&&... args){ return a(std::move(args)...); }; } template <typename F1, typename F2, typename... Fs> auto compose(F1&& f1, F2&& f2,...
I got inspired to do this after seeing this repo containing a bunch of weird syntactical quirks in JS, namely this example called "It's a fail!". The example was essentially the following: You would not believe, but … (![] + [])[+[]] + (![] + [])[+!+[]] + ([![]] + [][[]])[+!+[] + [+[]]] + (![] + [])[!+[] + !+[]]; /...
I am working on adding a GUI to the project that I was making in some course. I am curious if the layout looks good, if there variables and methods are shared properly between particular classes, if there setters and getters are made correctly and if you see anything that I should do better. Btw i want to add method to...
Linked List Implementation in Swift Swift 5.0, Xcode 10.3 I have written an implementation for a doubly linked list in Swift. As well, I decided to make the node class private and thus hidden to the user so they don't ever need to interact with it. I have written all of the algorithms that I needed to give it MutableCo...
The method that I wrote below functions properly; however, I believe that the code I wrote is not clean nor "good". I know the basics of regex but I do not know more advanced techniques as I am still an amateur at programming. static string SimpleColorOutput(Color color) { //If input = Color[A=255, R=8, G=14, B=21]...
I have a custom model binder which takes user input in HTML format, sanitize the HTML input by removing any script or XSS threat and returns the sanitized HTML string: public class AllowAndSanitizeHtmlBinder : IModelBinder { private HtmlSanitizer _htmlSanitizer = HtmlSanitizerFactory.CreateInstance(); public ...
Here the demo The code below creates a background-image over a background-color with different opacities for each element. Is there a cleaner way of achieving this? .component{ min-height: 100vh; min-width:100vw; font-size:5em; display:flex; justify-content: center; align-items: center; color:black; } ....
I am working on a python3.6.5 question about BST: Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left subtree and is smaller than the values in all the nodes in that node's right subtree. Write a function that, efficiently with re...
The code below shows my take at creating a wordsearch puzzle solver, where the wordearch is embedded into a .txt file that is parsed and fit into a vector<vector<char>>. Then, the inputted word is searched for. What would be the best way, in terms of effective OOP, to separate the program? Should I create two separate ...
I've just started coding and have written a program to calculate your tax to be paid. Is there anywhere where I can improve this? while True: try: income = int(input("Please enter your taxable income: ")) except ValueError: print("Sorry, I didn't understand that please enter taxable income as a numbe...
I made a Spring RESTful api as backend for a website. I would like to get feedback on coverage of errors and the response I return accordingly, am I using the status codes correctly? Basically anything that could be better I'd like to know. Here's a few methods from the rest controller: @PostMapping("/customers") ...
I am writing a small bash wrapper for bbcp. This is a fast network file transfer utility. bbcp requires the destination folder to be the last argument. bbcp user@remote:/a/file1 user@remote:/b/file2 destination_directory I would like to download all the files and then mv them into place in one go, preventing problems...
This script converts a server load value into percentage, compares it with non desired state ($warning and $critical) and returns all information in NRPE (Nagios Remote Plugin Executor) friendly output. Desired output: CPU_CORES=1 load=0.30 | load_in_percent=30;95;100 (And the main thing exit code.) Goal: Use so much l...
the code is very messy, long and I am looking how to shorten it and/or simplify it. There are a lot of repeated variables, for example; 'hourToDay' and then 'hourToDay1', 'hourToDay2' and so forth. Can you help me find a better way to make this program more efficient? P.S - I am a new coder and wanting to improve my ab...
I'm using RxJs for type along search, I setup an observable to emit a value after 1 second so it behaves like http with delay. I subscribe to it via the async operator in the template, the component has a switchMap to watch the searchTerm observable. Is this how typealong search should be implemented with RxJS? I've in...
I implemented the following mergesort algorithm in JavaScript, but I want to know your opinion about if is possible to do better than this. function mergesort(list){ if(list.length < 2){ return list }else if(list.length > 1){ let n = list.length let middle = n/2 return merge(merg...