Questions tagged [language-agnostic]
Use this tag for PROGRAMMING QUESTIONS that are independent of any particular programming language.
8,246
questions
-2
votes
0
answers
39
views
Vertical values with Delimiters moved into one line [closed]
I have a text file that has vertical column of values I would like to put in a single (horizontal) row. I want to put all the values between ^^ onto a single row delimited by a semicolon csv file.
...
0
votes
0
answers
12
views
how to create library agnostic chat widget [closed]
I am required to create a chat widget which could be integrated in to any frontend library especially vue and react , it would also provide configuration options , i need to know the server and client ...
0
votes
1
answer
22
views
Is there a function to compare two strings using a custom homoglyphs list
I need a function that would compare two strings and outputs an edit distance like Levenshtein, but only if the characters are homoglyphs in cursives. I have a list of those homoglyphs so I could feed ...
0
votes
1
answer
20
views
Is there a particular use case for fold() function
When accumulating a collection (just collection, not list) of values into a single value, there are two options.
reduce(). Which takes a List<T>, and a function (T, T) -> T, and applies that ...
1
vote
1
answer
26
views
Is the data written to main memory when we write to memory-mapped I/O area?
I have a basic understanding of Memory-Mapped I/O (MMIO). Below is copied from the Wikipedia page:
Memory-mapped I/O uses the same address space to address both memory and I/O devices. The memory and ...
2
votes
1
answer
26
views
Splitting rational bezier
According to someone a rational bezier can be split by projecting its control points from 2d to 3d (or from 3d to 4d and so on), splitting the resulting non-rational curve with De Casteljau, and then ...
0
votes
1
answer
46
views
Perspective projection of rational bezier
I need a method to project 3d conics to 2d. None of the articles tell how to do this with rational beziers. Another thing I need a method for is moving 3d or 2d conics to 4d or 3d respectively (as in ...
2
votes
6
answers
150
views
remove new line \n in large file (10GB)
I have large file 1.txt containing:
User: Test1
Password: P@sawFia1_f
User: Test2
Password: C99vijJiDB9fo@K!!1
I'm using sed -i '/\nPassword/ s///g' 1.txt for remove new line with Password: but it's ...
5
votes
1
answer
61
views
Algorithm to check if a multidimensional array contains another?
Say I have two multidimensional arrays of equal depth, say:
[ [1, 2, 3],
[4, 5, 6],
[7, 8, 9] ]
and
[ [2, 3],
[5, 6] ]
What sort of algorithm can I follow to determine if the latter is a ...
3
votes
1
answer
107
views
Substring search with max 1's in a binary sequence
Problem
The task is to find a substring from the given binary string with highest score. The substring should be at least of given min length.
score = number of 1s / substring length where score can ...
3
votes
1
answer
100
views
How do I save or export reports/findings/results from Semgrep?
When I run a scan, the findings are printed out on the CLI. How can I see or store these results? I can use piping (|) or output redirection (>) - but is there a semgrep-y or formatted way of ...
0
votes
1
answer
67
views
How to create quasi-copy of a file [closed]
I would like to create quasi-copy of my directory with sensitive data.
Then I would like to share this quasi-copy with others to provide so called 'real data'.
This 'real data' would allow others to ...
1
vote
1
answer
98
views
TIme complexity of two reversed sorted arrays
What would be the time complexity of two reversed arrays merge into one sorted array?
Is it O(n) or O(log n)?
1
vote
2
answers
67
views
Minimum size of subarray whose sum is k
I need to find minimum subarray length whose sum is greater or equal to k. Array will have only positive numbers.
eg
Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The
subarray [4,3] ...
0
votes
1
answer
33
views
Understanding Bezier derivation code that leads nowhere
I'm trying to convert Bezier.js implementation of calculating normals to a Shadertoy program, and the code appears to not use any of the calculated values. It needs to be for quadratic rationals as ...
-1
votes
1
answer
21
views
Intercept and transform key signals to a process in C++ or any other language
I want to intercept Russian keys in a specific application and send it something else. I don't really know the steps required to achieve it.
Is there a way to write an app in C++ that captures key ...
1
vote
2
answers
108
views
How to find longest accepted word by automata?
I need to write a code in Java that will find the longest word that DFA accepts. Firstly, if there is transition to one of previous states (or self-transition) on path that leads to final state, that ...
1
vote
1
answer
52
views
Being Idiomatic in code vs Dogmatic and why the distinction is important
After we finished the final in one of my C++ courses, there was one more optional lecture given (obviously the final was already done so most people didn't go), but I didn't have much else to do so I ...
0
votes
0
answers
10
views
What's a coroutine in a language agnostic sense? Is there necessarily a difference between a "coroutine factory" and an "execution context"?
What's a coroutine in a language agnostic sense?
In particular, I'm confused about whether there's necessarily a difference between a
factory for stamping-out-but-not-transferring-control-to ...
0
votes
1
answer
38
views
How to get the year, day, seconds, and milliseconds from a Unix timestamp (language agnostic)?
Not looking for the environment-specific date methods like this for calculating these date fields, but how do you isolate them from a Unix timestamp such as now, which was 1650045773120? It is in ...
2
votes
1
answer
39
views
Detecting inconsistency in a set of non-strict inequalities
Given a set of variables and a set of strict inequalities, it's straightforward enough to detect whether there is an inconsistency: make a directed graph whose nodes are variables; for each assertion ...
3
votes
1
answer
152
views
How to get different maximum matchings
I have a large bipartite graph and I can find a maximum matching quickly using Hopcroft-Karp. But what I would really like is a few hundred different maximum matchings for the same graph. How can I ...
0
votes
0
answers
16
views
Ordering equations in the face of sometimes-unordered terms
Superposition calculus is used for reasoning with equations; it reduces the size of the search space by applying an order to equations, based on an ordering of terms.
A suitable ordering of terms, ...
0
votes
1
answer
44
views
Find pairs in 2 files that are too large to fit in memory
I'm looking for a memory efficient way to find pairs in 2 possibly very large files (can be as large as 1TB each) that do not fit into memory. For the sake of simplicity let's say the file contains ...
0
votes
3
answers
84
views
What do programmers mean when they use the term "BruteForce approach to the problem "?
I wanted to understand what do programmers generally mean when they use the term " Brute Force " in their work .
2
votes
1
answer
61
views
How to find the path of least sum, moving right and down in a binary matrix
I have a binary matrix. Each column corresponds to a vertex in a graph. If I walk along the path (starting on the "col 1" vertex, then moving on to "col 2" etc.), I have to pay ...
0
votes
1
answer
46
views
Generic and Specific exception handling
Are there any performance improvement in specific exception handling over generic one (in any language)?.
I understand the implication of both in terms of good programming practice, ie, Specific ...
0
votes
1
answer
27
views
What is the term for an error where a space is missing?
What is the name of/term for a coding error where you forgot a space?
Example
SELECT *
FROM public.employees
INNERJOIN public.departments ON employees.dept_id = departments.id
...
1
vote
1
answer
81
views
Basic algorithm to resize a 2D-matrix
Let's say I have a black and white image of a "J", represented as a binary matrix, like this (white = 0, black = 1). If we let each cell in the matrix be a pixel, its size would be 6 x 10.
0 ...
1
vote
0
answers
40
views
Data structure for spatial closeness queries
Limitations
Memory is not an issue, as long as it fits on a normal PC. I'm not trying to optimize memory usage here.
Update speed is extremely important, then query speed.
Problem to solve
I have a ...
1
vote
1
answer
74
views
Different ways of implementing a coroutine
I can currently think of two ways of implementing a coroutine:
Whenever a coroutine is started, instead of storing local variables on stack, get a piece of memory from heap and use it to store local ...
1
vote
1
answer
95
views
Random number generator with 3 inputs
I am looking for a random number generator with 3 inputs for a terrain generator. The inputs are an x, y (position) and a seed value. And the function returns back a random number from 0-1.
So far I ...
2
votes
1
answer
94
views
Creating matrix with getting maximum of each row and column
I want to make the minimum matrix given the max of each row and column.
Example:
Given:
row_max = [50, 20]
col_max = [50, 20, 3]
Result:
array = [[50, 0, 0],
[0, 20, 3]]
1
vote
1
answer
85
views
How many scenarios should a unit test test?
Let's say there is a function:
type config struct {
percent float64
flat float64
}
func Calculate(c *config, arrayofdata *arrayofdata) float64 {
result := 0.0
for _, data := range ...
2
votes
2
answers
99
views
How to Solve Parallel Inheritance Hierarchies when we try to reuse code through inheritance
Recently in a job interview, they ask me "how to solve Parallel Inheritance Hierarchies when we try to reuse code through inheritance". I thought on Aggregation or Composition, but i was a ...
2
votes
2
answers
69
views
Algorithm to test if two line segments on a 2d grid are adjacent
Given two line segments on a 2D grid (horizontal or vertical), how can I determine if they are adjacent?
Two line segments A, B are adjacent if there exists at least one pair of points (ax, ay) in A ...
0
votes
1
answer
95
views
Fletcher 32-bit checksum test vectors
I've got some C# code (but the language is irrelevant) that generates a 32-bit Fletcher checksum on an array of 16-bit words. My issue is that I've implemented an optimized algorithm, and after an ...
0
votes
0
answers
30
views
What is the name of this reference class design pattern?
Is there a name for the design pattern where a single class is written to contain references to commonly used objects, which are usually singletons? And is it wise to use such a class or is there a ...
0
votes
0
answers
16
views
Is There A Word For An Operation That Returns The Same Type/Shape As the Input
This isn't for a specific language, but I was wondering if there was a programming term for an operation that returns the same type/shape as the input. I'm developing a CNN model and I want to show ...
1
vote
1
answer
128
views
Best Practice: "Soft Cancellation" with gRPC
It seems to me that the built in cancellation support of gRPC is quite aggressive in the following sense: If I invoke cancellation on client side, the communication channel is closed immediately. The ...
0
votes
0
answers
16
views
Determining modes based on the sum of enums
So, some APIs or programs may determine permissions or modes based on the sum of enums.
For example, we have a person with a value representing how the person can move:
CanFly: 32
CanRun: 16
CanWalk: ...
0
votes
3
answers
57
views
The point within the range of rectangle
In easy English can someone please explain to me this line of code.
public bool IsAt(Point2D pt)
{
return (pt.X > Width && pt.X < Width + X && pt.Y > Height &&...
0
votes
1
answer
30
views
How to Transform X and Y Coordinates to Left and Right Motor Movement
I am trying to implement an EKF Slam to a robot using python. The robot returns an estimate of its current x and y position and an angle (the direction the robot is facing). For my slam however I need ...
2
votes
1
answer
104
views
How does this Recursive Descent Parser match specific operators?
I likely just need to step away from the computer for a moment, but I'm puzzled about one detail in how this recursive descent parser is working. It is in a book called Crafting Interpreters by Bob ...
0
votes
1
answer
24
views
Program consisting of multiple executable files
If you're familiar with the internals of git (even a little bit), you may know that the git command is just the frontend to many other executables (as in, git is comprised of multiple executables, ...
0
votes
0
answers
54
views
What are good general techniques to extract the last n bytes from a stream of input
Assuming I have a binary stream of input bytes of unknown length that end with an identifiable EOF-like condition, what are some algorithms to extract the last, say 8 bytes and process them ...
0
votes
0
answers
55
views
Projecting 3D points in 2D plane
I have noisy 3D point cloud [x,y,z] plane for which, I fit a 2D plane (z = ax+by+c) by computing the coefficients [a,b,c] using least-squares. How can I project the points [x,y,z] onto this plane. I ...
1
vote
3
answers
69
views
Insert a text with indentation persevered on the next line of matched string
I have a file with a yaml data as below:
cat x.yml
foo:
- bar: 1
- zoo: 2
I am able to insert the text but this is messing the indentation(see 2nd line):
sed -r '/^[ ]+- bar:/a- hoo: 3' x.yml
foo:
...
0
votes
0
answers
15
views
Passing parameters to sibling classes
I'm developing a game, and I have a structure of classes that is giving me headaches, so I wonder if there's a better way
I have a class Battle, which contains a Map and contains a list of Units
class ...
0
votes
1
answer
26
views
Align whitespace after segmentation into sentences
I am using a segmentation library to split a string into sentences:
s = "Lucas ipsum dolor sit amet darth\n
mandalore kit. Endor Mr. Wookiee wicket\n
jawa yavin ackbar jabba? Padmé\n
...