From a7e10937a61dd419b46b8b91c36650d3d7be7f3a Mon Sep 17 00:00:00 2001 From: Zeheng Li Date: Fri, 9 Aug 2024 01:59:09 -0600 Subject: [PATCH] add examples --- src/htoo.py | 37 +++++++++++++++++++++++++++++++++++++ src/lessvsfewer.py | 28 ++++++++++++++++++++++++++++ src/velkomin.cpp | 7 +++++++ src/velkomin.go | 7 +++++++ src/velkomin.jl | 1 + 5 files changed, 80 insertions(+) create mode 100644 src/htoo.py create mode 100644 src/lessvsfewer.py create mode 100644 src/velkomin.cpp create mode 100644 src/velkomin.go create mode 100644 src/velkomin.jl diff --git a/src/htoo.py b/src/htoo.py new file mode 100644 index 0000000..9881ac4 --- /dev/null +++ b/src/htoo.py @@ -0,0 +1,37 @@ +import re +from collections import Counter + + +def f(chemical, k=1): + res = Counter() + regex = re.compile(r"(\d+|\w)") + prev = "" + + for c in regex.split(chemical): + if c.isalpha(): + res[c] += 1 + elif c.isdigit(): + res[prev] += int(c) - 1 + else: + continue + prev = c + for v in res: + res[v] *= k + return res + + +s, k = input().split() +t = input() + +a = f(s, int(k)) +b = f(t) + +made = True +for v in b: + if v not in a: + made = False + break + else: + b[v] = a[v] // b[v] + +print(0 if not made else min(b.values())) diff --git a/src/lessvsfewer.py b/src/lessvsfewer.py new file mode 100644 index 0000000..4b7c5a9 --- /dev/null +++ b/src/lessvsfewer.py @@ -0,0 +1,28 @@ +n, p = [int(d) for d in input().split()] +nouns = dict(tuple(input().split()) for _ in range(n)) +phrases = [] +for _ in range(p): + row = input().split() + row[-1] = nouns[row[-1]] + phrases.append(" ".join(row)) +rules = ( + "number of c", + "amount of m", + "most c", + "most m", + "fewest c", + "least m", + "more c", + "more m", + "fewer c", + "less m", + "many c", + "much m", + "few c", + "little m", +) +for row in phrases: + if row in rules: + print("Correct!") + else: + print("Not on my watch!") diff --git a/src/velkomin.cpp b/src/velkomin.cpp new file mode 100644 index 0000000..9741887 --- /dev/null +++ b/src/velkomin.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "VELKOMIN!"; + return 0; +} diff --git a/src/velkomin.go b/src/velkomin.go new file mode 100644 index 0000000..3a2054a --- /dev/null +++ b/src/velkomin.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("VELKOMIN!") +} diff --git a/src/velkomin.jl b/src/velkomin.jl new file mode 100644 index 0000000..e146483 --- /dev/null +++ b/src/velkomin.jl @@ -0,0 +1 @@ +print("VELKOMIN!")