All Questions
75,874
questions
3
votes
2
answers
65
views
Re-designing c-style Input Output
Re - designing c-style input output [ btw I use printf() and scanf() in the core ]
Reasons for redesigning it :-
Needs 2 functions for input output [ namely ...
4
votes
3
answers
258
views
Split word based on terms from an array
I was faced with a coding challenge and I'm looking for a more elegant way to achieve the goal.
The challenge
Take the word baseball from the first item in the string
array and split it into two ...
6
votes
1
answer
185
views
Proper way to send and receive buffer in Winsock
I have a piece of code to send and receive buffers. Is this the right way to do it? And am I guaranteed that the full buffer will be sent and received?
receiving function:
...
0
votes
0
answers
36
views
JMH benchmark for IndexedLinkedList
I have this data structure, which I benchmarked (link here):
...
1
vote
0
answers
31
views
Hashing service for files or directories on a generic filesystem [closed]
my program requires a hash to be generated for files and folders for data integrity between transfers and file system events (if hash is different, file is not ready). For data integrity, I wish to ...
2
votes
1
answer
63
views
A simple hangman game in Haskell
I just finished a course of functional programming in uni and continued to study Haskell because I found it very interesting! I made a simple hangman game and would like to hear any of your thoughts ...
3
votes
1
answer
175
views
API client that builds a response over multiple lines
I am performing a REST API call and I have copied their example code where they show how to perform such an api call. Their example is written in Javascript not Typescript though. To adapt the code I ...
2
votes
1
answer
79
views
Boolean evaluation
Given a boolean expression consisting of the symbols 0 (false), 1 (true), & (AND), | (OR), and ^ (XOR), and a desired boolean result value result, implement a function to count the number of ways ...
2
votes
1
answer
48
views
Clear output line in terminal after use for countdown (different length strings)
The method to overwrite the same line is well known and I use it for countdown, but what about when the next output string has a different size and will be generated by a single print? That's the ...
2
votes
1
answer
23
views
Implementing Ord trait for an Iterator Wrapper
Recently, I needed to sort iterators by their first value and/or use them in BinaryHeap. There are things I don't like about this implementation:
Using RefCell.
...
0
votes
2
answers
45
views
Speeding up row insertion to Pandas DataFrames [closed]
I have the below code that seems to be taking a while to run over time.
...
2
votes
2
answers
193
views
Multi stage Dockerfile for eccode compilation
I wrote a Dockerfile to install ecCodes for use in a python environment using cfgrib and xarray.
The tarball can be found on the ecCode releases page
Dockerfile
<...
1
vote
1
answer
53
views
Minimum number of swaps to sort a array, but swaps only allowed with elements 2 apart
I wanted to solve a problem where I sort an array of any size and return the minimum number of swaps.
The explanation for the distance 2 is that I choose 3 neighboring elements ABC and then swap them ...
15
votes
3
answers
3k
views
My 1 Week Python Journey — A Quiz Game that I made in Python
I started my Python Journey almost a week ago from now. I had been following a Youtube tutorial earlier, but switched to Harvard's CS50P instead. I decided on making a little Quiz Game with my ...
0
votes
0
answers
25
views
Create a shortcut with admin rights for the current vbscript or any other application with arguments using an array
I made a subroutine in order to create a shortcut for the current vbscript or any other application with arguments using an array that can be called as follow :
Create a shortcut to the current ...
2
votes
1
answer
43
views
make html table in sync with javascript array
I have an array of users containing user name with their rules on my practice project
I have generated a table in HTML from that array in JS, So I can
change the ...
0
votes
0
answers
75
views
SQL employee database querying Questions [closed]
SQL employee database querying Questions
Consider the employee database of an organization XYZ private limited
...
1
vote
0
answers
40
views
Merges two OKHTTP responses into one
The first request is sent asynchronously, then the id value is taken from the response to the first request and used in the second asynchronous request. And then both responses to request 1 and ...
3
votes
2
answers
84
views
Simple Java Tetris game
I have no IT background and taught myself Java and made a simple Tetris game. I compared my code on the internet with other tutorials. My first impression of those implementations is that they are ...
0
votes
1
answer
47
views
Using a RegEx to create a UUID string
I'm writing a Discord bot that sometimes requires a Minecraft account UUID to be looked up so this is the function (and MWE) I have written to do this.
...
1
vote
1
answer
49
views
Convert string to date C++
New to C++ here, by combining different pieces of code I've found, i came with this solution below to convert a date in string to a date object. It works as I want but I'm not certain to do the ...
2
votes
1
answer
43
views
Get some cryptocurrency rates from coingecko api
I'm currently learning some aspects of PEP8 and Python programming in general. Could you please code-review this little piece of code for me? I would be glad to hear any, even the smallest comments, ...
1
vote
0
answers
56
views
Entity Component System (ECS) in Java
While trying to write a game engine, I came up with this ECS / Component Based Architecture for its physics and drawing logic. I want to get some feedback on its architecture. I am using reflection ...
3
votes
1
answer
47
views
Crawler/scraper for soccer match results
I wrote this code some time ago as part of the web-scraping learning. Every now and then I find mistakes in it, as well as I have doubts. Feedback please, is this code compliant with the common best ...
0
votes
0
answers
51
views
ASP.NET Core 6 background DB logger
In an application, many actions need to be logged in the database. but this logging process should not slow down the request. So they should be done in an asynchronous queue or something.
This is my ...
0
votes
1
answer
44
views
Java - Select the maximum integers from sliding windows over an array
So I have the following algorithm. Given an array A[0 ... n - 1] and the window length w, compute all the windows ...
2
votes
2
answers
111
views
Bogo Sort Algorithm
I am a beginner programmer and have written a program that sorts a number of integers of your choosing using bogo sort.
Are there any improvements that could be made to make this code more efficient (...
0
votes
0
answers
10
views
Custom duration input component
I would love some pointers in terms of clean code, performance and maybe edge cases that I missed.
Component Template
...
5
votes
3
answers
304
views
Translating dictionary keys in complex nested Python structures
This is an actual work problem we had to solve. Put simply: given a structure (e.g. nested dictionaries) and a mapping of old dictionary keys to new ones, produce a new structure that is anatomically ...
3
votes
1
answer
42
views
Transform textarea input into camelCase
The code below transforms the text area's input to camelCase.
I am wondering if this code is considered correct to write in terms of performance and readability and if not, what are your improvements?
...
3
votes
1
answer
93
views
Longest Palindromic Substring | Python Code Giving TLE
Problem Statement
Given a string s , return the longest palindromic substring in s.
Constraints
...
0
votes
3
answers
82
views
Printing an array of numbers without duplicates
I had to make a program that have an array of numbers, and then I need to make a function that get the arr[0] and the length of the array, and then it will print ...
2
votes
1
answer
42
views
Implement simplified liquibase
I attended job interview and on live codeing session was asked to implement code based on some requirements. There are quite long text description but idea that we have to accept some file system path ...
2
votes
1
answer
35
views
Basic node login routes for authentication system
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
...
0
votes
1
answer
36
views
Approximation of the multiplicative matrix inverse (linalg.inv ())
I am trying to compute the multiplicative inverse of a large matrix (~ >40,000x40,000). This can be done with e.g. numpy.linalg.inv or ...
1
vote
4
answers
119
views
Spelling Java long values to human readable text in English
Now, I have extended my program taking some answers in the previous iteration into account:
...
1
vote
0
answers
15
views
Open a file, with a fallback path if it doesn't exist at one location
I am parsing a file that exists in either app/components/ui or in app/components. If the one in the first dir (...
6
votes
4
answers
894
views
Guessing the Number Game
I started my python journey 4 days ago. I am following a Youtube tutorial currently to understand the basics of Python. So bear in mind that I am REALLY new to this. I wanted to test myself a little ...
1
vote
1
answer
32
views
File dump in assembly
This is a file dump program written in assembly that displays 320 bytes at a time in 20 lines.
It shows the hex code for each character and also the string
At the start of the program it asks for the ...
3
votes
1
answer
50
views
Open a file, by looking in an ordered list of directories (search path)
I have a small Python application that needs to load a few different files (templates and config files). It should look in a number of destinations, in the following order, and load the file from the ...
0
votes
2
answers
67
views
12 hour to 24 hour time conversion
doing hackerrank challenges and been learning python3 for a month now, made this code to convert and return 12 hour to 24 hour time format in one of the challenges
...
0
votes
0
answers
30
views
No-Reference Image Quality Assessment (NR-IQA) for Video in Matlab - follow-up
This is a follow-up question for No Reference Image Quality Assessment for Video in Matlab. I followed the suggestions proposed by Cris Luengo to make the updated version code in this post. Some of ...
1
vote
0
answers
40
views
Python fractal tree generators
I wrote the scripts several days ago, they do exactly what I intended, but the performance is not very good, I am still stuck on for loops and don't know how to vectorize things, I wrote both scripts ...
5
votes
1
answer
73
views
Filtering an Option Result using a boolean Result in Rust
I'm trying to rewrite one of my pet projects in Rust, and when I was faced with the problem of filtering a Result<Option<T>, E> via a ...
4
votes
2
answers
258
views
Another number-guessing game
I am a newbie in Python and would very much need help in arranging and setting out function. I have programmed a number guessing game. The outlook of the program is very messy but I don't where to fix ...
5
votes
4
answers
1k
views
Converting int values in Java to human readable strings in English
(See also the next iteration.)
I have rolled this short program that converts int values to the human readable strings:
...
1
vote
1
answer
35
views
Updating large and heavily nested JSON properties based on existing properties using nested forEach loops
The structure of the JSON is as such:
Each parent record can have many DataGroups and each DataGroup can have many ...
3
votes
2
answers
73
views
Ball movement within an area
I was asked to write a code in C++ using threads, in which I have to have two limits and 4 characters. Characters can go inside the area limited at the same time when they approach from opposite sides....
3
votes
1
answer
67
views
"Select followed by First" versus "First followed by Select" when summing the data for a student
I am wondering which one I should choose between the following two options when I need to calculate the sum of Data of the student with ...
0
votes
0
answers
4
views
How do I make my code more readable? [migrated]
I've often come across the same kind of question:
- How do I make my code more readable?
- How can I improve my code?
And usually the answers are similar - regardless of language or problem.
That's ...