All Questions

Filter by
Sorted by
Tagged with
-2
votes
0answers
26 views

Making a function for a tie game in Tic Tac Toe [on hold]

I am making a tic tac toe game, and so far there is complete functionality except for a tie game instance. The program doesnt end when there isnt a winner. I am not sure how to approach this, maybe I ...
-3
votes
0answers
29 views

Chess OO design Movement Logic [closed]

I am reading a lot about chess impl and I have thoughts... In a lot of places I saw that Piece is the parent and all the types that can be as elephant are the children.There is abstract method : ...
-2
votes
0answers
30 views

How to vectorize the following set of code in python? [closed]

I am using NearestNeighbors for a text-based recommendation system. The purpose of the model is to return some set of codes For example: ...
6
votes
0answers
33 views

DSL for Makefile generation for dotfiles using symlinks

As I explain in my rant, I have been searching for a replacement to hand-crafted POSIX-make-compatible makefiles to manage my dotfiles (which use symlinks). I ...
3
votes
1answer
43 views

Pivotting SQL Table Response to JSON in JavaScript

Issue Our API returns two formats JSON and this SQL table format. I'm not sure what it is truly called so I'll give a few examples below. Like all API responses, it can be a list or a single response ...
2
votes
2answers
43 views

Cellular automaton (Conway's Game of Life) in python

As a practice exercise, I implemented a cellular automaton (Conway's Game of Life) in python (with help from this tutorial). I am very curious, if this code follows common best practices and I am ...
3
votes
1answer
35 views

Kruskals MST Algorithm

This code computes the Minimum Spanning Tree of a given graph using Kruskals Algorithm. It works successfully and I have provided test cases within the code. I would like feedback on code efficiency ...
3
votes
1answer
48 views

Print file out 1 character at a time in the terminal - Python

This program opens a file and prints the text out to the terminal 1 character at a time and at a predetermined speed using time.sleep() Simple and maybe, if you ...
-4
votes
0answers
15 views

In ionic i want to get the firestore doc id [closed]

In ionic, I want to get the firestore document id to display the stored information of the user who logged in. I set the documents name to the user's email like ...
-3
votes
0answers
47 views

Are there any ways to reduce the complexity of the following java code? [closed]

I need to reduce the following Java method's complexity to an acceptable level according to Sonar. At the moment, it gives this Sonar issue: Here is the code: ...
2
votes
3answers
118 views

Finding the next available filename

We're having a small debate in work about the following piece of code: ...
4
votes
1answer
55 views

Find Todos by Line Number (or any other reference) in Python

I write a lot of TODO's but I never keep track of where they are. This program will search through files (and recursively through folders if needed) and find any TODO comments and their line number. ...
-3
votes
1answer
67 views

Enhance Performance C# [closed]

I have the below code that performs well until input size reaches 1000. After that, it takes more than 2 milliseconds to finish. Any help? ...
2
votes
1answer
21 views

Find cycles in Graph using Union Find Algorithm on Adjacency List

My code detects if a cycle is present in a graph using Union find algorithm with Weighted tree analysis and path compression. It works and I have included test cases. ...
4
votes
4answers
1k views

Unix chat server making communication between terminals possible

This Server handles clients communicating with each other. Because I was not willing to actually give every client a name, they are named by their socket's file descriptor. This is my first ...
3
votes
1answer
28 views

SSH autokiller for connections from other systems

I was messing around with ssh and decided to write a python program that scans for any connections that aren't from the system, then terminates them. It works well ...
-1
votes
1answer
188 views

Angular - The complex flow of renewing expired JWT token [closed]

This the flow: login get two tokens (access token and refresh token) and two expiration time (one for each token) from server from now on the Angular application can determine if we're logged in by ...
-5
votes
0answers
35 views

Find the most occuring string in array with their required level [closed]

input = ['A','A','B','C','C','A','A','D','D','D','D','D','E','A','A'] requiredElements = 3 output = ['A','D','C']. it is possible to change the required elements ...
7
votes
1answer
78 views

Quicksort in JavaScript assuming an immutable array

Update: further succinct versions below (inspired by Haskell) Quick sort in JS assuming an immutable array: ...
3
votes
0answers
23 views

Swift iOS app for showing motivational quotes, with multiple screens

I'm one month into self-learning Swift, and I would like some advice to improve my coding skills. I have listed 2 situations that I think I need to improve. I'd like some feedback focusing on my use ...
3
votes
1answer
46 views

SQL queries in a dataframe

I want to get table names and column names from queries in a dataframe. The dataframe is like this: ...
-2
votes
0answers
22 views

Query is running slow even when the tables are indexed [closed]

The below query takes roughly 2 minutes for almost 2000+ records. The tables are indexed. what might be causing the issue? ...
2
votes
1answer
35 views

Project Euler #17: Number Letter Counts

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) ...
3
votes
1answer
22 views

Converting string of hex values to numpy array of specific shape

I am working on a project that needs to take a .bdf font file and turn it into a Numpy array. I am using the code below to turn the bitmap for the font into a numpy array. It currently works, I just ...
1
vote
0answers
20 views

Clojure test for Git operations

Is this code a good test for a testable Clojure code? ...
5
votes
0answers
63 views

A straightforward method for computing the Binomial probability mass function

I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have ...
3
votes
1answer
16 views

Bookmarking directories

When working on a large codebase, I often need to switch between deeply nested directories quickly. To make my life easier, I came up with a bookmarking script. ...
7
votes
1answer
80 views

Function to send email, refactored based on SOLID principles

I have the below method that is responsible for generating and sending a MailMessage using a SmtpClient object: ...
2
votes
0answers
48 views

Batch configuration script for a new computer

I've been working on a script which configures newly imaged computers (power settings, installed apps, etc) This is what I have so far: ...
1
vote
1answer
56 views

A minimalistic kind of read-copy-update class

This is a very simple read-copy-update (RCU)-inspired synchronization class: ...
2
votes
2answers
54 views

Rename and move images to a destination directory based on a text file followup

This is my third (and hopefully final) time re-writing this program. It was recommended I use Pathlib and it simplified my code, it's easier to read and understand ...
3
votes
1answer
77 views

Cancelable AsyncLazy that is thread-safe

I've been thinking about the AsyncLazy<T> class that Stephen Toub and Stephen Cleary present in various resources such as this. I am trying to find a way to ...
2
votes
1answer
44 views

Compare performance of Concurrent Dictionary with Dictionary+Locks

I wanted to measure the performance of Concurrent Dictionary vs Dictionary+Locks in a multithreaded environment. So I created my own SyncDict class of type...
-3
votes
0answers
29 views

pdf to text in Winpython [closed]

Could someone please point out the noob error being made in the following code to read text from PDF? [Just in case, portable WinPython needs to be used on Windoze without local admin rights.] The ...
4
votes
2answers
56 views

Array of all permutations in C

Is this a good compromise between readability and verbosity? Are there any bugs, additional error checking, or extraneous code as well? ...
7
votes
1answer
141 views

alternative to std::vector<std::function<…>> which uses tail recursion

An alternative to std::vector<std::function< >> which uses tail recursion to optimize calling the functions sequentially. I'm using this on a real-time ...
-2
votes
0answers
26 views

Python: Declaring a class within a function to encapsulate instantiation [closed]

I was wondering how acceptable or bad it is to declare a class within a function in python, that also takes care of a correct instantiation of this class. ...
3
votes
2answers
102 views

Text based fighting simulator in Python

This is my first large project, a text based fighting simulator. It is very clunky, do you have any ideas on how to make the code better? and how to make the code not get printed at once ...
2
votes
1answer
34 views

Trapezoidal rule for set of data

Here is the question from the book of Mark Newman-Computational Physics Exc 5.1 a) Read in the data and, using the trapezoidal rule, calculate from them the approximate distance traveled by the ...
2
votes
2answers
55 views

