Your task is to create a program that adds random numbers to previous sums in the ultimate number racing showdown.
Each racer (column) starts at 0 and adds either 1 or 0 to the previous sum at each step of the race until all of the racers reach the score required to win. The 1 or 0 should be chosen at random (the standard definition of random can be found here). The output will show the result of the race, with each column representing one racer, in this format:
>> racers:5,score needed:2
0 0 0 0 0 # all racers start at 0
+ + + + + # add
1 0 0 0 1 # random 1 or 0
= = = = = # equals
1 0 0 0 1 # sum
+ + + + +
0 0 0 0 1
= = = = =
1 0 0 0 2 # winner!
+ + + +
1 1 1 1
= = = =
2 1 1 1
+ + +
1 1 1
= = =
2 2 2 # losers
Note: only the numbers, +, and = need to be included in the output.
Input
Your program will accept the following two parameters as input:
- the number of racers (columns), which must be greater than two
- the score required to win, which must be greater than one
This is code-golf--the program with the least bytes wins.
Edit: there's a non-enforceable max score of 9--this is to preserve the integrity of the column. Also, spaces between columns can be omitted in the output.