instruction
stringlengths
71
95.1k
In the book they recommend to utilize an Array, but I think that it's easier to use an ArrayList instead, is there any problem with that? Is this code well designed? package com.company; import java.util.ArrayList; import java.util.NoSuchElementException; import java.util.Random; public class RandomQueue<Item>{ p...
I'm always down to learn better ways of doing thing and I wanted to see if I can get an input from the community to see if there is a way that I can improve this function: function pardot_dashboard_query() { $args = [ 's' => '<!-- wp:acf/pardot-form ', 'sentence' => 1, 'post_type' =...
I'm implementing row-level-locking on a MS SQL Server. The function I created below works, but even with a very small data set, it takes a significant amount of time to return the results. If I were to code this in VBA for example, I would call the username() function only once and store the result. Can this be done in...
I have written some code to determine an interpolation matrix over a grid of points. I originally wrote the code in matlab, where under the specified parameters it took just over 2 minutes. The equivalent code in Python however takes 40minutes! I was expecting Python to be slower, but not be such an amount! Any feedbac...
There is a function that draws triangles on the canvas area in each lines: function DivotTemplate(divot, canvas) { if (divot === void 0) { divot = defaultConfig; } var config = __assign(__assign({}, defaultConfig), divot); var ctx = canvas.getContext('2d'); if (!ctx) throw Error('Canvas context ...
I recently crafted a binary word search puzzle using HTML, CSS and JavaScript to dynamically build grids within a grid: var board = document.getElementById('board'); var characters = [ 'H','U','O','M','S','F','I','R','E','I', 'P','O','B','P','O','S','P','K','K','A', 'S','E','P','T','E','M','B','E','R','F'...
I wanted to get some feedback on a fluent unit testing framework I’ve written. I call the project Fluent VBA. You can find a link to the project on GitHub here Motivation This project was inspired when I read about Fluent Assertions in C# as I was reading a book on unit testing. Usage Fluent frameworks are intended to ...
I have a little project, chuy, which is basically a copy of Make. By request of users I have added support for toml configuration, since originally it only accepted json. The files that chuy have to check are: ["chuy.json","chuy.toml","pyproject.toml"]. The order of priority is the same order in which they are placed. ...
Need help to optimize the following code for lower time complexity: arrayMultiply(ipnArray: number[]): number[] { let outArray = []; for (let i=0; i<ipnArray.length; i++){ let currentNum = ipnArray[i]; let newArr = ipnArray.filter(nub => nub !== currentNum); let tempValue; for (let j=0; j<newArr.len...
In my learning course, I've implemented a message queue to which data gets pushed by some thread and later gets processed by some other thread. My implementation isn't that efficient as it involves creating minimum three copies of the same data which is not acceptable. So is there any way to avoid these unnecessary cop...
Challenge: find the top three most frequently used words in a string. Only imports from the base package are allowed (source: codewars) I'm looking for feedback on (1) readability, and (2) performance Was folding the string into "frequency map" a good choice? I have several small functions that I compose together. Are...
I've started to write my first APL project, so I would like to have general feedbacks on coding style, file organization, error handling and defensive programming, performance improvements, etc. The PNM format is handled by the following two functions: ∇img←readpnm file;data;x;y;type;⎕IO ⎕IO←1 data←83 ¯1 ...
As the title suggests, I'm writing an x64 Code Emitter. Right now I've only encoded 1 instruction (The add instruction). I want to know if this API can be improved at all. This is how you I use it. int main() { // The Operand type contains the type of the operand and a union with the contained value. // There a...
I'm trying to learn C++ with a background in python. This is my first program besides general practice. I wanted to remake the war game. I'm looking to get feedback on the C++ equivalent of its pythonicness. Some mistakes I believe I've made are possibly misusing the std functions, unnecessary type transformations, and...
This is the code I've written that'll take a word as input and write all its anagrams to a file. The java compiler forces me to use try-catch statements every time I wish to do something with the file. I want to know if there's any way to make my code shorter and more readable in general. As you can see, inside the wri...
function transformXCoordinate(x, xOrigin, y, yOrigin, theta) { return xOrigin + (x - xOrigin) * Math.cos(theta) - (y - yOrigin) * Math.sin(theta); } function transformYCoordinate(x, xOrigin, y, yOrigin, theta) { return yOrigin - (x - xOrigin) * Math.sin(theta) + (y - yOrigin) * Math.cos(theta); } function compute...
I have the following code which works great to do what it is meant to do. It scrapes the bodies of all e-mails in the inbox at an e-mail address using IMAP and retrieves the unique code sent inside the body and stores it in a database with the amount paid. I'm hoping to make it so when a user purchases something they...
I'm new to programming and was tasked with programming a generic circular FIFO queue, without using anything but an underlying array and self-programmed methods. I still don't know how to approach bigger projects like this yet. I managed to program something that technically works, but I need someone brutal to really t...
I've been tasked with creating some way to encrypt arbitrary text for a .NET Core app, with the following requirements: Messages will be between 10 bytes and 1 kB. Boss doesn't want me to use AES-GCM (which I know would be the sensible option as it's already included in .NET Core and I've already read that implementin...
I am a newbie in Ruby. I want to learn Ruby and I want to learn clear code in Ruby. I coded a number guessing game but my code is smelling bad. How I can do better code? class NumberGuess attr_accessor :num_of_guess, :random_num, :name def initialize(random_num, num_of_guess, name) @name = name @random_num...
print("Welcome to the Sieve of Eratosthenes, where you can generate prime numbers from 1 to n : ") n = int(input("Enter your n : ")) y = [y for y in range(1,n) if y*y < n] primes = [p for p in range(2,n+1)] length = len(primes) print(primes) for p in range(2,len(y)+2): for i in range(2,length+1): ...
My code is working perfectly fine, except for one-thing. The performance is not up-to the mark. What I am trying to achieve is I have an image with a few circles (each circle has a border with different color than circle fill color). When the user touches any circle, I want to change the border color of the selected c...
I just started learning java and wrote this variable length array as my first program. I wanted people's opinion on how "java" this code is. For example coding conventions, idioms that I could have used or any improvements that could be made. MyClass.java: package myproject; public class MyClass { public static v...
I want to enable bitmask-like behavior (ie. overloaded operator|, operator& and operator^) for some enum classes. This is what I came up with: #pragma once #include <type_traits> /// \brief Marks an enum class as enabled for bitmask behavior. /// \param type The name of the enum for which to enable the bitmask. /// \d...
This is one more implementation of Binary Search Tree in C++. There are many such implementations, however they are typically long and complex, and also many of them rely on pointers to parent nodes for deletion (which isn't necessary). My goals were simplicity, clarity and conciseness, especially for the erase functi...
In my coding interview for a company, I got the question to write a Minesweeper game. I did not manage to finish the game in 1 hour at that time, so now I have written it again after the interview. Could you please help me to check if my code follows good practices for a game-program ? I appreciate any ideas. import ra...
I have an array wrapper class that I'd like to get reviewed. There are two differences with other common questions on this site. First, my class needs to be "nullable", where a "null array" has a different meaning than an array of length zero. Second, I'm trying to test whether small size optimization (like gcc's std::...
In this post, I will present and compare two distinct algorithms for sieve of Eratosthenes: com.github.coderodde.math.prime.PrimeFinder package com.github.coderodde.math.prime; import java.util.ArrayList; import java.util.BitSet; import java.util.List; /** * This abstract defines the API for finding prime numbers. ...
I am working on a practice problem found here: https://www.hackinscience.org/exercises/sequence-mining Overview Sequence mining is useful for analyzing list of events when order matters. It's used for example for DNA and natural language analysis. Here, you'll implement an algorithm to extract common patterns among a ...
This is my first time using StackExchange. I did not have any idea what this website for, but I guess is a place to review the code? So, I'm just going to give it a shot. #include <iostream> std::string board[3][3]; void making_board(); void play_the_game(); void display_board(); void choose_position(int position, s...
I have been coding in Python for a number of years now. I've always felt that Matplotlib code takes up a lot more lines of code than it should. I could be wrong. I have the following function that plots a simple scatter plot graph with two additional solid lines. Is there any way for me to reduce the number of lines to...
I've implemented a Game of Life in Clojure and would like to understand what I can do better, especially in terms of idiomatic Clojure (without losing readability/maintainability) of the current version. This is my first "serious" Clojure program (beyond hello world). Things that I'm specifically interested in: Anythi...
I'm new to writing benchmarks and would like some advice whether I am doing this correctly. I currently have two classes: Person.java and PersonFinaliser.java which each have a single field age. The only difference is that PersonFinaliser.java has a finalizer() method. I am trying to measure the perfomance difference b...
I just have the free account at leetcode. I've been practicing some coding there in preparation for interviews. But I can't see the solution logic behind the IntegerToRoman conversion function. I solved both the leetcode Roman Numbers problems (Arabic -> roman, and roman -> Arabic). I made a solution of my own but its ...
Originally written in C (which was abysmal, you may check here if you want), I rewrote my simple credit card validation program using Python def main(): # Prompts user for card number nums = int(input("Number: ")) if len(str(nums)) > 16 or len(str(nums)) < 12: print("INVALID") else: card...
I wrote this code in c#. It is a question from LeetCode, number 49. Given an array of strings, group the anagrams. The examples it gives are: ["eat","tea","tan","ate","nat","bat"] then return: [["bat"],["nat","tan"],["ate","eat","tea"]] I am wondering what exactly my time complexity is? I believe it is O(2n) which ...
I have just recently picked up coding and am trying to improve my coding. I've written this bit of code to create a little adventure world. I haven't completed the code, everything runs how I want it too but I'm aware this code isn't efficient. I would like some advice and some help on how I would make my code better, ...
Given a file or directory, create an iterator that returns the non-empty words from the file or from all files recursively in the directory. Only process ".txt" files. Words are sequence of characters separated by whitespace. class WordIterable: def __init__(self, path: str): root = Path(path) sel...
So I did my own take (I wrote my own algorithm) for generating prime numbers from 1 to 1000. lst = [y for y in range(1000)] for i in range(0,len(lst)): #i = 1 and i is traversal print("iterate - " + str(i)) for j in range(i,0,-1): #divisor range print(j) if j != 1 and j < lst[i] and lst[...
I'm using Python's Enum to define the physical units in which a value is expressed. Eventually, I want to add them as an attribute to my pandas.Series and pandas.DataFrame instances, so that this information does not need to be stored in the variable name or in comments in the code. Also, it allows for automatic calcul...
I'm doing the following exercise from PPP - Bjarne Stroustrup, Chapter 19, ex.10. Implement a simple unique_ptr supporting only a constructor, destructor,->, * and release(). In particular, don't try to implement an assignment or a copy constructor Here's what I've done so far, for which I'd like to have a check. I d...
Dumbserver, or the simplest workable HTTP server. It is supposed to operate in the 'traditional' way, that is, mapping paths in requests to the directory structure. Why did I write it: I needed a simple development server for a website I'm trying to make. Instead of using Express or something like that for this purpose...
I want some opinions about my code that implements store and update for a Laravel 8 form request. The make function is for storing the data and the update function is for updating the data. <?php namespace App\Http\Requests; use App\Models\Admin; use Illuminate\Foundation\Http\FormRequest; class AdminRequest extend...
I implemented a solution for the problem below, but its performance is not good. I know I can find the solution online, I'm trying to understand what is causing the bad performance in my code Problem: You have an undirected, connected graph of \$n\$ nodes labeled from \$0\$ to \$n - 1\$. You are given an array graph wh...
I have an use case where I want to see how many slots have been used for a date in a restaurant. The slot can be deducted based either number of diners or per booking. Also I have to cater a case where a booking is made for multiple dates and then i have to consider those dates as well when checking how many slots have...
I have a button btnSearch and the event handler btnSearch_Click inside my asp.net web application, using web forms. (certain variables/controls have been renamed to generic variables) protected void btnSearch_Click(object sender, EventArgs e) { string n1, n2, n3; n1 = txtNum1.Text; n2 = txtNum2.Text; n3...
This question is an improvement of this one here: Implementing a unique_ptr - PPP Stroustrup exercise Here's my new code, following the suggestions by @JDługosz. I agree with the fact that T* operator is much better than T *operator, but the code formatter of VSCode does this automatically, I'll try to fix it. Sorry f...
I'm actually developing bot in discord.py and the longer I'm developing this, the more often I'm asking myself 'Is this code well-organized? How could I improve this to make easier to understand this code in future?' There's code: from reddit_memes import * from new_video_checker import * from mmorpg_checker import * f...
The following code works perfectly. It just works very slowly. Is there any way to speed up/optimize this code? I think its the amount of loops but I am unable to figure out how to reduce the number of loops without hampering the functionality of the code. ''' Sub inland() Dim sort As Worksheet Set sort = Workshee...
I got a number that can range be either 10, 20, 30, 40... up until 100. I'd like to make an array from that number. The array should be structured as follows: If the number is 10, the array should be: [0, 1, 2, 3 ... 10] If the number is 20, the array should be: [0, 2, 4, 6 ... 20] If the number is 30, the array should...
recently I have been trying to educate myself on REST APIs. As a part of that, I have created a small project using FastAPI in python and I would love to hear some feedback about it. When I wrote this, I didn't take into consideration any design pattern, and honestly, I almost knew nothing about them - on the last week...
DbRecordset is a new class added to a fork of the SecureADODB library, which wraps the ADODB.Recordset class. It complements the functionality of the DbParameters class from the previous post and focuses on updatable recordsets. IDbRecordset class formalizes its public interface providing methods for querying and updat...
I made a Sudoku Solver after following some tutorials. Then I made a Sudoku generator and everything works. I also used classes to make it look more organized. I wanted to know what I can do better to optimize my code. I would like to make it faster and more readable but not at the cost of performance. One optimization...
According to an online judge, the limit has been exceeded. Could someone help me optimize my solution for the Greatest Common Divisor of n numbers: #include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; int a[n]; for(int i = 0; i < n; i++){ cin >> a[i]; ...
It's a simple program, the user is prompted to enter number of variables. Then the user is prompted to enter coefficients and constants. That many equations will be there as many variables. Once filled up, submit button is clicked and the solutions are displayed. I've accomplished this much successfully. However I'm...
I am attempting to plot histograms for batch of images in Matlab. The file structure of input images and the experimental implementation are listed as below. File structure of input images The matlab code HistogramPlotting.m file is placed in the project root folder and there are multiple folders which is named by its...
I'm currently reading about "Lean controllers"/"Business logic on services" and trying to refactor some legacy code. However I am struggling to apply what is taught in the tutorials to real code. Online examples are simple. But in real code, I have controllers that need to use filtering, sorting, pagination (and the fa...
I have this array with dates. All the dates are checked before creating the array with preg_match and check_dates. GoodDates ( [0] => 2021-09-01 [1] => 2021-09-02 [2] => 2021-09-03 [3] => 2021-09-06 [4] => 2021-09-07 [5] => 2021-09-08 [6] => 2021-09-09 [7] => 2021-09-10 [8] => 2021-08-11 [9] => 2021-09-11 [10] => 202...
For a fake interview I decided to write Hangman. The first question I have is when reviewing someone's code for a job interview is it more important to write something short and sweet that gets the job done, or to write something using Dependency Injection and small OOP modules? Attached is a small example I came up wi...
Imagine you want to reserve a classroom over several days. You get a schedule, from the school, telling you when a certain classroom is still free. To make it easy for your students, you want to reserve the classroom at the same time every day. Regrettably the schedule is long and complex, and you cannot figure out whe...
I recently made a new project for Chutes and Ladders (the Hasbro version of Snakes and ladders) and it is located here: https://github.com/vchittar/ChutesAndLadders BoardLogic (implements an interface): @Service public class BoardLogic implements IBoardLogic { private static final Logger LOG = LoggerFactory.getLog...
I'm reading a CSV using Haskell. I'm not sure if this is the appropriate way to do it. This is what I'm doing: Read rows from a CSV -> return lazy byte string Parse the headers and rows from the CSV to a tuple -> (headers, [Stock]) Remove the headers -> [Stock] Filter the stocks that are "Common Stock" -> [Stock] Prin...
My project has grown for a year and now comprises of 19 standard modules, 7 class modules 11 forms. Some of the forms appear to freeze when called but, in fact, they are just slow to respond, taking a couple of minutes, regardless of what is clicked, e.g. just a change of focus or triggering an event procedure. The for...
I have implemented Sieve of Eratosthenes in Java as follows. Is there a way I can modify the below code to make it more efficient? The current execution time is 0.8481224 seconds import java.util.LinkedList; public class LinkedListEx { public static void main(String[] args) { long startTime = S...
I've written a simple JS that takes care to animate an icon. At first I wrote it quickly and without paying attention to any kind of optimization: import '../js/core/sidenav.js'; const SIDENAV_ITEM_USER = document.getElementById('sidenav-item-user'); const SIDENAV_ITEM_SEARCH = document.getElementById('sidenav-item-se...
I have written a simple server to host my page and CSS (CSS file is 22KB). Using sockets and TCP. Can any one please review it and give feedback on how can I make my server reliable using TCP and other C related feedback. #include <unistd.h> #include <stdio.h> #include <sys/socket.h> #include <stdlib.h> #include <netin...
I want to convert string to object array. Suppose I have following string. const str = "someValue,display"; I want to convert it like following. [{ columnVal: "someValue", display: true }] if it's display then I want value as true if noDisplay then false. I tried following but, to me it doesn't seems like best so...
I previously posted some code I've been working on and had a fantastic answer, but as I didn't post the full code I was then unable to bring it all together using the much faster numpy implementation, so a review of the full code is much appreciated. I now realise that using vectorised operations would be much, much fa...
I have a collection of strings, all of which are three characters in length: string[] test = { "abc", "bbc", "cbc", "aac", "bac", "ccc" }; I want to determine which char is present as the center character in the most number of elements. I've created a Linq query that accomplishes this goal: var champion = test.GroupBy...
I am doing this problem: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versi...
Suppose you have an IO (Either String (String, [Int])) and you want to filter the [Int]. Let's say we want to use the following filter: :t filter even Integral a => [a] -> [a] As far as I understand we need to lift the function filter even to be applied to an IO (Either String, (String, [Int])), so I did: :t (fmap . f...
I'm seeing a React course, we were studying fundamentals of javascript for a while. We saw how to access the content of an object and display it in console. My solution for the problem of displaying an unknown object was the following: function unpackObject(obj, tabs = '') { const props = Object.getOwnPropertyNam...
I develop a CMS-agnostic PHP formatted HTML-CSS "contact now" panel, sticky in the bottom of a website screen. The code is tested and works as can be seen from the following image. I ask a review of the code, primarily about the everything-first CSS. Sidenote: I format the HTML in PHP because PHP supports include which...
I'm pretty new to python but after watching Mr Robot I felt inspired to make a CLI portscanner. With all the fancy console outputs you see in movies like a progress bar. It's finished and works nicely however I am not very happy with having to write twice global host_IP in main() and scan_tcp(). I have to do this the o...
I had a coding assignment to write a Rock Paper Scissors game. The main task is not to show a solution but rather to test the coding style. The rules are such: Problem: rock is "O", paper is "[]", scissors is "8<". George and John play RPC(rock, paper and scissors) a couple of times. I receive 2 input strings containin...
I'm new at coding and I'm learning it on freeCodeCamp, that's the most hardest problem that I have already do at that site. After finishing it (after I vibrated as if I had won a world competition of something) I go straight to the internet to visualize another resolutions and try to understand and get better on coding...
I have a typescript function that executes an array of actions on a given string value. This is the code: processValue(value: string, actions: Action[]): any { actions?.forEach((action: Action) => { switch (action.type) { case ActionType.Append: { const { appe...
I was wondering if there is anything that I could do to make my code look cleaner and more descriptive for educational purposes? def quick_sort(array, start, end): if start < end: pivot_index = partition(array, start, end) quick_sort(array, start, pivot_index - 1) quick_sort(array, pivot_ind...
I wrote an implementation of the Linked list data structure. I mostly did this because it's the simplest collection data structure (at least the simplest to implement), and I wanted to practice implementing IEnumerable<T> and IEnumerator<T>. I also wanted to play around with generics. This was entirely a practice exerc...
We have been given two sorted arrays and a number K . We have to merge the two sorted arrays in the sorted manner and return the element at the Kth position. My approach is to use two variables which will tell us where are we in the two arrays. Start comparing arr1[arr1_index] with arr2[arr2_index] and see who is sma...
This is my first day coding, and I need help with sorting a table in ascending/descending order. The idea is that when a column is clicked it will sort in ascending order, and then it is clicked again it will sort in descending order, then repeat. This is the function I have created so far. /* * A function to s...
My teacher gave us this game to make. basically, the computer needs to generate randomly 5 letters and there would be 5 players if the player guesses the correct letter given by the computer It would print "good job" else "good luck next time", I would appreciate it if you could make my code a bit better. from string i...
I implemented an enumerate() method for C++ containers similar to Python's enumerate to iterate through a range with an index and the actual value. I have the following questions: Does the usage of the Const template parameter make sense for this scenario? Do I need additional iterator methods depending on the type of...
I am new to golang and I tried to implement various cache replacement algorithms (FIFO, FILO, LRU, MRU, LFU) in a generic or flexible fashion. I added some tests as well. My implementation uses the golang list package, which is a doubly-linked list. I appreciate any feedback or review. Thank you. ==> cache.go <== packa...
This is a range class, similar in functionality to the range function in python. It was originally made to work with just range-based for loops, like so: for(auto i : range(256)) // do some code but was workshopped by some people better at C++20 than me into being able to be used with C++20 ranges, like so: auto i...
I've created a full Tic tac toe game in Tkinter that has single and multiplayer modes. The single player mode then has a hard and easy difficulty. The easy difficulty is just choosing a random open spot and the hard difficulty uses the minimax algorithm. On top of all that, the grid size for the game is adjustable, but...
I am learning Haskell and I implemented a recursive function that generates possible strings by length and array (e.g. ['a'..'z']): comb :: Int -> [a] -> [[a]] comb 0 _ = [] comb 1 r = map (:[]) r -- convert "abc.." to ["a","b"...] comb n r = [i:s | i <- r, s <- comb (n-1) r] For example, comb 2 ['a'..'z'] gives ["aa...
I have been learning Ruby for 2 weeks. Today my bootcamp teacher taught Ruby Class and gave me homework. I coded simple library program. But I think the code is smelling bad. How can do better the code? class Book attr_reader :book_name, :author_name, :page_count, :more, :book_array def initialize() @book_name...
I am trying to calculate the time difference between samples that a satellite takes at the same location. I have data currently in a Pandas DataFrame that has latitude, longitude, and time of the sample. Here is a snapshot of the data (it has some extra columns that can be ignored): JulianDay LatSp Lo...
Clickpocalypse 2 is kind of dungeon crawler game but with minor controls. Script's purpose to automate what is left. To try it out: Open "Clickpocalypse 2" as separate browser window (not a tab, game have to be in active tab to work without delays) Select your party members and let them start palying Paste code in dev...
The function below is written in Lua and returns the list of buffers from the current neovim session, it also allows the option to specify a optional table (object) as a parameter, with a listed property to filter the type of buffer returned by the function (only listed buffers, or every single one). local function get...
This code counts the number of possible positions in the game of Cram on a mxn board. EDIT 1: In the original question I mistakenly mentioned that this number is equal to the number of domino tilings. While the two are related, this is wrong. This is the first C code I've written in a long time and I wonder whether the...
I'm starting an object orientated game engine in Java. My plans for the engine is to be able to split things easily into multi-core loads. My idea is that a Unique (interface with a GetUID() method) gets passed in. The Unique can also implement any number of other interfaces. In this case, the unique can also implement...
I have written simple command line project with Spring. And from what I think quality of code is pretty poor. I see what I could improve to remove duplicated code, but somehow I have no idea what would be proper way to do it. So I will copy/paste only code which I think need refactoring. Thos are three separate service...
I have a school project question (for Python) that goes like this: Given a string_input such as "abcd&1-4efg", the function must remove the "&1-4" and insert the string slice from 1 to 4 where the "&1-4" was. eg. if string_input = "abcd&1-4efg", "&1-4" is removed. The remaining characters are indexed as follows: a=0,...
I'm doing a past-year lab test in preparation for my upcoming test and I came across this question that took me a while to solve. It asks the programmer to create a function, trace_contacts(), that takes in 2 parameters (patient, history), and outputs a list of people who may have been infected (either directly or indi...
I've implemented a map using a Patricia tree, using u64 as keys. I would like general feedback on my code, but I have one thing that I think could be implemented in a lot cleaner way, but I can't figure out how to do it: As a Patricia tree is a full binary tree (meaning all internal nodes have exactly 2 children), a no...
I am writing a chess project using C++ and SDL. In this method I calculate all available moves a Knight can make and I want to refactor it. I basically move the knight Up/Down 2 squares and then Left/Right 1 square and then do the opposite. As you can see in the 2 for loops the difference is the way tempPosition.x and ...
What follows is an evaluator for a toy expression language. The language includes functions of a single variable (with lexical binding), along with numbers and a way to apply functions to expressions. For the sake of simplicity, bound variables are represented using De Bruijn indices. The main questions I have are: I ...
I'm having trouble with the slow computation of my Monte Carlo simulation code. Based on the pycallgraph, the bottleneck seems to be the module named miepython.mie_S1_S2 (highlighted by pink), which takes around 0.5 seconds per call. Below is an example of the implementation of miepython.mie_S1_S2. m = 1.336-2.462e-09...