Skip to content

Instantly share code, notes, and snippets.

@gulzaar
gulzaar / bonfire-return-largest-numbers-in-arrays.js
Created November 30, 2015 17:29
http://www.freecodecamp.com/gulzaar 's solution for Bonfire: Return Largest Numbers in Arrays
// Bonfire: Return Largest Numbers in Arrays
// Author: @gulzaar
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function largestOfFour(arr) {
// You can do this!
var mNum = new Array();
@gulzaar
gulzaar / BarChart.java
Last active January 4, 2016 17:51
Bar Chart Array with Java
// Fig. 7.6: BarChart.java
// Bar chart printing program.
public class BarChart {
public static void main( String[] args ) {
int[] array = { 0, 0, 0, 0, 0, 0, 1, 2, 4, 2, 1 };
System.out.println( "Grade distribution:" );
// for each array element, output a bar of the chart
@gulzaar
gulzaar / StudentPoll.java
Created January 4, 2016 17:55
Student Poll Calculation
// Fig. 7.8: StudentPoll.java
// Poll analysis program.
public class StudentPoll {
public static void main( String[] args ) {
// student response array (more typically, input at runtime)
int[] responses = { 1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 14 };
int[] frequency = new int[ 6 ]; // array of frequency counters
// for each answer, select responses element and use that value
// as frequency index to determine element to increment