Search Results

Search found 5 results on 1 pages for 'zerodivisible'.

Page 1/1 | 1 

  • The Skyline Problem.

    - by zeroDivisible
    I just came across this little problem on UVA's Online Judge and thought, that it may be a good candidate for a little code-golf. The problem: You are to design a program to assist an architect in drawing the skyline of a city given the locations of the buildings in the city. To make the problem tractable, all buildings are rectangular in shape and they share a common bottom (the city they are built in is very flat). The city is also viewed as two-dimensional. A building is specified by an ordered triple (Li, Hi, Ri) where Li and Ri are left and right coordinates, respectively, of building i and Hi is the height of the building. In the diagram below buildings are shown on the left with triples (1,11,5), (2,6,7), (3,13,9), (12,7,16), (14,3,25), (19,18,22), (23,13,29), (24,4,28) and the skyline, shown on the right, is represented by the sequence: 1, 11, 3, 13, 9, 0, 12, 7, 16, 3, 19, 18, 22, 3, 23, 13, 29, 0 The output should consist of the vector that describes the skyline as shown in the example above. In the skyline vector (v1, v2, v3, ... vn) , the vi such that i is an even number represent a horizontal line (height). The vi such that i is an odd number represent a vertical line (x-coordinate). The skyline vector should represent the "path" taken, for example, by a bug starting at the minimum x-coordinate and traveling horizontally and vertically over all the lines that define the skyline. Thus the last entry in the skyline vector will be a 0. The coordinates must be separated by a blank space. If I will not count declaration of provided (test) buildings and including all spaces and tab characters, my solution, in Python, is 223 characters long. Here is the condensed version: B=[[1,11,5],[2,6,7],[3,13,9],[12,7,16],[14,3,25],[19,18,22],[23,13,29],[24,4,28]] # Solution. R=range v=[0 for e in R(max([y[2] for y in B])+1)] for b in B: for x in R(b[0], b[2]): if b[1]>v[x]: v[x]=b[1] p=1 k=0 for x in R(len(v)): V=v[x] if p and V==0: continue elif V!=k: p=0 print "%s %s" % (str(x), str(V)), k=V I think that I didn't made any mistake but if so - feel free to criticize me. EDIT I don't have much reputation, so I will pay only 100 for a bounty - I am curious, if anyone could try to solve this in less than .. lets say, 80 characters. Solution posted by cobbal is 101 characters long and currently it is the best one. ANOTHER EDIT I thought, that 80 characters is a sick limit for this kind of problem. cobbal, with his 46 character solution totaly amazed me - though I must admit, that I spent some time reading his explanation before I partially understood what he had written.

    Read the article

  • [Flex 4] Removing sort arrows from AdvancedDataGridColumn Header.

    - by zeroDivisible
    Hello, I am doing this simple project using Flex 4 SDK and I got stuck with this simple problem: I have turned sortable property for AdvancedDataGridColumn to false, but the column header is still rendered as: As You can see, my label for this header is "06", but the column header is divided and it keeps the place for sort arrow. How can I change this? I would like my column header to contain only my label. I know that most probably I need to do some magic with AdvancedDataGridHeaderRenderer but I just started learning Flex and would like to receive some help. Thank You for help. Best regards, Mike.

    Read the article

  • Are there any examples/tutorials of using Spring 3.0 with Cassandra as a backend?

    - by zeroDivisible
    Hello, As I had written in title, I am trying to learn Spring 3.0 (I already know Django, Pylons and few simpler MVC frameworks) and try to use Cassandra as a backend for my web application. Are there any real world examples of doing this? Or maybe some tutorials? I know about the existence of documentation of both technologies, yet I am looking for something "faster" to read and get me rolling.

    Read the article

  • Using scanf() in C++ programs is faster than using cin ?

    - by zeroDivisible
    Hello, I don't know if this is true, but when I was reading FAQ on one of the problem providing sites, I found something, that poke my attention: Check your input/output methods. In C++, using cin and cout is too slow. Use these, and you will guarantee not being able to solve any problem with a decent amount of input or output. Use printf and scanf instead. Can someone please clarify this? Is really using scanf() in C++ programs faster than using cin something ? If yes, that is it a good practice to use it in C++ programs? I thought that it was C specific, though I am just learning C++...

    Read the article

  • [org-mode]: repeating task in every Mon, Wed, Fri at 18:00, need help with sexp.

    - by zeroDivisible
    Hello, As I had written in title, I need a little help with improvement of this sexp: * TODO remeber about thingie. SCHEDULED: <%%(or (= 1 (calendar-day-of-week date)) (= 3 (calendar-day-of-week date)) (= 5 (calendar-day-of-week date)))> Now it shows itself in the following days, but I would like to change two things about it: How can I also schedule on specific hours (i.e. 18:00 - 20:00) in the following days How can I made this task repeat itself, just like it repeats itself with <2010-05-13 Wed +1w> (by repetition I mean something like it automatically logs the closing date and time and comes back to the TODO state). I will be grateful for any help. Best regards, Mike.

    Read the article

1