Phsudo code
Programming

Tutor: None Selected  Time limit: 0 Hours 
Hello, hope you are well and in good health.
I am Shahzaib Elahi a student, I have an to write a phsudo code for generating 6 random numbers and assigning them to variables. I was planning on using an array in the phsudo code which stores the data on six variables.
I have written some of it I just want to show an expert such as yourself. How do I go about doing this?
Kind regards,
Shahzaib Elahi
for(int i =0; i<3; i++){
int randomInt = (int)(6.0* Math.random());
System.out.println("pseudo random int between 1 and 6 : "+ randomInt );
}
Output:
pseudo random int between 1 and 6:4
pseudo random int between 1 and 6:0
pseudo random int between 1 and 6:2
declare integer rand
set rand = random (1, 6)
display rand
Solution # 2
int min = 1;int max =6;
int a = rand(min, max);
end
these 2 solution are very simplest.
from itertools import product, tee
from random import choice
COLORS ='red ','green','blue','yellow','purple','pink'#, 'grey', 'white', 'black', 'orange', 'brown', 'mauve', 'gap'
HOLES =4def random_solution():"""Generate a random solution."""return tuple(choice(COLORS)for i in range(HOLES))def all_solutions():"""Generate all possible solutions."""for solution in product(*tee(COLORS, HOLES)):yield solution
def filter_matching_result(solution_space, guess, result):"""Filter solutions for matches that produce a specific result for a guess."""for solution in solution_space:if score(guess, solution)== result:yield solution
def score(actual, guess):"""Calculate score of guess against actual."""
result =[]#Black pin for every color at right position
actual_list = list(actual)
guess_list = list(guess)
black_positions =[number for number, pair in enumerate(zip(actual_list, guess_list))if pair[0]== pair[1]]for number in reversed(black_positions):del actual_list[number]del guess_list[number]
result.append('black')#White pin for every color at wrong positionfor color in guess_list:if color in actual_list:#Remove the match so we can't score it again for duplicate colors
actual_list.remove(color)
result.append('white')#Return a tuple, which is suitable as a dictionary keyreturn tuple(result)def minimal_eliminated(solution_space, solution):"""For solution calculate how many possibilities from S would be eliminated for each possible colored/white score.
The score of the guess is the least of such values."""
result_counter ={}for option in solution_space:
result = score(solution, option)if result notin result_counter.keys():
result_counter[result]=1else:
result_counter[result]+=1return len(solution_space) max(result_counter.values())def best_move(solution_space):"""Determine the best move in the solution space, being the one that restricts the number of hits the most."""
elim_for_solution = dict((minimal_eliminated(solution_space, solution), solution)for solution in solution_space)
max_elimintated = max(elim_for_solution.keys())return elim_for_solution[max_elimintated]def main(actual =None):"""Solve a game of mastermind."""#Generate random 'hidden' sequence if actual is Noneif actual ==None:
actual = random_solution()#Start the game of by choosing n unique colors
current_guess = COLORS[:HOLES]#Initialize solution space to all solutions
solution_space = all_solutions()
guesses =1whileTrue:#Calculate current score
current_score = score(actual, current_guess)#print '\t'.join(current_guess), '\t>\t', '\t'.join(current_score)if current_score == tuple(['black']* HOLES):print guesses,'guesses for\t','\t'.join(actual)return guesses
#Restrict solution space to exactly those hits that have current_score against current_guess
solution_space = tuple(filter_matching_result(solution_space, current_guess, current_score))#Pick the candidate that will limit the search space most
current_guess = best_move(solution_space)
guesses +=1if __name__ =='__main__':print max(main(sol)for sol in all_solutions())
This is what i found it from internet i have code related to this that i write for die a roll 6 times if you want that code then i posting you can it by yourself.this is what i am asking you
Simulations
Pseudorandom numbers are often used in simulations because they can be used to mimic random variations in the real world. Loops are used in simulations for many reasons: to loop over different points in time, different regions in space, different components of a device, different objects in an environment, different initial conditions.
For example, consider a program that simulates rolling of two 6sided dice, continuing until a 7 is rolled.
Roll die 1.
Roll die 2.
If the sum if 7, stop.
else roll both dice again.
To turn this into a loop, we need to figure out the test that indicates that we want to continue the loop. A sum of 7 is when we want to stop, so a sum not equal to 7 is when we want to continue.
While the sum of the dice is not equal to 7:
Roll die 1.
Roll die 2.
What is the sum of the dice before the loop? One option is to add two dice rolls before the loop.
Roll die 1.
Roll die 2.
While the sum of the dice is not equal to 7:
Roll die 1.
Roll die 2.
Another option is to prime the loop, to initialize the variable(s) being tested so that the test is true. In this case, we can initialize the sum to some value other than 7. Our pseudocode also includes more detail on computing the sum.
Initialize sum to 0.
While the sum of the dice is not equal to 7:
Roll die 1 and assign its value to roll1.
Roll die 2 and assign its value to roll2.
Assign roll1 plus roll2 to sum.
To simulate rolling a die, we need to generate a random integer between 1 and 6. Our implementation will include a Random object and call the nextInt method.
Construct a Random object.
Initialize sum to 0.
While the sum of the dice is not equal to 7:
Call the nextInt method of the Random object with parameter 6.
Assign this value plus one to roll1.
Call the nextInt method of the Random object with parameter 6.
Assign this value plus one to roll2.
Assign roll1 plus roll2 to sum.
Now we have enough detail to write the program.
import java.util.*; public class RollDice { public static void main(String[] args) { Random rand = new Random(); int sum = 0; while (sum != 7) { int roll1 = 1 + rand.nextInt(6); int roll2 = 1 + rand.nextInt(6); System.out.println("The dice are " + roll1 + " and " + roll2); sum = roll1 + roll2; } } }
Secure Information
Content will be erased after question is completed.