DWITE '09 R5 #1 - ASCII bar graphs

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE Online Computer Programming Contest, March 2010, Problem 1

The input will contain 5 lines, integers -5 \leq N \leq 5.

The output will plot the numbers as a graph. Each whole number gets an asterisk *; negative on the left of the central line drawn with pipes |, positive on the right. 0 does not get drawn. Empty spaces are filled with the minus sign - for alignment. See the sample graph for an example.

Sample Input

-5
-4
0
1
3

Sample Output

*****|-----
-****|-----
-----|-----
-----|*----
-----|***--

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments

There are no comments at the moment.