ऐप डाउनलोड करें
फ़ोल्डर चुनें और संपादन से पहले सहायक से संबंधित फ़ाइलें पढ़ने को कहें। काम का उद्देश्य और सीमाएँ बताएँ।
1–10000 प्रदर्शन चौड़ाई और 1/4 से 8 घनत्व अनुपात से एक से 64 URL-चौड़ाई जोड़ों में चुनें। सटीक दहलीज और सबसे बड़े विकल्प पर वापसी जाँचें; चुना URL प्राप्त किए बिना दोहराई चौड़ाई या अमान्य संख्या अस्वीकार करें।
फ़ोल्डर चुनें और संपादन से पहले सहायक से संबंधित फ़ाइलें पढ़ने को कहें। काम का उद्देश्य और सीमाएँ बताएँ।
संगत endpoint चुनें। उपलब्ध उपकरण और उत्तरों की गुणवत्ता चुने गए मॉडल तथा सर्वर पर निर्भर करती है।
बदलाव और कमांड का आउटपुट देखें। परिणाम स्वीकार करने से पहले प्रोजेक्ट की जाँच चलाएँ; बनाया गया कोड अपने आप परीक्षण किया हुआ नहीं होता।
वास्तविक व्यवहार की अपेक्षित परिणाम से तुलना करें। जाँच असफल हो तो अगले बदलाव से पहले कारण समझें।
import math
def image_candidate(candidates, width, ratio):
if type(width) is not int or not 1 <= width <= 10000 or type(ratio) not in (int, float) or not 0.25 <= ratio <= 8 or not math.isfinite(ratio):
raise ValueError("image.viewport")
if type(candidates) is not list or not 1 <= len(candidates) <= 64:
raise ValueError("image.candidates")
sizes, seen = [], set()
for pair in candidates:
if type(pair) not in (list, tuple) or len(pair) != 2:
raise ValueError("image.pair")
url, pixels = pair
if type(url) is not str or not 1 <= len(url) <= 2048 or any(ord(c) < 32 or ord(c) == 127 for c in url):
raise ValueError("image.url")
if type(pixels) is not int or not 1 <= pixels <= 100000 or pixels in seen:
raise ValueError("image.size")
seen.add(pixels)
sizes.append((pixels, url))
sizes.sort()
target = width*ratio
return next((url for pixels, url in sizes if pixels >= target), sizes[-1][1])
लागू करने से पहले समीक्षा करें. बदलाव और कमांड का आउटपुट देखें। परिणाम स्वीकार करने से पहले प्रोजेक्ट की जाँच चलाएँ; बनाया गया कोड अपने आप परीक्षण किया हुआ नहीं होता।