Bu yerda Python dasturining misolini ko'rib chiqamiz, u nuqtalar ketma-ketligini oladi va ularning barchasidan o'tadigan eng qisqa yo'lni "Shopping Salesman Problem" algoritmi yordamida qaytaradi: ``` itertools import permutatsiyalari def tsp(nuqtalar): # barcha nuqtalar orasidagi masofani hisoblash def masofani hisoblash ((p1, p2): x1, y1 = p1 x2, y2 = p2 qaytarish ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 # barcha nuqtalarning barcha mumkin bo'lgan permutatsiyalarini olish all_paths = permutations (((nuqtalar) # har bir yo'lning masofasini hisoblash va eng qisqa yo'lni kuzatish shortest_path = "inf" float") shortest_path_po
spam fails_task not_appropriate hate_speech sexual_content moral_judgement political_content toxicity humor violence