instruction
stringlengths
71
95.1k
I made a snake game in sfml and i'm kind of proud of the code's structure, but proud doesn't mean it's good, so i'm putting it here so that if there is something that could be bettered, you would know. main.cpp #ifndef UNICODE #define UNICODE #endif #include "app.h" int main() { app game(800, 600, L"Test"); ...
I have some imminent interviews and want to sharpen my game before going into them. I'm running through some practice problems. This LeetCode challenge is to add two numbers represented as linked lists. If you can critique this solution quite harshly, as though you would in a full-fledged SWE interview, I'd greatly app...
I have solved a seemingly easy problem: Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix is shown below: $$\begin{bmatrix} 1\, 1\, 1 \\ 2 \, 3\, 3 \\ 0\,1\,0\end{bmatrix}$$ The left-to-right diagonal = \$0+3+1=4\$. The right to left diagonal \...
As a result of my previous post, I have implemented / refactored my code and have started making successful use of my class. However I have come across a couple of new questions: The observer must call PopObjects() to consume the data in the vector. PopObjects() returns a bool so I don not have to check the vector cou...
The task is taken from leetcode You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zer...
I wrote a simple C++ lexer in python. Although it already works but I kinda feel I didn't follow the pythonic way. Any suggestion for improvements? Sample C++ Code Sample output Here's my code: mysrc.py: def keywords(): keywords = [ "auto", "bool", "break", "case", "catch", "char", "word...
Simple conversion of one type to another. Is there a better way with streams : Map<String, Set<String>> result = new HashMap<>(); for (Pair<String, String> pair : resultList) { Set<String> strSet = new HashSet<>(); strSet.add(pair.getRight()); result.merge...
Parser Combinators are the amazingly elegant way to write parsers that has evolved over on the functional programming side of the world, but have been less available or accessible for imperative languages. I have attempted somewhat to bridge this gap by stealing copying as many ideas from FP as were needed to make thes...
I have a websocket connection with 3-rd party API. The API returns a lot of data, in a peak hours it returns hundreds messages per second. I need to process the data for two purposes: save everything in a DB and send some data to RabbitMq. The idea is the following: I want to save data to DB when batch size is 1000 or ...
The following code works fine. When a user clicks on an element, an AJAX request is made, which will return the query result. The results are being displayed in a view. I read many articles where everyone is doing HTML code in controller when getting data with AJAX and show in view as same I did. Any good suggestions t...
I'm developing an app that use socket to receive messages from a chat. I'm using an MVP approach and I store the data in a Singleton class named DataBridge like this: class myApplication: Application() { val dataBridge: DataBridge = DataBridge() val deviceManager: DeviceManager = DeviceManager(this) overr...
I had a technical interview the other day and failed a certain question: Given a CSS selector (can just be a class name, id or an arbitrary number of selectors), return the parent DOM element in an array. The caveat is that you cannot use external libraries or use document.querySelector or document.querySelec...
The task is taken from leetcode Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: ...
Actually I got a form with multiple input (around 39) on which I wish to perform some check and display customs messages based on sets of conditions. I found a way to address my problem but I'm wondering (and I'm barely sure there is) if there's any better way to approach this. My trouble come from the fact there's a l...
I'm attempting to create a basic wiki for personal use. I've got a pretty good start, but the code is beginning to become cumbersome to modify, and some of the things I'm doing feel very fragile. I've heard and looked into using the MVC pattern, but I'm having trouble understanding how I would even implement my current...
I am building a CLI that wraps an API for work. The CLI is being build to handle the "common" tasks users can perform with the API so that they don't need to get into the details. If they want to do more, they are able to but have to use the API. The problem I'm running into is that it seems very inefficient to pluck ...
I have a csv file with sales transactions. Each transaction includes person identifiers (which are sometimes/often missing) and transaction data. Person identifiers are fname, lname, phone, email and social security number. I want to link each transaction to a unique person. As a business rule, I have set that two tran...
I am trying to learn the basics about neural networks by coding from scratch the perceptron model. Since I am not a programmer and would like to improve my coding skills I would like to get your comments about this code. What do you think about it (I tried to respect the different steps: forward and backward for backp...
Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to my code. I have updated my code with small summaries to provide more documentation. Here is the updated interface. names...
Edit: Licensed source can be found here. The intent behind this class is to allow different game systems to run at their own clock rate. The physics integration rate should not be connected to the screen refresh rate, for instance. Instancing this class should allow for accurate, independent timing of separate systems....
I am trying to solve the HackerRank New Year Chaos problem where the aim is as follows: A vector of size n is having values [1,2,3,...,(n-1),n] with no repetition. A kth element can switch only with the (k-1)th element. An element can maximum switch 2 times with its predecessor. Thus we can say that any kth element sho...
I've come with a solution super tricky for a simple requirement. I think I could solve the problem using LinQ, but I'm not seeing it so clearly at all. What's sure, I'm not comfortable with my code. The requirement is the following: Given a list of lists of string (IEnumerable>), take the first N elements from each but...
I'm implementing a basic array data structure with basic functionalities. #include <iostream> #include "barray.h" BArray::BArray(int init_size) { b_array = new int[init_size](); array_size = init_size; } BArray::BArray(int init_size, int init_val) { b_array = new int[init_size]; array_size = init_siz...
What I want to know I am writing a ML model called U-Net with Python (and TensorFlow). My question is not about the machine learning or Tensorflow, I want to know the best structure of the code. I write some code as my hobby and I've never written code as work, so I do not know what is the "good" code. My code I made t...
I'm fairly new to C++, so as a learning exercise for how to use various simple data structures efficiently and what I should and shouldn't avoid, I wrote the following code: #include <iostream> #include <string> #include <vector> #include <unordered_map> #include <queue> void primitive_test() { unsigned long l = 2...
This is an exercise in a book which ask me to implement Write an in-place function to eliminate adjacent duplicates in a []string slice. I am relatively new to golang and I am not sure if my implementation is correct and effective or not. func removeAdj(strings []string) []string { for i := 0; i < len(strings); i...
The task is taken from leetcode Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer ra...
I have this simple function that just reads a file, replaces all occurances of a string, and write it back to the file: def fileSearchReplace(targetFile, search, replace): with open(targetFile, 'r') as openFile: filedata = openFile.read() newData = filedata.replace(search, replace) with open(targe...
I started learning Python a month ago (used to write programs in Delphi before). Can you please take a look at my code and give me some tips what is good and what is bad in it? The aim is to find duplicate files on a disk and saves this information. I'm using md5 hash. Is it right to use global variable like I did? imp...
I programmed a generic queue in pure C and I'd love to receive some feedback from other programmers. You may use the following questions to guide your review. Is the API well thought and idiomatic? Does the code look "modern" (i.e. uses modern conventions etc)? Is the code efficient in terms of memory usage? Are the t...
Hi I am trying to get into Rust by implementing a small library for vector calculations. I am mainly asking to point out whether I chose a valid approach. I also am interested in comments on the overall details I might have missed or got the wrong way. So for my Vec3 implementation I basically declared a custom type w...
So I have the following models: class Poll < ApplicationRecord validates :title, presence: true, allow_blank: false validates :options, presence: true has_many :options, dependent: :destroy end class Option < ApplicationRecord validates :title, presence: true, allow_blank: false belongs_to :poll ...
As a continuation to my question Design for a very simple e-shop I made some of the changes proposed but not all of the proposed for example I was not able to make a factory for the setAttributes. And if anyone could give me a hint how to get rid of the if statements in the factory for the production of the IProducts i...
I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead of making several calls to System.out.print for each line, I create one large string by appending newlines to the StringBuilder, and then print that large string just once with System.out. Bu...
The goal of the code below is limited to the creation of the initial map only and not to the whole game mechanics itself. The rules are that there are 4 ships of length {2,3,4,5} and no ship may be placed adjacent or diagonally adjacent to another ship. For now I plan to stay with the 10x10 grid with 4 ships. In my imp...
My goal is to determine, of all of the currently visible cells in a collection view, which section has the most visible cells. Start by getting the index paths for the visible cells: let visible = collectionView.indexPathsForVisibleItems // [IndexPath] Originally I used an NSCountedSet followed by mapping and sorting....
I implemented an algorithm to find the modular multiplicative inverse of an integer. The code works, but it is too slow and I don't know why. I compared it with an algorithm I found in Rosetta Code, which is longer but way faster. My implementation: def modinv1(a, c) raise "#{a} and #{c} are not coprime" unless a.gcd...
This is extension of the rep-string task from Rosette code. I do not only want to check if the input string is the shortest periodic string (rep-string) or not, but also check if it is preperiodic. Periodic means, that a part must occur two or more times. Input is a binary string (only 1 and 0 chars). It can be for ex...
The task is taken from leetcode Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container ...
https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Please comment on performance Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ ...
I have a durations as such: [{'duration': 3600}, {'duration': 3600}] And I want the output to be {3600: 2}, where 2 is the number of occurrences of 3600. My first attempt is use a loop, as such: var count = {}; for (var d of durations) { var length = d.duration; if (length in count) { ...
One of my favorite classic programming exercises is the Subset Sum problem. I'm (trying) to learn Ada and it's the first thing I wanted to implement, even before a Hello World. The Subset Sum problem aims to find within a set of numbers, if a specified sum can be found by combining any number of elements from the set....
I'm adding rather extensive xml-doc comments to all Rubberduck inspection classes, like this: namespace Rubberduck.Inspections.Concrete { /// <summary> /// Warns about a variable that is assigned, and then re-assigned before the first assignment is read. /// </summary> /// <why> /// The first assign...
The code below is working properly but how do I make this code faster and more efficient. How do I perfect this code? Let's assume I have 1000 country, state and city records in a mongodb collection. I want to retrieve all the city data by matching country id and state id. Please tell me the perfect way to code. // @ro...
Problem: Source (with example): https://leetcode.com/problems/island-perimeter/ You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is e...
My scenario is the following: I'm modelling a Program which has many Modules. Each Module has Symbols, some of which pointing at dependencies, which are other Modules. So a Module can be pointed to by many other Modules as a dependency. Now I want to be able to modify a Module (typically, running an optimiser on its co...
Recently I made a script to get available IP automatically. I was woundering if anyone can give me tips on how to make this code look better, preferably in a class and OOP. I'm gonna show the code to my boss, but i want it to look clean and nice before i do so, and hopefully learn a thing or two about writing better co...
Until now we have always initialized the repositories, that containing MySql functions, at the beginning of each Form Something like that Form example code: public partial class FormTest: Form { private readonly ProductRepository prodRep = new ProductRepository(); private readonly UserRepository userRep = new U...
I'm writing an application that will end up with a set of standard CRUD operations for a bunch of object types, and I thought it would help simplify things if all the separate controllers had some common functionality. This will be using a view interface for everything rather than RESTful responses. I haven't been ab...
The task was taken from leetcode Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s. If you add periods ('.') between some...
Some days ago, I posted a question here: Field class as basis for a role playing game I payed respect to tips I find useful and made a further development of my Field-classes. These classes have to serve as a basis for a role playing game later. Now I tested my classes with a little snake game. You can download the pro...
I wrote code to show the structure of a Fibonacci sequence pattern in a graphical way. First I structure a tree given a variable the user inputs for how many iterations of the sequence they want to print. Then, it converts the numbers into the Fibonacci sequence. My concern is that this doesn't seem very efficient, fir...
Task: Return true if a transaction is allowed and return false if transaction is prohibited. Details: 1. String is represented as an "array" that can contain up to three elements. We need to evaluate a charge against a list of rules and see if we can allow the transaction to happen. Each rule (Allow or Deny) can cont...
This is the improved code of a question I asked some days ago. main.cpp #include "app.h" int main() { Game::app game(800, 600, L"Test"); game.start(); game.end(); } app.h #pragma once #include <SFML/Graphics.hpp> #include "Snake.h" #include "Board.h" namespace Game { class app { public: ...
It has been a royal pain that MSForm controls are missing simple events such as MouseOver and Blur, and I find myself often having a complex system of MouseMove events to achieve these for hover effects and other stylings. To solve this issue I've created two class modules EventListenerEmitter and EventListenerItem. Li...
I'm practicing for my Technical Interview and I'm worried my code does not meet the bar. What can I do to improve this answer? Here is the question: https://www.careercup.com/question?id=5739126414901248 Given colors = ["red", "blue", "green", "yellow"]; and a string str = "Lorem ipsum dolor sit amet"; write a function...
I'm working with a dictionary with 11830 keys/values, that have to loop over 13905 strings, that can have up to 50 words each. My series looks like this: strings "hello foo helloo" "bye bar byer" And my dictionary like this: dic={'hello':'hi','bye':'byebye'} So I want my final Series to look like this: strings "h...
I have a number of names divided into several lists. I am printing all the names which occur in more than one list, sorted by the number of occurrences. What is a better/easier/more pythonic way of doing this? I feel like my solution is overly complicated. import numpy as np list_1 = ['John Cleese', 'Terry Gilliam'] ...
This one is a research attempt to find out how to convert long values as unsigned long integers to Strings. It is much slower than java.lang.Long.toUnsignedString, but it was fun to code: net.coderodde.util.Long package net.coderodde.util; import java.util.Random; /** * This class contains a method for converting {@...
The task is taken from leetcode Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string ...
I was tasked with writing a Matryoshka doll program that manages the following: howManyDolls : returns an integer based on how many dolls are inside the stack howManyWearingBabushkas : returns an integer based on how many dolls are wearing a Babushka. The boolean variable babushka determines this. totalWeight : return...
I wrote this code and it works fine for my purpose, to look for some values and copy paste the result to another sheet (online for selected column). I want to know the opinion from this community regarding my code. I just learned the VBA for 1 week. Option Explicit Sub Analysis_ClientRating() Dim lastrow As Lo...
Following up from part one, I've attempted to convert the largest part of my project into an MVC pattern as per suggestions from the accepted answer. I've managed to split the original edit.php file into a template and the business logic part, but there's still a lot of repetition going on. I feel like there has to be ...
I'm just doing a small hobby project to solve a little problem I have and I'm using it as a learning exercise for ASP.Net MVC 5, .Net Core 2 and Bootstrap. I'm using a nuget package that handles interaction with a 3rd party api (EveStandard), I make the api calls that I need, spin up a view model which holds the data I...
You are given a square matrix \$A \in \mathbb{ N}^{n,n}\$, this number contains integers from \$1\$ to \$n^2\$. The task is to compute the minimal cost, to change this square into a perfect square. A perfect square is a Matrix, such that every row, column and (full) diagonal add up to a magic number. The Matrix is lim...
The task is taken from leetcode Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in the stack. Example: MinSt...
The code below retrieves data from database. Before the data is retrieved, a wait message is displayed. Once the data is retrieved, the message should be removed. What would be the best place to execute the remove_wait_message function? Currently it sits in do_stuff_to_data, but it does not seem logical, as those two ...
This script is a subset of a larger script where I have the output of many test simulations in the form of CSVs. Each file starts with the model name and includes the number of elements in my file. For example, edge_16elem_out.csv would be a first-order model (edge) with 16 elements. Another example would be edge3_1024...
I've developed a program in Python that calculates the lowest possible costing path between two points in a matrix, including the values contained in the start and finish cells. The code is below. Once the matrix gets larger than 4×4, it becomes very slow. Are there any obvious problems with my code (recursive method)....
For a homework assignment, I was asked to do this problem. It worked, but it looks messy in my opinion. I want to know if this is the best way to accomplish this task, and if there can be any improvements made to this code, such as efficiency and code compactness. The assignment is explained below: Write a method name...
Here is my std::vector implementation so far. It's not yet complete (it's missing the constructors), but I hope you can leave some feedback! #pragma once #include <memory> #include <utility> #include <type_traits> #include <stdexcept> #include "kmemory.h" namespace kstd { namespace detail { template<typename T...
So i took even more suggestions and improved the code from this question. Some of the suggestions i wasn't able to implement simply because of my "newbieness" in c++ programming main.cpp #include "app.h" int main() { // Window aspect ratio is always 4:3, so it only takes // a value that is then used as the s...
My Code: Connectivity(php) <?php $conn=mysqli_connect("localhost","root","","webchat_data"); //if($conn) //{ // echo "hi"; //} if(!$conn){ die("CONNECTION FAILED" .mysqli_connect_error()); } ?> Signup <?php include 'connectivity.php'; $uname=($_POST['uname']); $email=($_POST['Email']); $pass=($_POST['Password...
https://leetcode.com/problems/implement-trie-prefix-tree/ Please comment about performance and style. Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // returns false trie.startsWith("a...
I made a simple matrix program that prints some data..I want to know how to reduce amount of lines with some functions or whatever, because there is so much if-s,and for loops. Tried to make functions but almost every for loop is different, so that did not work. #include <stdio.h> main() { int i,j,m,n,sMain,sAnti,s...
I have multiple distinct processes that need to access external resources that are rate limited. The processes are all async in nature and run in different applications. In times past I would just use SemaphoreSlim this design doesn't allow for that. I've found several samples that seem to be half complete, or cut an...
I have an API which I can't modify. I have to use data as it is. I want to join data from two separate requests where the second request is based on data from the first one. I have a working solution already but the code quality, in my opinion, is low so I want to know your opinion (and if you can provide: better, mor...
Forward This is a continuation of my work in progress and the last iteration that I posted can be found here. I have designed a compact class template that uses SFINAE with constructor delegation to reduce the amount of code duplication, and to keep this as generic and portable as possible. I even added in a few funct...
Here is what a knapsack/rucksack problem means (taken from Wikipedia): Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its nam...
Was too bored in holidays...here's a code which finds the day of the week using the algorithm in this video. Please give a logical date in the correct format cause I didn't account for improper inputs cause I'm too lazy. My code is short and sweet. day=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Satur...
I decided to write my own vector class template for learning purposes. My main goal was a correct interpretation of C++20 standard (as of n4810). I took some liberties and decided to use concepts instead of plain typenames for iterators instead of SFINAE. On the other hand, I decided against Empty Base Class optimizati...
The task is taken from leetcode There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 E...
I wrote this method to upload a floor plan image: function upload_image($path, $file) { $errors = []; $ext = pathinfo($file["name"])['extension']; //randomly generate filename to avoid conflicts $filename = uniqid().'.'.$ext; if ($file["size"] > 2000000) { $errors[] = "The image cannot be ...
I've written a rudimentary parser for INI files: {-# LANGUAGE OverloadedStrings #-} import qualified Data.Map as M import Data.Maybe (fromMaybe) import qualified Data.Text as T type Ini = M.Map T.Text Section data Section = Section { name :: T.Text , properties ...
I have created a Sudoku generator in Java. Here I am using a basic solved sudoku as seed and by transposing it and shuffling its row and columns I get a new solved sudoku. //import java.util.Arrays; import java.util.Random; public class SudokuGenerator { private char[][] board = new char[9][9]; private int[]...
I was trying to output F(n) mod m to find the remainder of Fibonacci number, where F(n) could be a very big number: # Uses python3 n, m = [int(x) for x in input().split()] def fib(n): a = [0, 1] if (n <=1): return n else: for i in range(1, n): a.append((a[-1] + a[-2])%m) ...
I am new to programming in Rust and as an exercise I was making a simple Lottery checker program. It has a simple menu, the user enters a number for the corresponding option such as 'Add a line', 'Check if I am a winner' etc. So all the user needs to do is enter either a number or a 'y' or 'n'. So I created a simple To...
Currently my code is based around mouse events so that it is easier to test but I will be swapping these to touch events once I have had the code reviewed. The idea of the UX is that you need to mousedown for 500ms until you can move the spot (similar to that of iOS when re-arranging apps on the homescreen). Then the s...
After I've now officially announced, that I'm discontinuing my color picker for Windows, I'm about to embark on a journey through Linux development. I was quite strong in Delphi on Windows, and see no valid reason to focus - not that I'm not trying to, in quite many languages - mainly on development in Lazarus on Lin...
I am working on a application that is made completely in JavaScript (other than the database) and I've created a simple user management system for the application. This user management system creates a query to the database containing the user info (the database contains the user info not the query) based on a few com...
I have network printers which have different attributes (e.g. supported network protocols, languages, status, print modes). public abstract class PrinterAttribute { protected PrinterAttribute(int value, string dsc) { this.Value = value; this.Dsc = dsc; } protected PrinterAttribute(int value, string dsc...
I'm still pretty new to programming, only been doing it a week. I'm just wondering if I made any glaring mistakes or anything that could be improved code wise? import random the_board = [] players = [{'type': 'player', 'piece': 'X'}, {'type': 'player', 'level': 'smart', 'piece': 'O'}] def print_board(boar...
There a various examples in UIKit where a class has a property and a corresponding method to set the property along with an animated property. Examples include the progress and setProgress(_:animated:) of UIProgressView or the isEditing and setEditing(_:animated:) of UITableView. In Objective-C you implement this by ov...
In this LeetCode problem, Longest Palindromic Substring, it is listed under Dynamic Programming for Google interview preparation. My understanding of dynamic programming is roughly "recursion + memoization + guessing." In the Python solution to this answer below it is not clear to me where the dynamic programming is if...
Please feel free to review my countdown numbers game solver. Posted here too for people working on the same problem. For clarity the print statement "Eval..." means the program has used BODMAS on an entire mathematical statement (e.g: 1*3+10 = 31) "Running total" means the program recalculates the total after each mov...
This question is the follow-up to this previous question. Background Using this simulation I investigate a system in which enzymes proliferate in cells. During the replications of enzymes, parasites can come to be due to mutation. They can drive the system into extinction. I'm interested in where in the parameter spac...
So I want ask if I'm doing it right way. Im still learning.. I want check textarea duplicates and alert if duplicate and remove it. $(document).ready(function(){ $('#lol').keypress(function(){ var data = $('#lol').val().split('\n'); var result = data.filter((word, i, arr) => arr.indexOf(word) === i); $('#...
I'm trying to write a triple buffer that's wait free for a update + render loop after being bitten by lock starvation one too many times (on a different project, using a library). For reference, a triple buffer is effectively a single producer, single consumer channel, that allows for the producer to update the buffer ...
Given a set of \$k\$ \$n\$-vectors \$\vec{x_1}, \dots, \vec{x_k}\$, Gram-Schmidt process computes a basis \$\vec{y_1}, \dots, \vec{y_m}\$ (\$m \leq k\$) the vectors of which span the same space as \$\vec{x_1}, \dots, \vec{x_k}\$ but are mutually orthogonal: the inner product \$\vec{y_i}\cdot\vec{y_j} = 0\$ for all \$i ...
I'm writing a torrent streaming client. The plan is to wrap WebTorrent-cli and provide a Java interface to observe download state, cancel or pause downloads etc. Anyways, I came up with the following DownloadManagerImpl. I want the instances to this class be immutable, strictly enough that they remain thread safe if ac...