random-generator

Code Golf: Ghost Leg

The challenge The shortest code by character count that will output the numeric solution, given a number and a valid string pattern, using the Ghost Leg method. Examples Input: 3, "| | | | | | | | |-| |=| | | | | |-| | |-| |=| | | |-| |-| | |-|" Output: 2 Input: 2, "| | |=| | |-| |-| | | |-| | |" Output: 1 Clarifications ...

how to make a name from random numbers?

my program makes a random name that could have a-z this code makes a 16 char name but :( my code wont make the name and idk why :( can anyone show me what's wrong with this? char name[16]; void make_random_name() { byte loop = -1; for(;;) { loop++; srand((unsigned)time(0)); int random_integer; random_...

Generate random coordinates from area outside of a rectangle?

Hi all, I'm working on a simple tutorial, and I'd like to randomly generate the positions of the red and green boxes in the accompanying images anywhere inside the dark gray area, but not in the white area. Are there any particularly elegant algorithms to do this? There are some hackish ideas I have that are really simple (continue to...

VB.NET - Removing a number from a random number generator

I am trying to create a lottery simulator. The lottery has 6 numbers, the number generated must be between 1 - 49 and cannot be in the next number generated. I have tried using the OR function but I'm not entirely sure if I am using it properly. Any help would be great. Thanks. Public Class Form1 Private Sub cmdRun_Click(ByVal sender A...

how to use random bits to simulate a fair 26-sided die?

How do I use a random number generator that gives bits (0 or 1) to simulate a fair 26-sided die? I want to use a bitstream to pick letters of the English alphabet such that the odds of any one letter coming up is the same as the odds of any other letter (I know real words aren't like that and have specific frequency distributions for eac...

Generating a random cubic graph with uniform probability (or less)

While this may look like homework, I assure you it's not. It stems from some homework assignment I did, though. Let's call an undirected graph without self-edges "cubic" if every vertex has degree exactly three. Given a positive integer N I'd like to generate a random cubic graph on N vertices. I'd like for it to have uniform probabilit...

Random character generator with a range of (A..Z, 0..9) and punctuation

I need to create a random character generator that return a single character. The character should range within the letters of the alphabet, numbers 0 through 9, and some characters like ,.?/-. Any example would be appreciated. ...

How to effeciently spread objects on a 2D surface in a "natural" way?

Hello all, i would like to effeciently generate positions for objects on a given surface. As you probably guessed this is for a game. The surface is actually a 3D terrain, but the third dimension does not matter as it is determined by terrain height. The problem is i would like to do this in the most effecient and easy way, but still g...

What's wrong with this random date of birth generator?

I'm trying to write a random date of birth generator for a date of birth between 25 and 50 years ago. I'm stuck with Java 1.4 and am attempting to accomlish this via java.util.Calendar (yes, yes, I know I should be using the Joda libraries). Here's where I'm at: private static long ONE_YEAR_AS_MILLISECONDS = 365*24*60*60*1000; private...

How to generate random +ve -ve decimal with php?

how can I regenerate random decimal from -0.0010 to 0.0010 with php rand()? or any other? ...

Generate different random -ve +ve number with php rand()?

Dear all, I have asked a question about random generating -ve +ve decimal value here: http://stackoverflow.com/questions/3206563/how-to-generate-random-ve-ve-decimal-with-php But now i have another more challenging problem. May I know how can I generate random integer with -ve +value with a different set? like from -552 to 2200 as an e...

Generate a large random planar graph

What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distrbuted)? ...

How do I seed the random generator and create a random int in Objective-C

I have seen some examples of the random int in Objective-C, but all people are complaining about the same number sequence every time the application runs. I have read about seeding the random number, but I am not sure what that even means. How can a random number be generated differently every time, even after application has relaunche...

Help building a random name generator

Hi all, As a teacher I am looking to create a random name generator to use with my classes. I don't know much but I am willing to learn. I want my random name generator to be able to load class lists from an external csv or txt file - I want the random name generator to be able to recognise the time and load the pre-defined class for tha...

Choosing Hex Color Code From Multiple Options

Hello, Trying to get this to function, randomly chooses 1 of the 3 color choices. Is rand only capable of generating numbers? or Numbers/letters in a series. <div onclick="location.href='<?php the_permalink() ?>';" style="cursor:pointer;background:#<?php echo rand (DDCA73, A0AA47, ADBAE1)?>;" class="post bg thickbox" id="thickbox post-...

i want a variable that will change from a char to a int and vice versa depending on the user entry

i have to define a variable that i am using in a program but i want the variable to change from int to char. example #include <iostream> #include <cstdlib> int main() { int l=rand(); char x; std::cout<<"this program makes a random char or number enter n for a number or c if you want a letter\n"; std::cin>>l>>"\n"; ...

attempting to create string of random values

I'm trying to generate a string of a random length which consists out of random chars. To do so I have this code: class Program { static void Main(string[] args) { for (int i = 0; i < 1000; i++) { MyString test = new MyString(); test.Random(); Console.WriteLine(test.Value); ...

Random String in VB

I need to generate a lot of random 2 character strings for my application. it's a VB console application. basically what I have tried for random strings is this: Private Function GenerateRandomString(ByVal intLenghtOfString As Integer) As String 'Create a new StrinBuilder that would hold the random string. Dim randomString As ...

Generate a specific color for each string?

I have a DataGrid that shows orders that belong to product. I want to have a generated SolidColorBrush that is unique to each product. Update I need these colors to be solid and distinctive, or at least to be ordered in a distinctive way, i.e. there shouldn't be black, blue, green as these 3 colors can be confused with each other. Bes...

Efficient method to generate UUID String in JAVA (UUID.randomUUID().toString() without the dashes)

Hello, I would like an efficient utility to generate Unique sequences of bytes. UUID is a good candidate but UUID.randomUUID().toString() generates stuff like 44e128a5-ac7a-4c9a-be4c-224b6bf81b20 which is good as long as you don't need to transmit it over http, in which casa the dashes need to be removed. I'm looking for an efficient w...