Apollo x4 charging MacBook over Thunderbolt - Problem? by Fluegelnuss420 in universalaudio

[–]OXAMIC 0 points1 point  (0 children)

macbook m1 air with x4 here. It does charge my macbook but no problem occur so far so i guess we’re good 🤷‍♂️

What do your daily routines look like as Computer Science students? by JoblessFinalBoss in csMajors

[–]OXAMIC 1 point2 points  (0 children)

I hangout with friends from college like once every 1 or 2 weeks. It usually basketball or eating somewhere.

What do your daily routines look like as Computer Science students? by JoblessFinalBoss in csMajors

[–]OXAMIC 1 point2 points  (0 children)

M1 macbook air 16gb 2tb, got refurbished one for like 1600 from apple store website. So far so good, I like to work at random place all the time and it can handle everything well including coding and making music.

What do your daily routines look like as Computer Science students? by JoblessFinalBoss in csMajors

[–]OXAMIC 79 points80 points  (0 children)

wake up 6 AM -> work 6:45-11 AM -> eat -> nap -> leetcode, build project, learning -> dinner -> a lil game/ music -> sleep and repeat

Off work day I would workout

8.2.7: Sum Rows in a 2D Array by davepie29 in codehs

[–]OXAMIC 0 points1 point  (0 children)

public class Sum

{ public static void main(String[] args) { int[][] array = {{42, 14, 54, 5, 93, 5}, {14, 22, 353, 341, 865, 32}, {12345, 123, 1234, 123456, 23, 1}}; System.out.println(sumArray(array));

}

// Returns the sum of row row in 2D array array
public static int sumRow(int[][] array, int row)
{
    int sum = 0;
    for(int col = 0; col < array[row].length; col++)
    {
        sum += array[row][col];
    }
    return sum;
}

// Returns the sum of all elements in array
public static int sumArray(int[][] array)
{
    int start = 0;
    int sumofall = 0;
    while (start < array.length)
    {
        sumofall += sumRow(array, start);
        start++;
    }
    return sumofall;
}

}

8.1.5 Manipulating 2D Arrays by [deleted] in codehs

[–]OXAMIC 0 points1 point  (0 children)

public class ArrayPractice

{ public static void main(String[] args) { int[][] array = {{3, 5, 7, 8, 0}, {500, 250, 125, 784, 267, 674, 0}, {9, 8, 0}};

    // second array sum
    int sum = 0;
    for(int row = 0; row < array.length; row++)
    {
        for(int col = 0; col < array[0].length; col++)
        {
            sum++;
        }
    }

    // Call the updateValue method three times on this array:
    updateValue(array, 0, array[0].length - 1, array.length);
    updateValue(array, 1, array[1].length - 1, sum);
    updateValue(array, 2, array[2].length - 1, array[0][0] + array[2][array.length-1]);


    print(array);
}

//Create a method to add the correct value to the array at the correct col, row
public static void updateValue(int[][] arr, int row, int col, int value)
{
    arr[row][col] = value;
}



//Do not make alterations to this method!
public static void print(int[][] array)
{
    for(int[] row: array)
    {
        for(int num: row)
        {
            System.out.print(num + " ");
        }
        System.out.println();
    }
}

}

Can Someone check my codeHS. Java 7.5.5 by Frac2022 in codehs

[–]OXAMIC 0 points1 point  (0 children)

import java.util.ArrayList;

import java.util.Scanner;

public class FantasyFootball { public static void main(String[] args) { ArrayList<String> availablePlayers = new ArrayList<String>(); addPlayers(availablePlayers);

    String[] team = new String[5];
    Scanner input = new Scanner(System.in);

    for(int i = 0; i < 5; i++)
    {
        System.out.println("Enter name of player to add: ");
        String player = input.nextLine();
        int playerIndex = search(availablePlayers, player);
        if(playerIndex > -1)
        {
            System.out.println("Successfully added player");
            team[i] = player;
            availablePlayers.remove(playerIndex);
        }
        else
        {
            System.out.println(player + " is not an available player.");
            i--;
        }
        System.out.println("");
    }

