Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added wordlist for numbers only #11

Merged
merged 3 commits into from Apr 25, 2022
Merged

Added wordlist for numbers only #11

merged 3 commits into from Apr 25, 2022

Conversation

siddhantmadhur
Copy link
Contributor

Idea: A numbers only mode

Implementation: There can be infinitely cleaner methods to create this so it can be completely random but for convenience sake I made a list of 500+ numbers using the following script and put it in a .json

let arr = [];
for(let i = 0; i < 500; i++ ) {
	const max = 6;
	const length = Math.floor(Math.random() * max)
	const randomInt = Math.floor(Math.random() * 1000000 * length);
	if( randomInt !== 0 ){
		arr.push(`${randomInt}`)	
	}else{
		i = i - 1;
	}
}
console.log(arr);

Limitations: The list is limited to only 500 numbers

Future Ideas: Either directly implement the code into the site or create an improved list with more numbers

@salmannotkhan
Copy link
Owner

It's a great idea! Maybe something like words as text e.g "One", "Two", "Three" also can be a great idea.
But we have to figure out new names for it.

@salmannotkhan
Copy link
Owner

I'm thinking how we can make this logic more random

@siddhantmadhur
Copy link
Contributor Author

Is there any way to accept arrays from the main function itself, rather than pull it from a json file

@salmannotkhan
Copy link
Owner

We can do that in reducer but then whenever someone select number mode it'll recalculate all the numbers

@siddhantmadhur
Copy link
Contributor Author

Updated the logic

So I updated the code to generate numbers and generated 1290 numbers using it.

let arr = [];
let append = "";
for(let i = 0; i < 100; i++ ) {
	const max = Math.round(Math.random()*8); //decides how long the number is going to be
	if(max>4){
		append = ""; //resets 
		for(let j = 0; j < max; j++){ // loops max amt of times, checking if the new number is equal to the last number or not so its random
			const cursor = Math.round(Math.random() * 9)
			if(append.length>0){
				if(append.charAt(j-1).match(cursor)){
					j = j-1
				}else{
					append = append + `${cursor}`
				}
			}else{
				append = append + `${cursor}`
			}
		}
		arr.push(append)
	}else {
		i = i - 1;
	}
}
console.log(arr);

This new code made sure that the numbers being generated have no numbers being repeated in a row, for example: 11111 could not be generated but 12121 could

You can merge this now and I'll create a new PR if i think of a more "randomized" logic.

@salmannotkhan
Copy link
Owner

Sorry for late reply I was busy at work. I'll test this tonight and merge it.

@salmannotkhan
Copy link
Owner

Also you should take a look at Javascript crypto API it provides easier way to generate random number

@siddhantmadhur
Copy link
Contributor Author

No worries
Also sure I'll check it out

@salmannotkhan
Copy link
Owner

I think 1290 numbers are more than enough. Can you reduce it to 300 or something?

@salmannotkhan
Copy link
Owner

Because it is randomizing these numbers at runtime so it can hurt performance

@siddhantmadhur
Copy link
Contributor Author

yeah sure

@salmannotkhan
Copy link
Owner

Looks great

@salmannotkhan salmannotkhan merged commit ef2ff44 into salmannotkhan:main Apr 25, 2022
@salmannotkhan
Copy link
Owner

It looks like CSS requires some minor refinements for numbers mode but that's work for another day 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants