about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--daily/302easy/README.md2
-rw-r--r--daily/302intermediate/README.md52
-rwxr-xr-xdaily/302intermediate/barchart.py22
-rw-r--r--[-rwxr-xr-x]others/mkcal/ctmt.pas0
-rw-r--r--[-rwxr-xr-x]others/mkcal/llgc2m.pas0
-rw-r--r--[-rwxr-xr-x]others/mkcal/xepviec.pas0
-rw-r--r--others/volume1/fibonacci.pas103
7 files changed, 75 insertions, 104 deletions
diff --git a/daily/302easy/README.md b/daily/302easy/README.md
index 6c0adf4..fed8511 100644
--- a/daily/302easy/README.md
+++ b/daily/302easy/README.md
@@ -151,5 +151,5 @@ capitalization from the above table. Example:
 
 ## Bonus
 
-Note that *bacon* has a few different possibilities. Which is the heaviest by
+Note that `bacon` has a few different possibilities. Which is the heaviest by
 atomic weight?
diff --git a/daily/302intermediate/README.md b/daily/302intermediate/README.md
new file mode 100644
index 0000000..84ae459
--- /dev/null
+++ b/daily/302intermediate/README.md
@@ -0,0 +1,52 @@
+# [[2017-02-08] Challenge #302 [Intermediate] ASCII Histogram Maker: Part 1 - The Simple Bar Chart](https://www.reddit.com/r/dailyprogrammer/comments/5st2so/20170208_challenge_302_intermediate_ascii/)
+
+## Description
+
+Any Excel user is probably familiar with the bar chart - a simple plot showing
+vertical bars to represent the frequency of something you counted. For today's
+challenge you'll be producing bar charts in ASCII. 
+
+(Part 2 will have you assemble a proper histogram from a collection of data.)
+
+## Input Description
+
+You'll be given four numbers on the first line telling you the start and end of
+the horizontal (X) axis and the vertical (Y) axis, respectively. Then you'll
+have a number on a single line telling you how many records to read. Then
+you'll be given the data as three numbers: the first two represent the interval
+as a start (inclusive) and end (exclusive), the third number is the frequency
+of that variable. Example:
+
+    140 190 1 8 
+    5
+    140 150 1
+    150 160 0 
+    160 170 7 
+    170 180 6 
+    180 190 2 
+
+## Output Description
+
+Your program should emit an ASCII bar chart showing the frequencies of the
+buckets. Your program may use any character to represent the data point, I show
+an asterisk below. From the above example:
+
+    8
+    7           *
+    6           *   *
+    5           *   *
+    4           *   *
+    3           *   *
+    2           *   *   *
+    1   *       *   *   * 
+     140 150 160 170 180 190
+
+## Challenge Input
+
+    0 50 1 10
+    5
+    0 10 1
+    10 20 3
+    20 30 6
+    30 40 4
+    40 50 2
diff --git a/daily/302intermediate/barchart.py b/daily/302intermediate/barchart.py
new file mode 100755
index 0000000..e699fcd
--- /dev/null
+++ b/daily/302intermediate/barchart.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+from math import gcd
+
+minx, maxx, miny, maxy = map(int, input().split())
+n, step, z, s, d = int(input()), maxy - miny, len(str(maxy)), {minx, maxx}, {}
+for i in range(n):
+    start, end, freq = map(int, input().split())
+    step = gcd(step, freq - miny)
+    s.update({start, end})
+    d[start] = freq
+points = sorted(s)
+spaces = [' ' * len(str(i)) for i in points]
+for i in points:
+    d.setdefault(i, 0)
+while maxy >= miny:
+    print(str(maxy).rjust(z), end='')
+    for i, point in enumerate(points[:-1]):
+        print(spaces[i], '*' if d[point] >= maxy else ' ', sep='', end='')
+    print(spaces[-1])
+    maxy -= step
+print(' ' * z, ' '.join(str(i) for i in points), sep='')
diff --git a/others/mkcal/ctmt.pas b/others/mkcal/ctmt.pas
index bdd30f0..bdd30f0 100755..100644
--- a/others/mkcal/ctmt.pas
+++ b/others/mkcal/ctmt.pas
diff --git a/others/mkcal/llgc2m.pas b/others/mkcal/llgc2m.pas
index 3fc8ef2..3fc8ef2 100755..100644
--- a/others/mkcal/llgc2m.pas
+++ b/others/mkcal/llgc2m.pas
diff --git a/others/mkcal/xepviec.pas b/others/mkcal/xepviec.pas
index cfa39d6..cfa39d6 100755..100644
--- a/others/mkcal/xepviec.pas
+++ b/others/mkcal/xepviec.pas
diff --git a/others/volume1/fibonacci.pas b/others/volume1/fibonacci.pas
deleted file mode 100644
index c1bb423..0000000
--- a/others/volume1/fibonacci.pas
+++ /dev/null
@@ -1,103 +0,0 @@
-unit fibonacci;
-
-interface
-  const
-    fibonacci93: array[1..93] of qword = (
-      1,
-      1,
-      2,
-      3,
-      5,
-      8,
-      13,
-      21,
-      34,
-      55,
-      89,
-      144,
-      233,
-      377,
-      610,
-      987,
-      1597,
-      2584,
-      4181,
-      6765,
-      10946,
-      17711,
-      28657,
-      46368,
-      75025,
-      121393,
-      196418,
-      317811,
-      514229,
-      832040,
-      1346269,
-      2178309,
-      3524578,
-      5702887,
-      9227465,
-      14930352,
-      24157817,
-      39088169,
-      63245986,
-      102334155,
-      165580141,
-      267914296,
-      433494437,
-      701408733,
-      1134903170,
-      1836311903,
-      2971215073,
-      4807526976,
-      7778742049,
-      12586269025,
-      20365011074,
-      32951280099,
-      53316291173,
-      86267571272,
-      139583862445,
-      225851433717,
-      365435296162,
-      591286729879,
-      956722026041,
-      1548008755920,
-      2504730781961,
-      4052739537881,
-      6557470319842,
-      10610209857723,
-      17167680177565,
-      27777890035288,
-      44945570212853,
-      72723460248141,
-      117669030460994,
-      190392490709135,
-      308061521170129,
-      498454011879264,
-      806515533049393,
-      1304969544928657,
-      2111485077978050,
-      3416454622906707,
-      5527939700884757,
-      8944394323791464,
-      14472334024676221,
-      23416728348467685,
-      37889062373143906,
-      61305790721611591,
-      99194853094755497,
-      160500643816367088,
-      259695496911122585,
-      420196140727489673,
-      679891637638612258,
-      1100087778366101931,
-      1779979416004714189,
-      2880067194370816120,
-      4660046610375530309,
-      7540113804746346429,
-      12200160415121876738
-    );
-
-implementation
-
-end.