# All Questions

75,560 questions
Filter by
Sorted by
Tagged with
2 views

### Barabási–Albert model : Exponent value is not coming right as suggested by theoretical suggestion

i'm writing code for Barabási–Albert(BA) model, i checked the degree distribution its power law but the exponent gamma is (1.5) and the condition it should be between (2-3), can anyone tell me what ...
6 views

### Basic OpenGL application that renders multiple cubes on a textured plane, setup for a 3D game

I'm learning OpenGL and started work on a small 3D game (like Sokoban) for practice. I want to know if the design of my OpenGL code reflects a good understanding of the technology. For example, one ...
1 vote
11 views

### Cows and bulls game in JavaScript

I've been working on this game the last 2 days. The game is working but I need a feedback for my code. Can it be made simpler? Sorry if my code is very complicated or not well written: I am in the ...
8 views

### Codeforces 1574B [closed]

The following Python code is my solution to this code forces problem: https://codeforces.com/problemset/problem/1574/B. I coded the same thing as the tutorial (https://codeforces.com/blog/entry/95188),...
17 views

### How to add RMSE to python code? [closed]

I want to add RMSE into the python code. I've tried inserting the rmse code below but i got error only. How do i insert rmse into the whole proper code ? ...
18 views

### Playing a game of ConHex in Python

Background ConHex is game by Michail Antonow where two players try to create a connected chain of cells from one side of the board to the other side. They do this by claiming one empty position each ...
• 401
11 views

### java String default value in for each loop [closed]

what is the default value in x in this for each loop ...
35 views

### AES GCM C++ implementation

I have written a C++ program that uses the Crypto++ library to encrypt files using AES-256Bit (in GCM mode). I am planning to eventually have the program store the keys for the files in a file e.g. ...
• 11
40 views

### improved "tee" utility

We have modified the tee program with your suggestions from the previous pull request. Did I implement well? I would like to optimize the program even more, what ...
• 179
12 views

### daemon in a producer-consumer

The daemon program is associated with a message queue with a predefined key, to be blocked later when waiting for messages. The two programs implement a producer-...
• 179
12 views

### Resources/Advice for Stochastic Simulation Python [closed]

