instruction
stringlengths
71
71.9k
The problem is the following: We have a number of months to buy a number of supplies. The sooner we finish buying them, the better, but we don't know how much we can buy per month and would like to calculate all possible scenarios. Suppose months = 5 and supplies = 9, and (72000) means 7 in the first month, 2 in the se...
Given a binary tree, return the next right node. This question is attributed to GeeksForGeeks. For example, consider the following Binary Tree. Output for 2 is 6, output for 4 is 5. Output for 10, 6 and 5 is NULL. 10 / \ 2 6 / \ \ 8 4 ...
I have recently answered one question on Stack Overflow. Problem statement: Input sequence: PEACCEL User mutation input file: E2R C4W E6G The algorithm is for an input sequence of, say, PEACCEL and mutation E2R. We need to replace second character in sequence, that is, E to R, and so on for the combinations of ...
I am new to Java's Swing and built a test client that connects to a server. I was wondering if my use of a Controller class as a link between the classes ClientWindow and WebsocketService made sense and would be thankful for comments. (I can take it, so the more my code is criticized the happier I am.) For the sake of...
I am attempting this problem at Codeforces. I'm stuck as it gives a time limit exceeded error for large inputs though the logic I followed is similar to that of the editorial. I'd be grateful for any pointers that can be useful in improving my logic and/or code performance. import sys count = 0 def count_and_split(p)...
In the code below, I have a dictionary of attributes and values. I am checking to see if the value if an attribute is True, and if so adding the attribute to a list for later processing (it becomes part of a SQL group by). This code works fine, but I was wondering how it could be more "Pythonic". Note that the col_map ...
One of the tenets of Windsor IoC (probably applies to all IoC containers too) is to "release what you explicitly resolve", which admittedly should occur rarely. But we have a fair few UsingFactoryMethod setups in our installers, which are resolving directly (which appears to be a valid case for explicit resolution). H...
I have created a class that gets data from an ODBC connection. The code works but it is really slow - I'm talking up to 1.20ish minutes to run. I know my code is inefficient but I'm really not sure why it's so slow. Tips or advice on speeding it up would be much appreciated. <?php class machine { public $name = "...
Inspired a bit by a previous Brainfuck question and the recent fizzbuzz invasion, I decided to make FizzBuzz in Brainfuck. The code is entirely my own, except for the inclusion of the Printing a number algorithm that I found on StackOverflow. My code is divided into several parts. Setup Construct the tape to contain s...
I have the following piece of code and I would like to see what different approaches would be to solve that in a more elegant way. The thing is that I don't know whether is better to have the null checks or the try/catch block there or maybe the code below should not happen in the first place. Maybe one can give anot...
What do you think is wrong with this code, and how can it be improved? What corner case have I overlooked, if any? Note: I do not want to use any STL features here, but I'm okay with anything else from C++11. class min_heap{ int pvt,P; int arr[10000]; public: min_heap(){ P=1; } void add(in...
I recently suggested this method for emulating the Unix utility split in Python. Is there a more elegant way of doing it? Assume that the file chunks are too large to be held in memory. Assume that only one line can be held in memory. import contextlib def modulo(i,l): return i%l def writeline(fd_out, line): ...
I'm having a dip into F# and am attempting not to write it like it's C#. One area that bothers me is using members of System.String. These often need to be chained together, but the only way to do so that I've seen so far is pretty much the same as C#. For example, I've written a function to generate the pretty bit at ...
I have been Googling for a few days and am trying to find the best practices when it comes to using the Repository pattern. But what I found that there are no standards and everyone claims that their approach is the best approach. However, I have come up with this design based on what I have read online. It it good p...
Is there a better way to time the functions and print the result and function name dynamically? package project_euler object Timers extends App{ def time[R](f: => R): Unit = { val t0 = System.nanoTime() val r = f val t1 = System.nanoTime() val t = (t1-t0)/1000 println(s"The re...
Right now, I have base abstract GenericDAO class to execute CRUD operations with different kind of objects. I have Customer and Employee POJO classes which are used in specific DAO classes that extends GenericDAO class. Questions: How correct is the current base GenericDao implementation and SpecificDAO classes which...
I'm looking for some input here. I have a class that contains a value which is updated every few seconds by a method within that class. Right now, access to this value across multiple threads is done via synchronization, which I would like to eliminate. Would this make sense? class DataSegment { private Metrics...
The program asks the user to input 10 integers, and then prints the largest odd number that was entered. If no odd number was entered, it prints a message to that effect. q = int(raw_input("Please enter an integer:")) r = int(raw_input("Please enter another integer:")) s = int(raw_input("Please enter another integer:")...
I was skimming through this paper out of boredom. On pages 5 and 6, the paper shows a simple encryption/decryption scheme that Citadel uses to obfuscate data. The algorithm basically XORs the next character with the previous character. The code is roughly this (ugly, I know): void VisualEncrypt (void *buffer, unsigned...
This is a tiny learning program that lead to an interesting question: how can I best/most elegantly handle user entered numbers? This method works, fails cleanly, and reads well. It doesn't apply to types other than build in ones (as far as I know), but for floats and integers it's a nice feature. But it doesn't scale ...
I wrote a small component (still in the works but working) which takes a large SQL script file, splits it into different "blocks" based on GO statements, and executes them one by one. The only major flaw I know of is not being able to detect when a GO statement is inside of a comment block, for example... /* GO */ ......
Practicing Prototypal Code I'm focusing on practicing a very prototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where applicable in future projects. With this in mind, I don't have experience with prototypal programming before now, and wo...
I am trying to parse HTML using "jsoup". This is my first time working with "jsoup" and I read some tutorials on it as well. If you see my table, it has three <tr> as of now (I have shortened it down to have three table rows just for understanding purpose, but in general it will be more). Now I would like to extract Cl...
I've been trying to figure out the best way to create a inventory system in Python. I like the way this one works but what I was wondering was if there was a better way to write it. inv = ['Sword','Armor'] item_values = {'Sword':['Sword',5,1,15,2], 'Armor':['Armor',0,10,25,5]} print('Name\tAtk\tArm\tLb\t...
I have written a very simple web service with MVC and WebApi. Now I'm working on the client code which will be a WPF application (and soon Windows 8 Store/Phone app). What I have done works, but I'm not sure I'm doing it the "right" way. The purpose of the service is to check if there are any new software updates to th...
I have this one controller that serves up all the webpages and any dynamic content. Is this the most efficient way of doing this? Can it be improved? package uk.co.morleys; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.Servl...
I have written a C++ program to convert an infix expression to postfix expression using recursion. I would like to know if it can be improved if possible. Can we improve it by not using a stack? I am using a vector<char> as a stack here. #include <iostream> #include <vector> std::string inp; int i, len; std::vector<c...
The following method will add two strings of any length as binary numbers assuming the characters 1 and 0. I made this for fun in my spare time. Improvements are not critical but I would like to hear them. I would also like to know if there is a more efficient algorithm to simulate a ALU. static string BinAdd(string a...
I'd like this code to be improved. package com.array.demo; import java.util.Arrays; public class ArraysDemo { public static void main(String[] args) { // TODO Auto-generated method stub // array initialization int[] arr = { 5, 10, 12, 22, 4 }; int size = arr.length; int i,pos; // loop counter ...
I want to load JS files asynchronously to speed up page loading, but also need to execute JS code only once the scripts finish loading (so I need a way to implement callbacks). I based this off of some example code on the Google Pagespeed website: // Add script elements as a children of the body function downloadJSAtOn...
I'm looking for input on the code itself and formatting/style. This script parses the output of df -h on a Linux server and emails the user if the usage percentage is above the threshold (90% in this case). #!/usr/bin/perl use warnings; use strict; use Mail::Sendmail; my $svr = `hostname`; my @output = `df -h`; my ...
I've just completed coding my template engine. I'm willing to have a review on how to increase the quality, efficiency, elegance and performance of the code, perhaps by shortening the code, etc. I'm also open for suggestions on other ways of doing this. It would be really appreciated if you point out every tiny bit of ...
I have written this program to count the number of words in a string. I have checked my program for the worst-case scenario. If any of you can find any cases for which this program doesn't work, please let me know so that I can work and improve it. And just to be clear, we don't want symbols like, "," , "!" , "?", "." ...
I have a MySQL query which runs very slowly. I've rewritten it many times but no improvements yet. My current query for advanced search takes about 60 secs to complete. Any suggestions for improving this? Database: MySQL Webserver: Apache - PHP (PDO) Current code structure: SELECT B.title, COUNT(*) AS NUM FROM libr...
I am attempting to design an application that tracks currency and recent transactions in a safe. I am using entity-framework code-first in a wpf desktop application. The first goal is to be able to track whats currently in the safe. For example - 87 Ones, 55 Twos, 76 fives, etc.. The second goal is to be able to track...
I have a process with a number of stages that need to be completed in sequence. Each stage is largely parallelisable, involving looping over a large data structure and processing each item independently, and collating the results into the data structure used by the next stage. My approach is like the following: var wg ...
I have 3 simple predicates and 3 simple actions to be taken based on those predicates. In my actual application they are not based on integer arithmetic, and in fact are rather expensive to compute (in comparison to the actions taken), but their dependency chain is the same. #include <iostream> #include <tuple> bool p...
Original question: Template engine I updated my files as instructed, and now I require a review. Please point out the most minute things out to me for me to have better code. Once again, efficiency, elegance, and performance is what I need. Also, please point out places where better code can be used (for places like l...
This is my first public web-application. I'm a beginner to JavaScript and this is my first time using jQuery. It's not complete, but I'd love some feedback on the programming and the functionality. As I said, I'm just learning and I'm not sensitive, so feel free to be thorough with your criticism/feedback. You can view...
Originally, this isn't how I would have done this at all. I was told by someone I know who is a programmer that I needed to include several functions: one for removing and adding users, one for searching for users information etc. I would have made it so you can pass a username into the constructor and then get all the...
If it is possible, I'd like to be able to mash all of my arrays into one array, but still have the same functionality within my function (pick quote, pick creator, set padding). Pastebin var quotes = [ /*48px*/"The true sign of intelligence is not knowledge but imagination.", /*48px*/"A people without the knowl...
I have recently gotten back into development and I am wondering if the script I have just created is clearly documented and easily understandable throughout each step. Is it easy to understand? class Encryption { public function Encrypt ($String){ /* * Create an Encrypted String. * @Var ...
I've been learning how to code for the past three years. I have made some really good progress I think, and right now I'm trying myself on creating an MVC framework. I found this awesome idea on making templates. Here's how my framework basically works: Config file outside the root contains some constants (database pas...
I have some code to interface with a wire protocol that requires data to be inserted into a stream at regular byte intervals. Every 8KB (or at some other definable interval), a small chunk will be inserted. To make this easy, I decided to create a transform stream that would take a flowing stream and write fixed chun...
I am using Python3 to extract some information from a dictionary that contains 10k of CIDRs, but the running time is pretty long. Here is my purpose: I have a dictionary of CIDRs (10000) and a list of IPs (5000), then I want to go through each IP in the list and check if it belongs to one CIDR in the dictionary. Could ...
I am trying to write a class similar to std::set, and I was wondering if I handled the perfect forwarding right in implementing the emplace member function below. Basically, I forwarded calls to my class to a member set. But I wasn't sure whether I used std::forward enough. Also, is there an easy way to tell when some...
I'm still learning Ruby and I made the following function to convert "N" or "SE" into "NORTH" or "SOUTH EAST" respectively. The function works and the tests all pass, but the code seems to be overly complicated. Any suggestions on how to clean it up and make it more Ruby-ish? Code module Example class Utils CA...
I am writing this program to try and get some practice at C++ and correct and proper styling. This code is meant to take user input from a pip and then run it through the program. The user enters a pattern and that pattern is turned into regex which is compared against the input, such that it could look like this: cat...
I'm trying to apply sound today, and the goal in mind was a simple violin tuner. The actionListener seems repetitive/ How might I optimize it (what I tried just broke everything)? I also noticed the sounds bleed into each other. I don't mind that so much for the different keys (though I'm thinking of a toggle option ...
The code below downloads file in multiple chunks if split is set to some number, however there is a limit to maximum possible splits defined below by maxSplits if split is 0 or 1 then no extra thread overhead is laid on to split into further thread coming out of ThreadedFetch. Please review for refactor and efficiency ...
First of, here is my previous post. That should explain a fair bit. The reason I'm posting one more time, is I have changed a lot. Using more classes, let them do all the work, and the overall structure. #include <iostream> const int DATE_LENGTH = 6; class Date { private: char *ans; protected: ...
What do you think about this directive? For each input, it traverses the DOM towards the root and if it finds an element with the class readonly, it makes the input readonly. An ng-readonly directive on the input itself get honored: The input becomes readonly whenever ng-readonly evaluates to true or any enclosing elem...
I wrote an Ajax function, which should be used in a framework to interact with a webserver. The (self-written) Java-Webserver can be used to fetch files and folder-contents, create files and folders, and delete them. /** * Performs an Ajax-Request * @param {string} method HTTP-Method * @param {string}...
I wanted to work on HttpSessions and JSP. This is the view I have: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <div> <c:out value="All available products:"/> <br/> <br/> <c:forEach items="${applicationScope.allProducts}" var="product"> <c:out value="${produc...
/((([\w -]+)|("[\w -]+"))( *, *)?)+/ http://refiddle.com/18ql I'm trying to use a PHP regex to sanitize a user input for a list of fonts. The above one seems to work nicely, but also feels a bit long and redundant, having two [\w -]*s, and allowing a trailing comma, and possibly stuff I can't see. Can this be more eff...
The scenario is about processing 'Message' objects. Producer creates them and Consumer does the consumption. class Message{...} class MessageBatch{ public MessageBatch(Collection<Message> messages){...} public List<Message> getMessages(){...}; //more utility methods like getMessageIds(), etc. } The fo...
Honestly, I can't help but feel that this is done merely to confuse newcomers. Most of the errors on Stack Overflow by complete Android newbies mostly stem from that they have a static inner class Fragment that they don't understand how it works, why it's there, and try to use Activities even though they don't fully un...
We record software builds from our build machine into a database and for practice purposes I'm building a little web dashboard for it. The API is REST (WebApi) and provides access to query for Products, Branches, Profiles and specific Builds. The controller queries all products (each product contains a list of branches...
I made a little text-based game where you move a rover and it gives you the current coordinates. You can essentially move around a 1000x1000 grid, and get output into stdout on what your coordinates are. I'm simply wondering if I could improve anything. # Rover moving program from random import randint # Starting pos...
I have just written my first git hook script. It is very simple that simply finds any URLs in the commit message and uses the Google URL shortener to rewrite the URL nicely. it is located here. I feel it could be improved immensely (as it is my first) and would love to have your input. #! /bin/bash message=`cat $1` sh...
I stumbled upon an unaswered question, which looked like a good fit for a functional programming language. Here is the problem statement from codeeval: UGLY NUMBERS CHALLENGE DESCRIPTION: Credits: This challenge has appeared in a google competition before. Once upon a time in a strange situation, people called a numb...
I have a JavaScript function that is getting data out of a JSON file and then doing some formatting to it. The code works but I feel like it just an awful way of doing it. All criticism and help appreciated. function MCScrap(ZWA, ZWB, ZWC, ZWD, Number) { $(document).ready( function() { setInterva...
I am trying to write a version of Task.WhenAll for .NET 3.5 using the "Task Parallel Library for .NET 3.5". This is what I came up with. Is there a better way of doing this? public static Task WhenAll(IEnumerable<Task> tasks) { var tcs = new TaskCompletionSource<object>(); var remainingTasks = ...
I have a small game I'm working on with a set of interfaces: IHavePosition: public interface IHavePosition<T> { T Position { get; set; } } ICanMove: public interface ICanMove<T> : IHavePosition<T> { IEnumerable<IMotor<T>> Motors { get; set; } } ICharacter: public interface ICharacter<TPos> : IHave...
I have a userform that displays a goal time for workers to shoot for when completing a task. It also has a stopwatch on it that is controlled by a start, stop, and reset button on the userform. If the stopwatch time reaches the goal time and goes over, then there is a box called "extra time" that starts counting up. It...
I need to optimize the following function: $$ \max_{a',\ m'}\ f(a, m, e, m', a') $$ I have approximated \$f\$ with a grid \$F\$, which has a shape \$(nA, nM, nE, nM, nA)\$. Now, I want to interpolate over the last two dimensions (the ones I need to maximize over), and then maximize. The following code block is the on...
I just developed a URL shortener. index.php: <? $sql_host = "..."; $sql_db = "..."; $sql_user = "..."; $sql_pass = "..."; $conn_error = "Could not connect to database"; $con = mysqli_connect($sql_host, $sql_user, $sql_pass, $sql_db) or die($conn_error); $hash = htmlspecialchars($_GET["l"]...
I use the loop-every-single-list-item approach to filter out unique elements in a given list, which tends to be very inefficient way as a list grow in size, or as function call frequency increases. Lately I was working on event handling patch and needed fast method for filtering out unique function handlers in a callba...
I was reading about similar problems to the one I am having, and my guess is that I am having a 'memory leak'. I'm not sure exactly what that means, or how to correct it. Could you take a look at my code and help me optimize? LastRow in this bit is a little over 70000. start = Timer For Row = 4 To LastRow DoEvents ...
I've built a simple command line flashcard game for learning Korean. I'm a beginner programmer, so I just wanted to make sure I'm following best practices, especially pertaining to OOP principles. Any feedback would be greatly appreciated. Here's GitHub link and reposted below: class FlashCard def initialize #...
I am relatively new to TDD and am trying to adopt better names for my tests. I wrote the following tests abruptly and have since refactored them to the best of my ability, but despite my best efforts, the test names are still (mostly) abysmal. I am here today to ask that you review my test names. [Test] public void E...
The University Library where I work is in the process of redesigned our home page. One of the features we wish to include is a widget to display the current hours. Unfortunately for a variety of reasons this must be done using client side scripting instead of a PHP script which pulls from Google Calendar. After much...
I am learning Nimrod and needed a few functions from libsndfile. I deviated slightly from libsndfile to use namespace and stronger types that is available in Nimrod. when defined(windows): const soname = "libsndfile.dll" elif defined(macosx): const soname = "libsndfile.dylib" else: const soname = "libsndfi...
This query currently takes approximately 250 seconds to run and I'd like to reduce it by as much as I can. I have tried using left joins instead of subqueries and it increases run time. SELECT `items`.`id`, ifnull((SELECT sum(`history`.`quantity`) FROM `history` where `history`.`itemID` = `items`.`id` and `history`.`d...
I am using C# to get the user's input of how many buttons to change the color of. The buttons are in rows that have 1-10 button in each. If the user enters 11, then the entire first row will be filled out and the first button on the second row will change color. I have figured out how to accommodate for different nu...
I've written an interpreter for a simple assembly-like language and it's performing slower than I would like. It's split into 3 files: the Parser that converts the source to a vector of ints, the VM that actually runs the bytecode, and Tests that has a bubble sort written in the language. It sorts 100 numbers in about ...
Edit: This was an absolute ignorance on my part which leads to hierarchical locks and can be implemented much cleaner (in fact the right way, in a mutable world) using a pipe-line of messages or Agents. Please consider studying other actor models in .NET (like the one in F#). What are drawbacks/benefits of this simple ...
The use case is to convert an array of objects into a hash map where one property is the key and the other property is the value. Common case of using this is converting a "link" object in a hypermedia response into a hash map of links. jsfiddle function toHashMap(data, name, value) { return _.zipObject(_.pluck(dat...
I looked at a bunch of AngularJS directives checking for uniqueness of a username and decided to try for the simplest implementation. It does what I want but may not really be 'idiomatic' Angular. Here is the form element: <input type="text" name="username" ng-model="form.username" unique-username="" re...
I've been working on this module with the assistance of codereview, and based on the responses and my own research, this is my project so far. The goal behind the code is that it starts with a .NET bitmap object, extracts the byte array of image data from the bitmap, then transforms it into an array of arrays or matrix...
For a small project I'm working on, I've been looking for an iterable enum-like class in C++, since neither C-style nor scoped enums seem to support iteration in a way that isn't hack-y. I stumbled across this (relatively) old article, from which I've drawn inspiration to create a robust Enum class supporting iteration...
I have a chunk of code that get's all of the ICollection properties of the passed in object and then takes all of their values and adds them to another ICollection. End goal is to see which properties have child objects in them and thus finding out how many dependents the object has. The object is an EntityFramewo...
Wow, this one is definitely going to need some improvement. So, just for fun, I decided to make a program where the player moves across a 2-dimensional ASCII-art map. If the player types something such as down, the on screen representation moves down and "loads" a bit more of the map. from console import clear class ...
I have taken over maintenance of some code, and have restructured it after reading some documents about PSR-2: <?php function calc_p() { list($arg1, $arg2, $arg3) = func_get_args(); switch($arg1) { case 'ebook': $bp = 5; $tax = .08; break; case 'audio_book': ...
A while ago I posted this question about worker AI and Job Queues for a strategy game. I have posted other questions about the Job Queue, and now I would like to post this revised question about specifically the movement class for the workers in the game. I think it would make for a good code review. The basic idea is...
I have written the following code using a dynamic programming technique. Can I use ArrayList here? Please let me know if I can improve this code. package com.java.fib; import java.math.BigInteger; import java.util.HashMap; public class Fibonaci { public static void main(String[] args) { System.out.prin...
I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions multiple times. Because this class is instanced 14 times, the array is duplicated a lot. What would be a better way to do t...
Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree. Given tree: a / \ b c / \ / \ d e f g / \ / \ / \ / \ h i j k l m n o Modified tree: a / \ c b / \ / \ d e f...
I have a vector of uint16_t and I want to check if there is a bit which is only set in one vector. I then get its position within the vector as well as from the bit. Let's say we have: v[0] = 0100 v[1] = 0110 v[2] = 1001 I would like to know that ind = 1 and val = 2. In clumsy code this would be like that: #include ...
I decided to re-write my code responsible for WCF calls, as all of my methods had try-catch-finally blocks. I read that it is bad idea to use a using() statement as it does not close the WCF connection. After digging around, I found a solution based on delegates. Yesterday I decided to add an activator for calls that a...
I wrote this to consume valid IPv4 addresses in dotted-quad decimal form: def dotted_ip_to_num ip strings = ip.split('.').reverse strings.each_with_index.inject(0) do |sum, pair| str, i = pair sum + str.to_i * (2 ** (i * 8)) end end But my chain of each_with_index and inject (aka left-fold or reduce) loo...
I developing an algorithm to read a row from a table (specifically, I'm reading from an Excel file). I have three conditions about when to terminate the Read operation: When an empty cell is found (recognized by an ElementNotFoundException When a cell with errors is found (which corresponds to a null value) Both the t...
I have the following scenario - i have a grid on web page that is populated with data. User can check a check-boxes in grid and data is saved to DB on navigating to next page. If they then navigate back to the page and remove a selection the data is deleted from the DB and also if the original selection is still chec...
I have a data table and have to validate every field in it. I have refactor this code to this below, but the complexity is 15(!!) Should I make something like dictionary with type as Key and Func as Value? private bool CheckField(DataRow dataRow, ValidationField validationField) { bool result = fa...
As part of a C# class CsvConverter that converts various file types to CSV, I am designing a private class CsvConversionResult. My current design choice is to return a null value of CsvConversionResult if processing is successful. What can I add to or remove from my design to use "best practices"? Returning primitive d...
This is so ugly code. There must be better way to write it, but I'm noob to AS3. The goal is to make a square move at even speed counter-clockwise around the edge and on call reverseDirection();, changeColor();, or spin();. I'm trying to understand Tweenlite vars onStart and onStartParams. I'm sure that it can be used ...
I'm still learning about domain driven design, and I have created my first entity class User. Is this fully compliant with the DDD principles? Particularly my setters because I have business rules in them. Any other suggestions would be highly appreciated as well. namespace Models\Entities; class User { private ...
I have written a function that returns me the duplicates of a list: static List<SomeClass> findDuplicateElements(List<SomeClass> myObjects) { List<SomeClass> duplicates = myObjects .groupBy { it.someAttribute } .findAll { it.value.size() > 1 } .collect { it.value } .flatten() assert duplicates....
This is an app made by me to display a web page on blackberry and to add some more features like checking network connectivity while opening app, loading some URL in browser rather than app, making a splash screen and loading animation. The problem with the code is that when I run this app on blackberry device it after...
I have a nested loop which creates a drop down with 3 levels. Works fine on modern browsers but on IE8 it hangs and takes several seconds when there's even a moderate volume of data. It creates a list of publishers, when I click a publisher I get that publishers authors, click an author I get the years they're publish...