Lottery ticket approach
Tag : chash , By : Richard Laksana
Date : March 29 2020, 07:55 AM
will be helpful for those in need Create a view with all the people's names that have answered correctly. Then you can use a random number generator to select the person whos id matches the random number. If you need more help ask me. EDIT
|
PHP Lottery Ticket winner picker
Date : March 29 2020, 07:55 AM
Any of those help I'm thinking of keeping your idea of numbers instead of bring in an array. I'm going to have the players hold their ticket positions (start/end). When I pick a random ticket, I'm going to see if my number is within their bounds, and if it is, then I have found the winner. <?php
class TicketMaster {
private $players = array();
public $total = 0;
public function addPlayer($player) {
$player->tickets[0] = $this->total;
$this->total += $player->value;
$player->tickets[1] = $this->total;
$this->players[] = $player;
}
public function selectWinner() {
$ticket = rand(0, $this->total);
foreach ($this->players as $player)
if ($ticket >= $player->tickets[0] && $ticket <= $player->tickets[1])
return $player;
return false;
}
}
class Player {
public $name = '';
public $value = 0;
public $tickets = array(0, 0);
function __construct($name, $value) {
$this->name = $name;
$this->value = $value;
}
}
$ticketMaster = new TicketMaster();
$ticketMaster->addPlayer(new Player("John", 200));
$ticketMaster->addPlayer(new Player("Mike", 200));
$ticketMaster->addPlayer(new Player("Dave", 1000));
echo $ticketMaster->selectWinner()->name;
$ticket = rand(0, $this->total); //change to random_int, but I kept it at rand because eval.in only works with this one
|
Best practice to compare Object properties in C# Lottery Ticket
Tag : chash , By : Daniel Halsey
Date : March 29 2020, 07:55 AM
seems to work fine After careful considering the scenario I found it best to simply create more complex objects for each lotto number. This way it will give me functionality on each number (ie. set true if number is selected) Instead of: public int Number1
Class Number
{
int value;
bool isTrue;
}
class Number1 : Number
{
}
public class Chance : IEnumerable
{
public string chanceNumber;
public FirstNumber FirstNumber;
public SecondNumber SecondNumber;
public ThirdNumber ThirdNumber;
public FourthNumber FourthNumber;
public FifthNumber FifthNumber;
public PowerNumber PowerNumber;
public Number[] numbers;
public Chance()
{
}
public IEnumerator GetEnumerator()
{
numbers = new Number[] { FirstNumber, SecondNumber, ThirdNumber, FourthNumber, FifthNumber, PowerNumber};
return new NumberEnumerator(numbers);
}
}
|
mysql select to check lottery ticket combination
Date : March 29 2020, 07:55 AM
this will help This is a sample query that I think will achieve what you want. You just need to change the values in the IN expressions according to the result you want to search for: SELECT
main_b1, main_b2, main_b3, main_b4, main_b5, extra_b1, extra_b2,
((main_b1 IN (22, 23, 10, 11, 76)) +
(main_b2 IN (22, 23, 10, 11, 76)) +
(main_b3 IN (22, 23, 10, 11, 76)) +
(main_b4 IN (22, 23, 10, 11, 76)) +
(main_b5 IN (22, 23, 10, 11, 76))) AS main,
((extra_b1 IN (5, 9)) +
(extra_b2 IN (5, 9))) AS extra,
win_date
FROM win_archives
HAVING main >= 3 OR main = 2 AND extra > 0
ORDER BY main DESC, extra DESC, win_date DESC
INSERT INTO win_archives
(`id`, `main_b1`, `main_b2`, `main_b3`, `main_b4`, `main_b5`, `extra_b1`, `extra_b2`, `win_date`)
VALUES
(1, 22, 10, 5, 59, 61, 1, 9, '2011-01-02'),
(2, 43, 23, 11, 76, 25, 13, 9, '2015-03-30'),
(3, 22, 10, 5, 76, 61, 1, 4, '2014-06-02'),
(4, 43, 9, 11, 76, 25, 5, 9, '2012-08-07'),
(5, 22, 10, 5, 59, 61, 5, 12, '2016-12-02'),
(6, 22, 23, 11, 76, 10, 5, 6, '2017-07-19'),
(7, 22, 10, 5, 59, 61, 1, 9, '2018-09-02'),
(8, 43, 23, 11, 76, 22, 13, 8, '2005-04-11')
;
main_b1 main_b2 main_b3 main_b4 main_b5 extra_b1 extra_b2 main extra win_date
22 23 11 76 10 5 6 5 1 2017-07-19
43 23 11 76 22 13 8 4 0 2005-04-11
43 23 11 76 25 13 9 3 1 2015-03-30
22 10 5 76 61 1 4 3 0 2014-06-02
43 9 11 76 25 5 9 2 2 2012-08-07
22 10 5 59 61 1 9 2 1 2018-09-02
22 10 5 59 61 5 12 2 1 2016-12-02
22 10 5 59 61 1 9 2 1 2011-01-02
|
Have you give a lottery scratch effect in css3?
Tag : html , By : francisco santos
Date : March 29 2020, 07:55 AM
|