<jupyter_start><jupyter_text>3번<jupyter_code>def solution(gems):
    answer = []
    return answer<jupyter_output><empty_output><jupyter_text>2번<jupyter_code>exp = "100-200*300-500+20"
exp.split('-')
import re
symbol = re.compile('(\d+|[*+-])')
exp_list = re.findall(symbol, exp)
exp_list.index('!')
import re

def solution(expression):
    symbol = re.compile('(\d+|[*+-])')
    exp_list = re.findall(symbol, exp)
    operator_list = list(set(re.findall('[*+-]', exp)))
    answer = 0
    return answer
symbol = re.compile('(\d+|[*+-])')
exp_list = re.findall(symbol, exp)
operator_list = list(set(re.findall('[*+-]', exp)))
operator_list.index("2")
from collections import deque
d = deque(operator_list)
d
d.rotate()
d

from itertools import permutations
d = list(permutations(operator_list, 3))
d
import re
from itertools import permutations

def solution(expression):
    symbol = re.compile('(\d+|[*+-])')
    exp_list = re.findall(symbol, expression)
    operator_list = list(set(re.findall('[*+-]', expression)))
    result = 0
    
    for operators in list(permutations(operator_list, len(operator_list))):
        tmp_list = exp_list.copy()
        for operator in operators:
            while True:
                try:
                    idx = tmp_list.index(operator)
                    value = eval(tmp_list[idx-1] + operator + tmp_list[idx+1])
                    for i in range(3):
                            tmp_list.pop(idx-1)
                    tmp_list.insert(idx-1, str(value))
#                     if operator == '*':
#                         value = int(tmp_list[idx-1])*int(tmp_list[idx+1])
#                         for i in range(3):
#                             tmp_list.pop(idx-1)
#                         tmp_list.insert(idx-1, str(value))
                        
#                     elif operator == '+':
#                         value = int(tmp_list[idx-1])+int(tmp_list[idx+1])
#                         for i in range(3):
#                             tmp_list.pop(idx-1)
#                         tmp_list.insert(idx-1, str(value))
                        
#                     else:
#                         value = int(tmp_list[idx-1])-int(tmp_list[idx+1])
#                         for i in range(3):
#                             tmp_list.pop(idx-1)
#                         tmp_list.insert(idx-1, str(value))
                        
                except ValueError:
                    break
            if len(tmp_list) == 1:
                result = max(result, abs(int(tmp_list[0])))
        print(result)
            
                
    return result
expression = "100-200*300-500+20"
solution(expression)
a = [1,2,3]
a.index(2)
tmp_list = a.copy()
tmp_list
a[2] = 3
a
tmp_list
a
a.insert(1, 1)
a
import re
from itertools import permutations

def solution(expression):
    
    exp_list = re.findall('(\d+|[*+-])', expression)
    operator_list = list(set(re.findall('[*+-]', expression)))
    result = 0
    
    for operators in list(permutations(operator_list, len(operator_list))):
        tmp_list = exp_list.copy()
        for operator in operators:
            while True:
                try:    
                    idx = tmp_list.index(operator)
                    value = eval(tmp_list[idx-1] + operator + tmp_list[idx+1])
                    for i in range(3):
                            tmp_list.pop(idx-1)
                    tmp_list.insert(idx-1, str(value))                        
                except ValueError:
                    break
            if len(tmp_list) == 1:
                result = max(result, abs(int(tmp_list[0])))
    return result
def solution(gems):
    answer = []
    return answer<jupyter_output><empty_output><jupyter_text>3번<jupyter_code>def solution(gems):
    answer = []
    gem_list = set(gems)
    print('---', gem_list)
    for i in range(0, len(gems)):
        tmp = gem_list.copy()
        for j in range(i, len(gems)):
            print(gems[j])
            tmp =  tmp - {gems[j]}
            print(tmp)
            if not tmp :
                print(answer)
                if not answer:
                    answer.append(i + 1)
                    answer.append(j + 1)
                else:
                    tmp1 = answer[1]-answer[0]
                    tmp2 = j - i
                    if tmp2 < tmp1:
                        answer[0] = i + 1
                        answer[1] = j + 1
                
    return answer
