🛠️ToolsShed

ブラジャーサイズ変換

US・UK・EU・FR/BE・JPのブラジャーサイズを相互変換。

よくある質問

コード実装

# Bra Size Converter: US/UK/EU/FR/AU/JP band and cup systems

# Band size conversion (US/UK inches ↔ EU/FR cm-based number)
# US/UK band → EU/FR: multiply by 2.54, then round to nearest 5 (add ~1)
# EU band → US/UK: divide by 2.54 (round to nearest even)

EU_BAND_TABLE = {
    28: 60, 30: 65, 32: 70, 34: 75, 36: 80, 38: 85,
    40: 90, 42: 95, 44: 100, 46: 105, 48: 110,
}  # US/UK → EU

# Cup conversion: US cup letters match UK, but EU/FR is one step up
# US/UK A → EU/FR B,  US/UK B → EU/FR C, etc.
CUP_LETTERS = ['AA', 'A', 'B', 'C', 'D', 'DD', 'E', 'F', 'G', 'H']

def us_band_to_eu(us_band: int) -> int | None:
    return EU_BAND_TABLE.get(us_band)

def eu_band_to_us(eu_band: int) -> int | None:
    reverse = {v: k for k, v in EU_BAND_TABLE.items()}
    return reverse.get(eu_band)

def us_cup_to_eu_cup(us_cup: str) -> str:
    """US/UK cup → EU cup (one letter up)."""
    idx = CUP_LETTERS.index(us_cup.upper()) if us_cup.upper() in CUP_LETTERS else -1
    if idx == -1:
        return "?"
    eu_idx = min(idx + 1, len(CUP_LETTERS) - 1)
    return CUP_LETTERS[eu_idx]

def find_sister_sizes(band: int, cup: str, count: int = 3) -> list[str]:
    """Return sister sizes (same cup volume, different band/cup combos)."""
    cup_idx = CUP_LETTERS.index(cup.upper()) if cup.upper() in CUP_LETTERS else -1
    if cup_idx == -1:
        return []
    sizes = []
    bands = list(EU_BAND_TABLE.keys())  # US band values: 28,30,...,48
    for b in bands:
        diff = (b - band) // 2  # band step of 2 inches
        cup_i = cup_idx - diff
        if 0 <= cup_i < len(CUP_LETTERS):
            sizes.append(f"{b}{CUP_LETTERS[cup_i]}")
    return sorted(sizes, key=lambda s: abs(int(s[:-1]) - band))[:count*2-1]

# Example
us_band, us_cup = 34, 'B'
eu_band = us_band_to_eu(us_band)
eu_cup = us_cup_to_eu_cup(us_cup)

print(f"US/UK: {us_band}{us_cup}")
print(f"EU/FR: {eu_band}{eu_cup}")
print(f"Sister sizes: {find_sister_sizes(us_band, us_cup)}")
# US/UK: 34B
# EU/FR: 75C
# Sister sizes: ['34B', '36A', '32C', '38AA', '30D']

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.