Forked from WhiteBlue/gist:a6bea495cb9a71b38431106b42f24c1d
Created
June 3, 2020 15:34
-
-
Save rajendraprasad9/5b89126d961411293c347e5d26cf4c0b to your computer and use it in GitHub Desktop.
Revisions
-
WhiteBlue renamed this gist
May 12, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
WhiteBlue created this gist
May 12, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ # coding=utf-8 import copy op_method = ['+', '-', '*', '/'] def copy_arr(old, e): new_buf = copy.copy(old) new_buf.append(e) return new_buf def check_val(buf): code_val = '' for i in buf: code_val += str(i) if eval(code_val) == 24: print code_val def get_num(buf): if len(buf) < 7: if len(buf) != 0 and (len(buf) - 1) % 2 == 0: for i in op_method: get_num(copy_arr(buf, i)) else: for i in range(0, 9): if i in buf: continue if len(buf) != 0 and buf[len(buf) - 1] is '/': before_val = buf[len(buf) - 2] if i == 0 or before_val % i != 0: continue get_num(copy_arr(buf, i)) else: check_val(buf) if __name__ == '__main__': get_num([])