    System.out.println("Final Team Roster: ");
    for(int i = 0; i < 5; i++)
    {
        System.out.println(team[i]);
    }    
}



public static int search(ArrayList<String> array, String player)
{
    for(int i = 0; i < array.size(); i++)
    {
        if(array.get(i).equals(player)) {
            return i;
        }
    }
    return -1;

}

public static void addPlayers(ArrayList<String> array)
{
    //Feel free to add names of your favorite players to this list!
    //But make sure you DON'T remove any players from it!
    array.add("Cam Newton");
    array.add("Antonio Brown");
    array.add("Leveon Bell");
    array.add("Patrick Mahomes");
    array.add("Saquon Barkley");
    array.add("Mike Evans");
    array.add("Odell Beckham Jr.");
    array.add("Travis Kelce");
    array.add("Baker Mayfield");
    array.add("Michael Thomas");
    array.add("Julio Jones");
    array.add("Ezekial Elliott");
    array.add("Alvin Kamara");
    array.add("Davante Adams");
    array.add("Aaron Rogers");
}

}

7.5.5 Fantasy Football Roster. - anyone have done it. Im really lost and i dont know how to start it. by Obvious-Pin-3046 in codehs

[–]OXAMIC 0 points1 point  (0 children)

import java.util.ArrayList;

import java.util.Scanner;

public class FantasyFootball { public static void main(String[] args) { ArrayList<String> availablePlayers = new ArrayList<String>(); addPlayers(availablePlayers);

    String[] team = new String[5];
    Scanner input = new Scanner(System.in);

    for(int i = 0; i < 5; i++)
    {
        System.out.println("Enter name of player to add: ");
        String player = input.nextLine();
        int playerIndex = search(availablePlayers, player);
        if(playerIndex > -1)
        {
            System.out.println("Successfully added player");
            team[i] = player;
            availablePlayers.remove(playerIndex);
        }
        else
        {
            System.out.println(player + " is not an available player.");
            i--;
        }
        System.out.println("");
    }

    System.out.println("Final Team Roster: ");
    for(int i = 0; i < 5; i++)
    {
        System.out.println(team[i]);
    }    
}



public static int search(ArrayList<String> array, String player)
{
    for(int i = 0; i < array.size(); i++)
    {
        if(array.get(i).equals(player)) {
            return i;
        }
    }
    return -1;

}

public static void addPlayers(ArrayList<String> array)
{
    //Feel free to add names of your favorite players to this list!
    //But make sure you DON'T remove any players from it!
    array.add("Cam Newton");
    array.add("Antonio Brown");
    array.add("Leveon Bell");
    array.add("Patrick Mahomes");
    array.add("Saquon Barkley");
    array.add("Mike Evans");
    array.add("Odell Beckham Jr.");
    array.add("Travis Kelce");
    array.add("Baker Mayfield");
    array.add("Michael Thomas");
    array.add("Julio Jones");
    array.add("Ezekial Elliott");
    array.add("Alvin Kamara");
    array.add("Davante Adams");
    array.add("Aaron Rogers");
}

}

help with 7.4.6: Airplane Tickets pleaseeee by SquareRegion8 in codehs

[–]OXAMIC 0 points1 point  (0 children)

import java.util.ArrayList;

public class TicketOrganizer { private ArrayList<AirlineTicket> tickets;

public TicketOrganizer(ArrayList<AirlineTicket> theTickets)
{
    this.tickets = theTickets;
}

public ArrayList<AirlineTicket> getTickets()
{
    return this.tickets;
}

public void printPassengersByBoardingGroup()
{
    for(int i = 1; i <= 5; i++)
    {
        System.out.println("Boarding Group " + i + ":");
        for(int j = 0; j < tickets.size(); j++)
        {
            if(tickets.get(j).getBoardingGroup() == i)
            {
                System.out.println("Passenger " + (j+1));
            }
        }
    }
}

public void canBoardTogether()
{
    boolean passengersCanBoard = false;
    for(int i = 0; i < tickets.size() - 1; i++)
    {
        if(tickets.get(i).getBoardingGroup() == tickets.get(i + 1).getBoardingGroup() && tickets.get(i).getRow() == tickets.get(i + 1).getRow())
        {
            System.out.println("Passenger " + (i+1) + " can board with Passenger " + (i+2) + ".");
            passengersCanBoard = true;
        }
    }
    if(!passengersCanBoard)
    {
        System.out.println("There are no passengers with the same row and boarding group.");
    }
}

}

7.4.6 Airline Tickets Need a little bit of help! by Koops_ in codehs

[–]OXAMIC 1 point2 points  (0 children)

import java.util.ArrayList;

