instruction
stringlengths
71
71.9k
Please help me to improve the JavaScript validator plugin by making it more OO and robust. Requirement is to trigger the validation if there is an attribute data-formValidate present in the input tag. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>SignUp</title> <style> .error { ...
#include "stdafx.h" #include <exception> #include <string> #include <sstream> #include <iostream> #include <atomic> template <typename T> class Singleton { //thread safe atomic variable to check whether client is creating more than one instance static std::atomic_flag flag ; public: static T& getinstance(...
I have read the code reviews on this website: this one and this one So creating the pool in itself might not be that difficult, I'm more worried about the client closing the connection or the connection not being given back to the pool. So I have tried to implement this answer. public interface Connection { Object ...
I am creating a simple dungeon crawler game. My program runs and does what I want it to do so far, but I am starting to run into difficulty with adding new functionality, and I think one of the main issues is my class design. I want to refactor my classes according to proper OOP principles, of which I am attempting to ...
I'm trying to build an application which automatically refreshes the page with fresh stuff from the server. I was trying out the approach with something basic like printing out the time, to test out my approach. I go to the page, and it starts printing the time every 5 seconds in the console. When I switch to offline m...
I'm developing a webapp in ASP.Net MVC. One of the requirements of the project is that users follow a "workflow". The workflow has a number of steps, and a conditional branch. The workflow is long running (week+) and most steps rely on one or more API calls to a 3rd party. I have previously wondered about application "...
Write a function called manipulate_data which will act as follows: When given a list of integers, return a list, where the first element is the count of positives numbers and the second element is the sum of negative numbers. Sample code def manipulate_data(data): if isinstance(data, (list, tuple, set)): ...
Hope this is the right place. I've never developed on a team so never had any feedback on my code and I'd like to know what others think. I'm using this in a current project and it is working really well. I couldn't find anything ready made to do what I needed so I figured I'd make it. Github repo if anyone is interest...
I am a beginner in Java and I have a hobby project to create a tool for statistical calculations. Users can upload csv with results of a survey. The responses stored in a Response object which has two maps: Map<Integer, String> questionMap, Map<Integer, String> answerMap, where the integer(questionID) links the questio...
This is one of my first python projects. I decided to make a semi-complex login system in Python, using MySQL and the Twilio API. The current features are: Multi-account support Two-Factor Authentication Password Recovery Password Change I want some feedback on the code itself. I'm thinking of making a version 2 that...
I've come up with a way to externalize and read in my .sql files instead of having them in-code as strings. Note that I'm keeping the .sql file in the same package as the DAO (NOT separated into a separate resources folder). I'm curious what others think about this methodology. The sqlStatement is inject on class ...
I am designing a very basic file listing layout in HTML and CSS. Although its working but I would like to know if the following code could be improved upon so that its more good and follows the best practices. I am looking forward of supporting I.E 9+ too. Plus I would like to add a progress bar behind the left-wing. I...
I have just completed my first JavaScript/jquery project. It searches customers from .JSON file and sorts them by name or ID. Everything just works fine. The thing is, I am not sure that I have understood all the functions and methods that I have written. Could anyone tell me if this is the best way to read .JSON file ...
This is my first time trying to do anything proper in Boost::Asio, so I would love if someone could look at it and tell me if it makes sense. It's based on examples from documentation and bit of googling around, but I want to know if I've put it correctly together. I know this code doesn't do anything useful. I want to...
I've tried to make the code overall more PEP-8 friendly and added more comments to make it more readable. Added some new functions and methods like ranged attack and allegiance. Play around with it. Use "a" to give characters more moves, "s" to spawn more characters, "d" to spawn Goblins that move randomly, "f" to atta...
I've been wanting to go async with my HTTP calls but all the methods I tried have not worked, so I resolved to implement this as a task and then improve upon it. This is what I've come up with so far. Any noticeable improvements or unused techniques to make this go even faster and still produce viable images? Public Sh...
First of all: Sorry for my English, that said... I am developing an obligatory for my University, so far it has a class that provides the user with options to connect to a server (once connected it should offer other functionalities, but I only reached the connection option so far), it only shows console options, and c...
This is a old email eraser that deletes old unwanted email from your gmail or yahoo inbox, cause guys really we all had the nightmare of selecting and deleting 50 old emails at a time when their are thousands, well this one uses simple python imaplib library to do that, and even shows the email that its deleting with s...
I am looking to increase the speed of this Excel VBA Nested Loop. The loop compares dates from one sheet to a secondary sheet. If they match, I change the border around the cell to highlight it. It currently works fine, but takes about 30 seconds to process per sub. Is there a way to implement an array or other tact...
I'm creating an array of dates that won't be selectable in a calendar. The following works, although the way I've gone about it is quite long-winded. I was wondering if there is a more elegant way of getting all the dates in a month, where dates don't fall on various days a project does run on. It's probably more clea...
I've been trying to teach myself Rust, and I decided that a simple console calculator would be a good project to learn from. use std::io; extern crate regex; #[macro_use] extern crate lazy_static; use regex::Regex; fn main() { loop { println!("Enter input:"); let mut input = String::new(); ...
Is the following a good way to use the revealing module pattern? $(document).ready(function() { var wordsCounter = (function() { function init() { bindEvents(); } // cache dom var $textArea = $('#textArea'); var $words = $('#words'); //a span var $chars = $('#chars'); //a span fu...
Could you suggest any improvements in this Lucas sequence's implementation: from mpmath.libmp import bitcount as _bitlength def _int_tuple(*i): return tuple(int(_) for _ in i) def _lucas_sequence(n, P, Q, k): """Return the modular Lucas sequence (U_k, V_k, Q_k). Given a Lucas sequence defined by P, Q, re...
As an integral part (pun intended) of my APL interpreter (previous questions: 1 2 3 4), this suite of functions converts any data into integer handles. APL operates on arrays of data cells, so with this encoding my cells are all int but may semantically contain other types. This enables me to have heterogeneous arrays ...
I recently had quite a lot of fun answering a Stack Overflow question, and I think I've gone a bit overboard and ended up with a fairly decent way of populating a ComboBox from a Range. Given a simple UserForm featuring some ComboBox1 control that I'd want to populate from a ListObject on Sheet1, the calling/client cod...
I am currently writing a Java interface to a C library. It mostly just delegates calls and adds a object oriented layer on top of it to make integration into a regular Java program more natural. The C library talks to a (local) server which in turn communicates with a real device. My current design uses dependency inje...
I wrote a library for card games. To demonstrate how it can be used, I also wrote an Exploding Kittens card game as an example. I'm using CodeClimate to determine cyclomatic complexity. This method in the Exploding Kittens game has complexity too high (6): def play_card(self, card: KittenCard, player: Player = None, t...
Assignment: Write a program which reads a number n from the console. Then calculates the sum of all odd numbers between 1 and 2n + 1 (incl.). Assignment also on GitHub, Exercise 0.0. The functions read_hex and print_eax as well as the header and tail of the script are provided by the tutor. format PE console entry...
I wrote a simple console game, with the idea taken from a Reddit post. The basic Idea is: Player, controlled via arrow keys, has to escape the maze (reach the exit marked X). If a 2nd player is enabled, he controls a troll via WASD and has to catch the player before he reaches the exit. The 1st player can push walls ...
I was amazed by std::variant and got inspired to write my own. For now, it supports constructor+destructor pair, assignment operator and get<>() function to retrieve the value. The object doesn't allocate any dynamic memory. All of the supported functions are type safe. I wanted to use static_assert(), but I found that...
I wish to get rid of using switch case with statuses twice in my code. But create_message function will be bigger in the future, so must stay and I don't want to create messages in send_user_push_notification directly. Any ideas? def send_user_push_notification(order, parse_events) now = Time.zone.now case parse_e...
This program is one of the exercises I solved in my book. Can anyone suggest any improvements to it? import java.util.Random; import java.util.Scanner; public class GuessMyNumber { public static void main(String[] args) { Scanner in = new Scanner(System.in); Random random = new Random(); System.out.pri...
Last night I was messing with image programming in C# and I tried to make a program that takes an image and transforms it into another image, built with emojis. EmojifyEngine.cs /// <summary> /// Holds all methods involved in transforming a image into a emojified version of the image. /// </summary> static class Emojif...
I'm currently working on implementing overloaded operators for simplifying pop() and push() operations. Check out the //how can avoid this? comments. I've had some troubles understanding how to return a certain value without causing memory leaks due to unassigned free space: so far the only dirty and inelegant idea I'v...
I'm new to Haskell, and am trying to learn the basics with a simple function that will calculate the list of primes up to a given value (using the Sieve of Eratosthenes). Here is my code so far, which has the problem of becoming very slow for large inputs nmax: primes :: Integer -> [Integer] primes nmax | nmax <= 2 =...
I was trying this problem from a competitive forum: Remove the repeated characters from the input string and output the resulted string. Input string: "abcabd" Output string: "abcd" The minimum test cases are passed. Please provide your comments. string input = "abcabd"; string output; int len = input.length(); ...
I need to turn a lot of html elements as editable elements. You will double click on the element to edit, press enter to validate (send a PUT to the RESTapi), press esc to undo. I've written this piece of code. Are there any performance improvements to be made? var editable = (function() { var DELAY = 300, ...
I've made an IDE in Java, using swing. It uses a couple of resources (prefs.json and help.txt) and some imported .jar files for reading the JSON. I know the code's quite long, but the answer doesn't have to be a very detailed one. package io.j4cobgarby.github; import java.awt.BorderLayout; import java.awt.Component; i...
This code seems surprisingly fast at checking if a number is prime. def is_prime(number: int) -> bool: """Checks if a number is prime or not""" # number must be integer if type(number) != int: raise TypeError("Non-integers cannot be tested for primality.") # negatives aren't prime, 0 and 1 aren'...
I have a self referential database table: CREATE TABLE category ( id INT PRIMARY KEY, name VARCHAR, parent_id INT REFERENCES category (id) ); And the following INSERTS: INSERT INTO category (id, name, parent_id) VALUES (1, 'Programming', null); INSERT INTO category (id, name, parent_id) VALUES (2, 'Python...
Original code: Getting name from user, and handling any errors in C I fixed the bugs. Is there anything else to consider? #include "stdafx.h" #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdbool.h> #define BUFFSIZE 10 /*Checks to see if name contains actual characters and not just whitespace*/ ...
I have implemented my own Observer pattern. I want to post my events in a new thread. This thread would simply call all the the observers/listeners with the posted event. public class EventManager { private ArrayList<Observer> observerList = new ArrayList<>(); public void post(Object event) { new Th...
The mall management is trying to figure out what was the busiest moment in the mall in the last year. Each data entry includes a timestamp (seconds in Unix Epoch format), an amount of people and whether they entered or exited. Example: { time: 1440084737, count: 4, ActionType: "Entry" } How can I refactor th...
I just want to know what can be done to make this code smaller in a nice and easy way. Tests using System; using Vegan.Test.TestClass; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Data.Entity.Validation; using System.Linq; namespace Vegan.Test { [TestClass] public...
I've written a simple module that creates a fully connected neural network of any size. The arguments of the train function are list of tuples with a training example array first and an array containing its class second, list that contains a number of neurons in every layer including the input and the output layers, a ...
I spent an hour or so this morning compiling this, and since I have started reading Clean Code and The Pragmatic Programmer I figured I would let you help me get slightly better at this. Due to some crappy limitations with the specifics I was forced to work in Excel VBA instead of Access (someone doesn't want to build ...
I've created a function that takes an integer greater than zero as an input and converts it into its corresponding Roman numeral. If you're not familiar with Roman numerals, you can read about it on Wikipedia. I've tested this code with some examples, so it should be working correctly. I'd be interested in hearing ab...
In my Server class, I have a few methods that handle different queries to be sent to the database. Everything works fine, but I really want to DRY up this class, because I feel like it could be much better written than it is now. The class is designed to strictly handle all client to server interactions by having all p...
I want to test a simple controller and I want to know if this unit test covers all cases: Controller: @RequestMapping(method = RequestMethod.GET) public List<Tags> getAllTags(@RequestParam(value = "query", required = false) String query, @RequestParam(value = "limit", required = false) Integer limit, @R...
This class was inspired from Microsoft's array_view. It intended to use with mmap-ed memory for easily check bounds and so on. I probably will need to throw exceptions, but this is not my usual way of working. Any comments are welcome. #include <cstring> class BlobRef{ public: BlobRef(const void *mem, size_t const...
I was doing some sample example which were perfectly fine. But, when I read about SOLID design principle, I had to change my code. I have implemented DIP and DI (Constructor Injection) in my code. Please let me know whether I have implemented successfully or not. Old code before SOLID design principlss: class Program {...
I've inherited an Access database and am looking to start using it to do reporting. I've written a query that gets me the information I'm looking for, I'm just hoping someone can have a look over it and tell me if I'm doing it the wrong way or not. Anyway, the query takes information from 3 tables: sites - more detail...
I've been a developer for many years, but have always put together files of lists of functions to do everything that needed to be done (instead of using classes/objects like I should be). I've recently started forcing myself to try to get into more object-oriented programming. I wanted to get some feedback on whether ...
Below is a Python implementation of the quicksort algorithm using parallelism. It takes about 1 second per every 10 items in the list, which is hilariously unacceptable. Why is it so slow? from multiprocessing import * def quicksort(lyst, connection=None): if len(lyst) > 1: pivot = lyst.pop(len(lyst)-1) ...
I have made a RESTful API built with Node.js, Express, Basic-auth and Mongoose. it will respond JSON. This is the folder structure: . ├── index.js ├── lib │   ├── middleware │   │   ├── Authentication.js │   │   └── index.js │   ├── routes │   │   ├── Account.js │   │   └── index.js │   └── schemas │   └── Account...
Here is exercise 2.6 from SICP: Exercise 2.6: In case representing pairs as procedures wasn’t mind-boggling enough, consider that, in a language that can manipulate procedures, we can get by without numbers (at least insofar as nonnegative integers are concerned) by implementing 0 and the operation of adding 1...
Can anyone suggest any improvements? I already applied here the suggestions that was made for my first program (Guess the Number) that I posted. import java.util.Scanner; public class Temp { // convertion of fahrenheit to celcius and vise versa public static void main(String[] args) { double celcius, fah...
I'm working on Tic Tac Toe and I want do it for any ROW x COL board with any WIN_SIZE (e.g. 4x4 board requires 3 to win). I've done the hasWon method already but I'm not sure is it done right. Can you check what can I do better here? public boolean hasWon(Seed theSeed) { int count = 0; for (int col = 0; col < ...
I am currently working on a C# WPF project following the MVVM design pattern. I am using Autofac and Prism as core frameworks in the design. For unit testing I am using Xunit and Moq. I am also using the Automock Moq extensions in unit testing to help ease the creation of my models. For a prism event, I am to running a...
I order to speed up opening of a file (which contents are displayed in a series of tabs), I made it so that tab content is generated only when the user first clicks on the tab. If user never opens the tab, code never executes. The problem is I could not any find any TabPage events that would trigger when that tab is se...
I'm quite new to programming and was hoping you wouldn't mind taking a look at my code and giving some points as to how I could clean it up. Assignment guidelines: Create a program that reads multiple choice questions from 1 file and gives 10 random questions to the user. Do Not uses classes. Example of how the que...
I want to find if 'N' numbers are even or odd in the fastest way possible. Here's the following code which produces the desired output, but I do not know how efficient it is. int main() { int N,x; scanf("%d",&N); while(N--){ scanf("%d",&x); x&1 ? cout << "No" << endl : cout << "Yes" << endl; } return 0; Can th...
The following code books one appointment for one or more slots. I have never used database before, but have seen so many warnings regarding SQL injections. Since it has never affected me I have not paid attention. <?php include('php/connect.php'); if(isset($_POST['slots_booked'])) $slots_booked = mysqli_real...
I have been working on a script that can be used to automatically pull the batch ids that were processed 4 days ago and which need to be processed tomorrow on the server. The batch IDs from 3 days ago need to be processed the day after tomorrow, etc. The script only needs to output the processing dates for all batch ID...
I have written a very basic bandwidth usage monitor in C++/winpcap. I would like to get some feedback, regarding design choices, implementation, style, correctness. (Or anything else you care to mention for that matter). Win TaskManager schows 0% CPU usage and 1,7MB RAM, and the program runs and updates the files as ex...
I've inherited an existing application which is a WPF implementation of toast notifications. This application is installed to multiple client PCs across the estate and, once installed, runs in the background. The notifier then works regardless of who is logged onto the machine. One of the improvements I have been asked...
My code is as follows : import React, {PropTypes} from 'react'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import { filter_names } from './filterActions'; import Price from './price'; import Year from './year'; import Make from './make'; import Model from './model'; import Mileage from './...
I'm still learning C++ and also algorithms. So I'm expecting to do a lot of refactoring. Here's my code #include <iostream> #include <vector> #include <iterator> std::vector<int> mergesort(std::vector<int> &); std::vector<int> merge(std::vector<int> &, std::vector<int> &); std::vector<int>::iterator get_midpoint(std::...
I have been asked by a client to program a bot which searches Google and will show how many no of results I get. Note: I know about Google Custom Search API and it will not produce the exact output produced by the real google since it is searching only in particular domains My Code (With GUI): # SWAMI KARUPPASWAMI THUN...
Am I using the best conventions or are there better ways? static void makePigLatin(String text){ String[] textArray = text.split(" ") String buffer, translated for (int i = 0; i < textArray.length; i++) { buffer = "" translated = "" for (int j = 0; j < textArray[i].length();...
Here is my generic method for creating linq expression based on field name of a type, operator (as enumerations of operators generated from XSD) and value of field private Expression<Func<T, bool>> GetCriteriaPredicate<T>(string fieldName, OperatorRef selectedOperator, string value) { PropertyDescriptor ...
Here is a Battlehips game in F#. Now, before you start jumping up and down on my code, please understand that, for all its awesomeness, F# has a serious limitation: Its compilation is linear, and the solution structure cannot have folders. Any code that uses other code must be below the other code, whether in the sam...
I needed Line and LineF for the next stage of a project I'm working on, so I developed them. I also needed to determine if two lines intersected, preferably as cheaply as possible. (Lots of physics calculations.) So, I built Line. Then I built LineTests, then LineF. The intersection code is my favourite part, essential...
I wrote a program in Python and in Java to search for the smallest integer solution of the equation: $$a^5+b^5+c^5+d^5=e^5$$ (expected output is \$133^5 + 110^5 + 84^5 + 27^5 = 144^5\$) Powers and roots are either computed directly ("direct calculation" method) or computed and stored in an array ("power lookup" method)...
I have not yet developed a satisfying coding style in Haskell. In the code snippet below, there is a lot wrong to my taste: Helper functions which should be local to showEngFloat are defined outside. let ... in indentation madness More than 80 columns Can you show me how this same code can be written in a less indent...
I can have one of the following strings: var username = "i:0#.f|myprovider|domain\\myuser" var username2 = "myprovider|domain\\myuser" var username3 = "myuser" I always want only the myuser part of the string! I tried the following in JS var n = username.lastIndexOf('|'); var domainandusername = username.substring(n +...
I'm trying to solve this problem from the Australian Informatics Olympiad here. (These are past questions which I'm completing for the purpose of revision, if you are worried about the integrity of the competition, and unfortunately the organisation doesn't provide answers). Basically, when given an input with: a list ...
I have wrote a small C++ class that provides some basic serial I/O functionality (it uses the standard GNU/Linux API). At this stage is working fine, before adding new functionality I want to get some feedback for the current code. I structured the classes like this: There's a pure virtual class called AbstractIOHandle...
The code below is a working excerpt from a larger application that I am re-factoring. My question focuses on the performance aspect of using (or not using) objects in this case. I have a medium-ish size data set on a worksheet (6500 rows by 12 columns) and am building an application to merge (mostly) new data records w...
I've got a basic python function that I've been tasked with finishing in a class. It's already fulfilling all the requirements for an A as it's an introductory course to Python, but I'd like to get some advice on it still as it's taking quite some time to execute. I've got a few years of experience with general progr...
I have implemented the following logic: a base class, Animal, has a vector, friends. A derived class, Dog, then inherits from Animal. I then want to implement a set_friends() function that can be passed a Dog object and then fill its friends vector. I then want to be able to call print_friends() from the base class to ...
I've created this code (used the validation creation section from here) which creates dependent dropdown lists based on data which is in a pivot table style arrangement. The idea is that picking a client gives the options of what projects relate to that client, and picking the project gives options of milestones based ...
I have recently been trying to build a parser. After a month of trying and getting nowhere fast I decided, like I should have at begining, to research how parsers work and what they do. After a little research, I learned that parsers create a tree like structure of the language grammar, official called a abstract synt...
I have had an assignment to construct a movie knowledgebase and ten specified queries in Prolog. This is my first ever Prolog program, so I would appreciate any pointers toward how I could improve. We were instructed to not define any additional predicates than the three specified in Movie, and print_query_true and pri...
This is for homework but the deadline is over and I know the implementation is correct because it concurs with the math. At this point I just want to check my implementation for potential optimizations in terms of speed, memory usage, clarity, modularity, and anything else you guys might think of. (I know there is gene...
I have a little experience working with .hl7 data (format for transmitting health data), so I decided to try and write an .hl7 parser using fparsec. A standard .hl7 segment is a single line with: First 3 chars are the header Next 5 chars are the separators (typically |^~\&) Fields / repetitions delimited by pipes A s...
Given an unsigned integer \$N\$, I want to return \$P\$ with \$P\$ being a power of two such that \$P \ge N\$. Examples: 1 -> 1 2 -> 2 3 -> 4 5 -> 8 The goal is to provide a very fast implementation. This code is supposed to target a specific platform and we can make the assumption that the intrinsics used are suppor...
Recently I started focussing on semantic HTML. And strangely I still find it quite hard. Could you guys please check this file and give me some tips on what I can do better? Also Is it bad to use the "form" tag for only 1 input? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ...
LifeTracker.h #ifndef _LIFETRACKER_H_ #define _LIFETRACKER_H_ #include <vector> #include <algorithm> #include "MySIngleton.h" class LifetimeTracker { public: LifetimeTracker(unsigned int x) : longevity_(x) {} virtual ~LifetimeTracker() = 0; friend bool Compare(const LifetimeTracker* p, const LifetimeTr...
I needed a way to make a CLI based script a bit secure. So, I thought of the following workflow: the client will get the MAC of the user, sha256 it and put it in a file at a specific location then in my program, I'm also doing the same thing, check to see if the sha256 of the MAC is present in the file (and if it matc...
Recently I have been wanting to get better with Python, in particular with Python 3.x features and Python OOP, so I wrote what I thought at first would be pretty simple, a TicTacToe game, which turned out to become pretty complex after adding all that I wanted. Some of the features I added, besides the basic game logic...
Following this question, I've rewritten my module as follows: ;(function(ns) { //anonymous and auto-executing function for the module definition //default options for addEditEvents() var defaults = { element: $("body"), selector: "li", url: "", idInUrl: "", idAttr: "", ...
I have a standard Edit action in Asp.Net MVC 5 and I want to avoid throwing the unhandled exception when is made a get request without the id like ~/food/edit, so I did this. public ActionResult Edit(int id = 0) { if (id == 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } stri...
I have written a JS code to modify the structure of the table by parsing the webpage for particular table class and store the rows of the tables in an array. And use the array for the constructing a new table. The codes are below. (function() { 'use strict'; var headElements = new Array(); var bodyEleme...
I wrote a generic Queue that could with work any data type you give it. The Queue can do any the basic operations that you would expect a Queue can do such as enqueue, dequeue, peek and so on. I would like you to critique me on: My general style My ability to properly deallocate memory so that there is no memory leaks...
In the slow progress of the project that generated my all-but-tumbleweed previous question I've needed to make sum-unions (any better term?) of simple objects where key:value is sizeClass:tally -- I need the union of all sizeClasses, summing their values where they're the same. I came up with this and I wonder whether...
"ONE" and "ZERO". The basis of this project is in this video -> links to his code can be found in description In it the speaker asks you to check his math; I wrote my own code and then compared it against his. It is also in the other GIST i am adding to stack-exchange -> Credit for that code goes to MATT PARKER. TL;DR...
So Stackoverflow Documentation has added "Contributor Breakdown". For any given topic (and example) people can display who contributed in which way. That page is only available if you know the link though. And it's not linked publicly in any way. Since I like these hidden pages, but I keep forgetting the correct URLs ...
#include <iostream> #include <vector> #include <algorithm> template <typename T> int copy_max(T& to, T& from, unsigned char delim, size_t limit) { typename T::iterator pos = std::find(from.begin(), from.end(), delim); typename T::iterator prev_pos = pos; if(pos == from.end()) { return -1; ...
def mergesort( array ): # array is a list #base casee if len(array) <= 1: return array else: split = int(len(array)/2) #left and right will be sorted arrays left = mergesort(array[:split]) right = mergesort(array[split:]) sortedArray = [0]*len(array) ...