본문 바로가기
ICT

9. Learning Projects - Lottery number generator

by NeoSailer 2023. 5. 8.

Korean lottery is a game to select 6 numbers out of number range from 1 to 45 without same number and regardless order. 1st prize winner is one who gets all 6 numbers matched which are randomly chosen by lottery number picker machine.

 

PowerShell provides "Get-Random" built-in command which makes things quite easy. To print out 6 numbers in the range between 1 to 45, one line script does it all.

 

1..45 | Get-Random -count 6 | sort
2
32
35
36
39
40

 

Get-Random (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn

 

Get-Random (Microsoft.PowerShell.Utility) - PowerShell

The Get-Random cmdlet gets a randomly selected number. If you submit a collection of objects to Get-Random, it gets one or more randomly selected objects from the collection. Without parameters or input, a Get-Random command returns a randomly selected 32-

learn.microsoft.com

 

Easy-peasy..

반응형

댓글