instruction
stringlengths
71
71.9k
I'm having a lot of trouble in my Database program with trying to implement an effective DataGrid filtering method. After taking advice from a previous code review I'm trying to implement a DataModel method of coding. My previous method of searching my DataGrid was this; SearchGrid (PREVIOUS) private void SearchGrid(ob...
I'm serializing multiple elements using this code: public IEnumerable<Customer> GetCustomers(xmlString) { var xml = XElement.Parse(xmlString); var customers = xml.Elements("Customer"); var serializer = new XmlSerializer(typeof(Customer)); return customers.Select(c => { using (var reader = c.CreateReader()...
I am new to programming and I have just written my first program. It takes files from an SD card and copies then into a new named folder and has the option to name the files themselves or simply move them into the named folder. As I am new I am unsure of the correct convention in terms of layout or structure of a progr...
I am asking your preference between two similar solutions. First way : public function test($myvar) { switch ($myvar) { case 'test1': return [ 'value' => 'Value of test1', 'short' => 'Val 1' ]; break; } } $this->test...
I log records in external memory. Every record takes \$2\$ bytes. Now I need to read \$N\$ last records in chunks of \$18\$ bytes, so I did something like this. uint32_t chank = 18; //DELTA_SIZE * AVAILABLE_BUF_SIZE; uint32_t last_log_addr = (logNum * DELTA_SIZE) + START_LOG_ADRESS; uint32_t packet_size; uint32_t curr...
I am working with an object that needs to run an ExecuteEffect() method. Sometimes, the ExecuteEffect() only needs to run once, while in other cases, the ExecuteEffect() needs to keep running once / frame until some criteria is met (in my example, a real-time delay). To solve this, I used an IEnumerator: public overrid...
This builds a BinaryTree from given Inorder and Preorder lists. class TreeNode(object): """Node of a Binary tree.""" def __init__(self, key, left=None, right=None): self.key = key self.left = left self.right = right def __str__(self): return "{0}".format(self.key) def __repr__(self): ...
I made a data entry form that writes each category into a text file. As an example I used Regular, Premium and Diesel categories. They each have open, delivery, total, sales and close numbers for that day. How can I can improve my code? Also I tried to implement the login form but I couldn't get it to work. import tki...
I've created a search page on a rather large Audit table (populated by triggers on every database). There are 4 fields you can search by (and I put each textbox next to each other): User ID, Table ID, Date, Record ID. This is for programmer's use and high level managers who would know what these fields mean. Record ID ...
As a first step to making a PacMan clone, I wrote a Breadth-First Search demonstration that updates itself live as you draw walls and drag around the start and end points. It was inspired by the site that I learned the algorithm through, which has similar demonstrations. A sample of it: To use it, use the mouse to dra...
// ConsoleApplication1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <cstdlib> #include <iostream> #include <cmath> using namespace std; int main() { system("cls"); system("color 5"); float a; float b; float c; float Sector1Arithmetic; float S...
Objective: Given a set of sequences ( eg: step1->step2->step3, step1->step3->step5) ) arranged in an array of lists, count the number of times every contiguous sub-lists occur Where I need your help: The code below works, but is very slow on my original dataset (100M sequences, with 100 unique steps). Can you help me ...
I was asked to implement this in an interview a while back. I didn't pass the interview, mostly likely because it took me far too long to do. However, I'm interested to know how well implemented the actual code is. The task was to: Add one to a positive number represented as an array of integers. The question is the ...
This is one of my first Python scripts and I was wondering if it meets the correct conventions. Also are there things that you would write different? I am looking for some good comments so I can start to improve my Python code from the start. (I was not supposed to use imports here) Here's my implementation of Simplifi...
So basically, a user is prompted to input a number of stairs and a staircase when a guy on it is generated. I know this is sloppy and my variable names are rough, I'm actively working to change them now. I thought I would go ahead and post the working code though. How can I improve on this? What can I do better to do m...
Here's my custom formatter which I want to use for "application/x.product" content type: public class ProductFormatter : MediaTypeFormatter { public ProductFormatter() { SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/x.product")); } public override bool Can...
Right now I have no knowledge of templates, but I just finished learning about inheritance, and wanted to apply it to a Vector3 class that I had already created. My thoughts were that vectors of different dimensions share some common operations, and so it should be possible to apply an inheritance hierarchy to this. Ul...
This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It was well described how to implement the precomputed table but somewhere I seem to have miserably failed since the code ru...
We typically do our saves and deletes for our asp.net pages (SQL Server as back-end) in the code behind. I've seen some reference the idea of creating a stored procedure for this purpose. Is this the best approach or is what I'm doing practical enough? Any suggestions? Here's an example of the delete button function (f...
I've written a small bit of JavaScript which parses some HTML and generate a table of contents based on the various heading tags. The table of contents needs to be nested (E.g. H2 tags appear under H1). My code is currently working well but I'm not sure the my method of storing all the headings is the best (it's been a...
I have written code that reads in a CSV file and creates a tuple from all the items in a group. The group ID is in column 1 of the table and the item name is in column 2. The actual datafile is ~500M rows. Is there any way to make this code more efficient? Input file: "CustID"|"Event" 1|Alpha 1|Beta 1|AlphaWord 1|Delt...
I'm looking for some performance suggestions. The purpose is to toggle a data attribute value indicating when an element is either in view or out of view. You can also assign callbacks to be called when the element comes in and out of view. Secondarily, it indicates the direction of the scroll by adding a data attribut...
One of the most important parts at the core of rubberduck is the IdentifierReferenceResolver class, which is responsible for resolving each declaration as the parse tree is being walked and function, member and variable calls are being encountered. Proper scoping is the single most important concept here: when we meet ...
I am taking a class on ruby and our assignment is to take user input and print out a polynomial. Wondering if I can get any feedback to how to improve my code. class PolynomialElements attr_accessor :element, :size def printElement if size.to_i == 0 num = "#{@element}" elsif size.to_i == 1 if e...
I recently gave a test on HackerRank: Given a string, return the most concise string that can be formed from it. For example: string = 'watson Represents|watson represents|Watson represents a first step into cognitive systems, a new era of computing.|first step into Cognitive|Cognitive Systems; a new era|what does w...
About 2 weeks ago I made a Java game of Tic-Tac-Toe. It turned out great and it worked but it needed lots of help before it became a decent program. Since then, I have worked out lots of the kinks and errors. I would love to know what you think of my improved program. public class ADitionalPractice { public static boo...
I've recently been learning Python and decided to write an IRC bot as a good first project. Before now I've only really written scripts. I am using the Python IRC library. The IRC bot joins an IRC server and multiple channels, logs the channels and makes announcements by listening for messages on a port. I've gotten t...
Problem statement Given a node check whether the sub-tree rooted at given node is full binary tree or not. Definition A full binary tree (sometimes proper binary tree or 2-tree) is a tree in which every node other than the leaves has two children. Solution class TreeNode(object): """Node of a Binary tree.""" def ...
I have a table which has tasks with several statuses, user can use filter check-boxes to show and hide rows based on these status filters. function toggleRows(checkBox, img) { var show = $("#" + checkBox).prop("checked"); var rows = $('tr img[src="../_layouts/15/images/' + img + '.png"]').closest('tr') if...
I am currently working on a Redis project and I would love to know where I am likely to run into Unhandled Exceptions in the following code. A General Review would be great, don't hold back. This is code for Intercepting using proxies, and uses a considerable amount of Reflection to resolve unknown types. I am posting ...
They've always annoyed me, and as a matter of principle, would like to leave my HTML/CSS intact and have the various file upload plugins work with consistent behavior with any styled element. The following script places a transparent file input over a selected input. Note that solutions such as triggering an upload sc...
Is there any better way of doing this? function getRandomColor() { var chars = '0123456789ABCDEF'.split(''); var hex = '#'; for (var i = 0; i < 6; i++) { hex += chars[Math.floor(Math.random() * 16)]; } return hex; }
I am developing an application to validate the interaction between activities through intents. I created 5 ImageButtons with an image for each. Each button is a movie and if you click any of them, it's directed to a new activity with a synopsis of the film. In the activity with the synopsis, there is an "up navigation"...
I have a method like this: public boolean wasUserInactive() { boolean result = userInactive; userInactive = false; return result; } This works, but is there a “smarter” way to code this?
Due to various business and technical circumstances, I have to create an internet-facing .NET 4.5 WCF web service which should be called only by a certain party while not using native authentication schemes (mainly because I don't have an SSL certificate available, which precludes X.509 and user/password authentication...
This is a simple implementation of vector in C++. Please offer your reviews to improve the code. #ifndef VECTOR_HPP #define VECTOR_HPP template <typename T> class vector{ int size;//size allocated on the memory int index;//current number of elements T* arr; void resize(){ T* temp = new T[size];...
I created a Sudoku game with varied difficulty level. The Sudoku board creation process consist three stages: Creation of an empty board Filling the board with numbers Making holes in the filled game board The assigned numbers fulfill all Sudoku game conditions, and every puzzle has a unique solution (verified in the...
In this project I'm working on, I need to extract articles text from their original HTML document. This class, HtmlConnection, receives the URL of the article, and eventually it needs to produce a collection of the paragraphs inside the article. I'm using HTML agility pack and XPath to extract only relevent text from t...
I have to create a table that will allow users to upload different documents for each of the entry in the table. To be more exact, each row will contain a unique ID on first column, followed by 3 inputs (upload) for video, text and image, and a save button (each on next column of the row). The problem is that I have a ...
This detects the difference between two objects (or revisions): var A = {A: 10, B: 20, C: 30, D: 90, BB: 5, CC: 4, AA: 2}; var B = { B: 22, C: 30, L: 4, KK: 444, A:15}; var difference = diff(A, B); console.log(difference); document.write("<pre>"+JSON.stringify(difference, 0, 3)+"</pre>"); function diff(a, b) { ...
I have this code that creates unique passwords using the first letter of each word from the file. Before each password is created (written to a file) it is compared to all passwords that are currently in the file, so if the file has 50,000 passwords before a another is written it has to scan through all 50k. A user ca...
This is my own implementation of an hashtable. I would like to receive some reviews or some feedbacks. public class HashTableEntry<K,V> { private K key; private V value; private HashTableEntry<K,V> next; public HashTableEntry(K key, V value) { this.key = key; th...
I have the following if statement: if ($scope.current < $scope.questions.length) { $scope.current += 1; } if ($scope.current == $scope.questions.length && $scope.chapter < $scope.all.length - 1) { $scope.current = 0; $scope.chapter += 1; } if ($scope.current == $scope.questions.length &&...
I wrote this class which reads an SSH config file and checks whether an IP exists. If the IP does not exist, the class adds a block for that IP address. Header file: class SSHConfigFile : public QObject { Q_OBJECT public: explicit SSHConfigFile(QObject *parent = 0); signals: public slots: void registerIP...
I have code that is identical minus two changes that would happen each time, which I can use variable for, but I don't want to use a bunch of if statements. C = 1 fnd = Sheet1.Cells(C, 8) While InStr(fnd, "Customer Name:") <= 0 And C <= 300 C = C + 1 fnd = Sheet1.Cells(C, 8) Wend If C >= 300 Then Sheet2.Cells(r, 2) = "...
I'm working on a hobby kernel, with graphics and rendering fonts. The font format is BDF. Some of them (like for Ubuntu Mono) I used was ttf2bdf. Then I use a program called bdf2c which converts it to a .c file. From there, I can use the data in my program. First, let me start off by showing you code that won't change,...
I am trying to implement a function that merges two ordered lists into a third (ordered) one, but duplicates have to be discarded (basically the last step of a mergesort). I think that this code can be generalized to an arbitrary number or lists, by keeping a list of indices, rather than 2 explicit ones. def merge_no_...
I've made a python program to convert DuckyScript code to Arduino code for Leonardo boards. Below you can find both the project files and a sample script. compiler.py (the program base): #!/usr/bin/env python3 """ Usage: {} <input> <output> <input> should be a DuckieScript file and <output> will be an Arduino sketc...
Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files: public static void convertToCSV(final ResultSet rs) throws SQLException, IOException { final DateFormat format = new SimpleDateFormat("yyyyMMdd,HH:mm:ss"); format.setTime...
I recently developed a simple treap data structure in C#. In the future, I may have the class extend IDictionary. For now, I only expose a public accessor and a delete method. public TValue this[TKey key] { get { return Get(root, key).Value; } set { root = Set(root, new Node(key, value)); } ...
Write a program reads two integers representing a month and day and prints the season for that month and day. Assume that months are specified as an integer between 1 and 12 (1 for January, 2 for February, and so on) and that the day of the month is a number between 1 and 31. If the date falls between 12/16 and 3/15, ...
I have a dictionary which I use to lookup my binary and ASCII values (from A - P). It works, but my ascii2bin function just doesn't really feel right (and beautiful). Is there is a better way to write it? The ascii2bin function splits a 2-letter string (i.e. 'LA') and looks up the keys in the dictionary. Then concaten...
Given two int values, print whichever value is larger. However if the two values have the same remainder when divided by 5, then the print the smaller value. However, in all cases, if the two values are the same, print 0. This is what I have so far: public static void main(String[] args) { Scanner scan = new Scanne...
I have two implementations of a function that prints out a basic board for Tic-Tac-Toe. Which of these should I include and why? def display_board(board) for i in 0...9 print " #{ board[i] }" if (i+1)%3 != 0 print " |" elsif i != 9 print " \n#{'-'*11}\n" end end end def display_board(...
I want to show users what package they are, based on how many items they have in their cart. The code works, but I'm wondering if anything can be improved. function new_thing (){ //decleare variables global $x_subs; $lim01 = get_option(woomps_limit01); $lim02 = get_option(woomps_limit02); $lim03 = get_option(woomps_l...
Here is my attempt at implementing the Acyclic visitor pattern from here in C++11. The aim is to obtain an implementation which is easy to use and avoids all the boilerplate as much as possible. I would also like to keep the use of macros to a minimum, to keep the code readable. To use it, one makes the visitable base ...
Write a function lucky_sevens?(numbers), which takes in an array of integers and returns true if any three consecutive elements sum to 7. lucky_sevens?([2,1,5,1,0]) == true # => 1 + 5 + 1 == 7 lucky_sevens?([0,-2,1,8]) == true # => -2 + 1 + 8 == 7 lucky_sevens?([7,7,7,7]) == false lucky_sevens?([3,4,3,4]) == false ...
I recently got interviewed in a company for Senior level position. They asked me to develop auto-complete component (2 hours time limit) using plain JavaScript similar to this. I wrote below code, which works as expected, but they responded saying that the solution doesn't match expectations. Please help me figure out ...
I wrote a program that should check a dictionary that contains about 50000 other dictionaries. In those dictionaries, one of the keys has a list of words as value. Now, I iterate over those words, finding the words most similar to a queried input. However, it takes quite a while for it to finish. How can I speed up thi...
The aim is to duplicate and append each .grid__item into the .gallery element. The following code was my first instinct, and works fine, but can't help wonder if there is a more efficient way to write this. My concern is when the element count gets up to a high amount, that there will be some delay. Generate Dummy Elem...
I've got the following code that I use to output a list of all (public) fields in an object in an easy(ish) to read way. The issue with it is that the code is not easy to look at, and I'm not sure what I could do to improve it. I'm not too fond of all of the StringBuilders, the append calls are ugly and chaining them d...
The proper title of this question should be "Summations and products, and factorials oh my!". After getting quite a bit of useful feedback on this question from @mjolka, and a comment, I decided that there were many things to be improved. These are the following things that I've added/changed: A factorial function wh...
I have a few thousand json files containing order histories sitting in a directory from one of our systems. Since customers can opt in to receive marketing I'm opening each json file and then processing the data to scrape our active subscribers. At a later date I plan to expand this to bring this data into our CRM. As ...
Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams. In this problem you’ll be given two strings. Your job is to find if the two strings are anagrams of each other or not. If they are no...
I would like you to review the locking mechanism I implement in C# class. Will it be working correctly with many threads? Please don't mind rest of the code because I just try to repair the class quickly to have a thread safe logging class for my project. Any other suggestions are welcome. public static class Debug { ...
In my last post, I wrote a long, non-general tail-merging† facility for insertion sort. I thought I should instead write a general-purpose tail-merging function, that works even when the two lists are of different lengths. So here it is (requires SRFI 1): ;;; Returns a list that has the same content as `lst`, sharing t...
In Python it is really easy to get sliding window functionality using a deque with maxlen: from collections import deque deck = deque(maxlen=4) deck.append(0x01) deck.append(0x02) deck.append(0x03) deck.append(0x04) deck.append(0x05) for item in deck: print(item) # outputs 2, 3, 4, 5 This does two things - it gro...
MOTIVATION I have this small software package that allow users to maintain a simple text file that looks like tag1 path1 tag2 path2 . . . For example, it may look like home ~ root / funk ~/funky/funk Now, suppose the user is in the root directory /. When the user types dt funk, his current working directory changes t...
I have built a Twitter clone in Golang, using object orientation principles. I wish to know the design mistakes I have made. package blade import ( "database/sql" "fmt" ) type User struct { Name string Password string *sql.Tx } //User is a normal user who can login, register, tweet, retweet, ...
This is my first OOP PHP library and wanted to get advice on how I can improve what I wrote. This is what I needed to do: I'm also not sure on what it meant by "proportionally resize the shape up or down, given a floating-point scale factor" I think what I did what it meant but I could be wrong. Build a simple PHP lib...
I did a sample on Codility and finished the test task. The problem description is very short: The equilibrium index of a sequence is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For example, in a sequence A: $$A[0]=-7, A[1]=1, A[2]=5 ,A[3]=2, A[4]=-4, A[5]=...
This is a python implementation of the Alternating Direction Method of Multipliers - a method of constrained optimisation that is used widely in statistics (http://stanford.edu/~boyd/admm.html). This is simplified version, specifically for the LASSO: Given a sparse vector $$x \in R^n$$and matrix $$A \in R^{m \times n}...
I have written a basic ini file parser in C. It won't support big ini files, and isn't very fast when fetching configuration values, but should be enough for small ones. I couldn't find "proper" definition of ini file standard, so there is no handling screening symbols, and all and any error encountered during parsing ...
This code written by @Rahul Singh in this post: var result = _dbContext.ExtensionsCategories.ToList().GroupBy(x => x.Category) .Select(x => { var files = _dbContext.FileLists.Count(f => x.Select(z => z.Extension).Contains(f.Extension)); ...
I have a function that counts how many "assists" a team performs during the course of their day. The way I've written it feels bulky and inefficient using GregorianCalendar. Basically, the function counts specific types of assistance then returns the information in an object. Does anyone know of a cleaner way to do ...
I have finally assembled an attempt to create a thread safe logging class and also ensured by file flags that file should not be accessed by different processes at same time. This classed will be inside DLL. Below is the implementation, static class GMLogger { private static List<string> _buffer = new Li...
I wrote a function that finds the difference between two strings. This only works given that the difference is continuous. Beyond doubt this already exists, I am recreating this for educational purposes. I would like feedback about my performance and efficiency. Examples of this method: String difference = Difference("...
The code is self-explanatory. It has \$O(n)\$ complexity, and it tells whether a given string is the substring of the source string. Are there any cases where this algorithm fails? Is there anything that can be improved? public static boolean isSubStringOf(char src[], char target[]) { int pointTarget=0; for...
I'm fairly new to Java and was trying to make a program that's generates the primes from 2 - 100. I originally had a design of my own making but it was fairly inefficient so I did some research and come across the Sieve of Eratosthenes, which is supposedly the the efficient way to find primes from 2 - n. public class S...
This upvoted SO answer and this upvoted SO answer both check for null in a similar way: they call a function in the if or assert statement and "throw away" the result and then call the same method again in the success clause and operate on the result. I am new to Android development and have limited knowledge of Java, ...
I am trying to work on a WPF application and decided to go for Unit of Work and Repository pattern, along with MVVM. I am using Entity Framework as my ORM. Could you please do a code review? IGenericRepository.cs public interface IGenericRepository<T> { T GetById(int id); IQueryable<T> GetAll(); void Edit(T...
This code takes a integer x of range [0,127] as input, returns an array of four 32-bit integers, with x bits set. I'm trying to maximize switching to make it easier to filter out the ripple in the output. Another consideration is to make it fast because this code runs on an MCU (XMOS to be exact). Although this code wo...
I have a private container registry behind a firewall that will need some Google registry images. To make sure things are updated sanely, I'm writing a mirror script in Bash. I have one line that lists the images without their registry URIs, but it's overly complicated and I am piping through 3 awk statements. docker i...
Problem: A non-contiguous substring of string \$s\$ is a sequence of \$k \geq 0\$ characters in \$s\$, in the order in which they occur in \$s\$. For instance, the set of all non-contiguous substring of "abcd" are \$\{a,cd\}, \{ab,d\}, \{a,c\}, \{a,d\}, \{b,d\}\$. I want to mention this is from an assignment (which I...
I am about to post a question to Stack Overflow about how to do a better job adding a number to the list inside the User class. But I feel if I refactored this I might solve my problem with coupling my data like this. So I am open to suggestions. Ideone public static void addOrUpdate(Dictionary<int, User> dic, int key,...
I wanted to implement a bubble sort in Scala following the steps described in: http://www.bbc.co.uk/education/guides/z22wwmn/revision/3 import scala.collection.mutable.MutableList val result = bubbleSort(List(3,2,4,1,5)) def bubbleSort(list: List[Int]): (List[Int]) = { def doIteration(list: List[Int]): (List[Int], ...
I'm currently writing unit tests in Selenium (C#). I need to do two things in this particular test: Check if 2 errors (with html container) are displayed and check if another (given) error is not displayed. The test looks like this: bool errorWindowVisible = tmethods.IsElementVisible(driver, By.XPath("//div[@class='m...
I have users uploading files sometimes as large as 100+ GB to a local web server. The upload process works well and chunks come in at 50MB. The problem seems to be after the file is uploaded, when the web server assembles the files and the server (24GB RAM), despite not showing any graphical signs of memory pressure,...
I was looking through the JavaFX library, and I spotted that JavaFX DOES NOT HAVE A JOptionPane EQUIVALENT. (Or at least not in my version - as @Legato has said in comments, as of 8u40, there is a Dialog class. I use 8u25.) I decided the next step was to write a OptionPane class. Since JOptionPane has three types of op...
After reading about large files and memory problems, I'm suspecting that my code below may be inefficient because it reads the entire files into memory before applying the hash algorithm. Is there a better way? chunk_size = 1024 hasher = hashlib.md5() while True: try: data = f.read(chunk_size) except IO...
I have apparently correct code that still runs for weeks on my data (tens of millions of rows). I show the entire code for reference (and maybe other gains to be made), but the key operation is in the loop between lines 66 and 79. Basically, if a spell (spent in hospital) extended over a single calendar month, I wanted...
I am trying to make a ferry simulator with one ferry that works like a stack and another like a queue. I have a working class for stacks and queues with pop/push; I am trying to figure out how to simply this code for the ferry class. import java.util.Scanner; public class Ferry { static Stack ferry1 = new Stack...
I have a program which works but it is a bit too slow with big numbers. nbBlocs contains the size of the array, it can be up to 20000 and I enter the value inside on each position. nbQ is the number of queries (at most 20000 queries). For each query, it looks inside the array and tells me which is the closest value to...
This piece of code calculates the sum of all prime numbers below 1 million. It stood out to me that the Ruby script is around 20% faster. I know that Go should be faster just for being a compiled language. So how can I make the Go code run faster than it already does? I'm interested in solutions involving goroutines, p...
This is just a simple app. All it's suppose to do is move the dice around the screen when the user swipes up or down. It will move 2 dice (image drawables) to a position on the screen depending whether they swiped up or down. How can I make my code so it's more object-oriented? At the moment it isn't. Main.java public ...
This code aims to replace labels used to explain a text box's container. This is done by adding a default string when the text box is considered empty to explain the purpose of the text box. However, when the text box is not considered empty, the text box will behave normally. This is what I have written to solve my is...
For my computer science class I am tasked with writing a rock/paper/scissors game. I understand how to write the game, but I was wondering if someone more experienced than I could give me some pointers on how to become a better programmer. Is there anything I could do to reduce the size of the code, but without dimini...
I have been trying to implement parallel merge sort in Scala. My current implementation is about as fast as .sorted, but I have no idea what would be the right aproach to parallelize it. Input file with 1.2M integers: 1.333580 seconds (my implementation) 1.439293 seconds (.sorted) How should I parallelize this? objec...
The div and add functions are located randomly in my package structure. I have a function with this signature: def calc(x, y, func_name='add') How do I implement this function? My idea is to import all the modules, then use the dir function, like so: def import_submodules(package, recursive=True): """ Import all s...
I'm trying to learn how to write more readable code without introducing easily avoidable performance killers. This is part of a BitInputStream Java class I'm experimenting with. There are code parts before and after this provided segment to read less than 8 bits from iBuffer if data is not aligned to bytes - that's why...