Simple ASCII Gantt
Python 2, 39 Bytes
Straightforward solution using string multiplication :)
for x,y in input():print' '*x+'-'*(y-x)
Accepts input formatted like so:
((5,20),(5,20),(2,10),(15,19))
Check it out here.
CJam, 16 14 bytes
q~{S.*~'-e]N}/
This expects a list of lists as input. For example:
[[5 20] [5 20] [2 10] [5 19]]
gives:
---------------
---------------
--------
--------------
How it works
q~ e# Read the input and parse it as a list of list
{ }/ e# Go over each item in the list in a for loop
S e# S is basically this string - " "
.* e# Multiply each item of the first list with the corresponding index
e# item of the second list. This basically repeats the space
e# X times where X is the first number of the tuple. The second
e# number remains untouched as the second list was only 1 char long
~ e# Unwrap the space string and second number containing list
'- e# Put character '-' on stack
e] e# Make sure that the space is filled with - to its right so as to
e# make the total length of the string equal to the second number
N e# Put a newline. After all iterations, the result is printed
e# automatically to STDOUT
Try it online here
Brainfuck, 120 115 111 bytes
At least it's shorter than Java :) The input is a list of bytes, where each pair is a single line in the gantt.
++++[->++++++++<]>[->+>+<<]++++++++++>>+++++++++++++>+[,[->+>+<<]>>[-<<+>>],<[->-<<<<.>>>]>[-<<<.>>>]<<<<<.>>>]
Try out
http://copy.sh/brainfuck/
Set end-of-input to char with value \0
. Example input: \5\20\5\20\2\10\15\19
.
Note that setting the end-of-input value to \0
will have the side effect that no more input will be read (and thus stopping the program) when the input contains the number zero. In BF there is no other way of knowing when the input is exhausted.
Explanation*
++++[->++++++++<]> #Store <space> at index 1
[->+>+<<] #Move index 1 to index 2 and 3
++++++++++ #Increment index 1 to <newline>
>> #Move to index 3
+++++++++++++ #Increment index 3 to <dash>
> #Move to (empty) index 4
+ #Increment to start the main loop
[ #Main loop
, #Read first number to index 4
[->+>+<<]>>[-<<+>>] #Copy index 4 to index 5 (index 5 can now be altered)
, #Read second number (the number pair is now stored at index 5 and 6)
< #Move to first number (index 5)
[->-<<<<.>>>] #Decrement index 5 and 6 and print <space> until index 5 equals zero
> #move to second input (index 6)
[-<<<.>>>] #Decrement index 6 and print <dash> until index 6 equals zero
<<<<<.>>> #Print <newline> and move to index 4 (original first number)
] #End of main loop
*(You won't be able to compile/run this due to the comments)