2 ms·
When testing solutions to algorithmic problems, it's often useful to use randomized property checking to verify that the solution's expected properties hold for
by tmoertel 6y ago
When testing solutions to algorithmic problems, it's often useful to use randomized property checking to verify that the solution's expected properties hold for approximately all inputs. The QuickCheck family of testing tools is probably the best known application of this approach. It's also pretty easy to roll your own. Some hand-rolled examples in Python:
https://github.com/tmoertel/practice/blob/master/dailycodingproblem_com/find_non_triplicate_int.py#L266 https://github.com/tmoertel/practice/blob/master/dailycoding...
https://github.com/tmoertel/practice/blob/master/dailycodingproblem_com/p18_max_subarray_values.py#L135 https://github.com/tmoertel/practice/blob/master/dailycoding...
https://github.com/tmoertel/practice/blob/master/dailycodingproblem_com/p273_find_fixed_point_in_sorted_array.py#L88 https://github.com/tmoertel/practice/blob/master/dailycoding...