ketan yeluri.

Project GARAGE

Project GARAGE - Repo, Live

Logo

GARAGE stand for Graph Augmented Random Array Generation Engine

A garage for arrays?

Arrays (or simply a list) of numbers is the most commonly used input form for competitive programming questions. Having the ability to generate random arrays of a specific pattern offers the ability to test your algorithm to the limits.

With that idea in mind, presenting GARAGE - a first of its kind (don't quote me on that) graph-based random array generation with unique integers. Simply key in the graph using the smooth sliders, input the bounds and count values, and generate the array. Plotting the elements of the array would give an exagerrated version of the graph you input.

The best part... the generation is entirely done on the client side. Once the website is loaded, there is no more interaction with open internet. All the necessary Javascript is loaded on the first paint, and the browser resources are more than enough to carry out the generation.

How does it work?

Numbers confusing gif

Once the generate button is pressed, a snapshot of the sliders and input values is taken to prevent any memory corruption during the generation. Sliders each have a resolution of 300. A set of unique random integers within the bounds is generated and mapped to the slider values. The mapping is done by sorting the slider values (while keeping track of the slider they belong to) and sorting the random values, which are then mapped bijectively. The required amount of remaining values are generated randomly and their uniqueness is ensured by maintaining a set of generated values. Once this set is obtained, the values are sorted and then sprinkled procedurally (and literally) in the intervals between each slider. Since the mapped slider values are chosen arbitrarily, the size of intervals between each slider cannot be uniform, not to forget the intervals can overlap (over a peak or valley). Hence the distribution of the generated numbers amongst the intervals is also arbitrary.

But there are limits!

Keeping speed and efficiency in mind, the following are the limitations of the tool

  • Lower bound >= -10^9
  • Upper bound <= 10^9
  • Number of sliders <= Count <= 50000
  • 2 <= Number of sliders <= 10
Rookie number gif

Put together using

  • React.js - Written in React.js 18.1.0
  • p5.js - A JavaScript library for creative coding. Written with p5.js 1.4.1
  • Rando.js - A lightweight library for fast and cryptographically strong random number generation

Imagined and created by

Yeluri Ketan

With the help of

Sravanth Chowdary Potluri - Generation algorithm for k unique values in a given range