정수화 한후 오름차순으로 정렬

조회수 450회

이미지

import random
import math
import numpy as np
import xlwings as xw
                 #****인당t회 피킹하는 시뮬레이션을 n 번 했을 때 평균적인 거리(dis)****
print("상품은 몇 개 입니까?>> ")
q = int(input())
print("몇 번(n) 시뮬레이션 하겠습니까?>> ")
n = int(input())
arr = []
def sort_num(x):
    return x

A1 = (1,3,5,7,9,11,13,15,17,19)
B1 = (5,7,9,11,13,15,17,19,21,23,7,9,11,13,15,17,19,21,23,25,9,11,13,15,17,19,21,23,25,27)
C1 = (11,13,15,17,19,21,23,25,27,29,13,15,17,19,21,23,25,27,29,31,15,17,19,21,23,25,27,29,31,33,17,19,21,23,25,27,29,31,33,35,19,21,23,25,27,29,31,33,35,37)
result1 = 0

for i in range(n):
    for i in range(int(q)):
        x = int(random.randrange(1, 11))
        if x<=7 :
            ax = int(random.choice(A1))
            result1 = ax
        if x>7 and x<=9:
            ax = int(random.choice(B1))
            result1 = ax
        if x>9 and x<=10:
            ax = int(random.choice(C1))
            result1 = ax
    arr.append(result1)

print(sorted(arr))

이런식으로 코드를 짜봤는데 저 (x2-x1)이걸 어떻게 진행해야댈지 모르겠네여..

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)