I am quite new to writing code and I am trying to reproduce the simulations found in Fig.2 of this paper on the age incidence of CML (https://www.pnas.org/doi/pdf/10.1073/pnas.0607006103). I think I'...
23 views

### Can I optimize my implementation of generating Fibonacci series using recursion?

My function accepts a number, which generates total Fibonacci numbers. I am using recursion. Please follow the code below, ...
70 views

### Calculate the first largest factor of 600851475143

ٍProblem description: The prime factors of 13195 are 5, 7, 13 and 29. Largest prime factor 13195 is 29. What is the largest prime factor of the number 600851475143 ? Prime Factor: any of the prime ...
11 views

### Closing handles in Powershell; handling partial cases in a DRY fashion

Powershell contains no "goto" statement which is the normal way C++ code closes or 'frees' handles at the end of functions that use several or many handles (pointers). When interating with ...
• 109
8 views

### Rust program to print citations in Chicago author-date style

I have written a Rust program that lets you input a citation's metadata in a Bibtex-like format and generates a bibliography entry formatted in Markdown that conforms (more or less) to the Chicago ...
• 195
206 views

### Kosaraju's algorithm in C simple implementation

I am wondering can I please get some feedback for my simple implementation of the Kosaraju algorithm. More specifically how I de-allocate the things I allocated using ...
• 359
34 views

### Is this a correct implementation of factory method pattern? [closed]

Below, I have an implementation of the factory method pattern in Python. I don't like that I have to pass to get_instance the data object always with communities ...
19 views

### Basic authentication used to call a REST API, but how to determine if a wrong password is entered? [closed]

I'm using the following HTTP Basic Authentication with PHP to prompt the user for a username & password which is then passed to a REST API call to start or stop a process. As written this works ...
298 views

### A probability distribution function, to be called repeatedly during numerical integration

I am trying to speed up as much a possible this function in C++. As I explained in another post, Implementing multidimensional integral for a custom function in C++, this function will be used inside ...
• 259
26 views

### Correct usage of Java Generics for a simple cache holding objects of any particular type that contain an identifier of any particular type

The Stack Overflow question, I'm trying to create an inMemory database using Collections and generics, presents some code that attempts to use Java Generics for an in-memory cache of objects of any ...
32 views

### Magic Class Invoker for procedural script

I have inherited a project in bad conditions that contains the following class and I need your help to improve it, the truth is I don't know if it is correctly optimized or if it has security problems ...
• 111
22 views

### Python Data structure(Cannot understand one input in the solution) [closed]

You are analyzing sales data from a ticket office. The ticket for an adult is $20, while the ticket for a child under 18 is$5. The data you are given is in a dictionary format, where the keys are the ...
1 vote
43 views

### Hash game in C optimization

I developed this hash game in C for my college, but i need to optimize this code, can you help me? it works well, but I need it to be a little more organized and faster, the rand function is the only ...
25 views

### Python function that skews an image while preserving its aspect ratio using affine transformation

See this post for more details. I re-implemented my idea using affine transformations, and finally understood how transformation matrices are formed... Turns out it is stupidly simple, but nothing I ...
• 1,522
1 vote
23 views

### Process a binary file by chunk using a read stream in nodejs

I want to process a file chunk by chunk to prevent memory exhaustion. I need to consume the file using a read stream. When trying it, this implementation seems to work fine. I am asking your expert ...
• 143
1 vote
25 views

### Event handler for client webrtc video chat

This is my event handler for a videochat client that takes all the events that the server throws at us and routes them to different functions. All of the functions are imported and both settings and ...
• 11
74 views

### Calculate the sum of even Fibonacci numbers

This is my solution for problem 2 of Project Euler using Python: ...
17 views

### php flock with two instances [closed]

I am calling this script as "php flock.php" while logged in from ssh. for the past couple of days I've been trying to get the "Can't run, sorry" from one instance but both just ...
9 views

### Using Kotlin coroutines, is this the proper way to schedule a task whose result you don't care about inside a suspend function? [closed]

I'm kind of trying to simulate getting cached stuff from some cache and then update the UI and the cache with a webservice call. I'm wondering if this "skeleton" of doing it is fine. Is it ...
46 views

### Function that calculates the least amount of notes a ATM will dispense for a given amount

This is the code currently and it works. Currently have a DB with the type of note and the amount of that note available. This will, later on, remove the amounts of notes from the DB. I am happy with ...
23 views

### Validation rules for payment cards in a data set

I have the following part of code. I dislike this, because if I need to add additional validation rule, I have to make changes in loop and create a varaible to store boolean result. For example check ...
16 views

### pending signals using the sigpending() function

I used the sigpending () function in the next program to check the signals waiting at 1s intervals and display their numbers, then it ends with ...
271 views

### Project Euler - Problem #1 - Multiples of 3 or 5 - Python

This is my solution for problem 1 of the projectEuler with python: ...
41 views

### Changing the attributes of a file

I wrote a program that changes the attributes of a file. How can I make the program more efficient? Please find program problems. How can I improve the program? ...
• 51
55 views

### Recursively search directories and their subdirectories for images and videos, except system or locked folders

Search directories and their subdirectories for images and videos, except: Windows system folders, locked folders, and folders selected by me. For example, as a developer I have dozens of Visual ...
• 175
1 vote
30 views

### Multithreaded tcp server accepting two clients with task factory and graceful shutdown

as an exercise from multithreading and networking I have decided to create my own implementation of TCP server accepting connections from two clients (which is I think a pretty common case e.g. chess ...
• 11
1 vote
18 views

### Scala & Kafka: Getting the producer and consumer offset difference and log it

I'm looking to compare kafka's producer and consumer ...
• 111
6 views

### Getting "Cannot invoke "String.equalsIgnoreCase(String)" because "this.a" is null" error [closed]

enter code here package practice; import java.util.Scanner; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa....
28 views

### Integer array to string

This function creates takes an int * buffer and creates a neatly formatted string (useful for printing the contents of an array). Is the code easy to follow? Is it ...
• 155
149 views

### Dart Ioc Container

This package is on pub dev here It's on Github here ...
13 views

### How do I make this jQuery not wait for document [closed]

I'm trying to not make the document wait until it's completely finished loading, I just want the code to run normally, how can I modify this code so that the document isn't waiting? ...
1 vote
16 views

### Unit tests for PNGme steganography exercise in Rust

I want to become proficient in Rust and I've followed the PNGme exercise. I've completed it up until Chapter 4 included, where I've written a lot of tests myself for verifying that the command line ...
• 111
19 views

### Async recursion that must ultimately return a promise

I have an asynchronous function that must ultimately return a Promise (the first function). This function has many tasks but I've stripped them all down to just one for clarity. One such task is a ...
• 113
1 vote
73 views

### Minesweeper implementation in C++

I have implemented minesweeper in C++. You can get a box by entering the coordinates -row number, then column; starting from 0- of said box (eg: "0 0"); you can mark a box as a bomb by ...
21 views

### Spawning a child process that is accessible in global scope through use of eval()

So basically my question is what would be a better way to achieve my goal? The code below works fine but looks like it is extremely inefficient and could be achieved in a better way. The code ...
• 103
63 views

### Need to make my Tictactoe Game better (Java)

I need some help with a school-project that I have! My code is very unnecessarily long, and I know that there is better ways to write it. So I have this code (generated code is not included & some ...
1 vote
45 views

### A reduce method which aggregates common data in objects

I built a method using reduce of JS to aggregate together data from a DB in a better shape. What I'm wondering is, if that method can be simplified with a more ...
• 229
435 views

### Implementation of the "tee" utility program

How can I optimize the program? To make it more optimal? The program should be more optimal in terms of source code, compiled executable size, memory usage, speed, bugs etc. Please criticize the ...
• 179
36 views

### Game based loosely on cricket

Cricket is a PC game which is similar to real cricket but has little different rules There will be N number of players , Y number of overs, here one over means each player will hit one ball each, let'...