instruction
stringlengths
71
95.1k
I managed to make this work without breaking the program if you enter some weird numbers in the range. The thing is I know this could have been done simpler and smarter. I can't really see how right now so I'm hoping you'll enlighten me. Thanks print("Perfect Square Finder!") print("Enter a range to find perfect square...
I've been trying to implement delegate for my event system. I thought that maybe std::function can do the trick for me, but it turned out to be not comparable, so what i have end up doing is this - std::function replacement. It allows to bind function pointers to TFunction object and call it later with specified parame...
I'm having multiple FirstOrDefault() statements, in this case 2, on a collection. var id = data.Col.FirstOrDefault(x => x.Type == Types.Id)?.Value; var email = data.Col.FirstOrDefault(x => x.Type == Types.Email)?.Value; In the worst scenario this will loop 2 times over my entire collection. I'm searc...
(Previous and initial iteration lives here.) (The next iteration is here.) Now I was able to spare some lines by putting diff related state in an object. Also, I relied on Files.readAllLines, as advised. com.github.coderodde.diff.Diff.java: package com.github.coderodde.diff; import java.io.File; import java.io.IOExcep...
I am a newbie js "developer" and for practice, I created a tiny (8 methods) JavaScript library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how do I improve the code quality? full code: function isObject(val) { if (val === null) { return false;} return...
I wrote a generic dynamic array using the preprocessor. My use case for it is a compiler I'm writing that uses dynamic arrays a lot, and my current void pointer implementation is becoming a bit hard to use as I have to remember the type each array stores when using it. I'm wondering if this is a good readable implement...
I have solved this LeetCode problem. Depending (perhaps) on the server load, I once scored the following performance figures: My code follows: class LRUCache { private static final class LinkedListNode { final int key; int value; LinkedListNode next; LinkedListNode prev; L...
welcome everybody I wrote a simple code to measure time easily Features Easy include and just call timeit() Fast It just calculates the average time in the loop Light No lots of code, just one function is written CrossPlatform It doesn't using any third party libraries, so it should work anywhere Syntax timeit(name...
I've started teaching myself c/c++ with the intent of being able to writing python bindings to c code. I have a c library used for astronomical calculations given a date lat lon and some other parameters. In my implementation, I use a date range to run a start stop step for loop over the astronomical calcs (I don't ac...
I started writing this game from scratch yesterday, and I wasn't completely new to C++'s future library. I only use the std::async class to launch asynchronously the conio.h defined getch function, to get user's input without stopping the execution of the rest, which has to update the screen each 0.1s (I did it with ch...
I created a box-select feature for the tk.Text widget. You can select, cut, copy, paste, drag/drop and type with column-centric behavior. I'd like any feedback that is available. The code is pretty heavily commented, but I can give a gist of its working mechanics. Every box-selection-specific method moves, changes, del...
a maze solver in C. I have not included the maze generation code because i'm not looking for a review on that in this post, but the maze solver operates on a 1D array of cells, for more info: Maze generation algorithm review Sample run: Bottom left is the starting point (0, 6) Top right is the ending point (6, 0) solv...
C++ Timeit A quick C++ library to measure/compare code execution time Features Easy include and just call timeit() or compareit() Fast It just calculates the average time in the loop Light No lots of code, just two functions are written CrossPlatform It doesn't use any third-party libraries, so it should work anywhe...
I am writing a Python code to find the connected components of a graph using BFS. The code works but takes a long time to run. Please suggest possible optimizations of my code. The graph is stored as a dictionary g. For example, g could be {'a':['b','c'], 'b':['a'], c:['a','d'], 'd':['c']}. The list nodes contain all p...
I wrote a rudimentary graph class that supports the following eight combinations: Undirected/directed Weighted/unweighted Adj list/Adj matrix implementation #include <algorithm> #include <cassert> #include <cmath> #include <common.h> #include <list> #include <vector> #include <ranges> #include <stdexcept> namespace...
I am a self-taught front-end developer, trying to land a job, the PHP and MySQL are quite new to me, since I only watched and did some code through Traversy Media courses. This is a test project, where I need to build a product list page that pulls data from a database and presents them in tables/boxes. The entries are...
I am doing web scraping to the next web page (which is my root URL to start scraping tables): https://www.iso.org/standards-catalogue/browse-by-ics.html What I am trying to achieve is to parse the table with id 'datatable-ics' and then from the 'ICS' links contained in href tags from td in each row make a new request t...
I am just trying to understand the minimax algorithm better and how it works, so I made this basic connect4 game with raylib. It works fine, but I think there must be some kind of flaw in the logic, because the algorithm sometimes doesn't choose the fastest way to a winning situation. This is my core problem, but there...
I teach a data structures and algorithms course. Students can choose C++ or Java. As an exercise for myself, I am doing the assignments in Haskell. My primary goal is to understand what aspects of my class are easier in Haskell, and which aspects are more challenging. I am a fairly noob Haskell coder. Hence, I tend to ...
Background Info I am an intermediate level Python programmer. This is my implementation of a MP3 Playlist class challenge that was hosted on 101 Computing.Net. The goal of the challenge was to implement a Class in Python to maintain an MP3 Playlist. The key features of the class are the ability to: Enqueue an MP3 to t...
Given a pandas data frame containing objects with ids and latitudes and longitudes: id latitude longitude 0 a 52.617960 1.717728 1 b 51.773427 -4.455351 2 c 52.206543 -4.345786 I would like to find the closest object with a different id in the same data frame resulting in the following data: closest_i...
Attention: if you read the question and are going to use the defaultDiacriticsRemovalMap in the future → I analyzed the name of all professional football athletes and added some letters that do not exist in the original map, so it is modified for my use, test it first and see if that way too it's ok for you! Currentl...
I implemented (a refinement of) the Sieve of Eratosthenes for counting primes less than a given number n. This is a coding exercise from LeetCode. The class Solution is of course not necessary but only for the purpose of submitting the code on LeetCode. The code passes the tests when n is not very large, but "Time Limi...
Currently I find out which is the biggest array and from it I generate a while loop and I go around errors with try catch: function stackoverflow() { var sheet = SpreadsheetApp.getActive().getSheetByName('Ratings Time A'); var menu = [ ['Atletico Lanus'], ['1795.72'], ['Atletico Lanus'], ['Independi...
I am given a task to update MongoDB document timestamp-type field. Because of different kinds of field name, I have to check field name many times. This code works and does exactly what I want to, but it is inelegant. Is there has any pythonic way? ''' --------------- user --------------- _id | ObjectId...
I have written this code to write string to file. If File is not created then create file and If created append to same file. File is created daywise. public static void WriteLog(string sMessage) { try { //string logfolderpath = System.Configuration.Config...
I have a list of words in English. My aim is to find all pairs of words that differ by exactly one letter (i.e. edit distance is 1). For instance: PAY-PLAY, WARM-ARM, WORD-WORK. The naive algorithm is to compare every word with all other words in the list. I've improved it by noticing that if one word is two letters or...
I am working on a groupby-aggregation function that will work without RAM overflow issues. Essentially, I want it to run as fast as possible, while not necessarily loading the entire data structure into RAM. The best solution would load as much as possible into RAM for increasing performance/speed, and then offload p...
C++ FString A quick C++ formatting library I was working on a logging library, and needed some way to format strings quickly, simple and clean, so I wrote this library. This library is not the best in general, but for my project needs it is the fastest and the best Features Easy include and just call fstring() Fast ...
(See the previous iteration here.) After further revising my code, I have: com.github.coderodde.diff.Diff.java: package com.github.coderodde.diff; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Objects; public class Diff...
Recently I was writing a class that had overloaded read methods for various data types. One of the sets of types I wanted to handle were integral std::chrono::time_points. For this I wrote the following code: // Return a timestamp from a chunk at a given offset as if from an // integer in network byte order tem...
I am currently building a custom dynamic tab component. In my component, I am dynamically creating a class name which I use to determine which tab is active and which is not. It seems to be working though upon observation there seems to be some errors. The objective is to include a background colour when the active tab...
I decided to try and make a code that can calculate the n-th term of any sequence (any sequence that only contains n^a, sequences like a^n and n! won't work) and calculate the next numbers of the sequence to further my understanding of Python, here it is: from math import factorial from fractions import Fraction class...
I am trying to create a string class without std::string. Just for educational purpose. So I created some utility functions, and it would be very nice if you guys could take a look at the code for mistakes. Does anyone see any errors? (probably) // Includes. #include <iostream> // for "print()" and "std". #include <ss...
I have two Pandas data frames: one with Daily data and one with Weekly data. I want to add the weekly data to each row of the daily data for each group of column A. For example, for each row on the daily data frame from 2022/07/04 to 2022/07/09, I want to add the weekly data from 2022/07/04 for each group of column A a...
I have been working on a library to represent graphs (directed graphs and undirected graphs). I know that there are already many such libraries but I wanted to create my own as a learning exercise. I have not tested the library extensively so there are likely to be bugs etc. But what I am really interested in is the de...
I'm packing several values from a struct into a buffer to send them over Bluetooth. I don't want to send the whole struct and I also don't want to deal with padding, so I'm copying just the values I need. I also don't want to use anything that requires external tooling like Protobuf. This is what I came up with. (Short...
I've written code that 99.x% of the time does the same thing as def format(timestamp: datetime) -> str: return timestamp.strftime("%X") but follows the German "Sommerzeitverordnung" ("daylight savings time decree") during the hour before and after the autumn switchover. Die Stunde von 2 Uhr bis 3 Uhr erscheint da...
so Im trying to wrap SQL INSERT statements to PDO transaction in PHP OOP. I don't know if I'm doing it right and this is the best/easiest way to do it. So what is important for me is: There can be multiple(unpredictable) INSERT statement (which will be in loop in the final code) I want to wrap all of these queries to t...
I made a small shell implementation in C. It reads stdin and executes the command. It can also take in a file name from argv and execute all the arguments in the file. It supports redirection with > and you can also run multiple commands with & in between commands. It has 3 built in commands which are cd, path and exit...
I am using a python scraper code to grab publicly available data from http://103.48.16.132/echalan/ but it takes almost ~6gb of memory and more cpu. I need to run multiple instance of the this code which is not possible thusly. Can anyone suggest me a tweak or edit to lessen the memory and cpu footprint of this code. I...
In a docker compose environment there are several apps that communicate with each other. One of these apps is a logger (a centralized logger). Every part of the system that needs to log something, will call the logger's APIs (which is written with gRPC). The logger adds these log requests to a queue (a BlockingCollecti...
I've been working on a WebGPU-backed Rust renderer that batches together 2D colored sprites. I hadn't gotten onto the "sprite" portion of it yet, but I'm already finding some performance issues. Although the code works, the renderer can't easily handle 8000 colored quads, while other renderers seem to easily hold their...
I wrote the following script to parse an SEP article and call pandoc to convert it to EPUB. I'd love your feedback. There is no function but I didn't think it was worth adding. Also there is no test to see if the file is executed or imported, but since it is supposed to be an executable this is not a problem in my opin...
I'm currently working on a solution to add a number to a file name if the number does not exist or increase de number by one if the number exist. For instance if you input "filename.jpeg" the code will add a 1 and return "filename(1).jpeg". In case the number already exist in the name for instance "hello_world(3).pdf" ...
Here's the code for a Breakout style game I made in Python. I was hoping to see if someone can give me some advice on improving anything. I have a bug with the collision between the ball and the top bricks/blocks, and I'm still working on that. Since it doesn't follow "code review" I have removed what I said earlier an...
Trying to implement a simple memoize using Map, so that it can support Symbols and Objects using reference, please let me know if I am missing anything import { MEMOIZED, NOT_FOUND, VALUE_KEY } from "./constants"; import type { Memoize } from "./types"; const getFromCache = (cache, args) => args.every(arg => (cache ...
(See the next iteration .) I have this program (call it, for example, prioset.exe), that asks for two command line arguments: (1) the target process PID, (2) a priority class selector in the range 0...5 (as specified in the WinAPI docs, where 0 stands for idle priority class, and 5 for real-time priority class. My main...
A function to create a radial gradient from one rgb colour to another and using rayon to improve performance. Are there better way to convert between some of the types / any obvious performance improvements I could implement? use image::RgbImage; use rayon::prelude::*; fn radial_gradient( geometry: (i32, i32), ...
I have a problem where I need to display the below output 1 23 456 78910 My first solution is let numberStepper = (stepLimit) => { let stepCounter = 0; let step = ''; for(let row = 1; row <= stepLimit; row++) { step = ''; for(let col = 1; col <= row; col++) { stepCounter++; ...
Our team often has indeterminate access issues to our Aritfactory binaries. These issues can go missed because we may have our binaries locally cached and our projects builds may still succeed until there is new dependencies that might throw an error. I wrote a simple script to try to access Artifactory and alert us if...
The problem I have solved is as follows: Consider a table of dogs, DOGGIES, that records on each row the ID of a doggy, one skill that they have, when they started having it, when they stopped having it (assume a useful placeholder if they never stop), and an extra bool column called IS_NO_LONGER_GOOD_BOY. This bool c...
I am trying to become better at designing classes for dependency injection and IOC in general. It is often not an intuitive concept. I have the following python interface and implementation for a string-based logger. class ILogger(ABC): @abstractmethod def info(self, msg: str): pass @abstractmethod...
After improving the previous post, I came up with the following program: #include <Windows.h> #include <iostream> #include <sstream> #include <string> using std::wcout; using std::wcerr; using std::wstring; using std::wstringstream; static const DWORD BAD_PRIORITY_CLASS_SELECTION = 0xffff0000; static void MyPrintHel...
I have the following DataFrame in pandas: code town district suburb 02 Benalmádena Málaga Arroyo de la Miel 03 Alicante Jacarilla Jacarilla, Correntias Bajas (Jacarilla) 04 Cabrera d'Anoia Barcelona Cabrera D'Anoia 07 Lanjarón Granada Lanjaron 08 Santa Cruz de Tenerife Santa Cruz de Tenerife Centro-Ifar...
In the posts I have a date field and a start and end date range. I need to query if it matches date or if it matches between the dates in the range. This Query works, but how can I optimize? $args = array( 'post_type' => array('post'), 'post_status' => array( 'publish' ), 'posts_per_page' => 20, ...
I'm trying to get the diff between two directories, e.g. dir1 - changed.txt - deleted.txt - index.txt - nested - changed.txt - deleted.txt - index.txt dir2 - changed.txt - added.txt - index.txt - nested - changed.txt - added.txt - index.txt } added: ["added.txt", "nested/added.txt"] delete...
I tried and made a program using my beginner knowledge of C to split a string into multiple sub strings. I just wondered how languages like Python and Javascript implemented the split() function. Thus, I gave it a try. It works and gives the desired output. Since I'm a beginner, I'd be really happy if someone reviewed ...
I am aware there are several ways to deal with shell-executions in Python but I haven't really found the right one for me as it includes the following structure: command [--maincommand.subcommand value] I want to create a backup of a collection from my ArangoDB, using: arangodump --server.endpoint tcp://qohelet.at:81...
I have recently started coding in Python and this is my first proper project. The user enters an RNA sequence and the program converts the code into the corresponding amino acid sequence. The user can then choose what kind of a mutation they want to introduce and where. The program will then output the amino acid seque...
Created a linked-list based queue and stack. I was required to use my Dlist implementation when coding the queue and stack. /* * Linkedlist.h * * Created on: Jul 12, 2022 * Author: nick */ #ifndef LINKEDLIST_H_ #define LINKEDLIST_H_ #include <cstdlib> #include <iostream> using namespace std; template <t...
I wrote this script for gaining experience, this script takes in a website link (NSFW) and download the video on that site. It uses regular expressions to parse the website source code to extract urls for downloading. I'd appreciate it if anyone could take a look and told me the all thing I did wrong, as I'm sure I hav...
A c# format provider that formats a double into a string using engineering notation rules. If the value is outside of the defined notation symbols it will default to using scientific notation. I wrote this code to better handle a mess of case statements that previously handled the engineering notation formatting for an...
I have completed a project I was working on using the methods I know how, but it is very inefficient. I am a beginner trying to figure out how I can improve my work by using software solutions. I have a large dataset and I put it into smaller dataframes (grouped by part numbers) which I will loop through to perform the...
I have come up with a quick and simple IoC container to enable minimal dependency injection support in one of my Java projects. The container supports services with: A transient lifetime, meaning, a new instance of the service will be created each time they are requested from the container. A singleton lifetime, which...
The following class is used in an application to record internet radio streams*. These streams consist of big chunks of audio data with smaller chunks of metadata between them. By monitoring the metadata, one can determine not only what song is playing at the moment but also when the song changes. *AFAIK this is legal...
I would do this in SQL using string_agg but the server is SQL Server 2012 and beyond my control. So I'm trying a python approach. I have a dataframe of shape [20225 rows x 7 columns], and there a bit of transformation required. There are sometimes duplicate rows, but only in one column. So what I want to do is find the...
I'm writing a C/C++ (intended to also be valid C code) for having a noreturn macro variable as widely portable as possible between C and C++ compilers. #ifndef __has_include #define __has_include(library) 0 #endif #if __has_include(<stdnoreturn.h>) #include <stdnoreturn.h> #endif #if __has_include(<stdnoreturn.h>) ||...
I noticed I tend to use many if-conditions in my code, and I know there is a way to simplify this with one-liners. The function is iterating through configuration dictionaries so that I can log parameters in MLflow not as a long non-readable string: but as key-value pairs: !pip install mlflow !python -m pip install -...
The array contains digits and it is unsorted. Its length could be as big as 120000. I need to count the smaller numbers to the right of each digit. This is a coding challenge on Codewars which requires a specific code efficency to be completed (Solve X amount in Y time). https://www.codewars.com/kata/56a1c63f3bc6827e13...
I have a use case where I need to check, whether / is mounted read-only. Here's the module where I implemented this check: """Check mount points.""" from __future__ import annotations from contextlib import suppress from os import linesep from pathlib import Path from re import fullmatch from subprocess import check_o...
I am writing a small framework that I intend to build upon in the future. I am also using this framework to teach people how to support multi-threading in 3D rendering, and thus wanted to be sure I was exposing them to code that was decently clean. The goal is to write a simple example in which we split a frame into ti...
I have written code for the basic implementation of a Deque in C++ using Array(pointer). Please review my code and suggest ways to make it simpler, compact, and efficient. Also would appreciate feedback on any aspect of my code. #include <iostream> #include <cstdlib> class queue { private: int size = 0, front = -1...
The code has been super useful with my work datasheets. They all have this pattern and the VBA code makes sure it all has the right format. Why is it so slow? Sometimes it takes 2~3 minutes to run a few lines of data. Sub a_organizar_protocolo() On Error Resume Next Application.DisplayFormulaBar = False Ap...
The code below has been a vehicle for learning the syntax of inline assembly for gcc/clang and that is the focus of my question. In addition to anything else that I've missed I would also like feedback on the following statements: If r's constraint were instead "=r" then the compiler would be free to assume that the ...
I am quite new at C++ and I really wanna learn how to work with allocating memory. So I have created some utility functions. I am aware that C++ uses new and delete instead of malloc and free Do these functions cause any memory leakage? (They probably do since I am experiencing some bugs). // Includes. #include<stdio.h...
The following is a function that I am working on: function descFormatter(version, product) { formattedDescription = ''; if (version.includes('aef')) { product = product.replace("^", "*"); formattedDescription = `${version}:${product}`; } if (version.includes('eef_{placeholde...
I'm grabbing the totals of each string that I created. Is there a way to simplify this by doing loops? I've tried a couple different methods but haven't had any luck. This code prints what I want too. But I know their is easier way to write it. using System; using System.Runtime.InteropServices; using Excel = Microsoft...
I am implementing some of the architectural designs from Google I/O's app to my own app, but I have come across something in their app that has created some confusion for me. They have a domain layer with repository usecases, which I use myself in my apps usually. However, I do have to provide these usecases with dagge...
In an application there is a table for one-time-passwords (OTP) which will be sent to users via SMS. These OTPs are needed for a maximum of two hours in order to detect abusing behaviours. A simple DB cleaner will delete these rows (DeleteAsync is from this library): public class DbCleaner : BackgroundService { pri...
The Solution I recently came across this solution here, for a Type.FromText() function in M for Power Query*. This solution allows a user to extract the actual type itself of a column, as named (textually) in the TypeName column generated by Table.Schema(). It struck me that there is a solution far simpler than listin...
I have tried to come with below bash script which is at least working for me, i know its not perfect and that why i want some review and suggestion to make it more aligned with bash practices. I'm trying to read bash manuals and seeking help from google and stackoverflow questions and answers. I'm not able to explain w...
I wasn't quite happy with the way localStorage handles non-string values, for example localStorage.setItem("foo",{test:5});localStorage.getItem("foo"); returns string literal '[object Object]', so i thought it would be a good idea to wrap it in json, came up with betterLocalStorage = { get: function(key) { ...
Intro I have been learning haskell and functional programming using random Project Euler problems. Currently, I have solved Problem 11. What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? My solution My solution consists of 4 parts. Fi...
Here's the result: use std::env; use std::error::Error; use std::ffi::OsString; use std::process; use std::vec::Vec; fn print_line(data: &Vec<Vec<String>>, name: &Option<&String>, col: usize) -> Result<(), Box<dyn Error>>{ if let Some(n) = name { print!("{} = {{",n); }else{ return Err(From::fro...
I have the following text dataset: 4 million paragraphs of length between (10-60 words each). paragraphs = ['yarrow heart lamium bleeding daisy pea', 'sweet shasta sedum daisy yarrow rhododendron', 'rhododendron pea shasta daisy gladiolus heart', 'gladiolus lamium rhododendron heart pea shasta', 'heart daisy yarrow...
I've long used a simple matrix class with a vector and rows/cols for the shape. But I've always disliked getters even when necessary to prevent exposing invariants. Then came c++20 which provided the ability to modify consts in a class with the change in Basic.Life. So then I modified my matrix class to get rid of the...
I already know that I shouldn't really use the global function and that how I judge who wins is also really inefficient so I would appreciate improvements for that. I watched a tutorial about Object Oriented Programming and this was my first attempt at using what i learned. I redid a game I did without OOP. The Rules f...
I wrote a C++ simulator that performs algorithms for glibc malloc() and free(). The core logic is basically the same, with the following differences: chunk alignment unit is sizeof(Chunk) (32 in a typical 64bit machine), whereas in glibc it is 2 * sizeof(size_t) (16 in a typical 64bit machine). glibc uses an equilibri...
crustaceans! This is my attempt at creating an all_pairs operation for rust iterators. The code has to generate a new iterator which, when iterated, produces all pairs of elements from each iterator, so for example: assert_eq!( vec![1, 2].iter().all_pairs(vec!['a', 'b'].iter()).collect::<Vec<_>>(), vec![(&1, &'...
I created a class designed to validate passwords based on user defined criteria. Each PasswordValidator object objects a minimum and maximum password length, a character blacklist, as well as customizable Uppercase, Lowercase, and digit requirements. I am well aware that I could have used regex but I wanted to avoid us...
I have a requirement to essentially scan a filesystem on any kind of filesystem and move a resource whenever it is ready. To do this I have the following code from dataclasses import dataclass from datetime import datetime from enum import Enum, auto from typing import Optional, Callable, List, Any, Dict from os.path i...
Here is the function called sumZero, where it should return the sum of any two numbers in the array to sum upto zero. where the array is a sorted array. My approach: Using 2 pointers approach, calling it as p1 and p2, where p1 points to zero, and p2 points to p1+1. and pointers get incremented function sumZeroPointers(...
Coming from a python background, I recently started learning django, currently at the javascript section. This tic-tac-toe code is to familiarize myself with javascript basic concepts. No application code is included, just JS and HTML. tic-tac-toe.css td { background: black; width: 2em; height: 2em; fon...
After writing a C++ simulator for malloc() and free(), (C++ imitation of glibc malloc(), free()), I thought: "My simulator cannot expand the initial arena. Then how about giving the initial arena a really big one from the beginning? If I can't put the arena in the main memory, I can just have it on a disk file!" So I w...
I made a 3 reel slot machine using the pygame library in Python. This is what I have so far. I want to improve it to make it work for a 3x5 slot machine with multiple paylines, right now it is a 1x3 slot machine. I also want to improve on my programming skills as I am still fairly new to programming and have only been ...
Hi this is my problem statement File 1 contains lines like this : aaaa 1 aaaa 2 bbbb 1 bbbb 2 bbbb 3 cccc 1 cccc 2 dddd 1 dddd 2 File 2 contains these lines: aaaa cccc I need to find from file 1 the matching lines for the last occurrence- so my output to be like aaaa 2 cccc 2 I wrote this i...
I needed a PHP function that would filter values from one array into a new one, while also removing those values from the original array. After looking through the docs, I didn't see any such function, so I wrote my own. While I don't expect it to run with any comparable efficiency as a native function, I am curious if...
I currently have some code in Java which looks something like this, but I want to refactor this. List<Object> combinedStatus = new ArrayList(); for (List<Long> batch: batches){ CompletableFuture<Object> future = ask(); futureHolder.add(future); } try { for (CompletableFuture<Object> future: futureHolder) { ...
I made a program that allows a player to play Tic Tac Toe against a computer. Of course, I didn't make it analyse the slightly harder algorithms, as I am just a beginner at programming. Are there any ways to improve this code? Is it quite long and hard to read. from random import randint from turtle import Screen impor...