Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
3 answers
184 views

Efficiently generate a random position inside an outer rectangle but outside an inner rectangle

It should be a uniform distribution (ie: every point is equally as likely). I also don't want to use the simple solution of: "in a loop check to see if the current generated point is within the ...
Ryan Peschel's user avatar
-1 votes
1 answer
99 views

Sine function guessing cognitive app

Please help with improving this application. It is a guessing game, for learning the values of the sine function, and boosting brain power in the process. ...
Attila Vajda's user avatar
2 votes
1 answer
155 views

Combinations of elements in array

I wrote this code to get all possible arrangements for an array containing 3 elements: ...
John's user avatar
  • 59
3 votes
0 answers
97 views

Speed up a JavaScript function for inverting matrices using Gauss elimination

I wrote this function and I'm interested if it can be sped up by improving the code. The function accepts either column major 1D array or 2D row major array. Maybe there are some obvious JS tricks ...
user9163823's user avatar
2 votes
0 answers
171 views

JavaScript functions to generate Pythagorean triples

I am sure you know what Pythagorean triples are, in the extremely unlikely case that you don't know: A Pythagorean triple consists of three positive integers a, b, and c, such that $$a^2 + b^2 = c^2$$...
Ξένη Γήινος's user avatar
3 votes
2 answers
357 views

Intersection of 2D vector equation straight lines

I know the vectors that describe two perpendicular lines, $$\mathbf{a} + \lambda\mathbf{d}$$ and $$\mathbf{b} + \mu\mathbf{d'}$$ I've written a JavaScript function to get the coordinates of the point ...
user avatar
3 votes
1 answer
985 views

Convert number from old range to new numeric range

I have a function that takes a specific number and a range, and re-scales it to the corresponding number in a different range. ...
Skully's user avatar
  • 133
4 votes
2 answers
500 views

find closest distance between two numbers (looking for improvement)

Let's say I have a number set like below // 1,2,3,4,5,6,7,8 Now I want to go from 2 to 5. ...
Amir Rahman's user avatar
3 votes
0 answers
329 views

converting from byte arrays to strings of integers, and back

I have this code to go from an array of bytes (arbitrarily long) to a "bigint" string (really, an arbitrarily long string composed of integers 0-9), and go from that long integer string into ...
Lance Pollard's user avatar
0 votes
3 answers
1k views

Get the Most frequent element in an array

I have been trying to optimize this: ...
Eliaz Bobadilla's user avatar
3 votes
1 answer
71 views

Collect distances from 1 point to all others in a graph

Problem: I have a weighted graph. I want to get distance from definite point to all other points in the graph.(and then get path to them) I used modified dijkstra algorithm So, here is code: ...
Данил Черкашин's user avatar
3 votes
1 answer
377 views

I need help optimizing a function that returns all divisors

This is my code: export function all_divisors(num: number): number[] { return range(1, num+1).filter(i => num % i === 0).toArray(); } the ...
grian's user avatar
  • 151
2 votes
0 answers
447 views

Code is timeout - Hamming Number

I have a problem with my code, because his is required a long time to be done(only when I put big numbers like 2000)... I am trying to do the Hamming Numbers kata on codewars.com: A Hamming number is ...
MarkoKovacevic's user avatar
9 votes
1 answer
1k views

Convert Decimal to Fraction

This code below converts number from decimal to fraction. I don't know if there's a better way or better methods to do this job so any advice would be appreciated. ...
user3756068's user avatar
6 votes
2 answers
208 views

Find the best matching combination of numbers

I need to manipulate chunks quantity until total will be as close as possible to the ...
stkvtflw's user avatar

15 30 50 per page