diff --git a/01-monolithic/README.md b/01-monolith/README.md similarity index 63% rename from 01-monolithic/README.md rename to 01-monolith/README.md index de26f9d..eafb983 100644 --- a/01-monolithic/README.md +++ b/01-monolith/README.md @@ -1,11 +1,12 @@ -Style #1 Monolithic +Style #1 ============================== Constraints: - No abstractions -Alternative names of this style: +Possible names: +- Monolith - Labyrinth - Brain dump diff --git a/01-monolithic/tf-01.py b/01-monolith/tf-01.py similarity index 100% rename from 01-monolithic/tf-01.py rename to 01-monolith/tf-01.py diff --git a/02-code-golf/README.md b/02-code-golf/README.md new file mode 100644 index 0000000..48ff775 --- /dev/null +++ b/02-code-golf/README.md @@ -0,0 +1,11 @@ +Style #2 +============================== + +Constraints: + +- As few lines of code as possible + +Possible names: + +- Code golf +- Try hard \ No newline at end of file diff --git a/02-code-golf/tf-02.py b/02-code-golf/tf-02.py new file mode 100644 index 0000000..2151d19 --- /dev/null +++ b/02-code-golf/tf-02.py @@ -0,0 +1,7 @@ +import re, string, sys + +stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase)) +words = [x.lower() for x in re.split("[^a-zA-Z]+", open(sys.argv[1]).read()) if len(x) > 0 and x.lower() not in stops] +unique_words = list(set(words)) +unique_words.sort(lambda x, y: cmp(words.count(y), words.count(x))) +print "\n".join(["%s - %s" % (x, words.count(x)) for x in unique_words[:25]])