Skip to content

Instantly share code, notes, and snippets.

@jakewilson801
Created September 11, 2013 03:50
Show Gist options
  • Save jakewilson801/6519157 to your computer and use it in GitHub Desktop.
Save jakewilson801/6519157 to your computer and use it in GitHub Desktop.
I got 99 problems and a bit aint one
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String args[]) {
System.out.println(getC(2));
System.out.println(getC(3));
List<Thumbnail> thumbs = new ArrayList<Thumbnail>();
thumbs.add(new Thumbnail(5, "www.itv.com/thumbnail1"));
thumbs.add(new Thumbnail(10, "www.itv.com/thumbnail2"));
thumbs.add(new Thumbnail(13, "www.itv.com/thumbnail3"));
thumbs.add(new Thumbnail(16, "www.itv.com/thumbnail4"));
System.out.println(getThumbnail(0, thumbs));
System.out.println(getThumbnail(6, thumbs));
System.out.println(getThumbnail(11, thumbs));
System.out.println(getThumbnail(17, thumbs));
}
public static double getC(double radius) {
return 2 * Math.PI * radius;
}
public static String getThumbnail(int time, List<Thumbnail> thumbs) {
if (thumbs.get(0).time > time)
return thumbs.get(0).url;
for (int i = 0; i < thumbs.size(); i++) {
if (thumbs.get(i).time > time)
return thumbs.get(i - 1).url;
}
return thumbs.get(thumbs.size() - 1).url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment