instruction
stringlengths
71
95.1k
This code is a project that I am working on to eventually analyze some images but right now I am purely trying to read an image and convert it to black and white. The input should be either white or something else which would end up as black so it is easy to check for this. import matplotlib.pyplot as plt import matpl...
This simple game tries to solve the problem of a game that often end in a lock. It does so by providing the players with Xs and Os with superpowers. With great powers come possible disadvantages. For example the X- can delete an O already on the board, but because the effect contains a random element, it is just as lik...
Before a job interview, I was asked to create a program that can calculate the score of a bowling game. The full assignment and my code can be viewed on my Github. The company told me that this was not good enough, so I would like to get feedback about what's wrong and how to improve it. Assignment The game consists o...
I'm in the unfortunate position to where I have to create files and folders programmatically that have to work with a legacy system. In this process, the file and folder names have to be heavily sanitized. The POST requests that create the files and folders are sent from the client in javascript, while the actual creat...
Given a linked list and two positions m and n. The task is to rotate the sub-list from position m to n, to the right by k places. (link to GeeksforGeeks) Examples Input: list 1->2->3->4->5->6, m = 2, n = 5, k = 2 Output: 1->4->5->2->3->6 Explanation: Rotate the sub-list 2 3 4 5 towards right 2 times then the modified l...
I have been learning Java for the past two months, and started writing this task about simulating Bank and BankAccount to practise a bit of OOP and exception handling. Problem is I am not confident that the solution is ok. It is working fine, I just think it could be written better, but since I am a novice, I would rea...
I have this code and I would like to know if I filtered my code correctly. I am practicing my security coding for a system that I am working on and I would like to know if I am doing it the right way. If there is any thing that I can improve to get things more solid I would very much like to know about them. <?php requ...
While reviewing a PR, I found an enum being used like this: class Entity { public enum STATUS { NEW, SENT, FAILED, OK } @Column(name = "STATUS") // a NUMBER(1) column in DB private int status; // + get/set //... } // Inside methods... Entity e = new Entity(); e.setStatus(STATUS.SENT.ordinal()); Entity...
Scenario: I have an excel file that contains some data in the first sheet. That data can be simple strings on a cell or CheckBoxes (marked or not). Data example: +---------+-------+------------------+------+------------------+ | item1 | 2004 | | | | +---------+-------+---------...
If I create a class that implements IComparable<T>, I must implement CompareTo<T>. It is also recommended that I implement IEquatable<T> and the non-generic IComparable. If I do all that, I am required or encouraged to: Override GetHashCode() Implement CompareTo(Object) Override Equals(Object) Implement Operator ==(T,...
I am working on a choice-based simulation and players have to choose between different locations, I am pushing those choices to an array locationLog and my MakeStats() function below builds an array from it. I tend to break code into bits because it helps me, but want to make sure others can understand it. var hasAttor...
I'm making an e-commerce site, using MySQL for storing data. CREATE TABLE `admins` ( `id` int(10) UNSIGNED NOT NULL, `shop_id` int(10) UNSIGNED DEFAULT NULL, `name` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL, `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `phone` int(11) NOT NULL, `em...
I've written an implementation of malloc, realloc, and free. I wanted to make a malloc implementation that is sufficiently simple and easy to maintain. I don't care so much for performance, but I'd like to know if anything stands out that can easily be fixed. An explanation of how it works is in the source file. Other ...
I have an object (ShoppingCart) that has a list of CartItems, which contains the related Product and the quantity bought. public class ShoppingCart extends BaseEntity { @OneToMany(mappedBy = "shoppingCart", cascade = CascadeType.ALL, orphanRemoval = true) private List<CartItem> cartItems = new ArrayList<>(); ...
I am trying to learn what SFINAE is. I believe I understand it quite well; however, I do not have a lot of practice in the subject. I mean I would find it difficult to list all the cases in which SFINAE should or could be used, or it would be difficult for me to immediately understand what a given sample of an SFINAE c...
This is like the reverse functionality of Text file to spreadsheet. One or multiple .xlsx files in the path of the script get opened and the content is split into multiple .txt files. For example, say you have two excel files in the folder: file1.xlsx file2.xlsx The output created: spreadsheet_to_text.py """ Re...
I like to play word games that give you a set of letters and you get points for the more words you can make out of those letters. I have some code that works, but it's pretty slow. I was wondering if anyone had any idea on how to speed it up or if this is even the right place for this. Here's the code import itertools...
Background This year I've taken on the challenge of Advent of Code. The second challenge of the first day is to calculate a frequency for a special device based on a series of numbers. Here's a quote from the challenge describing the problem. --- Part Two --- You notice that the device repeats the same frequency cha...
I wanted to get some constructive feedback on my solution to the Fraudulent Activity Notification problem from HackerRank: HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. If the amount spent by a client on a particular day is greater than or equal to 2× the ...
I was solving Project Euler #7 on Hackerrank but for two cases, execution time is more than 2 sec. Can you help with optimizing? I'm new to programming. #include <stdio.h> #include <stdbool.h> /*INPUT EXAMPLE 2 -> no of test cases 3 -> 1st test case 5 -> 2nd test case */ bool IsPrime(unsigned long); int main(){ int...
I made an object tracker for debugging and testing purposes called ccm_counter (construction, copy, move counter). It counts constructor, copy and move calls. It can be used to detect inefficient forwarding and unnecessary (or unintended) copies. The behavior is as follows: What it does Let vector<A> be the type you wa...
It is sometimes necessary for a generator function to expose state. In those situations it is advised to wrap the generator function as method __iter__ in a class. Here is an example: class C: def __iter__(self): for i in range(4): yield i self.state = i It is convenient...
I made a simply user vs. computer game on Tic Tac Toe. I used Object Oriented Programming to increase my understanding of this programming paradigm. Can you criticize any design flaws I have in my code? #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 15 20:56:48 2018 @author: von-vic """ import r...
Given an input N as the size of a centrifuge, I need to find out the number of balanced configurations. The full description is here. Centrifuge is a piece of equipment that puts multiple test tubes in rotation at very high speeds. It consists of a cylindrical rotor with holes situated evenly along the circumference o...
Motivation I recently picked up Emacs. As part of the process, I've started to configure the editor to fit my needs with Emacs Lisp. The Elisp indentation rules are still foreign to me, so I pretty much depend on Emacs' electric-indent-mode to work. There's always C-x h and C-M-\ to the rescue, though. That being said,...
I'm trying to replace a number of keywords with other corresponding values. I started with this method: Dictionary<string, string> keywords = GetKeywords(); foreach (var pair in keywords) { var re = new Regex($@"\b{pair.Key}\b"); if (re.IsMatch(text)) text = re.Replace(text, pair.Value); } ..which beco...
I'm a beginner and I wrote this (working) code for n-ary tree. The specifics: Each node is to be built with an integer value. Each node has a variable number of children. The nodes should have an add(Node n) method, that adds a child node. The Tree should have a contains(int val) method, that returns a Boolean value...
Previous post: Display all files in a folder (object) along with nested subdirectories Task: Given a main directory/folder, list all the files from it and if this directory contains nested sub-directories, list their files as well. Background: It was bought to my attention that the use of dummyCounter is considered bad...
I created online shop with angular 7 and I am not sure is good architecture. I created 5 modules: main module products shop-cart core admin I have service : admin.service.ts products.service.ts data-storage-service.ts message-data.service.ts shop-cart.service.ts I have module for routing: app-routing.module.ts p...
I have two arrays: char input[] = "ughIuytLikeretC"; and bool mask[] = { false, false, false, true, false, false, false, true, true, true, true, false, false, false, true, }; My function takes these two arrays and returns the characters in input whose positions are true in mask such that in this example, ...
I am doing a simple application for a pet hotel. I have almost finished but I'm still new on Python and I would like to see if there is a more efficient way to write this, whilst supporting both Python 2 and 3. My next steps would be to write a searching algorithm (search by booking ID) and sorting algorithm (merge sor...
This is my attempt at an implementation of the modern Fisher-Yates shuffle in Java. I'm not sure if it can be made more efficient, but I did my best to make it as simple as possible, and I learned how to use generics specifically for this, so If I did something wrong in that regard, let me know. package com.kestrel.tes...
I wanted to update some properties of my UriString but since this type is immutable, it wouldn't work. Actually, I just wanted to update the Path property but I don't want to have a constructor with several parameters like in the other question because this is too much work and sometime not desireable. Instead, I requ...
I am enrolled in an online JavaScript course and one of our coding challenges was presented as follows: John and his family went on a holiday and went to 3 different restaurants. The bills were $124, $48, and $268. To tip the waiter a fair amount, John created a simple tip calculator (as a function). He likes to tip ...
I wrote this simple program similar to "tiny password manager". Now I am looking for feedback how I can improve it. As always, a big topic in C code is error handling. So what programming techniques could I use to write nicer code instead of all this boilerplate. Also, which errors should I catch and what error could I...
I am trying to compute the difference in timestamps and make a delta time column in a Pandas dataframe. This is the code I am currently using: # Make x sequential in time x.sort_values('timeseries',ascending=False) x.reset_index(drop=True) # Initialize a list to store the delta values time_delta = [pd._libs.tslib.Time...
I'm almost sure that this can be done more efficiently than it is, but I've spent about 30 minutes just staring at my screen. This is for a home project, but I'm using it as a way to improve my coding, so while it works, I'm almost sure that there is a better way to do this. Effectively, on my website there is an eleme...
I have a collection of items in my database with a ParentId property. I'm reading the categories as a flat structure and I would like to convert it to a hierarchy list by populating the ParentCategory and ChildCategories properties. // Domain class public class Category { public Category() { this.ChildC...
Background I am since a long time ago developing a JavaFX application for creating and analysing 'Mech loadouts for Mechwarrior Online. I previously had a very crude search function based on a FilteredList and a big and complicated predicate. This proved to have many drawbacks, prefix hits were a pain to do and this m...
The game of Set involves cards with four properties: number, symbol, shading, and colour. Three cards make a "Set" if the property is either all the same or all different across the three cards, for each of the four properties. I wrote some code to verify if three cards constitute a "Set". But I'm not satisfied with t...
This is my first pygame project that I've worked on and wanted to start with something simple. Pong was, I think, a pretty good choice now that I'm done with it. I will continue to make improvements to the game and adjustments, but I would like the community to review and give suggestions for improvements. I'm a hobbyi...
I have made a small and simple tool for Windows using C++ and the Win32 API to allow people to change their resolution in Fortnite, without having to search for the configuration file and manually edit it themselves. The program has a width and height input for the user to enter their desired resolution, and an apply b...
The Needleman-Wunsch algorithm is a way to align sequences in a way that optimizes "similarity". Usually, a grid is generated and then you follow a path down the grid (based off the largest value) to compute the optimal alignment between two sequences. I have created a Python program, that given two strings, will creat...
Definition of Happy numbers taken from Wikipedia. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycl...
I am relatively new to Python. I wrote this solution to the well known map coloring problem and also implemented the MRV and Degree heuristics. Here, I am considering the map of Australia - ['WA', 'NT', 'SA', 'Q', 'NSW', 'V', 'T'] and 3 given colors - ['R','G', 'B'] # choosing first node with degree heruistics # applyi...
In some specific scenarios, I want to run code after the constructor for a class has run (namely: access std::enable_shared_from_this::shared_from_this()). To solve this without introducing an error prone init method for all classes with this behaviour I have built a generic pattern that allows constructors to "defer" ...
I am building a Quiz app in swift (my first app) to practice a few skills (using CoreData, working with plists, UIKit etc.) and later to work with a server which stores the Exercises. Here's my current point in development: https://bitbucket.org/paescebu/staplerch/src/master/ My question is not precise, more general, I...
I have rolled this program for reading the MBR: #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <cctype> #include <iostream> #include <string> #include <utility> using std::isprint; using std::cout; using std::cin; using std::move; using std::size_t; using std::string; constexpr size_t MBR_SIZE = 512; cons...
I am working on a project that requires me to modify an input list as follows: INPUT: List of numbers, each tagged with a label i.e. [[2, 'a'], [3, 'b'], [1, 'c'], ...] DESIRED OUTPUT: Sort the list and grab the elements with the highest numerical component, store them in another list, and maybe rerun the function on t...
I created a mega menu using flexbox, and because I'm not really into CSS, a review would be helpful. I know it would be better to avoid the third ul-level but this is not possible, because the HTML is generated by another system. And we decided to use the second ul level as a marker for a new row in the mega menu. With...
The code works; the problem is in the processing. I feel like the code can further improved and I believe the answer is Arrays however, my knowledge is very limited. Here, I loop through ~ 1000 columns. Each column has a start and end date; which will span from 1 day to 20 days, averaging ~ 3-5 days for each column. Up...
I've stopped programming in Python for a long time now, someone recommended to me that the best way to get into it is by trying to code a game of Hangman, and that's what I did. Or tried to, at least. import random class Game: def __init__(self, game_word): self.game_word = game_word class Player: d...
I have the following code snippet, which essentially does the following: Given a 2d numpy array, arr, compute sum_arr as follow: $$sum\_arr[i, j] = \begin{cases} arr[i, j] + min(sum\_arr[i - 1, j-1:j+2]), &i > 0\\ arr[i, j], &i = 0\end{cases}$$ (reasonable indices for j - 1 : j + 2 of course, all within 0 and w) ...
I was trying to implement the algorithm of the 3D well-separated pair decomposition WSPD using an octree. First, I begin by implementing the class OctreeNode as follows: public class OctreeNode { public static final int BSW = 0; public static final int BSE = 1; public static final int BNW = 2; public static final int...
I'm new to React and started this project as a sandbox to experiment with it. I implemented a main page wich has a header and some content. The content is selected on the header. I'm wondering how it stands on the react best practices and other ways it could be implemented. On the main app, we hold as state the index o...
Request input (Z) from user, \$-65535 \leq Z \leq 65535\$. Check if \$(X^2)-(Y^2)=Z\$ (while \$0 \leq X,Y \leq 1000\$). I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from \$0 \mapsto 1000\$, after that add ...
I made an algorithm to train my skill in dynamic programming and I would like to have feed back on it. This algorithm takes a money system (int) and have a certain amount of money to render. Do you see any problems in this code? public static int wayToRenderMemo(int[] array, int i, double cost, HashMap memo) { if(i...
Given a string print its words in decreasing order of frequency. Example: i/p - "aa bbb ccc aa ddd aa ccc" o/p - aa,ccc,ddd,bbb Scala: import collection.mutable.PriorityQueue import collection.mutable.HashMap object FindWordFreq extends App { case class wordFreq(w: String, c: Int) extends Ordered[wordFreq] { ...
I wanted your opinion on the first RPG game I made in C#. What things can I improve on with the code? Events: static class Events { public static void SpawnWeapon(string weapon_name) { Console.WriteLine("\nAfter that fight you looted a weapon from the enemy party: {0}", weapon_name); Player.Equi...
I'm working on a game and I have developed A* path finding for certain enemies. But I think I have some optimization issues. If I put the player in an area that cannot be reached and put 3 or 4 enemies around him they are forced to use A* until there are no options left. This causes a dramatic slowdown. There are seve...
Preface sorted built-in function has key keyword-only parameter. Most of the custom implementations like the following for heapsort algorithm import heapq import itertools from typing import (Iterable, TypeVar) Domain = TypeVar('Domain') def heapsort(iterable: Iterable[Domain]) -> Iterable[Domain...
So I was working on merge sort today, and was trying to speed it up. I would like your opinion on the implementation and if it's possible to make it faster. Besides that I was wondering if there are any mistakes that i am making code wise, things that are considered a bad practice. I like making algorithms for fun, an...
I'm working on an app that will be used for employee management and I'm using MySQL for the database. You can add employees, view/update/delete them, and on the dashboard I'm listing them in different tables depending on what's needed. I was wondering if my insert and update code can be improved somehow. Because my upd...
I built a chess game in C++. My main concern is the design. For example, in the board class it has a 2D array of pieces. This array represents the positions of the pieces, but the piece class also has a variable to store its position (used to check the validity of the move sense each piece has a different move capabili...
User has three attempts (locks you out for 10 seconds if you fail) to log in to send an email. Afterwards, you need to insert your username and password to send your message to someone of your will. Any improvements that I can make? import smtplib import time def send_mail() : try : content = input("Typ...
I have a text file like this example: >chr12:86512-86521 CGGCCAAAG >chr16:96990-96999 CTTTCATTT >chr16:97016-97025 TTTTGATTA >chr16:97068-97077 ATTTAGGGA This file is divided into different parts, and every part has 2 lines. The line which starts with > is ID and the 2nd line is a sequence of letters and the letters a...
Building out a React component that is supposed to hold the following information and display it in a feed-like page. The idea is to later map over the individual entries in an array. Author Timestamp Message Title Message body Currently, I have the following code in one file (BuildingUpdateBox.js): import React from...
Assume you have the following data in the form of a csv-file. The content looks something like this: ,Action,Comedy,Horror 1,650,819, ,76,63, 2,,462,19 ,,18,96 3,652,457,18 ,75,36,89 which can be interpreted as a table of the form: Action Comedy Horror 1 650 819 ...
I have a file with word frequency logs from a very messy corpus of scraped Polish text that I am trying to clean to get accurate word frequencies. Since this is a big text file, I divided it into batches. Here is a snippet from the original file: 1 środka(byłe 1 środka.było 1 środkacccxli. 1 (środkach) 1 „środkac...
I write this solution to the popular N Queens problem using backtracking algorithm. I am relatively new to Python. I would like to know what are the ways to refactor this code and also code style of Python in general. def isSafe (board, row, col): # check left row for y in range(col): if board[row][y] =...
I've made a python script to get some statistics from a server log. I would like some guidelines to improve my code: make it run faster, be more pythonic, etc. I don't write python professionally (embedded developer) so please go easy on me. Here's the code: ''' Find the number of 'exceptions' and 'added' event's in th...
I have read your rules and in particular the part about bite-sized portions, so I am apprehensive about posting this but want to do it anyway. I have recently begun getting into C and in particular ncurses with the desire to make some games for the sake of historical appreciation (at least a Rogue clone, probably more)...
I'm using react native to build an iOS app, but have little to no experience in obj C or iOS development. The app I'm building has a bunch of content files that aren't user specific, will be downloaded from some CDN, and will (mostly) be behind a paywall. As I understand it, the best place for this would be somewhere w...
I am trying to solve this problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. and this is my implementation: public int[] twoSum(int[] numbers, int target) { Map<Integer, Integer> numbersMap = new HashMap<Integer, Integer>(); int[] requiredNumbers...
I, also, need to know whether this is a valid implementation of the factory pattern. The amount of effort which goes into configuring DriverFactory to simply get a WebDriver instance seems disproportionate to the point where I ask: "is there not a better way?" The main class code: package dur.bounceme.net.SeleniumBase...
The program uses a very simple algorithm to calculate the supporting forces of a simply supported beam. I'd like to know if thorwables are good practice to handle semantic errors and if one should always use "getters" and "setters" or if it is ok to access fields in data model objects directly (the load Class). How d...
This post is based on the 0-1 Knapsack problem. I came across this problem in Assignment #4 of Professor Tim Roughgarden's course Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming on Coursera. Question 1: In this programming problem and the next you'll code up the knapsack algorithm from lecture. L...
Looking for a critique of this simple logger class I'm working on in my transition to TypeScript. The purpose of the logging class is to just print to a console either info, warn or error messages. The main things I'm after feedback on are my usage of the TypeScript type system. I.e interfaces/types/whatever else could...
Problem statement I have entities whose relations form a graph. As an example, let's imagine Users and Groups. Each user has a Set of groups s*he belongs to; each Group has a Set of Users, representing its members. When constructing objects of those types, there is no clear hierachy. One could start by constructing a G...
I am trying to solve this problem: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. and this is my implementation: public int searchInsert(int[] numbers, int target) { int startIndex = 0; int endIndex = n...
There is a Graph implementation. I'm using Set to store unique Edges and Map to store Vertices and their associated edges. Assume Vertex and Edge class has been defined somewhere else implementing hashcode() and equals() working fine. public class Graph { static class Vertex {} static class Edge {} priva...
The program below is meant to find all of the fare prime numbers under a user specified value. A fare prime being a number that when its digits are rotated, each combination makes a prime number. An example being 113 because 113, 311, and 131 are all prime numbers. My current problem is that the program takes a very lo...
I solved this system design interview question. The problem description Design a parking lot Constraints and assumptions What types of vehicles should we support? Motorcycle, Car, Bus Does each vehicle type take up a different amount of parking spots? Yes Motorcycle spot -> Motorcycle Compact spot -> Mo...
This is my first attempt at python game in pygame. It's a maze game where the maze is randomly generated using Prim's Algorithm. import pygame import random import time pygame.init() # all fonts used font1 = pygame.font.SysFont("comicsansms", 49, True) font2 = pygame.font.SysFont("comicsansms", 150, True) font3 = pyga...
A 'slow sort' is probably the slowest practical sort. It compares each element with the elements after it, and swaps immediately if one is greater than the other, and goes back to the start of the array. For example: CBAD -> BCAD -> ACBD -> ABCD My code: function go() { var arrLen=Math.floor(Math.random()*20)+30...
So, I just wanted to post something on Rosetta Code, and I found this task of generating and plotting a Julia set: http://www.rosettacode.org/wiki/Julia_set. There was already one solution but it was quite inefficient and not Pythonic. Here is my attempt on this: """ This solution is an improved version of an efficient...
I am developing a framework that allows to specify a machine learning model via a yaml file with different parameters nested so the configuration files are easy to read for humans. I would like to give users the option of instead of specifying a parameter giving a range of options to try via a list. Then I have to take...
I'm studying C with a Deitel's book. The book asks me to write a program that simulates a virtual PC (with virtual memory in an array called memory[100]). Then the book asks me to write a program that sums 10 numbers. I did it but I had to initialize some variables (memory[20], memory[21], memory[22]) before running th...
I solved this problem: Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what...
Function : User enters a word in korean and the program translates (defines) it in english. What improvements can I make? Extra : What other challenges would you recommend that incorporates both JSON and python? KoreanDictionary.py import json from difflib import get_close_matches korean_data = json.load(open("kor...
I solved this problem: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. How can I improve its execution time and also, if there is any better way of doing it? public ListNode mergeTwoLists(ListNode listNode1, ListNode listNod...
Introduction I'm doing an OpenGL program in C. As of now I'm working on the 3D camera system and got the control right. Now I'm working on the mouse control. It works, but I have used two different ways to do it. The problem The two different ways are using a global variable and callback, and just using a local variabl...
The task: You will receive several input lines in one of the following formats: "{card} - {sport} - {price}" "check {card}" The card and sport are strings. Price will be a floating point number. You need to keep track of every card. When you receive a card, a sport and a price, register the card in the datab...
I am working on an application in C# WPF which reads a large file containing a number of HL7 formatted reports. My application takes in the file, reads and extracts any lines that starts with OBX and stores it into a List. It then tries to extract report headers from the each line, if one exists, based on a handle-full...
I've been studying more C using C Programming: A Modern Approach: A Modern Approach 2nd Edition by K.N. King as well as reading the comp.lang.c FAQ and the Code Review section here on Stack Exchange to improve my C skills. I would like your feedback on this recent program I wrote to calculate the volume of a box. It us...
I'm trying to solve the Hackerrank's Insertion Sort Advanced Analysis problem using BST (similar to this question on SO). As I put items in the tree, I need to find out the number of items greater than it (the get_rank() method in the code): class Node: def __init__(self, data): self.left = None sel...
I'm writing a byte array at the end of file. The code works fine, but can you please suggest performance improvements? static void Main(string[] args) { string PathToFile = "C:\\myfile.m4a"; WriteAaray(PathToFile, GetMyList()); } public static List<float> GetMyList() { // This list i...
I am coding a bot for Starcraft 2, in which many distances have to be calculated every frame. Here is the part of the library that is being used and I want to improve: https://github.com/Dentosal/python-sc2/blob/develop/sc2/position.py I built a new class Points that inherits from np.ndarray. It is not yet connected to...
I'm trying to get reacquainted with C after years of higher-level languages. I wrote a small fixed-width to CSV converter. It works (for ASCII at least) and it's quite fast, but I wonder if I missed anything or if it can be made even faster. I'm reading the file line by line and process the desired columns (some can be...
I want to the user to filter a list of receipts by various criteria. Just the regular, an empty filter should show all items, an entry in customer should show all receipts from that customer and an additional entry in date should show all entries from said customer on the given date. I have the feeling, my if else appr...