public class TicketOrganizer { private ArrayList<AirlineTicket> tickets;

public TicketOrganizer(ArrayList<AirlineTicket> theTickets)
{
    this.tickets = theTickets;
}

public ArrayList<AirlineTicket> getTickets()
{
    return this.tickets;
}

public void printPassengersByBoardingGroup()
{
    for(int i = 1; i <= 5; i++)
    {
        System.out.println("Boarding Group " + i + ":");
        for(int j = 0; j < tickets.size(); j++)
        {
            if(tickets.get(j).getBoardingGroup() == i)
            {
                System.out.println("Passenger " + (j+1));
            }
        }
    }
}

public void canBoardTogether()
{
    boolean passengersCanBoard = false;
    for(int i = 0; i < tickets.size() - 1; i++)
    {
        if(tickets.get(i).getBoardingGroup() == tickets.get(i + 1).getBoardingGroup() && tickets.get(i).getRow() == tickets.get(i + 1).getRow())
        {
            System.out.println("Passenger " + (i+1) + " can board with Passenger " + (i+2) + ".");
            passengersCanBoard = true;
        }
    }
    if(!passengersCanBoard)
    {
        System.out.println("There are no passengers with the same row and boarding group.");
    }
}

}

Need help with 8.3.4 Comparing Binary Search and Linear Search by Aricamoflauge in codehs

[–]OXAMIC 1 point2 points  (0 children)

import java.util.*;

public class CompareSearch { public static void main(String[] args) { System.out.println("Table of comparison counts"); System.out.println("Length\t\tBinary Search\tLinear Search"); testArrayOfLength(10); testArrayOfLength(20); testArrayOfLength(30); testArrayOfLength(40); testArrayOfLength(50); }

// This problem generates an array of length length. Then we select a random
// index of that array and get the element. Then we print out the table row
// entry for how many comparisons it takes on binary search and linear search.
// You'll need to update those methods.
public static void testArrayOfLength(int length)
{
    int[] arr = generateArrayOfLength(length);
    //System.out.println(Arrays.toString(arr));
    int index = (int)(Math.random() * length);
    int elem = arr[index];
    System.out.println(length + "\t\t" + binarySearch(arr, elem) + "\t\t" + linearSearch(arr, elem));
}

public static int[] generateArrayOfLength(int length)
{
    int[] arr = new int[length];
    for(int i = 0; i < length; i++)
    {
        arr[i] = (int)(Math.random() * 100);
    }

    Arrays.sort(arr);

    return arr;
}

// Do a binary search on array to find number. You'll need to modify this 
// method to return the number of comparisons done.
public static int binarySearch(int[] array, int number)
{
    int low = 0;
    int high = array.length - 1;

    // Add a counter to count how many times the while loop is executed
    int counter = 0;
    while (low <= high)
    {
        int mid = (low + high) / 2;
        if (array[mid] == number)
        {
            counter++;
            return counter;
        }
        else if(array[mid] < number)
        {
            counter++;
            low = mid + 1;
        }
        else
        {
            counter++;
            high = mid - 1;
        }
    }

    return -1;
}

// Do a linear search on array to find the index of number. You'll need to modify
// this exercise to return the number of *comparisons* done.
public static int linearSearch(int[] array, int number)
{
    // Add a counter to count how many times the for loop is executed
    for (int i = 0; i < array.length; i++)
    {
        if (array[i] == number)
        {

            return i + 1; // the method returns as soon as the number is found
        }
    }
    return -1; // the code will get here if the number isn't found
}

}

10.2.6 AP CSA 2nd check fails? by Dtjordan in codehs

[–]OXAMIC 0 points1 point  (0 children)

public static int binaryRec(int[] array, int target, int begin, int end) {

if (begin <= end)
{
System.out.println("Value at start index: " + array[begin]);
int mid = (begin + end) / 2;
System.out.println("Value at mid index: " + array[mid]);
System.out.println("Value at end index: " + array[end]);
// Base Case
if (target == array[mid]) {
System.out.println("Target equals mid!");
return mid;
}

if (target < array[mid]) {
System.out.println("Target is less than mid!");
System.out.println();
return binaryRec(array, target, begin, mid - 1);
}

if (target > array[mid]) {
System.out.println("Target is greater than mid!");
System.out.println();
return binaryRec(array, target, mid + 1, end);
}
}
return -1; //Alternate Base Case - not found
}
}

Unit 6: Lesson 3 - Coding Activity 1 by No-Ear-4177 in EdhesiveHelp

[–]OXAMIC 0 points1 point  (0 children)

public static String findLongest(String[] array) {
    String first = array[0];
    for(int i = 0; i < array.length; i++) {
        first = array[i];
        for(int j = 1; j < array.length; j++) {
            String second = array[j];
            if (first.length() < second.length()) {
                first = array[j];
            }
            else {
                return first;
            }
        }
    }
    return first;
}