Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Aug 9, 2024
1 parent 428b0d3 commit a7e1093
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/htoo.py
Original file line number Diff line number Diff line change
@@ -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()))
28 changes: 28 additions & 0 deletions src/lessvsfewer.py
Original file line number Diff line number Diff line change
@@ -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!")
7 changes: 7 additions & 0 deletions src/velkomin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>

int main()
{
std::cout << "VELKOMIN!";
return 0;
}
7 changes: 7 additions & 0 deletions src/velkomin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("VELKOMIN!")
}
1 change: 1 addition & 0 deletions src/velkomin.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("VELKOMIN!")

0 comments on commit a7e1093

Please sign in to comment.