task_id stringlengths 4 6 | category stringclasses 8
values | subcategory stringclasses 13
values | prompt stringlengths 152 1.03k | canonical_solution stringlengths 18 1.32k | test stringlengths 135 1.21k | entry_point stringlengths 2 37 |
|---|---|---|---|---|---|---|
EN/0 | ๆๅ | ๆๅ | def eto_from_year(year: int) -> str:
"""
Given a year in the Western calendar, find the zodiac sign for that year.
The zodiac signs repeat in order: the zodiac (ๅญ, ไธ, ๅฏ
, ๅฏ, ่พฐ, ๅทณ, ๅ, ๆช, ็ณ, ้
, ๆ, ไบฅ).
>>> eto_from_year(2024)
'่พฐ'
>>> eto_from_year(2023)
'ๅฏ'
>>> eto_from_year(2000)
'... | eto_cycle = ["ๅญ", "ไธ", "ๅฏ
", "ๅฏ", "่พฐ", "ๅทณ", "ๅ", "ๆช", "็ณ", "้
", "ๆ", "ไบฅ"]
index = (year - 4) % 12
return eto_cycle[index]
| def check(candidate):
assert candidate(2020) == "ๅญ"
assert candidate(2021) == "ไธ"
assert candidate(2022) == "ๅฏ
"
assert candidate(2023) == "ๅฏ"
assert candidate(2024) == "่พฐ"
assert candidate(2025) == "ๅทณ"
assert candidate(2026) == "ๅ"
assert candidate(2027) == "ๆช"
assert candidate(2028)... | eto_from_year |
EN/1 | ๆๅ | ๆๅ | def month_to_emoji(month: int) -> str:
"""
A function that accepts the month and returns the corresponding emoji.
"""
number_to_emoji = {
1: '๐', 2: '๐น', 3: '๐', 4: '๐ธ', 5: '๐', 6: 'โ',
7: '๐', 8: '๐', 9: '๐', 10: '๐', 11: '๐', 12: '๐'
}
emoji = number_to_emoji.get(mon... | emoji = month_to_emoji(month)
return f'{emoji}ไปๆใฏ{month}ๆใงใ{emoji}'
| def check(candidate):
assert candidate(1) == '๐ไปๆใฏ1ๆใงใ๐'
assert candidate(2) == '๐นไปๆใฏ2ๆใงใ๐น'
assert candidate(3) == '๐ไปๆใฏ3ๆใงใ๐'
assert candidate(4) == '๐ธไปๆใฏ4ๆใงใ๐ธ'
assert candidate(5) == '๐ไปๆใฏ5ๆใงใ๐'
assert candidate(6) == 'โไปๆใฏ6ๆใงใโ'
assert candidate(7) == '๐ไปๆใฏ7ๆใงใ๐'
assert ca... | create_monthly_message |
EN/2 | ๆๅ | ๆๅ | def get_rokuyou(days: int) -> str:
"""
Assuming that today's Rokuyo is "ๅ
ๅ", returns the Rokuyo from the specified number of days later.
argument:
days (int): Number of days since today
Return value:
str: Rokuyo (any of "ๅ
ๅ", "ๅๅผ", "ๅ
่ฒ ", "ไปๆป
", "ๅคงๅฎ", "่ตคๅฃ")
"""
| rokuyou_names = ["ๅ
ๅ", "ๅๅผ", "ๅ
่ฒ ", "ไปๆป
", "ๅคงๅฎ", "่ตคๅฃ"]
index = days % 6
return rokuyou_names[index]
| def check(candidate):
assert candidate(0) == "ๅ
ๅ"
assert candidate(1) == "ๅๅผ"
assert candidate(2) == "ๅ
่ฒ "
assert candidate(3) == "ไปๆป
"
assert candidate(4) == "ๅคงๅฎ"
assert candidate(5) == "่ตคๅฃ"
assert candidate(6) == "ๅ
ๅ"
assert candidate(7) == "ๅๅผ"
assert candidate(30) == "ๅ
ๅ"
asser... | get_rokuyou |
EN/3 | ๆๅ | ๆๅ | def get_japanese_holiday(month: int) -> list:
"""
If you enter a month, it will return a list of Japanese holidays in that month.
argument:
month (int): month (1-12)
Return value:
list: list of applicable holidays
Usage example:
>>> get_japanese_holiday(1)
['New Year's Day... | holiday_dict = {
1: ['ๅ
ๆฅ', 'ๆไบบใฎๆฅ'], # ๆไบบใฎๆฅใฏ1ๆใฎ็ฌฌ2ๆๆๆฅ
2: ['ๅปบๅฝ่จๅฟตใฎๆฅ'], # 2ๆ11ๆฅ
3: ['ๆฅๅใฎๆฅ'], # ๆฅๅใฎๆฅใฏๅนดใซใใฃใฆๅคๅใใใใ3ๆ20ๆฅ้
4: ['ๆญๅใฎๆฅ'], # 4ๆ29ๆฅ
5: ['ๆฒๆณ่จๅฟตๆฅ', 'ใฟใฉใใฎๆฅ', 'ใใฉใใฎๆฅ'], # 5ๆ3ๆฅ, 5ๆ4ๆฅ, 5ๆ5ๆฅ
6: [], # 6ๆใฏ็ฅๆฅใชใ
7: ['ๆตทใฎๆฅ'], # ๆตทใฎๆฅใฏ7ๆใฎ็ฌฌ3ๆๆๆฅ
8: ['ๅฑฑใฎๆฅ'], # ๅฑฑ... | def check(candidate):
assert candidate(1) == ['ๅ
ๆฅ', 'ๆไบบใฎๆฅ'] # 1ๆ
assert candidate(2) == ['ๅปบๅฝ่จๅฟตใฎๆฅ'] # 2ๆ
assert candidate(3) == ['ๆฅๅใฎๆฅ'] # 3ๆ
assert candidate(4) == ['ๆญๅใฎๆฅ'] # 4ๆ
assert candidate(5) == ['ๆฒๆณ่จๅฟตๆฅ', 'ใฟใฉใใฎๆฅ', 'ใใฉใใฎๆฅ'] # 5ๆ
assert candidate(7) == ['ๆตทใฎๆฅ'] # 7ๆ
assert candidate... | get_japanese_holiday |
EN/4 | ๆๅ | ๆๅ | def check_season(seasons: list, target: str) -> str:
"""
Determines whether the given season is included in the given list.
argument:
seasons (list): list of seasons (e.g. ['Spring', 'Summer', 'Autumn', 'Winter'])
target (str): Season to judge (e.g. 'summer')
Return value:
str: Returns "ๅซใพ... | if target in seasons:
return 'ๅซใพใใฆใใ'
return 'ๅซใพใใฆใใชใ'
| def check(candidate):
assert candidate(['ๆฅ', 'ๅค', '็ง', 'ๅฌ'], 'ๅค') == 'ๅซใพใใฆใใ'
assert candidate(['ๆฅ', '็ง'], '็ง') == 'ๅซใพใใฆใใ'
assert candidate(['ๅค'], 'ๅค') == 'ๅซใพใใฆใใ'
assert candidate(['ๆฅ', '็ง'], 'ๅค') == 'ๅซใพใใฆใใชใ'
assert candidate(['ๅฌ'], '็ง') == 'ๅซใพใใฆใใชใ'
assert candidate(['ใ', 'ใ', 'ใ', 'ใ', '... | check_season |
EN/5 | ๆๅ | ๆๅ | def count_particles(text: str) -> int:
"""
Create a function that counts the number of occurrences of particles (``ga'', ``no'', ``ha'', ``wo'', and ``ni'') in Japanese sentences.
argument:
text (str): Japanese text
Return value:
int: Number of particle occurrences
Usage example:
>>> ... | particles = ['ใ', 'ใฎ', 'ใฏ', 'ใ', 'ใซ']
count = 0
for particle in particles:
count += text.count(particle)
return count
| def check(candidate):
assert candidate("็งใฏๅญฆๆ กใซ่กใใพใใ") == 2
assert candidate("ไปๆฅใฎๅคฉๆฐใฏ่ฏใใงใใ") == 2
assert candidate("AIใฏไธ็ใๅคใใใ") == 2
assert candidate("ใใใใฎใฎใฏใฏใใ") == 9
assert candidate("ใใใฏๅฉ่ฉใๅซใพใใฆใใพใใใ") == 2
| count_particles |
EN/6 | ๆๅ | ๆๅ | from typing import List, Dict
def count_emoji_occurrences(text: str, emoji_list: List[str]) -> Dict[str, int]:
"""
Counts the number of occurrences of an emoji in the given text, based on the specified list of emoji.
argument:
text (str): input text
emoji_list (List[str]): List of emojis to count
... | emoji_counts = {emoji: 0 for emoji in emoji_list} # ๆๅฎใใใ็ตตๆๅญใใในใฆ0ใงๅๆๅ
for char in text:
if char in emoji_counts:
emoji_counts[char] += 1
return emoji_counts
| def check(candidate):
assert candidate("๐๐๐๐๐๐๐", ["๐", "๐", "๐"]) == {'๐': 3, '๐': 2, '๐': 1}
assert candidate("๐๐๐๐๐๐๐", ["๐", "๐", "๐"]) == {'๐': 3, '๐': 4, '๐': 0}
assert candidate("๐โจ๐ซ๐๐โจ", ["๐", "โจ", "๐ซ"]) == {'๐': 3, 'โจ': 2, '๐ซ': 1}
assert candidate("", ["๐", "๏ฟฝ... | count_emoji_occurrences |
EN/7 | ๆๅ | ๆๅ | from typing import List
def parse_taiko_rhythm(rhythm_string: str) -> List[int]:
"""
Parses the string representing the Japanese drum rhythm, converts each rhythm symbol to the corresponding number of beats, and returns it as a list.
The Japanese drum rhythm consists of the following symbols:
- 'ใใณ': ... | # ใชใบใ ่จๅทใจๆๆฐใฎๅฏพๅฟ่พๆธ
note_durations = {
'ใใณ': 4,
'ใใณ': 2,
'ใใฏ': 1
}
# ๅ
ฅๅๆๅญๅใ็ฉบ็ฝใงๅๅฒใใๅฏพๅฟใใๆๆฐใใชในใใซใใ
beats = [note_durations[note] for note in rhythm_string.split()]
return beats
| def check(candidate):
assert candidate('ใใณ ใใณ ใใฏ ใใณ ใใณ') == [4, 2, 1, 2, 4]
assert candidate('ใใณ ใใณ ใใณ ใใฏ ใใฏ ใใณ') == [2, 2, 4, 1, 1, 4]
assert candidate('ใใณ ใใณ ใใณ') == [4, 4, 4]
assert candidate('ใใฏ ใใฏ ใใฏ ใใฏ') == [1, 1, 1, 1]
assert candidate('ใใณ ใใณ') == [2, 4]
assert candidate('ใใณ') == [4]
| parse_taiko_rhythm |
EN/8 | ๆๅ | ๆๅ | def count_dango(s: str) -> int:
"""
Count the dango "o" contained in the string s.
argument:
s (str): string to check
Return value:
int: number of dumplings
Execution example:
>>> count_dango("oo-oo-oo-o-")
7
>>> count_dango("oo-o-o-oo-")
6
... | return s.count('o')
| def check(candidate):
assert candidate("oo-oo-oo-o-") == 7
assert candidate("oo-o-o-oo-") == 6
assert candidate("o-o-o-o-o-") == 5
assert candidate("ooo-ooo-o-") == 7
assert candidate("o-oo-o-o-") == 5
| count_dango |
EN/9 | ๆๅ | ๆๅ | import re
def is_haiku(haiku: str) -> bool:
"""
Determines whether the given string is in 5-7-5 haiku form.
Note:
Inputs other than hiragana do not need to be considered.
Also, one hiragana character is counted as one sound.
argument:
haiku (str): Hiragana string separ... | parts = haiku.split()
if len(parts) != 3:
return False
syllable_count = [len(re.findall(r'[ใ-ใ]', part)) for part in parts]
return syllable_count == [5, 7, 5]
| def check(candidate):
assert candidate("ใฏใใใใ ใฉใใใธใจใใ ใตใใใใ") == True
assert candidate("ใตใใใใ ใใใใจใณใใ ใฟใใฎใใจ") == True
assert candidate("ใใใใใ ใใใซใใฟใใ ใใฟใฎใใ") == True
assert candidate("ใชใคใใใ ใคใใใฎใฉใใ ใใใฎใใจ") == True
assert candidate("ใตใใใ ใใใ ใฟใ") == False
assert candidate("ใฏใ ใใใ ใฉใ ใใธใจใ ใ ใตใใ ใใ"... | is_haiku |
EN/10 | ๆๅ | ๆๅ | def missing_positions(player_positions):
"""
Check the baseball positions and identify the missing positions.
argument:
player_positions (list): List of positions the player is in (in Kanji).
Return value:
list: List of missing positions.
Execution example:
>>> positions = ["ๆ... | required_positions = {
"ๆๆ",
"ๆๆ",
"ไธๅกๆ",
"ไบๅกๆ",
"ไธๅกๆ",
"้ๆๆ",
"ไธญๅ
ๆ",
"ๅทฆ็ฟผๆ",
"ๅณ็ฟผๆ"
}
current_positions = set(player_positions)
missing = required_positions - current_positions
return list(missing)
| def check(candidate):
assert set(candidate(["ๆๆ", "ๆๆ", "ไธๅกๆ", "ไบๅกๆ", "ไธๅกๆ", "้ๆๆ"])) == {"ไธญๅ
ๆ", "ๅทฆ็ฟผๆ", "ๅณ็ฟผๆ"}
assert set(candidate(["ๆๆ", "ๆๆ", "ไธๅกๆ", "ไบๅกๆ", "ไธๅกๆ", "้ๆๆ", "ไธญๅ
ๆ"])) == {"ๅทฆ็ฟผๆ", "ๅณ็ฟผๆ"}
assert set(candidate([])) == {"ๆๆ", "ๆๆ", "ไธๅกๆ", "ไบๅกๆ", "ไธๅกๆ", "้ๆๆ", "ไธญๅ
ๆ", "ๅทฆ็ฟผๆ", "ๅณ็ฟผๆ"}
assert set(ca... | missing_positions |
EN/11 | ๆๅ | ๆๅ | def judo_match_winner(A: dict, B: dict) -> str:
"""
Determine the winner or loser of a judo match.
argument:
A (dict): Player A's score and foul information
- "ไธๆฌ" (int): Number of one
- "ๆใใ" (int): number of wazaari
- "ๆๅฐ" (int): number of teachings
B (... | # 1. ไธๆฌๅใกใฎๅคๅฎ
if A["ไธๆฌ"] > B["ไธๆฌ"]:
return "A"
elif A["ไธๆฌ"] < B["ไธๆฌ"]:
return "B"
# 2. ๆใใใฎๅคๅฎ๏ผ2ใคใงไธๆฌใจๅ็ญ๏ผ
if A["ๆใใ"] >= 2:
return "A"
if B["ๆใใ"] >= 2:
return "B"
if A["ๆใใ"] > B["ๆใใ"]:
return "A"
if A["ๆใใ"] < B["ๆใใ"]:
return "B"
# 3... | def check(candidate):
# ไธๆฌๅใกใฎไพ
assert candidate({"ไธๆฌ": 1, "ๆใใ": 0, "ๆๅฐ": 0},
{"ไธๆฌ": 0, "ๆใใ": 0, "ๆๅฐ": 0}) == "A"
assert candidate({"ไธๆฌ": 0, "ๆใใ": 0, "ๆๅฐ": 0},
{"ไธๆฌ": 1, "ๆใใ": 0, "ๆๅฐ": 0}) == "B"
# ๆใใใฎๅคๅฎ
assert candidate({"ไธๆฌ": 0, "ๆใใ": 2, "ๆๅฐ": 1},
... | judo_match_winner |
EN/12 | ๆๅ | ๆๅ | def check_kendo_gear(gear: list) -> str:
"""
A function that determines whether all Kendo armor is available.
argument:
gear (list): List of equipped armor
Return value:
str: 'ๆบๅๅฎไบ' or 'ๆบๅไธ่ถณ'
Usage example:
>>> check_kendo_gear(['้ข', 'ๅฐๆ', '่ด', 'ๅ'])
'ๆบๅๅฎไบ'
>>> check_kendo_gea... | required_gear = {'้ข', 'ๅฐๆ', '่ด', 'ๅ'}
if required_gear.issubset(set(gear)):
return 'ๆบๅๅฎไบ'
else:
return 'ๆบๅไธ่ถณ'
| def check(candidate):
assert candidate(['้ข', 'ๅฐๆ', '่ด', 'ๅ']) == 'ๆบๅๅฎไบ'
assert candidate(['้ข', 'ๅฐๆ', 'ๅ']) == 'ๆบๅไธ่ถณ'
assert candidate(['้ข', 'ๅฐๆ']) == 'ๆบๅไธ่ถณ'
assert candidate(['้ข', '้ข', '้ข', '้ข']) == 'ๆบๅไธ่ถณ'
assert candidate(['้ข', 'ๅฐๆ', '่ด']) == 'ๆบๅไธ่ถณ'
assert candidate([]) == 'ๆบๅไธ่ถณ'
assert can... | check_kendo_gear |
EN/13 | ๆๅ | ๆๅ | import datetime
def get_weekday(date: str) -> str:
"""
A function that returns the day of the week that corresponds to a given date.
argument:
date (str): date (yyyy-mm-dd format)
Return value:
str: Day of the week
Usage example:
>>> get_weekday("2024-01-01")
'ๆๆๆฅ... | dt = datetime.datetime.strptime(date, "%Y-%m-%d")
weekdays = ["ๆๆๆฅ", "็ซๆๆฅ", "ๆฐดๆๆฅ", "ๆจๆๆฅ", "้ๆๆฅ", "ๅๆๆฅ", "ๆฅๆๆฅ"]
return weekdays[dt.weekday()]
| def check(candidate):
assert candidate("2024-01-01") == "ๆๆๆฅ"
assert candidate("2024-01-02") == "็ซๆๆฅ"
assert candidate("2024-01-03") == "ๆฐดๆๆฅ"
assert candidate("2024-01-04") == "ๆจๆๆฅ"
assert candidate("2024-01-05") == "้ๆๆฅ"
assert candidate("2024-01-06") == "ๅๆๆฅ"
assert candidate("2024-01-07")... | get_weekday |
EN/14 | ๆๅ | ๆๅ | def weight_needed_for_sumo(height: int, current_weight: int) -> tuple:
"""
From your height and current weight, calculate the amount of weight gain needed to reach the average BMI of a sumo wrestler.
If the sumo wrestler's average BMI is 33, returns the target weight and required weight gain.
argument:... | target_bmi = 33
height_m = height / 100
target_weight = target_bmi * (height_m ** 2)
weight_increase = target_weight - current_weight
target_weight = int(round(target_weight))
weight_increase = int(round(weight_increase))
return (target_weight, weight_increase)
| def check(candidate):
assert candidate(180, 100) == (107, 7)
assert candidate(175, 80) == (101, 21)
assert candidate(160, 60) == (84, 24)
assert candidate(200, 120) == (132, 12)
assert candidate(165, 75) == (90, 15)
assert candidate(150, 50) == (74, 24)
assert candidate(190, 90) == (119, 29)... | weight_needed_for_sumo |
EN/15 | ๆๅ | ๆๅ | def calculate_mission_success(skill: int, difficulty: int) -> int:
"""
Calculate the ninja's mission success rate.
The mission success rate can be calculated from the difference between the ninja's technical ability and the difficulty of the mission.
argument:
skill (int): Ninja's technical... | return max(0, skill - difficulty) | def check(candidate):
assert candidate(80, 50) == 30
assert candidate(40, 60) == 0
assert candidate(100, 100) == 0
assert candidate(70, 50) == 20
assert candidate(50, 50) == 0
assert candidate(90, 30) == 60
assert candidate(30, 70) == 0
assert candidate(1, 100) == 0
assert candidate(... | calculate_mission_success |
EN/16 | ๆๅ | ๆๅ | def get_condiment_by_hiragana(hiragana: str) -> str:
"""
Returns the seasoning that corresponds to the hiragana in the input line.
argument:
hiragana (str): Hiragana for the line (``ใ'', ``ใ', ``ใ'', ``ใ'', ``ใ'')
Return value:
str: Compatible seasonings ("็ ็ณ", "ๅกฉ", "้
ข", "้คๆฒน", "mis... | condiments = {
"ใ": "็ ็ณ",
"ใ": "ๅกฉ",
"ใ": "้
ข",
"ใ": "้คๆฒน",
"ใ": "ๅณๅ"
}
return condiments.get(hiragana)
| def check(candidate):
assert candidate("ใ") == "็ ็ณ"
assert candidate("ใ") == "ๅกฉ"
assert candidate("ใ") == "้
ข"
assert candidate("ใ") == "้คๆฒน"
assert candidate("ใ") == "ๅณๅ"
| get_condiment_by_hiragana |
EN/17 | ๆๅ | ๆๅ | from collections import Counter
def rank_sushi_ingredients(orders: list) -> list:
"""
A function that returns popular sushi items from a sushi order list in order of ranking.
argument:
orders (list): List of ordered sushi items
Return value:
list: List of sushi toppings arranged in order of ... | count = Counter(orders)
sorted_items = sorted(count.items(), key=lambda x: (-x[1], x[0]))
return [item[0] for item in sorted_items]
| def check(candidate):
# ๅบๆฌ็ใชใในใใฑใผใน
assert candidate(["ใพใใ", "ใตใผใขใณ", "ใพใใ", "ใใใ", "ใตใผใขใณ", "ใพใใ"]) == ['ใพใใ', 'ใตใผใขใณ', 'ใใใ']
assert candidate(["ใใณ", "ใใณ", "ใใพใ", "ใใ", "ใใ", "ใใ"]) == ['ใใ', 'ใใณ', 'ใใพใ']
assert candidate(["ใพใใ", "ใพใใ", "ใพใใ"]) == ['ใพใใ']
assert candidate(["ใใซ", "ใใใ", "ใใใ", "ใใ", "ใ... | rank_sushi_ingredients |
EN/18 | ๆๅ | ๆๅ | def daruma_block(blocks: list, count: int) -> list:
"""
Daruma blocks are arranged in the order of blocks.
Drops the bottom block count times and returns the list of currently remaining Daruma blocks.
argument:
blocks (list): list of Daruma blocks
count (int): Number of drops
Return value:... | return blocks[:-count] if count < len(blocks) else []
| def check(candidate):
assert candidate(['่ตค', '้', '็ท', '้ป'], 1) == ['่ตค', '้', '็ท']
assert candidate(['่ตค', '้', '็ท', '้ป'], 2) == ['่ตค', '้']
assert candidate(['่ตค', '้', '็ท', '้ป'], 3) == ['่ตค']
assert candidate(['่ตค', '้', '็ท', '้ป'], 4) == []
assert candidate(['่ตค', '้'], 1) == ['่ตค']
| daruma_block |
EN/19 | ๆๅ | ๆๅ | def can_hanako_see_fireworks(A: int, B: int, C: int, D: int) -> bool:
"""
Determine whether Hanako can watch the fireworks display.
- A (int): Start date of the fireworks display (number of days from today, afternoon).
- B (int): End date of the fireworks display (number of days from today, afternoon).... | return C <= B and D > A | def check(candidate):
assert candidate(2, 4, 1, 3) == True
assert candidate(1, 5, 3, 6) == True
assert candidate(2, 4, 0, 5) == True
assert candidate(2, 4, 0, 2) == False
assert candidate(3, 5, 0, 3) == False
assert candidate(1, 2, 3, 4) == False
assert candidate(2, 3, 4, 5) == False
| can_hanako_see_fireworks |
EN/20 | ๆๅ | ๆๅ | def is_seven_gods(god_name: str) -> bool:
"""
Returns True if it is the name of the Seven Lucky Gods.
>>> is_seven_gods("ๆตๆฏๅฏฟ")
True
>>> is_seven_gods("ๅคง้ปๅคฉ")
True
>>> is_seven_gods("้ฟๅผฅ้ๅฆๆฅ")
False
"""
| seven_gods = ["ๆตๆฏๅฏฟ", "ๅคง้ปๅคฉ", "ๆฏๆฒ้ๅคฉ", "ๅผ่ฒกๅคฉ", "็ฆ็ฆๅฏฟ", "ๅฏฟ่ไบบ", "ๅธ่ข"]
return god_name in seven_gods
| def check(candidate):
assert candidate("ๆตๆฏๅฏฟ") == True
assert candidate("ๅคง้ปๅคฉ") == True
assert candidate("ๆฏๆฒ้ๅคฉ") == True
assert candidate("ๅผ่ฒกๅคฉ") == True
assert candidate("็ฆ็ฆๅฏฟ") == True
assert candidate("ๅฏฟ่ไบบ") == True
assert candidate("ๅธ่ข") == True
assert candidate("้ฟๅผฅ้ๅฆๆฅ") == False
ass... | is_seven_gods |
EN/21 | ๆๅ | ๆๅ | def sanmoku_winner(board: list) -> str:
"""
Determine the winner or loser of tic-tac-toe.
Tic-tac-toe is won when three Go pieces of the same color line up vertically, horizontally, or diagonally.
It is assumed that a given board always has a winner or loser.
argument:
board (list)... | directions = [(0, 1), (1, 0), (1, 1), (1, -1)] # ๆจช, ็ธฆ, ๅณไธใใ, ๅทฆไธใใ
n = len(board)
for row in range(n):
for col in range(n):
if board[row][col] in ("้ป", "็ฝ"):
player = board[row][col]
for dr, dc in directions:
if all(
... | def check(candidate):
# ๆจชๆนๅใฎๅๅฉ
board1 = [
["้ป", "้ป", "้ป", "", ""],
["", "็ฝ", "", "", ""],
["", "", "", "็ฝ", ""],
["", "", "", "", ""],
["", "", "", "", ""]
]
assert candidate(board1) == "้ป"
# ็ธฆๆนๅใฎๅๅฉ
board2 = [
["", "", "", "", ""],
["็ฝ", "... | sanmoku_winner |
EN/22 | ๆๅ | ๆๅ | def goldfish_scooping_score(fish_weights: list, poi_strength: int) -> int:
"""
Calculate the goldfish scooping score.
Returns 0 if the sum of the weights exceeds the strength of the poi.
argument:
fish_weights (list of int): List of weights for each goldfish (e.g. [3, 2, 5])
poi_str... | total_weight = sum(fish_weights)
if total_weight > poi_strength:
return 0
return total_weight
| def check(candidate):
assert candidate([3, 2, 5], 10) == 10
assert candidate([2, 2, 2], 7) == 6
assert candidate([3, 4, 6], 10) == 0
assert candidate([4, 3, 3], 10) == 10
assert candidate([1, 1, 1], 3) == 3
assert candidate([], 10) == 0
| goldfish_scooping_score |
EN/23 | ๆๅ | ๆๅ | import math
def calculate_folds(x: float) -> int:
"""
Calculate the number of folds of origami from the length of one side of a small square.
argument:
x (float): The length of one side of a small square.
Return value:
int: Number of times the origami was folded n.
"""
| n = math.log2(1 / x)
return int(n)
| def check(candidate):
assert candidate(0.5) == 1
assert candidate(0.25) == 2
assert candidate(0.125) == 3
assert candidate(0.0625) == 4
assert candidate(1) == 0
assert candidate(0.03125) == 5
assert candidate(0.015625) == 6
| calculate_folds |
EN/24 | ๆๅ | ๆๅ | def day_or_night(hour: int, solstice: str) -> str:
"""
Determines whether the specified time is daytime or nighttime. Consider sunrise and sunset depending on the season.
- hour (int): Time (integer from 0 to 23).
- solstice (str): One of "summer solstice", "winter solstice", "spring equinox", "aut... | if solstice not in ("ๅค่ณ", "ๅฌ่ณ", "ๆฅๅ", "็งๅ"):
raise ValueError("solsticeใฏ'ๅค่ณ', 'ๅฌ่ณ', 'ๆฅๅ', '็งๅ'ใฎใใใใใๆๅฎใใฆใใ ใใใ")
# ๅญฃ็ฏใใจใฎๆฅใฎๅบใปๆฅใฎๅ
ฅใๆๅป
if solstice == "ๅค่ณ":
sunrise, sunset = 4, 20
elif solstice == "ๅฌ่ณ":
sunrise, sunset = 7, 17
elif solstice in ("ๆฅๅ", "็งๅ"):
sunrise, s... | def check(candidate):
assert candidate(4, "ๅค่ณ") == "ๆผ"
assert candidate(3, "ๅค่ณ") == "ๅค"
assert candidate(12, "ๅค่ณ") == "ๆผ"
assert candidate(20, "ๅค่ณ") == "ๅค"
assert candidate(21, "ๅค่ณ") == "ๅค"
assert candidate(7, "ๅฌ่ณ") == "ๆผ"
assert candidate(6, "ๅฌ่ณ") == "ๅค"
assert candidate(12, "ๅฌ่ณ") == "ๆผ... | day_or_night |
EN/25 | ๆๅ | ๆๅ | from typing import List
def are_all_kites_high_enough(heights: List[float], threshold: float) -> bool:
"""
Determine whether the height of all kites is greater than or equal to a threshold.
argument:
heights (List[float]): Current height of each kite (m)
threshold (float): Threshold for fl... | return all(height >= threshold for height in heights)
| def check(candidate):
assert candidate([10.0, 12.5, 9.0], 5.0) == True
assert candidate([3.0, 6.0, 2.0], 5.0) == False
assert candidate([7.0, 8.0, 9.0], 6.0) == True
assert candidate([3.0, 5.0], 5.0) == False
assert candidate([10.0, 10.5, 11.0], 10.0) == True
| are_all_kites_high_enough |
EN/26 | ๆๅ | ๆๅ | from typing import List
def karaoke_score_with_grade(target: List[int], actual: List[int]) -> str:
"""
Calculates the pitch accuracy score in karaoke and assigns grades.
Compare the ideal pitch list (target) and the pitch list for singing (actual),
Returns a score according to the proportion of matchin... | # ไธ่ดใใฆใใ้ณ็จใฎๆฐใใซใฆใณใ
match_count = sum(1 for t, a in zip(target, actual) if t == a)
# ในใณใขใใใผใปใณใใผใธใง่จ็ฎ
score_percentage = (match_count / len(target)) * 100
# ๆ็ธพใๅคๅฎ
if score_percentage >= 90:
grade = "S"
elif score_percentage >= 80:
grade = "A"
elif score_percentage >= 70:
... | def check(candidate):
assert candidate([60, 62, 64, 65, 67], [60, 62, 64, 65, 67]) == "S"
assert candidate([60, 62, 64, 65, 67], [60, 62, 63, 65, 67]) == "A"
assert candidate([60, 62, 64, 65, 67, 68, 69], [60, 61, 64, 64, 67, 68, 69]) == "B"
assert candidate([60, 62, 64, 65, 67], [60, 61, 64, 65, 66]) =... | karaoke_score_with_grade |
EN/27 | ๆๅ | ๆๅ | def translate_thank_you(language_code):
"""
Translate "ใใใใจใ" by specifying the language code.
Args:
language_code (str): ISO 639-1 language code
(Example: "ja", "en", "ru", "fr", "ko", "es", "de", "it", "zh", "ar")
Returns:
str: Translation of "ใใใใจใ" into the specified langua... | translations = {
"ja": "ใใใใจใ", # ๆฅๆฌ่ช
"en": "Thank you", # ่ฑ่ช
"ru": "ะกะฟะฐัะธะฑะพ", # ใญใทใข่ช
"fr": "Merci", # ใใฉใณใน่ช
"ko": "๊ฐ์ฌํฉ๋๋ค", # ้ๅฝ่ช
"es": "Gracias", # ในใใคใณ่ช
"de": "Danke", # ใใคใ่ช
"it": "Grazie", ... | def check(candidate):
assert candidate("ja") == "ใใใใจใ"
assert candidate("en") == "Thank you"
assert candidate("es") == "Gracias"
assert candidate("fr") == "Merci"
assert candidate("de") == "Danke"
assert candidate("it") == "Grazie"
assert candidate("zh") == "่ฐข่ฐข"
assert candidate("ko") =... | translate_thank_you |
EN/28 | ๆๅ | ๆๅ | def check_ichiju_sansai(menu):
"""
Determine whether the menu satisfies the format of one soup and three dishes.
argument:
menu (dict): menu
{"ๆฑ็ฉ": list of str, "ไธป่": list of str, "ๅฏ่": list of str}
Return:
bool: True if it satisfies the format of one soup and three dishes,... | if set(menu.keys()) != {"ๆฑ็ฉ", "ไธป่", "ๅฏ่"}:
return False
if len(menu["ๆฑ็ฉ"]) == 1 and len(menu["ไธป่"]) == 1 and len(menu["ๅฏ่"]) == 2:
return True
return False
| def check(candidate):
assert candidate({"ๆฑ็ฉ": ["ๅณๅๆฑ"], "ไธป่": ["็ผใ้ญ"], "ๅฏ่": ["ใใฒใใ", "ๆผฌ็ฉ"]}) == True
assert candidate({"ๆฑ็ฉ": ["่ฑๆฑ"], "ไธป่": ["็
ฎ็ฉ"], "ๅฏ่": ["ใใฒใใ", "ใใใใตใฉใ"]}) == True
assert candidate({"ๆฑ็ฉ": ["ๅณๅๆฑ"], "ไธป่": ["็ผใ้ญ"], "ๅฏ่": ["ใใฒใใ"]}) == False
assert candidate({"ๆฑ็ฉ": ["ๅณๅๆฑ"], "ไธป่": ["็ผใ้ญ"]})... | check_ichiju_sansai |
EN/29 | ๆๅ | ๆๅ | def get_hiragana(key: int, presses: int) -> str:
"""
Returns hiragana depending on the phone's key and number of presses.
argument:
key (int): Pressed key number (0-9).
presses (int): Number of key presses (1 or more).
Return value:
str: Corresponding Hiragana character.
""... | key_map = {
1: ["ใ", "ใ", "ใ", "ใ", "ใ"],
2: ["ใ", "ใ", "ใ", "ใ", "ใ"],
3: ["ใ", "ใ", "ใ", "ใ", "ใ"],
4: ["ใ", "ใก", "ใค", "ใฆ", "ใจ"],
5: ["ใช", "ใซ", "ใฌ", "ใญ", "ใฎ"],
6: ["ใฏ", "ใฒ", "ใต", "ใธ", "ใป"],
7: ["ใพ", "ใฟ", "ใ", "ใ", "ใ"],
8: ["ใ", "ใ", "ใ"],
9:... | def check(candidate):
key_map = {
1: ["ใ", "ใ", "ใ", "ใ", "ใ"],
2: ["ใ", "ใ", "ใ", "ใ", "ใ"],
3: ["ใ", "ใ", "ใ", "ใ", "ใ"],
4: ["ใ", "ใก", "ใค", "ใฆ", "ใจ"],
5: ["ใช", "ใซ", "ใฌ", "ใญ", "ใฎ"],
6: ["ใฏ", "ใฒ", "ใต", "ใธ", "ใป"],
7: ["ใพ", "ใฟ", "ใ", "ใ", "ใ"],
8: ["ใ",... | get_hiragana |
EN/30 | ๆๅ | ๆๅ | def calculate_congestion_rate(max_capacity: int, current_passengers: int) -> float:
"""
Calculate the congestion rate of the train.
Arguments:
max_capacity (int): Train capacity (maximum capacity)
current_passengers (int): Number of passengers currently on board
Return:
float: ... | return (current_passengers / max_capacity) * 100
| def check(candidate):
assert candidate(100, 120) == 120.0
assert candidate(100, 50) == 50.0
assert candidate(150, 150) == 100.0
assert candidate(200, 180) == 90.0
assert candidate(300, 450) == 150.0
| calculate_congestion_rate |
EN/31 | ้ขจ็ฟ | ้ขจ็ฟ | def get_izumo_traditional_month_name(n: int) -> str:
"""
Returns the traditional month name of the Izumo region that corresponds to the current month.
In the Izumo region, October is called "็ฅๆๆ".
argument:
n (int): current month (1-12)
Return value:
str: Ancient month name in ... | month_names = [
"็ฆๆ", "ๅฆๆ", "ๅผฅ็", "ๅฏๆ", "็ๆ", "ๆฐด็กๆ",
"ๆๆ", "่ๆ", "้ทๆ", "็ฅๆๆ", "้ๆ", "ๅธซ่ตฐ"
]
return month_names[n - 1]
| def check(candidate):
assert candidate(1) == "็ฆๆ"
assert candidate(2) == "ๅฆๆ"
assert candidate(3) == "ๅผฅ็"
assert candidate(4) == "ๅฏๆ"
assert candidate(5) == "็ๆ"
assert candidate(6) == "ๆฐด็กๆ"
assert candidate(7) == "ๆๆ"
assert candidate(8) == "่ๆ"
assert candidate(9) == "้ทๆ"
asser... | get_izumo_traditional_month_name |
EN/32 | ้ขจ็ฟ | ้ขจ็ฟ | def calculate_remaining_bill(total_bill: int, boss_bills: list, other_members_count: int) -> int:
"""
A function that splits the bill.
argument:
total_bill (int): Total amount
boss_bills (list): list of amounts paid by the boss
other_members_count (int): Number of people other than the boss
... | total_boss_payment = sum(boss_bills)
remaining_amount = total_bill - total_boss_payment
if remaining_amount <= 0:
return 0
remaining_per_member = remaining_amount // other_members_count
return remaining_per_member
| def check(candidate):
assert candidate(10000, [3000, 2000], 3) == 1666
assert candidate(15000, [5000], 4) == 2500
assert candidate(20000, [8000, 8000], 1) == 4000
assert candidate(10000, [10000], 3) == 0
assert candidate(10000, [11000], 3) == 0
assert candidate(1000000, [400000, 300000], 10) == ... | calculate_remaining_bill |
EN/33 | ้ขจ็ฟ | ้ขจ็ฟ | def hanako_otoshidama(before_price: int, growth_percentage: int, saving_price: int, item_price: int):
"""
The New Year has arrived. Hanako receives her New Year's gift.
New Year's gift is the amount increased by `growth_percentage`% from the previous year's `before_price`.
Hanako should determine whethe... | current_otoshidama = before_price * (100 + growth_percentage) // 100
total_money = current_otoshidama + saving_price
if total_money >= item_price:
return "่ณผๅ
ฅๅฏ่ฝ"
else:
return f"ๅทฎ้กใฏ{item_price - total_money}ๅ"
|
def check(candidate):
assert candidate(10000, 10, 5000, 16000) == "่ณผๅ
ฅๅฏ่ฝ"
assert candidate(10000, 5, 3000, 15000) == "ๅทฎ้กใฏ1500ๅ"
assert candidate(5000, 20, 2000, 10000) == "ๅทฎ้กใฏ2000ๅ"
| hanako_otoshidama |
EN/34 | ้ขจ็ฟ | ้ขจ็ฟ | def is_shichi_go_san_age(birth_year: int, current_year: int) -> bool:
"""
Given the year of birth and the current year, determine whether that age is eligible for Shichi-Go-San.
Since Shichi-Go-San is celebrated in the years when people are 3, 5, or 7 years old, it returns True if it is applicable, and Fals... | age = current_year - birth_year
return age in {3, 5, 7}
| def check(candidate):
assert candidate(2020, 2023) == True
assert candidate(2018, 2023) == True
assert candidate(2016, 2023) == True
assert candidate(2017, 2023) == False
assert candidate(2020, 2024) == False
assert candidate(2015, 2023) == False
assert candidate(2021, 2023) == False
| is_shichi_go_san_age |
EN/35 | ้ขจ็ฟ | ้ขจ็ฟ | def corrections_needed(lyrics: str) -> int:
"""
Compare the given lyrics with the lyrics of Japan's national anthem "Kimigayo".
Calculate the number of edits required to correct mistakes.
Lyrics comparison is performed using character strings that do not include spaces.
argument:
lyrics (str): ... | correct_lyrics = "ๅใไปฃใฏๅไปฃใซๅ
ซๅไปฃใซ็ดฐ็ณใฎๅทใจใชใใฆ่ใฎใใใพใง"
lyrics = lyrics.replace(" ", "")
len_lyrics, len_correct = len(lyrics), len(correct_lyrics)
dp = [[0] * (len_correct + 1) for _ in range(len_lyrics + 1)]
for i in range(len_lyrics + 1):
dp[i][0] = i
for j in range(len_correct + 1):
... | def check(candidate):
assert candidate("ๅใไปฃใฏๅไปฃใซๅ
ซๅไปฃใซ็ดฐ็ณใฎๅทใจใชใใฆ่ใฎใใใพใง") == 0
assert candidate("ๅใไปฃใฏๅไปฃใซๅ
ซๅไปฃใซ็ดฐ็ณใฎๅทใจใชใใฆ่ใฎใใใพใ ") == 1
assert candidate("ๅใไปฃใฏๅไปฃใซ็พๅไปฃใซ็ดฐ็ณใฎๅทใจใชใใฆ่ใฎใใใพใง") == 1
assert candidate("ๅใไปฃใฏๅไปฃใซๅ
ซๅไปฃใซ็ดฐ็ณใฎๅทใจใชใ่ใฎใใใพใง") == 1
assert candidate("ๅใไปฃใฏๅไปฃใซๅ
ซๅไปฃใซ็ดฐ็ณใฎๅทใจใชใใฆ่ใฎใใใพ") == 1
assert candidate("ๅใไปฃ... | corrections_needed |
EN/36 | ้ขจ็ฟ | ้ขจ็ฟ | def is_correct_hinamatsuri_order(dolls: list) -> bool:
"""
Given the correct order of the dolls for Hinamatsuri, create a function to determine whether the input order is correct.
Argument:
- dolls (list): the order of the dolls
Return:
- bool: True if correct, False if incorrect
Example:... | correct_order = ["ใๅ
่ฃๆง", "ใ้ๆง", "ไธไบบๅฎๅฅณ", "ไบไบบๅๅญ", "้่บซ", "ไปไธ"]
return dolls == correct_order
| def check(candidate):
assert candidate(["ใๅ
่ฃๆง", "ใ้ๆง", "ไธไบบๅฎๅฅณ", "ไบไบบๅๅญ", "้่บซ", "ไปไธ"]) == True
assert candidate(["ใ้ๆง", "ใๅ
่ฃๆง", "ไธไบบๅฎๅฅณ", "ไบไบบๅๅญ", "ไปไธ", "้่บซ"]) == False
assert candidate(["ใ้ๆง", "ใๅ
่ฃๆง", "ไธไบบๅฎๅฅณ", "ไบไบบๅๅญ", "้่บซ", "ไปไธ"]) == False
assert candidate(["ใๅ
่ฃๆง", "ใ้ๆง", "้่บซ", "ไธไบบๅฎๅฅณ", "ไบไบบๅๅญ", "ไปไธ"]) == False... | is_correct_hinamatsuri_order |
EN/37 | ้ขจ็ฟ | ้ขจ็ฟ | def get_ehou_direction(year: int) -> str:
"""
A function that receives the year in the Western calendar and returns the lucky direction (ๆฑๅๆฑ, ๅๅๆฑ, ่ฅฟๅ่ฅฟ, or ๅๅ่ฅฟ) of that year.
argument:
year (int): year of the Western calendar
Return value:
str: Direction of lucky direction for the year
Usa... | directions = ['ๆฑๅๆฑ', 'ๅๅ่ฅฟ', '่ฅฟๅ่ฅฟ', 'ๅๅๆฑ']
return directions[year % 4]
| def check(candidate):
assert candidate(2020) == 'ๆฑๅๆฑ'
assert candidate(2021) == 'ๅๅ่ฅฟ'
assert candidate(2022) == '่ฅฟๅ่ฅฟ'
assert candidate(2023) == 'ๅๅๆฑ'
assert candidate(2024) == 'ๆฑๅๆฑ'
assert candidate(2025) == 'ๅๅ่ฅฟ'
assert candidate(2026) == '่ฅฟๅ่ฅฟ'
assert candidate(2027) == 'ๅๅๆฑ'
assert... | get_ehou_direction |
EN/38 | ้ขจ็ฟ | ้ขจ็ฟ | def is_keigo(text: str) -> bool:
"""
A function that determines whether the input sentence is honorific language (ending in "ใพใ" or "ใงใ").
argument:
text (str): Japanese text
Return value:
bool: Returns True if the sentence is honorific (ending with "ใพใ" or "ใงใ"), otherwise returns false.
... | if text.endswith('ใพใใ') or text.endswith('ใงใใ'):
return True
return False
| def check(candidate):
assert candidate("็งใฏๅญฆๆ กใซ่กใใพใใ") == True
assert candidate("ไปๆฅใฏใใๅคฉๆฐใ ใญใ") == False
assert candidate("ใๆไผใใใใฆใใใ ใใพใใ") == True
assert candidate("ๆจๆฅใฎๅคฉๆฐใฏๆชใใฃใใ") == False
assert candidate("ไปๆฅใฏๅคฉๆฐใใใใงใใ") == True
assert candidate("ๅฝผใฏ่ตฐใใฎใๆฉใใ") == False
assert candidate("AIใฏ้ฒๅใใฆใใพใ... | is_keigo |
EN/39 | ้ขจ็ฟ | ้ขจ็ฟ | def count_hashi_pair(s: str) -> int:
"""
Counts the number of chopsticks (two chopsticks make a set) in the string s.
Args.
s (str): string
Return.
int: Number of chopsticks
Ex.
>>> count_hashi_pair(""||-|-|||-"")
3
"""
| count = s.count("|")
return count // 2
| def check(candidate):
assert candidate("||-|-|||-") == 3
assert candidate("|||-|-|") == 2
assert candidate("-|---|") == 1
assert candidate("|-||-|") == 2
assert candidate("|||||") == 2
| count_hashi_pair |
EN/40 | ้ขจ็ฟ | ้ขจ็ฟ | from typing import List
def calculate_total_beans(ages: List[int]) -> int:
"""
Calculate the number of beans that the whole family will eat.
Assume that each family member eats as many beans as their age.
argument:
ages (List[int]): List of ages of each family member.
Return value:
... | return sum(ages)
| def check(candidate):
assert candidate([10, 15, 20]) == 45
assert candidate([5, 8, 13]) == 26
assert candidate([1, 2, 3, 4]) == 10
assert candidate([30, 25, 15]) == 70
assert candidate([7, 6, 5, 4]) == 22
| calculate_total_beans |
EN/41 | ้ขจ็ฟ | ้ขจ็ฟ | def classify_bow(angle: int) -> str:
"""
Based on the angle of the bow, the type of bow ('ไผ้', 'ๆฎ้็คผ', 'ๆๆฌ็คผ') is determined.
argument:
angle (int): angle of bow (integer)
Return value:
str: type of bow ('ไผ้', 'ๆฎ้็คผ', 'ๆๆฌ็คผ', or '็กๅนใช่งๅบฆ')
Execution example:
>>> classify_bow(15)... | if angle == 15:
return "ไผ้"
elif angle == 30:
return "ๆฎ้็คผ"
elif angle == 45:
return "ๆๆฌ็คผ"
else:
return "็กๅนใช่งๅบฆ"
| def check(candidate):
assert candidate(15) == "ไผ้"
assert candidate(30) == "ๆฎ้็คผ"
assert candidate(45) == "ๆๆฌ็คผ"
assert candidate(20) == "็กๅนใช่งๅบฆ"
assert candidate(0) == "็กๅนใช่งๅบฆ"
assert candidate(60) == "็กๅนใช่งๅบฆ"
| classify_bow |
EN/42 | ้ขจ็ฟ | ้ขจ็ฟ | def judge_janken(a: str, b: str) -> str:
"""
Determines the result of rock, paper, scissors and returns the winner as "A" or "B", and in case of a tie, returns "ๅผใๅใ".
It is based on the rule that "ใฐใผ" beats "ใใงใญ", "ใใงใญ" beats "ใใผ", and "ใใผ" beats "ใฐใผ".
argument:
a (str): Player A's hand ("ใฐใผ",... |
if a == b:
return "ๅผใๅใ"
win_map = {
("ใฐใผ", "ใใงใญ"): "A",
("ใใงใญ", "ใใผ"): "A",
("ใใผ", "ใฐใผ"): "A",
("ใใงใญ", "ใฐใผ"): "B",
("ใใผ", "ใใงใญ"): "B",
("ใฐใผ", "ใใผ"): "B"
}
return win_map.get((a, b))
| def check(candidate):
assert candidate("ใฐใผ", "ใใงใญ") == "A"
assert candidate("ใใผ", "ใใงใญ") == "B"
assert candidate("ใใงใญ", "ใฐใผ") == "B"
assert candidate("ใฐใผ", "ใใผ") == "B"
assert candidate("ใใงใญ", "ใใผ") == "A"
assert candidate("ใใผ", "ใฐใผ") == "A"
assert candidate("ใฐใผ", "ใฐใผ") == "ๅผใๅใ"
assert ... | judge_janken |
EN/43 | ้ขจ็ฟ | ้ขจ็ฟ | def convert_to_japanese_time(hour: int, minute: int) -> str:
"""
A function that converts the time (hour, minute) in 24-hour notation to Japanese notation for AM/PM.
argument:
hour (int): Time in 24-hour notation (0 <= hour < 24)
minute (int): minute (0 <= minute < 60)
Return value:
str: J... | if 0 <= hour < 12: # ๅๅ
meridian = "ๅๅ"
display_hour = hour if hour != 0 else 0 # 0ๆใฏใใฎใพใพ0ๆ
else: # ๅๅพ
meridian = "ๅๅพ"
display_hour = hour - 12 if hour != 12 else 12 # 12ๆใฏใใฎใพใพ12ๆ
return f"{meridian}{display_hour}ๆ{minute}ๅ"
| def check(candidate):
assert candidate(0, 0) == 'ๅๅ0ๆ0ๅ'
assert candidate(0, 15) == 'ๅๅ0ๆ15ๅ'
assert candidate(11, 59) == 'ๅๅ11ๆ59ๅ'
assert candidate(12, 0) == 'ๅๅพ12ๆ0ๅ'
assert candidate(12, 30) == 'ๅๅพ12ๆ30ๅ'
assert candidate(23, 59) == 'ๅๅพ11ๆ59ๅ'
assert candidate(14, 30) == 'ๅๅพ2ๆ30ๅ'
as... | convert_to_japanese_time |
EN/44 | ้ขจ็ฟ | ้ขจ็ฟ | def identify_nanakusa(name: str) -> bool:
"""
Returns True if the given name `name` applies to the seven spring herbs, otherwise returns False.
The seven herbs of spring are "ใใ", "ใชใใช", "ใใใใ", "ใฏใในใ", "ใปใจใใฎใ", "ใใใช" or "ใใใใ".
argument:
- name (str): Hiragana name
Return value:
- ... | # ๆฅใฎไธ่ใฎใชในใ
nanakusa = {"ใใ", "ใชใใช", "ใใใใ", "ใฏใในใ", "ใปใจใใฎใ", "ใใใช", "ใใใใ"}
# ๅๅใไธ่ใซๅซใพใใใใฉใใใๅคๅฎ
return name in nanakusa
| def check(candidate):
assert candidate("ใใ") == True
assert candidate("ใชใใช") == True
assert candidate("ใใใใ") == True
assert candidate("ใฏใในใ") == True
assert candidate("ใปใจใใฎใ") == True
assert candidate("ใใใช") == True
assert candidate("ใใใใ") == True
assert candidate("ใใใ") == False
a... | identify_nanakusa |
EN/45 | ้ขจ็ฟ | ้ขจ็ฟ | def calculate_postcard_fee(fee: int, x: int) -> int:
"""
This is a function that calculates the price of postcards.
argument:
fee (int): Fee for one postcard (yen)
x (int): Number of postcards
Return value:
int: Total postcard fee (yen)
example:
>>> calculate_postcard_fee(63, ... | return fee * x
| def check(candidate):
assert candidate(63, 1) == 63
assert candidate(63, 5) == 315
assert candidate(63, 10) == 630
assert candidate(70, 10) == 700
assert candidate(84, 2) == 168
assert candidate(84, 3) == 252
| calculate_postcard_fee |
EN/46 | ้ขจ็ฟ | ้ขจ็ฟ | from typing import List
def sort_koinobori(sizes: List[int]) -> List[int]:
"""
Sort the carp streamer size list from largest to largest.
- sizes (List[int]): List of sizes (cm) of each carp streamer.
- Returns: A list of carp streamers sorted by size.
example:
>>> sort_koinobori([30, 50, 70, ... | return sorted(sizes, reverse=True)
| def check(candidate):
assert candidate([30, 50, 70, 20]) == [70, 50, 30, 20]
assert candidate([100, 200, 150]) == [200, 150, 100]
assert candidate([10, 10, 10]) == [10, 10, 10]
assert candidate([5, 3, 8, 1]) == [8, 5, 3, 1]
assert candidate([500, 100, 300, 200]) == [500, 300, 200, 100]
assert ca... | sort_koinobori |
EN/47 | ้ขจ็ฟ | ้ขจ็ฟ | def compare_fortunes(last_year: str, this_year: str) -> str:
"""
Compare last year's fortune with this year's fortune and decide whether this year's fortune is better, worse, or unchanged than last year.
Omikuji ranks are evaluated in the following order (left is best):
ๅคงๅ > ไธญๅ > ๅฐๅ > ๅ > ๆซๅ > ๅถ > ๅคงๅถ
... | fortune_ranks = {
"ๅคงๅ": 1,
"ไธญๅ": 2,
"ๅฐๅ": 3,
"ๅ": 4,
"ๆซๅ": 5,
"ๅถ": 6,
"ๅคงๅถ": 7
}
last_rank = fortune_ranks.get(last_year, float('inf'))
this_rank = fortune_ranks.get(this_year, float('inf'))
if this_rank < last_rank:
return '่ฏใ... | def check(candidate):
assert candidate("ๅ", "ๅคงๅ") == '่ฏใ'
assert candidate("ๅคงๅ", "ๅฐๅ") == 'ๆชใ'
assert candidate("ไธญๅ", "ไธญๅ") == 'ๅคๅใชใ'
assert candidate("ๅถ", "ๅ") == '่ฏใ'
assert candidate("ๅคงๅถ", "ๅคงๅ") == '่ฏใ'
assert candidate("ๅคงๅ", "ๅคงๅถ") == 'ๆชใ'
assert candidate("ๆซๅ", "ๆซๅ") == 'ๅคๅใชใ'
assert... | compare_fortunes |
EN/48 | ้ขจ็ฟ | ้ขจ็ฟ | from typing import List
def determine_winner(red_scores: List[int], white_scores: List[int]) -> str:
"""
The winner of the ็ด
็ฝๆญๅๆฆ will be determined.
Each group is given a score, and the team with the highest total score is the winning team.
Returns either "็ด
็ต", "็ฝ็ต", or "ๅผใๅใ".
Example:
>>> de... | red_total = sum(red_scores)
white_total = sum(white_scores)
if red_total > white_total:
return "็ด
็ต"
elif white_total > red_total:
return "็ฝ็ต"
else:
return "ๅผใๅใ"
| def check(candidate):
assert candidate([10, 20, 30], [15, 25, 20]) == 'ๅผใๅใ'
assert candidate([50, 40, 60], [30, 20, 10]) == '็ด
็ต'
assert candidate([10, 20, 30], [40, 50, 60]) == '็ฝ็ต'
assert candidate([100, 200, 300], [100, 150, 200]) == '็ด
็ต'
assert candidate([0, 0, 0], [0, 0, 0]) == 'ๅผใๅใ'
asser... | determine_winner |
EN/49 | ้ขจ็ฟ | ้ขจ็ฟ | import datetime
def get_tokyo_seijinshiki_date(year: int) -> str:
"""
Finds the coming-of-age ceremony date in Tokyo for the specified year.
argument:
year (int): year
Return value:
str: Date of coming-of-age ceremony (YYYY-MM-DD format)
Usage example:
>>> get_tokyo_seiji... | # ๆๅฎใใใๅนดใฎ1ๆ1ๆฅใๅๅพ
first_january = datetime.date(year, 1, 1)
# ็ฌฌ1ๆๆๆฅใ่จ็ฎ
first_monday = first_january + datetime.timedelta(days=(7 - first_january.weekday()) % 7)
# ็ฌฌ2ๆๆๆฅใ่จ็ฎ
seijin_shiki_date = first_monday + datetime.timedelta(days=7)
return seijin_shiki_date.strftime('%Y-%m-%d')
| def check(candidate):
assert candidate(2024) == "2024-01-08"
assert candidate(2023) == "2023-01-09"
assert candidate(2025) == "2025-01-13"
assert candidate(2022) == "2022-01-10"
assert candidate(2020) == "2020-01-13"
| get_tokyo_seijinshiki_date |
EN/50 | ้ขจ็ฟ | ้ขจ็ฟ | def check_yakudoshi(age: int, gender: str) -> str:
"""
Based on age and gender, it determines whether the age is in bad year, mae-yaku, or after-yaku.
argument:
age (int): Age to judge
gender (str): gender ('male' or 'female')
Return value:
str: One of the โๅๅนดโ, โๅๅโ, โๅพๅโ, or "ๅๅนดใงใฏใชใ"
... |
male_yakudoshi = {
'ๅๅ': [24, 40, 60],
'ๅๅนด': [25, 41, 61],
'ๅพๅ': [26, 42, 62]
}
female_yakudoshi = {
'ๅๅ': [18, 32, 36],
'ๅๅนด': [19, 33, 37],
'ๅพๅ': [20, 34, 38]
}
if gender == '็ทๆง':
yakudoshi_dict = male_yakudoshi
elif gender == 'ๅฅณๆง':
... | def check(candidate):
# 1. ็ทๆงใฎใในใ
assert candidate(24, '็ทๆง') == 'ๅๅ' # ๅๅ
assert candidate(25, '็ทๆง') == 'ๅๅนด' # ๅๅนด
assert candidate(26, '็ทๆง') == 'ๅพๅ' # ๅพๅ
assert candidate(40, '็ทๆง') == 'ๅๅ' # ๅๅ
assert candidate(41, '็ทๆง') == 'ๅๅนด' # ๅๅนด
assert candidate(42, '็ทๆง') == 'ๅพๅ' # ๅพๅ
assert c... | check_yakudoshi |
EN/51 | ้ขจ็ฟ | ้ขจ็ฟ | def calculate_rice_time(rice_type: str) -> int:
"""
A function that returns the soaking time (minutes) required to cook rice.
Minimum requirements:
- rice_type is one of "็ฝ็ฑณ", "็็ฑณ", or "็กๆด็ฑณ" .
- If any other rice_type is specified, -1 is returned.
rule:
- "็ฝ็ฑณ" requires 30 minutes of soaki... | if rice_type == "็ฝ็ฑณ":
return 30
elif rice_type == "็็ฑณ":
return 360 # 6ๆ้ = 360ๅ
elif rice_type == "็กๆด็ฑณ":
return 0
else:
return -1 # ไธๆใชใ้ฃฏใฎ็จฎ้ก
| def check(candidate):
assert candidate("็ฝ็ฑณ") == 30
assert candidate("็็ฑณ") == 360
assert candidate("็กๆด็ฑณ") == 0
assert candidate("ใใก็ฑณ") == -1
assert candidate("้ป็ฑณ") == -1
assert candidate("") == -1
assert candidate("WHITE") == -1
assert candidate("็ฝ") == -1
assert candidate("็กๆด") == -1... | calculate_rice_time |
EN/52 | ้ขจ็ฟ | ้ขจ็ฟ | def min_cooking_time(ingredients):
"""
A function that calculates the minimum time to fry tempura using two pots.
argument:
ingredients (list): list of ingredients for frying time
Return value:
int: minimum frying time
Usage example:
>>> min_cooking_time([2, 3, 2, ... | # ้ฃๆใฎๆใๆ้ใใฝใผใ๏ผ็ญใ้ ๏ผ
ingredients.sort()
# 2ใคใฎ้ใไฝฟใฃใๆๅฐๆ้ใ่จ็ฎ
time1 = 0 # ้1ใฎๆ้
time2 = 0 # ้2ใฎๆ้
for i in range(len(ingredients)):
if time1 <= time2:
time1 += ingredients[i] # ้1ใซ้ฃๆใ่ฟฝๅ
else:
time2 += ingredients[i] # ้2ใซ้ฃๆใ่ฟฝๅ
return max(time1... | def check(candidate):
assert candidate([2, 3, 2, 1, 4]) == 7
assert candidate([3, 3, 3, 3]) == 6
assert candidate([5]) == 5
assert candidate([1, 2, 3, 4, 5, 6]) == 12
| min_cooking_time |
EN/53 | ้ขจ็ฟ | ้ขจ็ฟ | from datetime import datetime
def generate_work_message(start_time: str, end_time: str) -> str:
"""
A function that generates a message after work based on the start and end times.
Arguments:
start_time (str): Start time of work (HH:MM format)
end_time (str): End time of work (HH:MM format)
R... | start = datetime.strptime(start_time, "%H:%M")
end = datetime.strptime(end_time, "%H:%M")
work_duration = (end - start).seconds / 3600 # ๅคๅๆ้๏ผๆ้ๅไฝ๏ผ
if work_duration >= 8:
return "ใ็ฒใๆงใงใใใใใฃใใไผใใงใใ ใใใ"
else:
return "ใ็ฒใๆงใงใใใๆๆฅใใใใฐใใพใใใใ"
| def check(candidate):
assert candidate("09:00", "18:00") == "ใ็ฒใๆงใงใใใใใฃใใไผใใงใใ ใใใ"
assert candidate("09:00", "16:30") == "ใ็ฒใๆงใงใใใๆๆฅใใใใฐใใพใใใใ"
assert candidate("08:00", "16:00") == "ใ็ฒใๆงใงใใใใใฃใใไผใใงใใ ใใใ"
assert candidate("10:00", "15:00") == "ใ็ฒใๆงใงใใใๆๆฅใใใใฐใใพใใใใ"
assert candidate("11:00", "19:00")... | generate_work_message |
EN/54 | ้ขจ็ฟ | ้ขจ็ฟ | from datetime import datetime, timedelta
def calculate_bedtime(wake_up_time: str, sleep_duration: str) -> str:
"""
Calculates the time you should go to bed to get the desired amount of sleep.
Arguments:
- wake_up_time (str): Time you want to wake up in the morning (e.g. โ07:30โ)
- sleep_durati... | wake_up_time_obj = datetime.strptime(wake_up_time, "%H:%M")
sleep_hours, sleep_minutes = map(int, sleep_duration.split(':'))
sleep_duration_obj = timedelta(hours=sleep_hours, minutes=sleep_minutes)
bed_time_obj = wake_up_time_obj - sleep_duration_obj
return bed_time_obj.strftime("%H:%M")
| def check(candidate):
assert candidate("07:30", "8:00") == "23:30"
assert candidate("07:30", "8:30") == "23:00"
assert candidate("18:00", "7:30") == "10:30"
assert candidate("18:15", "7:30") == "10:45"
assert candidate("09:00", "7:00") == "02:00"
assert candidate("10:00", "7:00") == "03:00"
... | calculate_bedtime |
EN/55 | ้ขจ็ฟ | ้ขจ็ฟ | def can_all_family_wait(times, num_people):
"""
A function to determine whether the Aoki family can all wait in line at a restaurant.
The waiting time is (number of people until they enter the restaurant) * 30 minutes.
Arguments:
- times (list): List of acceptable waiting times (in minutes... | wait_time = num_people * 30
for time in times:
if time < wait_time:
return False
return True
| def check(candidate):
assert candidate([60, 90, 120], 1) == True
assert candidate([60, 90, 120], 2) == True
assert candidate([60, 90, 120], 3) == False
assert candidate([60, 90, 120], 4) == False
assert candidate([120, 120, 120], 4) == True
assert candidate([120, 150, 150], 4) == True
assert... | can_all_family_wait |
EN/56 | ้ขจ็ฟ | def evaluate_score(score: int) -> str:
"""
Grades will be evaluated based on the points given.
Performance evaluation criteria:
- 80 points or more: "่ฏ"
- 60 points or more but less than 80 points: "ๅฏ"
- Less than 60 points: "ไธๅฏ"
argument:
score (int): Input score (0-100)
Retu... | if score >= 80:
return "่ฏ"
elif score >= 60:
return "ๅฏ"
else:
return "ไธๅฏ"
| def check(candidate):
assert candidate(85) == "่ฏ"
assert candidate(75) == "ๅฏ"
assert candidate(45) == "ไธๅฏ"
assert candidate(60) == "ๅฏ"
assert candidate(80) == "่ฏ"
assert candidate(59) == "ไธๅฏ"
assert candidate(100) == "่ฏ"
assert candidate(0) == "ไธๅฏ"
| evaluate_score | |
EN/57 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | from typing import List
def calculate_yamanote_distance(start: str, end: str, stations: List[str]) -> int:
"""
Given a list of stations on the Yamanote Line, a departure station, and an arrival station, calculate the number of stations from the departure station to the arrival station.
Since the Yamanote L... | start_index = stations.index(start)
end_index = stations.index(end)
clockwise_distance = (end_index - start_index) % len(stations)
counterclockwise_distance = (start_index - end_index) % len(stations)
return min(clockwise_distance, counterclockwise_distance)
| def check(candidate):
stations = ["ๆฑไบฌ", "ๆๆฅฝ็บ", "ๆฐๆฉ", "ๆตๆพ็บ", "็ฐ็บ", "ๅๅท", "ๅคงๅด", "ไบๅ็ฐ", "็ฎ้ป", "ๆตๆฏๅฏฟ", "ๆธ่ฐท",
"ๅๅฎฟ", "ไปฃใ
ๆจ", "ๆฐๅฎฟ", "ๆฐๅคงไน
ไฟ", "้ซ็ฐ้ฆฌๅ ด", "็ฎ็ฝ", "ๆฑ ่ข", "ๅคงๅก", "ๅทฃ้ดจ", "้ง่พผ", "็ฐ็ซฏ",
"่ฅฟๆฅๆฎ้", "ๆฅๆฎ้", "้ถฏ่ฐท", "ไธ้", "ๅพกๅพ็บ", "็ง่ๅ", "็ฅ็ฐ"]
assert candidate("ๆฑไบฌ", "ๅๅท", stations) == 5
assert can... | calculate_yamanote_distance |
EN/58 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def is_japan_prefecture(prefecture):
"""
A function that determines whether a given prefecture name is a Japanese prefecture.
This function is based on a list of Japan's 47 prefectures (1 capital, 1 prefecture, 2 prefectures, 43 prefectures).
Checks whether the entered prefecture name is included i... | japan_prefectures = [
'ๅๆตท้', '้ๆฃฎ็', 'ๅฒฉๆ็', 'ๅฎฎๅ็', '็ง็ฐ็', 'ๅฑฑๅฝข็', '็ฆๅณถ็',
'่จๅ็', 'ๆ ๆจ็', '็พค้ฆฌ็', 'ๅผ็็', 'ๅ่็', 'ๆฑไบฌ้ฝ', '็ฅๅฅๅท็',
'ๆฐๆฝ็', 'ๅฏๅฑฑ็', '็ณๅท็', '็ฆไบ็', 'ๅฑฑๆขจ็', '้ท้็',
'ๅฒ้็', '้ๅฒก็', 'ๆ็ฅ็', 'ไธ้็',
'ๆป่ณ็', 'ไบฌ้ฝๅบ', 'ๅคง้ชๅบ', 'ๅ
ตๅบซ็', 'ๅฅ่ฏ็', 'ๅๆญๅฑฑ็',
'้ณฅๅ็', 'ๅณถๆ น็', 'ๅฒกๅฑฑ็', 'ๅบๅณถ็', 'ๅฑฑๅฃ็',... | def check(candidate):
true_prefectures = [
'ๆฑไบฌ้ฝ', 'ๅคง้ชๅบ', 'ๅๆตท้', '็ฆๅฒก็', 'ๆฒ็ธ็', '้ๆฃฎ็',
'ๅฒฉๆ็', 'ๅฎฎๅ็', '็ง็ฐ็', 'ๅฑฑๅฝข็', '็ฆๅณถ็', '่จๅ็',
'ๆ ๆจ็', '็พค้ฆฌ็', 'ๅผ็็', 'ๅ่็', '็ฅๅฅๅท็',
'ๆฐๆฝ็', 'ๅฏๅฑฑ็', '็ณๅท็', '็ฆไบ็', 'ๅฑฑๆขจ็',
'้ท้็', 'ๅฒ้็', '้ๅฒก็', 'ๆ็ฅ็', 'ไธ้็',
'ๆป่ณ็', 'ไบฌ้ฝๅบ', 'ๅ
ตๅบซ็', 'ๅฅ่ฏ็', 'ๅๆญ... | is_japan_prefecture |
EN/59 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def contains_major_river(text: str) -> bool:
"""
Determines whether text contains the name of one of Japan's three major rivers.
Japan's three major rivers are "ไฟกๆฟๅท", "ๅฉๆ นๅท", and "็ณ็ฉๅท".
argument:
text (str): Character string to be evaluated.
Return value:
bool: True if any of the three ... | major_rivers = ["ไฟกๆฟๅท", "ๅฉๆ นๅท", "็ณ็ฉๅท"]
return any(river in text for river in major_rivers)
| def check(candidate):
assert candidate("ๆจๆฅใฏไฟกๆฟใซ่กใใพใใใ") == False
assert candidate("ๅฉๆ นใฎๆตๅใฏๅบใใงใใญใ") == False
assert candidate("็ณ็ฉๅฐๆนใฏ้ชใๅคใใงใใ") == False
assert candidate("ไฟกๆฟๅทใฏๆฅๆฌๆ้ทใฎๅทใงใใ") == True
assert candidate("ใใฎๅฐๅใงใฏๅฉๆ นๅทใๆๅใงใใ") == True
assert candidate("็ณ็ฉๅทใๆตใใ้ขจๆฏใฏ็พใใใ") == True
assert candidat... | contains_major_river |
EN/60 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def get_region(prefecture: str) -> str:
"""
Accepts a Japanese prefecture name as input and returns the corresponding region name.
If a prefecture that does not exist is entered, "Unknown" is returned.
>>> get_region('ๅๆตท้')
'ๅๆตท้ๅฐๆน'
>>> get_region('็ง็ฐ็')
'ๆฑๅๅฐๆน'
"""
| regions = {
"ๅๆตท้ๅฐๆน": ["ๅๆตท้"],
"ๆฑๅๅฐๆน": ["้ๆฃฎ็", "ๅฒฉๆ็", "ๅฎฎๅ็", "็ง็ฐ็", "ๅฑฑๅฝข็", "็ฆๅณถ็"],
"้ขๆฑๅฐๆน": ["่จๅ็", "ๆ ๆจ็", "็พค้ฆฌ็", "ๅผ็็", "ๅ่็", "ๆฑไบฌ้ฝ", "็ฅๅฅๅท็"],
"ไธญ้จๅฐๆน": ["ๆฐๆฝ็", "ๅฏๅฑฑ็", "็ณๅท็", "็ฆไบ็", "ๅฑฑๆขจ็", "้ท้็", "ๅฒ้็", "้ๅฒก็", "ๆ็ฅ็"],
"่ฟ็ฟๅฐๆน": ["ไธ้็", "ๆป่ณ็", "ไบฌ้ฝๅบ", "ๅคง้ชๅบ", "ๅ
ตๅบซ็", "ๅฅ่ฏ็", "ๅๆญๅฑฑ็"],
... | def check(candidate):
assert candidate("ๅๆตท้") == "ๅๆตท้ๅฐๆน"
assert candidate("็ง็ฐ็") == "ๆฑๅๅฐๆน"
assert candidate("็ฆๅณถ็") == "ๆฑๅๅฐๆน"
assert candidate("ๆฑไบฌ้ฝ") == "้ขๆฑๅฐๆน"
assert candidate("่จๅ็") == "้ขๆฑๅฐๆน"
assert candidate("ๆ็ฅ็") == "ไธญ้จๅฐๆน"
assert candidate("็ณๅท็") == "ไธญ้จๅฐๆน"
assert candidate("ๅคง้ชๅบ") == ... | get_region |
EN/61 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def is_in_tokyo(ward: str) -> bool:
"""
A function that determines whether it is in Tokyo's 23 wards.
argument:
ward (str): Ward name to be judged.
Return value:
bool: True if the argument is the name of Tokyo's 23 wards, False otherwise.
example:
>>> is_in_tokyo("ๆฐๅฎฟๅบ")
True
>... | tokyo_23_wards = {
"ๅไปฃ็ฐๅบ", "ไธญๅคฎๅบ", "ๆธฏๅบ", "ๆฐๅฎฟๅบ", "ๆไบฌๅบ", "ๅฐๆฑๅบ", "ๅขจ็ฐๅบ", "ๆฑๆฑๅบ",
"ๅๅทๅบ", "็ฎ้ปๅบ", "ๅคง็ฐๅบ", "ไธ็ฐ่ฐทๅบ", "ๆธ่ฐทๅบ", "ไธญ้ๅบ", "ๆไธฆๅบ",
"่ฑๅณถๅบ", "ๅๅบ", "่ๅทๅบ", "ๆฟๆฉๅบ", "็ทด้ฆฌๅบ", "่ถณ็ซๅบ", "่้ฃพๅบ", "ๆฑๆธๅทๅบ"
}
return ward in tokyo_23_wards
| def check(candidate):
assert candidate("ๆฐๅฎฟๅบ") == True
assert candidate("ๆธ่ฐทๅบ") == True
assert candidate("ๆธฏๅบ") == True
assert candidate("ๅไปฃ็ฐๅบ") == True
assert candidate("ๆฑๆธๅทๅบ") == True
assert candidate("ๆจชๆตๅธ") == False
assert candidate("ๅคง้ชๅธ") == False
assert candidate("ๆญๅนๅธ") == False
as... | is_in_tokyo |
EN/62 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def get_hottest_location(temperature_data):
"""
Given city and temperature data, returns the city with the highest temperature.
argument:
temperature_data (dict): Dictionary of cities and their temperature data.
Return value:
str: Name of the city with the highest temperature.
Exe... | return max(temperature_data, key=lambda location: temperature_data[location])
| def check(candidate):
assert candidate({"ๆฐๅฎฟๅบ": 35.5, "ๅคง้ชๅธ": 34.0, "็ฆๅฒกๅธ": 36.2}) == "็ฆๅฒกๅธ"
assert candidate({"ๆจชๆตๅธ": 29.8, "ไบฌ้ฝๅธ": 33.1, "็ฅๆธๅธ": 32.7}) == "ไบฌ้ฝๅธ"
assert candidate({"ไปๅฐๅธ": 25.3, "้ท้ๅธ": 24.1, "้ซๆพๅธ": 26.0}) == "้ซๆพๅธ"
assert candidate({"้ๆฒขๅธ": 31.2}) == "้ๆฒขๅธ"
assert candidate({"ๅฏๅฑฑๅธ": -5.0, "็ง็ฐๅธ"... | get_hottest_location |
EN/63 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def append_administrative_unit(prefecture: str) -> str:
"""
Returns the given prefecture name with the correct administrative unit ("้ฝ", "้", "ๅบ", "็").
argument:
prefecture (str): prefecture name without administrative unit
Return value:
str: Prefecture name with administrative unit
... | prefectures_with_special_units = {
"ๆฑไบฌ": "ๆฑไบฌ้ฝ",
"ๅคง้ช": "ๅคง้ชๅบ",
"ไบฌ้ฝ": "ไบฌ้ฝๅบ",
"ๅๆตท้": "ๅๆตท้"
}
if prefecture in prefectures_with_special_units:
return prefectures_with_special_units[prefecture]
else:
return prefecture + "็"
| def check(candidate):
assert candidate("ๆฑไบฌ") == "ๆฑไบฌ้ฝ"
assert candidate("ๅๆตท้") == "ๅๆตท้"
assert candidate("ๅคง้ช") == "ๅคง้ชๅบ"
assert candidate("ไบฌ้ฝ") == "ไบฌ้ฝๅบ"
assert candidate("ๅผ็") == "ๅผ็็"
assert candidate("็ฅๅฅๅท") == "็ฅๅฅๅท็"
assert candidate("ๆ็ฅ") == "ๆ็ฅ็"
assert candidate("ๆฐๆฝ") == "ๆฐๆฝ็"
ass... | append_administrative_unit |
EN/64 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def is_tokaido_shinkansen_nobori(stations: list) -> str:
"""
Determines whether the specified station on the Tokaido Shinkansen is an 'ไธใ' (ๆฑไบฌ-bound) or 'ไธใ' (ๆฐๅคง้ช-bound) station.
This function takes a list of stations, which consists of different stations for the departure and arrival stations.
It retur... | tokaido_shinkansen_stations = [
"ๆฑไบฌ", "ๅๅท", "ๆฐๆจชๆต", "ๅฐ็ฐๅ", "็ฑๆตท", "ไธๅณถ", "ๆฐๅฏๅฃซ", "้ๅฒก", "ๆๅท", "ๆตๆพ",
"่ฑๆฉ", "ไธๆฒณๅฎๅ", "ๅๅคๅฑ", "ๅฒ้็พฝๅณถ", "็ฑณๅ", "ไบฌ้ฝ", "ๆฐๅคง้ช"
]
start_station, end_station = stations[0], stations[1]
if start_station not in tokaido_shinkansen_stations or end_station not in tokaido_shi... | def check(candidate):
assert candidate(["ๆฐๅคง้ช", "ๆฑไบฌ"]) == "ไธใ"
assert candidate(["ๆฑไบฌ", "ๆฐๅคง้ช"]) == "ไธใ"
assert candidate(["ๅๅคๅฑ", "ๆฑไบฌ"]) == "ไธใ"
assert candidate(["้ๅฒก", "ๅๅคๅฑ"]) == "ไธใ"
assert candidate(["ไบฌ้ฝ", "ๆฐๅคง้ช"]) == "ไธใ"
assert candidate(["ๅๅท", "ๆฐๆจชๆต"]) == "ไธใ"
assert candidate(["ๆๅท", "่ฑๆฉ"])... | is_tokaido_shinkansen_nobori |
EN/65 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def is_japan_three_views(place: str) -> bool:
"""
Determine whether the specified place name is one of the three most scenic places in Japan.
>>> is_japan_three_views(""ๆพๅณถ"")
True
>>> is_japan_three_views(""ๅคฉๆฉ็ซ"")
True
>>> is_japan_three_views(""ๅฎฎๅณถ"")
True
>>> is_japan_three_views("... | japan_three_views = {"ๆพๅณถ", "ๅคฉๆฉ็ซ", "ๅฎฎๅณถ"}
return place in japan_three_views
| def check(candidate):
assert candidate("ๆพๅณถ") == True
assert candidate("ๅคฉๆฉ็ซ") == True
assert candidate("ๅฎฎๅณถ") == True
assert candidate("ๅฏๅฃซๅฑฑ") == False
assert candidate("ๆฑไบฌใฟใฏใผ") == False
assert candidate("็ต็ถๆน") == False
assert candidate("ๅฑไน
ๅณถ") == False
assert candidate("ๆฒ็ธ") == False
| is_japan_three_views |
EN/66 | ๆฅๆฌๅฐ็ | ๆฅๆฌๅฐ็ | def is_prefectural_capital(city: str) -> bool:
"""
Determines whether the specified city is the capital of the prefecture.
Argument:
city (str): City name
Return:
bool: True if the capital of the prefecture, False otherwise
Ex:
>>> is_prefectural_capital("ๆฑไบฌ")
True
>>> is_pref... | prefectural_capitals = {
"ๆญๅน", "้ๆฃฎ", "็ๅฒก", "ไปๅฐ", "็ง็ฐ", "ๅฑฑๅฝข", "็ฆๅณถ", "ๆฐดๆธ", "ๅฎ้ฝๅฎฎ", "ๅๆฉ",
"ใใใใพ", "ๅ่", "ๆฑไบฌ", "ๆจชๆต", "ๆฐๆฝ", "ๅฏๅฑฑ", "้ๆฒข", "็ฆไบ", "็ฒๅบ", "้ท้",
"ๅฒ้", "้ๅฒก", "ๅๅคๅฑ", "ๆดฅ", "ๅคงๆดฅ", "ไบฌ้ฝ", "ๅคง้ช", "็ฅๆธ", "ๅฅ่ฏ", "ๅๆญๅฑฑ",
"้ณฅๅ", "ๆพๆฑ", "ๅฒกๅฑฑ", "ๅบๅณถ", "ๅฑฑๅฃ", "ๅพณๅณถ", "้ซๆพ", "ๆพๅฑฑ", "้ซ็ฅ", "็ฆๅฒก",
"ไฝ่ณ", "... | def check(candidate):
assert candidate("ๆฑไบฌ") == True
assert candidate("ๆธ่ฐท") == False
assert candidate("ๅๆตท้") == False
assert candidate("ๆญๅน") == True
assert candidate("ๆดฅ") == True
assert candidate("ๅคงๆดฅ") == True
assert candidate("้ซๆพ") == True
assert candidate("ๅผ็") == False
assert cand... | is_prefectural_capital |
EN/67 | ๆๅ | ๆๅ | def check_olympic_year(year: int) -> bool:
"""
A function that checks whether it is the year in which the Olympics were held in Japan.
argument:
year (int): year to check
Return value:
bool: True if the year the Olympics were held in Japan, False otherwise.
Usage example:
... | olympic_years = {1964, 1972, 1998, 2021}
return year in olympic_years
| def check(candidate):
assert candidate(1964) == True
assert candidate(1972) == True
assert candidate(1998) == True
assert candidate(2021) == True
assert candidate(2000) == False
assert candidate(2016) == False
assert candidate(2024) == False
| check_olympic_year |
EN/68 | ๆๅ | ๆๅ | def get_essay_by_author(author: str) -> str:
"""
A function that returns the three major essays related to a given author.
argument:
author (str): name of the author
Return value:
str: Titles of three major essays related to the author
"""
| essays = {
"ๆธ
ๅฐ็ด่จ": "ๆ่ๅญ",
"้ดจ้ทๆ": "ๆนไธ่จ",
"ๅ็ฐๅ
ผๅฅฝ": "ๅพ็ถ่"
}
return essays.get(author)
| def check(candidate):
assert candidate("ๆธ
ๅฐ็ด่จ") == "ๆ่ๅญ"
assert candidate("้ดจ้ทๆ") == "ๆนไธ่จ"
assert candidate("ๅ็ฐๅ
ผๅฅฝ") == "ๅพ็ถ่"
| get_essay_by_author |
EN/69 | ๆๅ | ๆๅ | def convert_wareki_to_seireki(wareki: str) -> int:
"""
Converts the given Japanese calendar to the Western calendar. The Japanese calendar is limited to era names from ``ๆๆฒป'' to ``ไปคๅ.''
The Japanese calendar is expressed as "ไปคๅ3ๅนด" or "ๅนณๆ30ๅนด".
Argument:
wareki (str): Japanese calendar string
... | eras = {
"ไปคๅ": 2019,
"ๅนณๆ": 1989,
"ๆญๅ": 1926,
"ๅคงๆญฃ": 1912,
"ๆๆฒป": 1868
}
era_name = wareki[:2]
year_str = wareki[2:-1]
year = 1 if year_str == "ๅ
" else int(year_str)
return eras[era_name] + year - 1
| def check(candidate):
assert candidate('ไปคๅ3ๅนด') == 2021
assert candidate('ๅนณๆ30ๅนด') == 2018
assert candidate('ๆญๅ64ๅนด') == 1989
assert candidate('ๅนณๆๅ
ๅนด') == 1989
assert candidate('ๅคงๆญฃๅ
ๅนด') == 1912
assert candidate('ๆๆฒป45ๅนด') == 1912
assert candidate('ไปคๅๅ
ๅนด') == 2019
assert candidate('ๆญๅ1ๅนด') == 1926... | convert_wareki_to_seireki |
EN/70 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def convert_to_manyo_gana(text: str) -> str:
"""
A function that converts a given string to Manyogana.
Convert each Hiragana character to its Manyogana counterpart. Here, we will perform a temporary and simple conversion.
For example, ใใใisใๅฎใใใใใisใไปฅใใใใใisใๅฎใ.
argument:
text (str... | hira_to_manyo = {
'ใ': 'ๅฎ', 'ใ': 'ไปฅ', 'ใ': 'ๅฎ', 'ใ': '่กฃ', 'ใ': 'ๆผ',
'ใ': 'ๅ ', 'ใ': 'ๅนพ', 'ใ': 'ไน
', 'ใ': '่จ', 'ใ': 'ๅทฑ',
'ใ': 'ๅทฆ', 'ใ': 'ไน', 'ใ': '้ ', 'ใ': 'ไธ', 'ใ': 'ๆฝ',
'ใ': 'ๅค', 'ใก': '็ฅ', 'ใค': 'ๅท', 'ใฆ': 'ๅคฉ', 'ใจ': 'ๆญข',
'ใช': 'ๅฅ', 'ใซ': 'ไป', 'ใฌ': 'ๅฅด', 'ใญ': '็ฅข', 'ใฎ': 'ไน',
... | def check(candidate):
assert candidate("ใใใ") == 'ๅฎไปฅๅฎ'
assert candidate("ใใใใใ") == 'ๅ ๅนพไน
่จๅทฑ'
assert candidate("ใใใใใ") == 'ๅทฆไน้ ไธๆฝ'
assert candidate("ใใกใคใฆใจ") == 'ๅค็ฅๅทๅคฉๆญข'
assert candidate("ใชใซใฌใญใฎ") == 'ๅฅไปๅฅด็ฅขไน'
assert candidate("ใฏใฒใตใธใป") == 'ๆณขๆฏๅธ้จไฟ'
assert candidate("ใพใฟใใใ") == 'ๆซ็พๆญฆๅฅณๆฏ'
assert cand... | convert_to_manyo_gana |
EN/71 | ้ขจ็ฟ | ้ขจ็ฟ | def is_matching_iroha_song(text: str) -> bool:
"""
A function that determines whether the given string completely matches the Iroha song.
Ignore spaces and line breaks in the input string.
Full text of the Iroha song (check for matches, ignoring spaces and line breaks):
ใใใฏใซใปใธใจใกใใฌใใ
ใใใใใใใคใญใชใใ... | iroha_song = "ใใใฏใซใปใธใจใกใใฌใใใใใใใใใคใญใชใใใใใฎใใใใพใใตใใใฆใใใใใใฟใใใฒใใใ"
cleaned_text = ''.join(char for char in text if char not in ' \n')
return cleaned_text == iroha_song
| def check(candidate):
# ใใใฏๆญใจๅฎๅ
จใซไธ่ดใใใฑใผใน
assert candidate("ใใใฏใซใปใธใจใกใใฌใใใใใใใใใคใญใชใใใใใฎใใใใพใใตใใใฆใใใใใใฟใใใฒใใใ") == True
# ๆน่กใในใใผในใๅซใพใใใใใใใฏๆญใฎ้ ็ชใๆญฃใใใฑใผใน
assert candidate("ใใใฏใซใปใธใจ ใกใใฌใใ ใใใใใใ ใคใญใชใใ ใใใฎใใใใพ ใใตใใใฆ ใใใใใใฟใ ใใฒใใใ") == True
assert candidate("ใใใฏใซใปใธใจ\nใกใใฌใใ\nใใใใใใ\nใคใญใชใใ\nใใใฎใใใใพ\nใใตใใใฆ\nใใใ... | is_matching_iroha_song |
EN/72 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def contains_fullwidth_katakana(text: str) -> bool:
"""
Checks whether the given string contains full-width katakana characters.
Returns True if full-width katakana is included.
argument:
text (str): string to check
Return value:
bool: True if full-width katakana is included, False... | for char in text:
if '\u30A0' <= char <= '\u30FF':
return True
return False
| def check(candidate):
assert candidate("ใขใคใฆใจใช") == True
assert candidate("ใซใญใฏใฑใณ") == True
assert candidate("ใใญใผใฏใผใซใ") == True
assert candidate("ใใใใช") == False
assert candidate("ใซใฟใซใ") == True
assert candidate("็ไปฎๅ") == False
assert candidate("KATAKANA") == False
assert candidate("kataka... | contains_fullwidth_katakana |
EN/73 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def next_katakana(char: str) -> str:
"""
A function that returns the character following the specified character in a katakana table.
If the specified character is the last character ('ใณ'), it will return to the first character ('a').
argument:
char (str): 1 character katakana
Return value:
... | katakana_list = ['ใข', 'ใค', 'ใฆ', 'ใจ', 'ใช',
'ใซ', 'ใญ', 'ใฏ', 'ใฑ', 'ใณ',
'ใต', 'ใท', 'ใน', 'ใป', 'ใฝ',
'ใฟ', 'ใ', 'ใ', 'ใ', 'ใ',
'ใ', 'ใ', 'ใ', 'ใ', 'ใ',
'ใ', 'ใ', 'ใ', 'ใ', 'ใ',
'ใ', 'ใ', 'ใ ', 'ใก... | def check(candidate):
assert candidate("ใข") == 'ใค'
assert candidate("ใซ") == 'ใญ'
assert candidate("ใฒ") == 'ใณ'
assert candidate("ใณ") == 'ใข'
assert candidate("ใฝ") == 'ใฟ'
assert candidate("ใจ") == 'ใฉ'
assert candidate("ใณ") == 'ใข'
assert candidate("ใ") == 'ใ'
assert candidate("ใฏ") == 'ใฒ'
| next_katakana |
EN/74 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def replace_katakana(s, replacement):
"""
Replaces katakana characters in the given string s with the specified string replacement.
argument:
s (str): Target string.
replacement (str): String used for replacement.
Return value:
str: String resulting from replacing katakana.
... | return "".join(replacement if "ใก" <= char <= "ใณ" or char == "ใด" else char for char in s)
| def check(candidate):
assert candidate("ใซใฟใซใใจใฒใใใช", "*") == "****ใจใฒใใใช"
assert candidate("ใซใฟใซใ", "!") == "!!!!"
assert candidate("ใฒใใใชใจๆผขๅญ", "?") == "ใฒใใใชใจๆผขๅญ"
assert candidate("ๆผขๅญใจใซใฟใซใ", "#") == "ๆผขๅญใจ####"
assert candidate("ใใขใคใใใฆใใจใชใ", "+") == "ใ++ใใ+ใ++ใ"
| replace_katakana |
EN/75 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def calculate_katakana_percentage(text: str) -> float:
"""
A function that calculates the percentage of katakana in a text.
Arguments:
text (str): Japanese text
Return value:
float: Percentage of katakana (to one decimal place)
Example:
>>> calculate_katakana_percentage("ใณใณใใฅใผใฟ")
... | if len(text) == 0:
return 0.0
total_chars = len(text)
katakana_count = sum(1 for char in text if '\u30a0' <= char <= '\u30ff')
percentage = (katakana_count / total_chars) * 100
return round(percentage, 1)
| def check(candidate):
assert candidate("ใณใณใใฅใผใฟ") == 100.0
assert candidate("ใซใฟใซใใจใฒใใใช") == 44.4
assert candidate("ใซใฟใซใใจๆผขๅญ") == 57.1
assert candidate("ใใข้ฟใใณ") == 40.0
assert candidate("ใซใฟใซใใใฒใใใชใๆผขๅญ") == 50.0
assert candidate("ๆผขๅญใฎใฟ") == 0.0
| calculate_katakana_percentage |
EN/76 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def convert_katakana_to_halfwidth(text: str) -> str:
"""
You are given a text (text) composed of hiragana and katakana syllabary characters.
Create a function that converts all katakana characters in the text to half-width characters.
Rules:
- Keep hiragana and already half-width katakana chara... |
fullwidth = "ใขใคใฆใจใชใซใญใฏใฑใณใตใทในใปใฝใฟใใใใใใใใใใใใใใใใใ ใกใขใคใฆใจใฉใชใซใฌใญใฏใฒใณ"
halfwidth = "๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต๏ฝถ๏ฝท๏ฝธ๏ฝน๏ฝบ๏ฝป๏ฝผ๏ฝฝ๏ฝพ๏ฝฟ๏พ๏พ๏พ๏พ๏พ๏พ
๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏พ๏ฝฆ๏พ"
return text.translate(str.maketrans(fullwidth, halfwidth))
| def check(candidate):
assert candidate("ใใใใใใขใคใฆใจใช") == "ใใใใใ๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต"
assert candidate("ใฏใฒใณใใใ") == "๏พ๏ฝฆ๏พใใใ"
assert candidate("ใซใฟใซใ ใฒใใใช") == "๏ฝถ๏พ๏ฝถ๏พ
ใฒใใใช"
assert candidate("ใขใคใฆใจใช ใขใคใฆใจใช") == "๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต ๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต"
assert candidate("ใฏใฒใณ ใฏใฒใณ") == "๏พ๏ฝฆ๏พ ๏พ๏ฝฆ๏พ"
assert candidate("๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต") == "๏ฝฑ๏ฝฒ๏ฝณ๏ฝด๏ฝต"
assert candi... | convert_katakana_to_halfwidth |
EN/77 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def is_two_char_shiritori_valid_katakana(words: list) -> bool:
"""
A function that determines whether or not the rules for two-character shiritori using katakana are satisfied.
Returns True if the two-character shiritori is valid, and False otherwise.
Rules:
- The โlast two charactersโ of each word... | for i in range(len(words) - 1):
if len(words[i]) < 2 or len(words[i + 1]) < 2:
return False
if words[i][-2:] != words[i + 1][:2]:
return False
return True
| def check(candidate):
assert candidate(["ใทใชใใช", "ใใชใฏใ", "ใฏใใใท", "ใใทใง"]) == True
assert candidate(["ใใใ", "ใใใชใงใผใทใซ", "ใทใซใค", "ใซใคใฌใฉ"]) == True
assert candidate(["ใญใใใญ", "ใใญใขใซใช", "ใซใชใขใ", "ใขใใชใญ"]) == True
assert candidate(["ใฟใใญ", "ใญใใ", "ใใณ", "ใณใคใ"]) == False
assert candidate(["ใใณ", "ใณใฟใ", "ใใใญ", "ใญใใณ"])... | is_two_char_shiritori_valid_katakana |
EN/78 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def katakana_to_romaji(name: str) -> str:
"""
This function takes the furigana for the name โnameโ and converts it to full-width capital letters.
Ex:
>>> katakana_to_romaji("ใฟใใซ")
'TANAKA'
"""
| katakana_map = {
'ใข': 'A', 'ใค': 'I', 'ใฆ': 'U', 'ใจ': 'E', 'ใช': 'O',
'ใซ': 'KA', 'ใญ': 'KI', 'ใฏ': 'KU', 'ใฑ': 'KE', 'ใณ': 'KO',
'ใต': 'SA', 'ใท': 'SHI', 'ใน': 'SU', 'ใป': 'SE', 'ใฝ': 'SO',
'ใฟ': 'TA', 'ใ': 'CHI', 'ใ': 'TSU', 'ใ': 'TE', 'ใ': 'TO',
'ใ': 'NA', 'ใ': 'NI', 'ใ': 'NU', 'ใ': 'NE... | def check(candidate):
assert candidate("ใขใชใญ") == "AOKI"
assert candidate("ใซใใณ") == "KANEKO"
assert candidate("ในใบใญ") == "SUZUKI"
assert candidate("ใฟใใซ") == "TANAKA"
assert candidate("ใใทใ") == "NISHIDA"
assert candidate("ใใธใขใ") == "FUJIMOTO"
assert candidate("ใใฆใฉ") == "MIURA"
assert candid... | katakana_to_romaji |
EN/79 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def encode_shift(s: str):
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def decode_shift(s: str):
"""
This function takes a string encoded with the encode_shift function as an argument and returns the decoded string.
"""
| return "".join([chr(((ord(ch) - ord("a") - 5) % 26) + ord("a")) for ch in s]) | from random import randint, choice
import string
import copy
def check(candidate):
letters = string.ascii_lowercase
for _ in range(50):
str = ''.join(choice(letters) for i in range(randint(10, 20)))
encoded_str = encode_shift(str)
assert candidate(copy.deepcopy(encoded_str)) == str
| decode_shift |
EN/80 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | from collections import Counter
def most_frequent_katakana(text: str) -> str:
"""
A function that returns the most frequent katakana character in a string.
It ignores hiragana and kanji characters in the string and only counts katakana.
Arguments:
text (str): A string containing hiragana, katakana ... | katakana = [ch for ch in text if 'ใข' <= ch <= 'ใณ']
if not katakana:
return ""
counter = Counter(katakana)
most_frequent = counter.most_common(1)[0][0]
return most_frequent
| def check(candidate):
assert candidate("ใฒใใใช") == ""
assert candidate("ใซใฟใซใ") == "ใซ"
assert candidate("ๆผขๅญ") == ""
assert candidate("ใขใขใคใขใคใฆใขใคใฆใจใขใคใฆใจใช") == "ใข"
assert candidate("ใขใคใคใฆใฆใจใจใช") == "ใค"
assert candidate("ใฒใใใชใใซใฟใซใใๆผขๅญใๅซใ") == "ใซ"
assert candidate("ใใฉใฌใใค็ไปฎๅใคใซใณใธใฒใใฏใ ") == "ใค"
| most_frequent_katakana |
EN/81 | ๆฅๆฌ่ชๅฆ็ | ็ไปฎๅ | def determine_winner(names: list) -> str:
"""
In a game involving ไฝ่ค, ้ดๆจ, and ้ซๆฉ, calculate the score for each player from the given list of names,
and return the player with the highest score.
Calculation method for score:
- Total number of katakana + (total number of unique katakana * 10) - (... | katakana = "ใขใคใฆใจใชใซใญใฏใฑใณใตใทในใปใฝใฟใใใใใใใใใใใใใใใใใ ใกใขใคใฆใจใฉใชใซใฌใญใฏใฒใณ"
def calculate_score(name: str) -> int:
""" ๅๅใใๅพ็นใ่จ็ฎใใ """
count_katakana = sum(1 for char in name if char in katakana) # ็ไปฎๅใฎ็ทๆฐ
unique_katakana = len(set(char for char in name if char in katakana)) # ้่คใชใใฎ็ไปฎๅใฎ็ทๆฐ
... | def check(candidate):
assert candidate(['ใขใคใฆใจใช', 'ใขใขใขใขใขใข', 'ใใขใใคใฆใจใช']) == 'ไฝ่ค'
assert candidate(['ใขใขใฆใฆใชใช', 'ใขใคใฆใจใช', 'ใขใขใขใขใขใข']) == '้ดๆจ'
assert candidate(['ใขใคใฆใจใช', 'ใขใขใขใขใขใข', 'ใขใคใฆใจใชใขใคใฆใจใช']) == '้ซๆฉ'
| determine_winner |
EN/82 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def romaji_to_hiragana(romaji: str) -> str:
"""
Convert Hepburn-style romaji to hiragana.
argument:
romaji (str): Romaji to be converted (50 sounds only)
Return value:
str: String converted to hiragana
Execution example:
>>> romaji_to_hiragana("konnichiha")
'ใใใซใกใฏ'... | romaji_map = {
"a": "ใ", "i": "ใ", "u": "ใ", "e": "ใ", "o": "ใ",
"ka": "ใ", "ki": "ใ", "ku": "ใ", "ke": "ใ", "ko": "ใ",
"sa": "ใ", "shi": "ใ", "su": "ใ", "se": "ใ", "so": "ใ",
"ta": "ใ", "chi": "ใก", "tsu": "ใค", "te": "ใฆ", "to": "ใจ",
"na": "ใช", "ni": "ใซ", "nu": "ใฌ", "ne": "ใญ",... | def check(candidate):
assert candidate("aiueo") == "ใใใใใ"
assert candidate("akasatana") == "ใใใใใช"
assert candidate("hamayarawa") == "ใฏใพใใใ"
assert candidate("konnichiha") == "ใใใซใกใฏ"
assert candidate("sushi") == "ใใ"
assert candidate("satsumaimo") == "ใใคใพใใ"
| romaji_to_hiragana |
EN/83 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def extract_hiragana(text: str) -> str:
"""
A function that extracts and returns only hiragana from a string `text`.
argument:
text (str): input string
Return value:
str: String with only hiragana extracted
Example:
>>> extract_hiragana("ใใใซใกใฏใ")
'ใใใซใกใฏ'
>>> extract_hiragana("... | return ''.join(char for char in text if 'ใ' <= char <= 'ใ')
| def check(candidate):
assert candidate("") == ''
assert candidate("ใใใซใกใฏใ") == 'ใใใซใกใฏ'
assert candidate("ไปๆฅใฏใใๅคฉๆฐใงใใญใ") == 'ใฏใใใงใใญ'
assert candidate("ใใใซใกใฏใไปๆฅใฏใใๅคฉๆฐใงใใญใ") == 'ใใใซใกใฏใฏใใใงใใญ'
assert candidate("ใฒใใใชใซใฟใซใๆผขๅญ") == 'ใฒใใใช'
assert candidate("ใฒใใใชใHiraganaใhiragana") == 'ใฒใใใช'
| extract_hiragana |
EN/84 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | from typing import List
def all_prefixes(string: str) -> List[str]:
"""
Returns a list of all prefixes, from shortest to longest, for the string given as an argument.
However, it is assumed that all character strings are in hiragana.
example:
>>> all_prefixes('Aiu')
['A', 'Ai', 'Aiu']
"""... | result = []
for i in range(len(string)):
result.append(string[:i+1])
return result
| def check(candidate):
assert candidate('') == []
assert candidate('ใใใใใ') == ['ใ', 'ใใ', 'ใใใ', 'ใใใใ', 'ใใใใใ']
assert candidate('ใฒใใใช') == ['ใฒ', 'ใฒใ', 'ใฒใใ', 'ใฒใใใช']
| all_prefixes |
EN/85 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def sort_in_japanese_order(words: list) -> list:
"""
Sorts the input word list in alphabetical order.
argument:
words (list): word list to be sorted
Return value:
list: list of words sorted alphabetically
Execution example:
>>> sort_in_japanese_order(["ใใใ", "ใใใ", "ใใ"])
... | return sorted(words, key=lambda word: ''.join(chr(ord(c)) for c in word)) | def check(candidate):
assert candidate(["ใใใ", "ใใใ", "ใใ"]) == ["ใใใ", "ใใ", "ใใใ"]
assert candidate(["ใใฟ", "ใใ", "ใใ"]) == ["ใใ", "ใใฟ", "ใใ"]
assert candidate(["ใใใฒ", "ใใใ", "ใใ"]) == ["ใใ", "ใใใ", "ใใใฒ"]
assert candidate(["ใซใฟใซใ", "ใฒใใใช", "ใใใ"]) == ["ใใใ", "ใฒใใใช", "ใซใฟใซใ"]
assert candidate(["ใใ", ... | sort_in_japanese_order |
EN/86 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def sort_in_japanese_order(words: list) -> list:
"""
Sorts the input word list in alphabetical order.
argument:
words (list): word list to be sorted
Return value:
list: list of words sorted alphabetically
Execution example:
>>> sort_in_japanese_order(["ใใใ", "ใใใ", "ใใ"])
... | return sorted(words, key=lambda word: ''.join(chr(ord(c)) for c in word)) | def check(candidate):
assert candidate(["ใใใ", "ใใใ", "ใใ"]) == ["ใใใ", "ใใ", "ใใใ"]
assert candidate(["ใใฟ", "ใใ", "ใใ"]) == ["ใใ", "ใใฟ", "ใใ"]
assert candidate(["ใใใฒ", "ใใใ", "ใใ"]) == ["ใใ", "ใใใ", "ใใใฒ"]
assert candidate(["ใซใฟใซใ", "ใฒใใใช", "ใใใ"]) == ["ใใใ", "ใฒใใใช", "ใซใฟใซใ"]
assert candidate(["ใใ", ... | sort_in_japanese_order |
EN/87 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def can_create_henohenomoheji(text: str) -> bool:
"""
By rearranging the given string `text`, determine whether it is possible to create ``Henohenomoheji''.
Returns True if it can be created, False otherwise.
>>> can_create_heno_heno_moheji("ใธใฎใธใฎใใธใ")
True
>>> can_create_heno_heno_moheji("ใธใธใธใฎใฎ... | required_characters = {"ใธ": 3, "ใฎ": 2, "ใ": 1, "ใ": 1}
for char, count in required_characters.items():
if text.count(char) < count:
return False
return True
| def check(candidate):
assert candidate("ใธใฎใธใฎใใธใ") == True
assert candidate("ใธใธใธใฎใฎใใ") == True
assert candidate("ใธใฎใธใฎใธใฎใธ") == False
assert candidate("ใธใฎใธใธใใใฎ") == True
assert candidate("ใธใธใธใใใใ") == False
assert candidate("ใฏใฒใตใธใปใฎใป") == False
| can_create_henohenomoheji |
EN/88 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | from typing import List
def max_shiritori_chain(words: List[str]) -> int:
"""
Returns the chain number of how many times Shiritori lasts.
Rules:
- Match the last letter of the previous word with the first letter of the next word
- Ends if the same word appears or if the last letter of the ... | if not words:
return 0
chain_count = 0
seen_words = set()
for i in range(len(words)):
word = words[i]
if word in seen_words or word[-1] == "ใ":
break
seen_words.add(word)
if i > 0 and words[i - 1][-1] != word[0]:
break
chain_c... | def check(candidate):
assert candidate(["ใญใ", "ใใใค", "ใคใฟใ", "ใใคใญ", "ใญใใฟ"]) == 5
assert candidate(["ใใใ", "ใใพ", "ใพใ", "ใใฌ", "ใฌใใ", "ใใใดใค"]) == 3
assert candidate(["ใใใ", "ใใพ", "ใพใ", "ใใใ"]) == 3
assert candidate(["ใใใ", "ใใฃใฑ", "ใฑใ", "ใใพ", "ใพใคใ"]) == 2
assert candidate(["ใใใ", "ใใใใ", "ใใพ", "ใพใคใ"]) ==... | max_shiritori_chain |
EN/89 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def validate_aiueo_poem(prefix: str, poem: list) -> bool:
"""
A function that determines whether each line of an essay begins with the specified prefix character string.
Args:
prefix (str): The first character string of the AIUEO composition (any character string).
poem (list): A list of Aiueo essa... | if len(prefix) != len(poem):
return False
for i, line in enumerate(poem):
if not line.startswith(f"{prefix[i]}: {prefix[i]}"):
return False
return True
| def check(candidate):
# ๆญฃใใใใใใใไฝๆใฎใใงใใฏ
assert candidate("ใใใใใ", ["ใ: ใใ", "ใ: ใใฌ", "ใ: ใใฟ", "ใ: ใใณ", "ใ: ใใใ"]) == True
assert candidate("ใใใใใ", ["ใ: ใใใ", "ใ: ใใ", "ใ: ใใใ", "ใ: ใใฟ", "ใ: ใใ"]) == True
assert candidate("ใใกใคใฆใจ", ["ใ: ใใฌใ", "ใก: ใกใ", "ใค: ใคใ", "ใฆ: ใฆใใฟ", "ใจ: ใจใใ"]) == True
# ่ชคใฃใใใใใใ... | validate_aiueo_poem |
EN/90 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def is_valid_reverse_shiritori(words: list) -> bool:
"""
A function that determines whether a list of hiragana satisfies the reverse shiritori rules.
Gyaku-shiritori places the first letter of the previous word at the end of the next word.
argument:
words (list): list of hiragana words
Return ... | for i in range(1, len(words)):
if words[i-1][0] != words[i][-1]:
return False
return True
| def check(candidate):
assert candidate(["ใใใ", "ใกใ", "ใใใก", "ใใ"]) == True
assert candidate(["ใใใ", "ใใใ", "ใใ", "ใใ", "ใใ"]) == True
assert candidate(["ใใฃใฑ", "ใใ", "ใใ", "ใใใ"]) == True
assert candidate(["ใใใ", "ใใใ", "ใใฃใฑ", "ใฑใใ"]) == False
assert candidate(["ใใใ", "ใใฃใ", "ใใฉใ", "ใใ"]) == False
| is_valid_reverse_shiritori |
EN/91 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def hiragana_ascii_sum(s: str) -> int:
"""Takes a string of hiragana as an argument and returns the sum of the ASCII codes (Unicode code points) for hiragana characters only."""
| total_sum = 0
for char in s:
if 'ใ' <= char <= 'ใ':
total_sum += ord(char)
return total_sum
| def check(candidate):
assert candidate("ใใ") == 24710
assert candidate("ใใใใใ") == 61885
assert candidate("ใใใใใช") == 61867
assert candidate("ใabcใ") == 24710
assert candidate("12345ใใ") == 24710
assert candidate("ใใใ") == 37300
| hiragana_ascii_sum |
EN/92 | ๆฅๆฌ่ชๅฆ็ | ๅนณไปฎๅ | def extract_repeated_words(words: list) -> list:
"""
A function that extracts only words in which the same string is repeated twice from a list of strings.
Args:
words (list): list of strings
Returns:
list: list containing only words that are repeated twice
example:
>>> extract_repeat... | result = [word for word in words if len(word) % 2 == 0 and word[:len(word)//2] == word[len(word)//2:]]
return result
| def check(candidate):
assert candidate(['ใใใใ', 'ใใณใใณ', 'ใใใใ', 'ใใใใ', 'ใฉใใฉใ', 'ใฒใใฒใ', 'ใญใใญใ']) == ['ใใใใ', 'ใใณใใณ', 'ใใใใ', 'ใฉใใฉใ', 'ใฒใใฒใ', 'ใญใใญใ']
assert candidate(['ใใใใ', 'ใใใใ', 'ใใใใ', 'ใใใใ']) == ['ใใใใ']
assert candidate(['ใใใใ', 'ใใใใ', 'ใใใใ', 'ใใใใ', 'ใใใใ']) == ['ใใใใ', 'ใใใใ', 'ใใใใ', 'ใใใใ']
... | extract_repeated_words |
EN/93 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def hiragana_to_katakana(name: str) -> str:
"""
Converts the name entered in hiragana to katakana.
argument:
name (str): Full name entered in hiragana
Return value:
str: Full name converted to katakana
Usage example:
>>> hiragana_to_katakana('ใใชใ ใใใ')
'ใฟใใซ ใฟใญใฆ'
>>> hi... | hiragana = (
"ใใใใใ
ใใใใใใใใใใใใใใใใใใใใใใใใใ"
"ใใ ใกใขใคใฅใฆใงใจใฉใชใซใฌใญใฎใฏใฐใฑใฒใณใดใตใถใทใธในใบใปใผใฝ"
"ใพใฟใใใใใใ
ใใใใใใใใใใใใใใใ"
)
katakana = (
"ใกใขใฃใคใฅใฆใงใจใฉใชใซใฌใญใฎใฏใฐใฑใฒใณใดใตใถใทใธในใบใปใผใฝใพ"
"ใฟใใใใใ
ใใใใใใใใใใใใใใใใใใใใใใใใ"
"ใใใ ใกใขใฃใคใฅใฆใงใจใฉใชใซใฌใญใฎใฏใฐใฑใฒใณใด"
)
# ใฒใใใชใใซใฟใซใใซๅคๆ
return name.tr... | def check(candidate):
# ๅบๆฌ็ใชไฝฟ็จไพ
assert candidate('ใใชใ ใใใ') == 'ใฟใใซ ใฟใญใฆ'
assert candidate('ใใจใ ใใใ') == 'ใตใใฆ ใธใญใฆ'
assert candidate('ใใพใ ใฏใชใ') == 'ใคใใ ใใใณ'
# ๆงใ
ใชใฒใใใชๆๅญๅ
assert candidate('ใใใ ใฟใใ') == 'ใญใ ใฉ ใใตใญ'
assert candidate('ใใฐใใ ใพใใฒใ') == 'ใณใใคใท ใใตใใญ'
assert candidate('ใฏใใใจ ใใใจ') == '... | hiragana_to_katakana |
EN/94 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def classify_japanese_characters(text: str) -> dict:
"""
Classifies the input string into kanji, hiragana, katakana, and other characters and returns the number of each character.
argument:
text (str): string to process
Return value:
dict: Classification results for each character type... | result = {'ๆผขๅญ': 0, 'ใฒใใใช': 0, 'ใซใฟใซใ': 0, 'ใใฎไป': 0}
for char in text:
if '\u4e00' <= char <= '\u9fff':
result['ๆผขๅญ'] += 1
elif '\u3040' <= char <= '\u309f':
result['ใฒใใใช'] += 1
elif '\u30a0' <= char <= '\u30ff':
result['ใซใฟใซใ'] += 1
else:
... | def check(candidate):
assert candidate("ไปๆฅใฏๆดใใงใใ") == {'ๆผขๅญ': 3, 'ใฒใใใช': 4, 'ใซใฟใซใ': 0, 'ใใฎไป': 1}
assert candidate("ใใใใใใขใคใฆใจใช") == {'ๆผขๅญ': 0, 'ใฒใใใช': 5, 'ใซใฟใซใ': 5, 'ใใฎไป': 0}
assert candidate("ไฝ่ฒใฎๆๆฅญใงใฏใตใใซใผใใใใพใใไปๆฅใๅ
ๆฐไธๆฏใซ้ ๅผตใใพใใใใ") == {'ๆผขๅญ': 12, 'ใฒใใใช': 15, 'ใซใฟใซใ': 4, 'ใใฎไป': 2}
assert candidate("ABC123!@#ๆผขๅญใฒใ... | classify_japanese_characters |
EN/95 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def sort_japanese_characters(text: str) -> str:
"""
A function that receives a string, sorts and combines hiragana, katakana, kanji, and alphabets.
argument:
text (str): input string
Return value:
str: string of characters arranged in hiragana, katakana, kanji, alphabetical order
Usage ex... | hiragana = sorted([char for char in text if 'ใ' <= char <= 'ใ'])
katakana = sorted([char for char in text if 'ใก' <= char <= 'ใถ'])
kanji = sorted([char for char in text if 'ไธ' <= char <= '้พฏ'])
alphabet = sorted([char for char in text if 'A' <= char <= 'Z' or 'a' <= char <= 'z'])
return ''.join(hiraga... | def check(candidate):
assert candidate("ใฒใใใช") == "ใใชใฒใ"
assert candidate("ใซใฟใซใ") == "ใซใซใฟใ"
assert candidate("ๆผขๅญ") == "ๅญๆผข"
assert candidate("Alphabet") == "Aabehlpt"
assert candidate("ใฒใใใชใซใฟใซใๆผขๅญAlphabet") == "ใใชใฒใใซใซใฟใๅญๆผขAabehlpt"
| sort_japanese_characters |
EN/96 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def solve(s):
"""
A string s is given.
If s[i] is hiragana or katakana, convert that character (hiragana to katakana, katakana to hiragana).
If it contains other characters, leave it as is.
If the string does not contain any hiragana or katakana characters, reverse the entire string.
The functio... | flg = 0
idx = 0
new_str = list(s)
for i in s:
if 'ใ' <= i <= 'ใ': # ใฒใใใชใใซใฟใซใใซๅคๆ
new_str[idx] = chr(ord(i) - ord('ใ') + ord('ใก'))
flg = 1
elif 'ใก' <= i <= 'ใณ': # ใซใฟใซใใใฒใใใชใซๅคๆ
new_str[idx] = chr(ord(i) - ord('ใก') + ord('ใ'))
flg = 1
... | def check(candidate):
# ็ฐกๅใชใฑใผในใใใงใใฏ
assert candidate("ใใ") == "ใขใค"
assert candidate("1234") == "4321"
assert candidate("ใขใซ") == "ใใ"
assert candidate("#ใ@ใค") == "#ใข@ใ"
assert candidate("#ใใใฆใจ^45") == "#ใขใคใใ^45"
assert candidate("#6@2") == "2@6#"
# ๅข็ใฑใผในใใใงใใฏ
assert candidate("#$ใ^ใซ... | solve |
EN/97 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def count_sentences(text: str) -> int:
"""
A function that counts how many Japanese sentences there are.
Sentences are defined to be separated by one of "ใ", "๏ผ", or "๏ผ".
argument:
text (str): input Japanese text
Return value:
int: number of sentences
Usage example:
>>> count_sent... | if not text:
return 0
sentences = [sentence for sentence in text.split('ใ') if sentence] # ใใใใงๅๅฒ
temp_sentences = []
for sentence in sentences:
temp_sentences.extend([s for s in sentence.split('๏ผ') if s]) # ใ๏ผใใงใใใซๅๅฒ
final_sentences = []
for sentence in temp_sentences:
... | def check(candidate):
assert candidate("") == 0
assert candidate("ใใฏใใใใใใพใใ") == 1
assert candidate("ไปๆฅใฏใใๅคฉๆฐใงใใญใๆๆฅใๆดใใใจใใใงใใญ๏ผ") == 2
assert candidate("ใใฏใใ๏ผไปๆฅใฏไฝใใๅงใใใใ๏ผ") == 2
assert candidate("ใใฏใใใใใใพใใไปๆฅใฏใใๅคฉๆฐใงใใญ๏ผๆๆฅใฎๅคฉๆฐใฏใใใใงใใใใ๏ผ") == 3
| count_sentences |
EN/98 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def count_onsen_symbols(text: str) -> int:
"""
Counts and returns the number of hot spring symbols "โจ๏ธ" from the input string.
Args:
text (str): input string
Returns:
int: Number of hot spring symbols โโจ๏ธโ
"""
| return text.count('โจ๏ธ')
| def check(candidate):
assert candidate("โจ๏ธ") == 1
assert candidate("โจ๏ธโจ๏ธโจ๏ธโจ๏ธโจ๏ธ") == 5
assert candidate("โจ๏ธใโจ๏ธใโจ๏ธใโจ๏ธใโจ๏ธใโจ๏ธ") == 6
assert candidate("โจ๏ธๆธฉๆณใซๅ
ฅใใพใใใโจ๏ธ") == 2
| count_onsen_symbols |
EN/99 | ๆฅๆฌ่ชๅฆ็ | ๆททๅ | def check_katakana_hiragana_match(katakana: str, hiragana: str) -> bool:
"""
A function that checks whether katakana and hiragana match.
Arguments:
katakana (str): katakana string
hiragana (str): hiragana string
Return value:
bool: True if katakana and hiragana match, False otherwi... | def katakana_to_hiragana(katakana: str) -> str:
katakana_map = {
'ใข': 'ใ', 'ใค': 'ใ', 'ใฆ': 'ใ', 'ใจ': 'ใ', 'ใช': 'ใ',
'ใซ': 'ใ', 'ใญ': 'ใ', 'ใฏ': 'ใ', 'ใฑ': 'ใ', 'ใณ': 'ใ',
'ใต': 'ใ', 'ใท': 'ใ', 'ใน': 'ใ', 'ใป': 'ใ', 'ใฝ': 'ใ',
'ใฟ': 'ใ', 'ใ': 'ใก', 'ใ': 'ใค', 'ใ': 'ใฆ', 'ใ': ... | def check(candidate):
assert candidate("ใฟใใซ", "ใใชใ") == True
assert candidate("ในใบใญ", "ใใใ") == True
assert candidate("ใซใใ", "ใใฃใฑ") == True
assert candidate("ใฟใซใใท", "ใใใฏใ") == True
assert candidate("ใฟใใซ", "ใชใใ") == False
assert candidate("ใตใใฆ", "ใใใ") == False
assert candidate("ใฌใใณใฆ", "ใใฃใฑ") ... | check_katakana_hiragana_match |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.