Example #1
0
	def check_answer(self,answer):
		if not (answer['incorrect_bit'] != None and
		 answer['incorrect_bit'].isdigit()):
			return False

		code_word_string = ''
		for code in self.code_word:
			code_word_string += code
		return int(answer['incorrect_bit']) == \
		 hamming_util.check_code_word(code_word_string,self.parity)
Example #2
0
    def check_answer(self, answer):
        if not (answer['incorrect_bit'] != None
                and answer['incorrect_bit'].isdigit()):
            return False

        code_word_string = ''
        for code in self.code_word:
            code_word_string += code
        return int(answer['incorrect_bit']) == \
         hamming_util.check_code_word(code_word_string,self.parity)
Example #3
0
    def check_answer(self, answer):
        # fill code_word with bits specified by answer
        new_code_word = ''
        for i, bit in enumerate(self.code_word, 1):
            if bit == None:
                bit = answer['bit_' + str(i)]

                # every input must be binary
                if bit not in ['0', '1']:
                    return False
            new_code_word += bit

        # check correctness of new_code_word
        return hamming_util.check_code_word(new_code_word, self.parity) == 0
Example #4
0
	def check_answer(self,answer):
		# fill code_word with bits specified by answer
		new_code_word = ''
		for i,bit in enumerate(self.code_word,1):
			if bit == None:
				bit = answer['bit_' + str(i)]

				# every input must be binary
				if bit not in ['0','1']:
					return False
			new_code_word += bit

		# check correctness of new_code_word
		return hamming_util.check_code_word(
		 new_code_word,self.parity) == 0