亞東科技大學 電機系 施勢帆老師的教學網站

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 5|回復: 0

PIN 擷取器

[複製鏈接]

66

主題

66

帖子

315

積分

管理員

Rank: 9Rank: 9Rank: 9

積分
315
發表於 昨天 16:18 | 顯示全部樓層 |閱讀模式
https://chatgpt.com/share/6aeae9c6-d9f0-83ee-8c4f-bd2f305efd42

def pin_extractor(poems):
    secret_codes = []
    for poem in poems:
        secret_code = ''
        lines = poem.split('\n')
        for line_index, line in enumerate(lines):
            words = line.split()
            if len(words) > line_index:
                secret_code += str(len(words[line_index]))
            else:
                secret_code += '0'
        secret_codes.append(secret_code)
    return secret_codes   

poem = """Stars and the moon
shine in the sky
white and
until the end of the night"""

poem2 = 'The grass is green\nhere and there\nhoping for rain\nbefore it turns yellow'
poem3 = 'There\nonce\nwas\na\ndragon'

print(pin_extractor([poem, poem2, poem3]))



回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|亞東科技大學 電機系 施勢帆老師的教學網站

GMT+8, 2026-11-5 01:36 , Processed in 0.037238 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回復 返回頂部 返回列表