不二如是 发表于 2022-9-20 19:31:36

0023-编程打卡:HaHaHahahahaHa中有几个人?

本帖最后由 不二如是 于 2022-9-20 19:31 编辑




**** Hidden Message *****

一星答案:

from unittest import result

def kooka_counter(laughing):
    temp = ''
    count = 0
    for i in range(0, len(laughing), 2):
      if temp != laughing:
            temp = laughing
            count += 1
    return count

result = kooka_counter("hahahahahahahaHaHa")
print(f"共有{result}位")


二星答案:

def kooka_counter(laughing):
    laughing = laughing.replace('a', '')
    if laughing:
      count = 1
      for i in range(len(laughing) - 1):
            if laughing != laughing:
                count += 1
      return count
    else:
      return 0

三星答案:

**** Hidden Message *****

基础语法:

https://www.bilibili.com/video/BV1c4411e77t

算法讲解:

https://www.bilibili.com/video/BV1HT4y1K7DY



hveagle 发表于 2022-9-20 21:02:13

HaHaHahahaHahaHaHahahaHa

tomok 发表于 2022-9-22 09:13:37

{:5_108:}

hornwong 发表于 2022-9-23 10:14:16

{:5_108:}
页: [1]
查看完整版本: 0023-编程打卡:HaHaHahahahaHa中有几个人?