+ 3
Code Challenge - Random
This is a unique challenge! In this you have to make your own random() function in Java, C++, C# or JavaScript! This function by-default should generate numbers between 0-10. #CodeItOff! https://code.sololearn.com/cglNhhybKHiI/?ref=app
13 Answers
+ 9
https://code.sololearn.com/cMUCJqFL1X65/?ref=app
+ 8
Ok I understand what you mean. :D
+ 7
It has flaws btw. I have added a note in the code comments to specify its 'educational use only' claim. :>
+ 7
I met with the even number issue with this code too, then did a little tweak. I suppose it is random enough?
https://code.sololearn.com/cbJDCXAlR5EX/?ref=app
+ 3
@Hasty Well Done!
+ 3
@cheeze It will never generate good randomness
+ 2
am using time for rng lol
random = () => new Date().getMilliseconds() % 10
this will generate random numbers from 0 inclusive to 10 exclusive
+ 2
yeah tru, they kept giving me even numbers
ill work on it if i reach home
EDIT: i came up with this which is surprisingly more random
random = () => ~~(new Date().getMilliseconds() / 100)
+ 2
@ I know it's C++ But Pointers aren't available in Java
+ 1
I think you might understood it now
+ 1
Ow, It's Hatsy. I just Noticed it, Sorry for saying You Hasty and Hasty Again and again
0
@Hasty Thai code can't be used in all the languages I mentioned. The Code must be one that can be used in all of the above mentioned languages. By the way Nice Try!
https://code.sololearn.com/cbJDCXAlR5EX/?ref=app
0
@Hatsy See My Work : : Inspired from Your's
https://code.sololearn.com/cglNhhybKHiI/?ref=app