gems = ["DIA", "RUBY", "RUBY", "DIA", "DIA", "EMERALD", "SAPPHIRE", "DIA"]
solution(gems)
a = {'DIA', 'RUBY'}
b = a.copy()
b
b - {'DIA'}
def solution(gems):
    answer = []
    gem_list = set(gems)
    for i in range(0, len(gems)):
        tmp = gem_list.copy()
        for j in range(i, len(gems)):
            tmp =  tmp - {gems[j]}
            if not tmp :
                if not answer:
                    answer.append(i + 1)
                    answer.append(j + 1)
                else:
                    tmp1 = answer[1]-answer[0]
                    tmp2 = j - i
                    if tmp2 < tmp1:
                        answer[0] = i + 1
                        answer[1] = j + 1
                
    return answer<jupyter_output><empty_output><jupyter_text>1번<jupyter_code>def solution(numbers, hand):
    answer = ''
    board = [[1,2,3], [4,5,6], [7,8,9], ['*',0,'#']]
    lh = (3, 0)
    rh = (3, 2)
    idx = (0, 0)
    for number in numbers:
        if number in [1,4,7]:
            if number == 1:
                lh = (0, 0)
                answer += "L"
            elif number == 4:
                lh = (1, 0)
                answer += "L"
            else:
                lh = (2, 0)
                answer += "L"
        elif number in [3,6,9]:
            if number == 3:
                rh = (0, 2)
                answer += "R"
            elif number == 6:
                rh = (1, 2)
                answer += "R"
            else:
                rh = (2, 2)
                answer += "R"
        else:
            for i, num_list in enumerate(board):
                try:
                    idx = (i, num_list.index(number))
                except ValueError:
                    continue
            lh_to_num = abs(lh[0] - idx[0]) + abs(lh[1] - idx[1])
            rh_to_num = abs(rh[0] - idx[0]) + abs(rh[1] - idx[1])
            if lh_to_num > rh_to_num:
                rh = idx
                answer += "R"
            elif lh_to_num < rh_to_num:
                lh = idx
                answer += "L"
            else:
                if hand == 'right':
                    rh = idx
                    answer += "R"
                else:
                    lh = idx
                    answer += "L"
    
    return answer<jupyter_output><empty_output><jupyter_text>2번<jupyter_code>import re
from itertools import permutations

def solution(expression):    
    exp_list = re.findall('(\d+|[*+-])', expression)
    operator_list = list(set(re.findall('[*+-]', expression)))
    result = 0
    
    for operators in list(permutations(operator_list, len(operator_list))):
        tmp_list = exp_list.copy()
        for operator in operators:
            while True:
                try:    
                    idx = tmp_list.index(operator)
                    value = eval(tmp_list[idx-1] + operator + tmp_list[idx+1])
                    for i in range(3):
                            tmp_list.pop(idx-1)
                    tmp_list.insert(idx-1, str(value))                        
                except ValueError:
                    break

        result = max(result, abs(int(tmp_list[0])))
    return result<jupyter_output><empty_output><jupyter_text>3번<jupyter_code>def solution(gems):
    answer = []
    gem_list = set(gems)
    for i in range(0, len(gems) - len(gem_list) + 1):
        tmp = gem_list.copy()
        for j in range(i, len(gems)):
            tmp =  tmp - {gems[j]}
            if not tmp :
                if not answer:
                    answer.append(i + 1)
                    answer.append(j + 1)
                else:
                    tmp1 = answer[1]-answer[0]
                    tmp2 = j - i
                    if tmp2 < tmp1:
                        answer[0] = i + 1
                        answer[1] = j + 1                
    return answer
def solution1(gems):
    answer = []
    gem_list = set(gems)
    for i in range(0, len(gems) - len(gem_list) + 1):
        tmp = gem_list.copy()
        for j in range(i, len(gems)):
            tmp =  tmp - {gems[j]}
            if not tmp :
                if not answer:
                    answer.append(i + 1)
                    answer.append(j + 1)
                else:
                    tmp1 = answer[1]-answer[0]
                    tmp2 = j - i
                    if tmp2 < tmp1:
                        answer[0] = i + 1
                        answer[1] = j + 1                
    return answer
gems = gems
solution1(gems)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12636749274391607, 'fraction_numerical': 0.020651931234650592, 'mean_word_length': 1.2930637317635014, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '557147', 'license': 'MIT', 'n_tokens_mistral': 2915, 'n_tokens_neox': 2703, 'n_words': 613, 'path': 'algo/Untitled.ipynb', 'repo_name': 'hbyyy/TIL', 'size': '8958'}