Filter list items

I have a list of items I pull from SharePoint and want to filter them in my custom list view page. So my function works exactly how I want, but it seems messy and I'm hoping someone could point me to ...
1
vote
1answer
49 views

A method to get a document's path

I have a model called Document, in this I have a method that I use throughout my website to get the full path to the specific document: ...
0
votes
0answers
16 views

Best project structure for styled-components that are rendered by multiple files [closed]

Here is my situation: Filter.js Renders a bunch of Filter components Filte structure: ...
6
votes
1answer
111 views

Calculate working hours using Python

This is a simple boilerplate / template for a bigger program (I hope), either linked to a DB or including a GUI frontend using PYQT or TKinter. This is just a little tool I wrote to keep track of my ...
3
votes
2answers
67 views

Count character 'a' in first n characters of indefinitely repeating string s

Problem statement: Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n ...
2
votes
1answer
85 views

Create Node tree from list of paths

I have this list of paths: ...
-3
votes
0answers
32 views

mips code in assembly [closed]

im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input ...
10
votes
6answers
4k views

Animal Shelter Management C++

I am working my way through "Cracking the Coding Interview" and I came up the question(3.6) to design a data structure to manage an Animal shelter with 2 animals, Cats, and Dogs such that when we ...
1
vote
0answers
14 views

Splitting torch tensor by flags

Working with PyTorch tensors, I need to split the batch of items by its flags, so the items in x_batch_one and x_batch_two are ...
13
votes
2answers
1k views

Asynchronous Circular Buffer in C#

Preamble I want to be able to test methods which communicate over a simple exclusively asynchronous two-way stream-like interface which may underneath use any of a number of communication methods (e....
5
votes
4answers
75 views

Project Euler #14: Longest Collatz Sequence starting point

Problem statement: The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we ...

15 30 50 per page