1. A defect-amelioration system comprising: a test-out connect for applying signals to a device; a test-in connect for receiving signals output by the device; and testing logic that outputs test signals to the test-out connect and receives signals output by the device in response to the test signals through the test-in connect to test the device in order to identify defects, computes a new configuration for the device from an original configuration and the identified defects so that, when the device is configured according to the new configuration, the device operates correctly despite the identified defects, the testing logic computing the new configuration by: considering the rows of configuration matrix C as available codewords; sorting the defect matrix rows by the number of defects represented by each row, in descending order, to produce sorted defect matrix rows; for each row of the sorted defect matrix rows, starting with a selected sorted defect matrix row, searching for a codeword in the available codewords that is compatible with the defect matrix row, and when a compatible codeword is found, inserting the codeword into the reconfiguration matrix R at a position corresponding to the position of the defects represented by the defect matrix row and removing the compatible codeword from the available codewords; wherein the identified defects are represented by one or more defect matrices, and wherein, when more than one defect matrix represents the defects, the rows of the more than one defect matrices are aligned and all rows at a given position within the more than one defect matrices together comprise a defect matrix row; wherein the original configuration is represented by a configuration matrix having m rows, each row comprising a codeword, each codeword, when expressed as a binary number, having n bits; wherein the new configuration is represented by a reconfiguration matrix having m rows, each row comprising a codeword, each codeword when expressed as a binary number, having n bits; and stores the new configuration in memory for subsequent configuration of the device.