how do i make this so once the user inputs a number and presses enter(or something) it runs the if else statements! please help!
public static void main(String[] args) {
System.out.println("please guess the number between 1 and 100.");
boolean run = true;
int y = 0;
Random ran = new Random();
int x = ran.nextInt(99);
while (ru...
I would like to get an AND -operator to the following Vim command
:command! -nargs=1 GrepSource :! grep <args> `sed -n 's/^source \(.*\)/\1/p' %`
such that I can use the command to find sources at
# source <path>
# . <path>
source <path>
. <path>
I am not sure whether it is possible or not to get AND -operator to SED or Vim.
How ...
I have a php script that is run once a minute. The script runs a second script, then sleeps for a given amount of time.
Right now the time is static. 20 seconds each time.
What i need to so is randomize the amount of time it sleeps. It can be more than a total of 60 seconds, but NOT less.
So here is what i have now.
$sleep1 = rand(2...
I am trying to think of an elegant way of getting a random subset from a set in F#
Any thoughts on this?
Perhaps this would work: say we have a set of 2x elements and we need to pick a subset of y elements. Then if we could generate an x sized bit random number that contains exactly y 2n powers we effectively have a random mask with y...
I have several content tables that I want to fill up with random paragraphs of text. In MS Word, I can simply put =rand() and presto! I get three paragraphs of fresh-off-the-press text.
Is there a SQL script/command that I can use to generate random dictionary words using t-sql?
...
I have the following script;
Timer=0;
function countdown(auctionid)
{
var auctions;
var divs;
Timer=Timer+1;
if((Timer%10=="0")||(Timer=="1")){
$.get("current.php", {
id:auctionid},
function(data){
auctions=data.split("||");
for(n=0;n<=auctions.length;n++)
{
if(auctions[n] != undefined)
{
divis=auctions[n].split("##");
$('#futu'+divi...
I have a timer that grabs a file every 10 seconds:
if((Timer%10=="0")||(Timer=="1")){
I also have a random number generator:
var randomNum = Math.floor(Math.random() * 10) + 2;
I also have a variable which stores the time remaining:
Timer=0;
function countdown(auctionid)
{
var auctions;
var divs;
Timer=Timer+1;
i...
I have an array which tells whether a card is in use:
int used[52];
This is a terrible way to pick a random card if I have many used cards:
do {
card = rand() % 52;
} while (used[card]);
since if I have only 3-4 unused cards, it'll take forever to find them.
I came up with this:
int card;
int k = 0;
int numUsed = 0;
for (k=...
Before I start, I want to point out that I'm pretty sure this actually happened. All my logs suggest that it did.
I'd like to know whether I'm wrong and this is impossible, whether it's just incredibly unlikely (which I suspect), or if it's not that unlikely and I'm doing something fundamentally wrong.
I have 4 instances of the same c...
i would like to know what algorithm and what programming language wikipedia is using to randomly choose an article to display.
i would also like to know how does it work so fast?
...
I'm having trouble with the NLTK under Python, specifically the .generate() method.
generate(self, length=100)
Print random text, generated using a trigram language model.
Parameters:
* length (int) - The length of text to generate (default=100)
Here is a simplified version of what I am attempting.
import nltk
word...
Without using any framework..
I wrote 2 functions:
function get_random_color()
{
var color = "";
for(var i = 0; i < 3; i++) {
var sub = Math.floor(Math.random() * 256).toString(16);
color += (sub.length == 1 ? "0" + sub : sub);
}
return "#" + color;
}
function get_rand_color()
{
var color = Math.floor(Ma...
I have an array of double values "vals", I need to randomly index into this array and get a value. GenRandomNumber() returns a number between 0 and 1 but never 0 or 1. I am using Convert.ToInt32 to basically get everything to the left of my decimal place, but there must be a more efficient way of doing this?
Here's my code:
public doub...
In a view in django I use random.random(). How often do I have to call random.seed()?
One time for every request?
One time for every season?
One time while the webserver is running?
...
This question answers the question on how to select a random sample from oracle which is exactly what I need. I do not understand however the difference between that solution
SELECT *
FROM (
SELECT *
FROM mytable
ORDER BY
dbms_random.value
)
WHERE rownum <= 1000
and something li...
So far I've been using the C# Mersenne Twister found here to generate random numbers:
http://www.centerspace.net/resources.php
I just discovered SFMT which is supposed to be twice as fast here:
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
Can anyone point me at a C# implementation of SFMT?
My requirements are to generate an...
When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class?
...
What I am talking about is like this website :
http://www.ernesthemingwaycollection.com
It has a static wallpaper and a set of images that change from page to page, I want to implement a similar way of displaying random images from a set of images using ASP.NET.
EDIT : I want the image to stay the same in a session, and change from a s...
Use case: the "I forgot my password" button. We can't find the user's original password because it's stored in hashed form, so the only thing to do is generate a new random password and e-mail it to him. This requires cryptographically unpredictable random numbers, for which mt_rand is not good enough, and in general we can't assume a ho...
Possible Duplicate:
why do i always get the same sequence of random numbers with rand() ?
This is my file so far:
#include <stdio.h>
int main(void) {
int y;
y = generateRandomNumber();
printf("\nThe number is: %d\n", y);
return 0;
}
int generateRandomNumber(void) {
int x;
x = rand();
return x;
}
...