Skip to content

Instantly share code, notes, and snippets.

View Luhua-codes's full-sized avatar
🍣

Luhua-codes

🍣
  • Canada
View GitHub Profile
@Luhua-codes
Luhua-codes / W8Q12.py
Last active March 14, 2021 02:52
Pain (more practice questions from APS106)
"""
a) The sum of two vectors is just the element-wise sum of their elements.
For example, the sum of [1, 2, 3] and [4, 5, 6] is [5, 7, 9]. Write a function
called sparse_add that takes two sparse vectors stored as dictionaries
and returns a new dictionary representing their sum.
c) It would be useful to automatically “sparsify” a vector. Write a function that called
sparsify that takes in a list of integers and returns a dictionary representing a
sparse vector.
@Luhua-codes
Luhua-codes / FDM Coding Challenge.java
Last active March 18, 2021 19:51
From STEMing Up 2019-08-21
import java.util.*;
public class FDM_codingChallenge {
void archie() {
int[][] archie_choords = new int[4][2];
boolean found = false;
char[][] test_basement = {
{'1', '1', '1', '1', '1', '1', '1', '1', '1', '1'},
{'1', '0', '0', '0', '0', '0', '0', '0', '0', '1'},
{'1', '0', '0', 'A', '0', '0', '0', '0', '0', '1'},
@Luhua-codes
Luhua-codes / MATH1014 A1Q5b.java
Last active March 18, 2021 19:51
Answer to assignment 1 question 5b 2021-02-07
import java.util.*;
public class Assignment1Q5b {
public static void main(String[] args) {
double k, a = 1, b = 1, n = 1, err;
Scanner in = new Scanner(System.in);
do {
try {
System.out.print("Enter the lower bound of the integral: ");
@Luhua-codes
Luhua-codes / APS106 W6Q4.py
Last active February 25, 2021 21:29
the hell question with hockey involved
# hell
def boxy_boi(box_score):
winScore = 0
winTeam = ""
for i in range(0, 2):
team = box_score[i]
#print("team: ", team)
score = team[1]
@Luhua-codes
Luhua-codes / Date and Time.java
Last active February 13, 2021 17:24
Hackerrank submissions that didn't save
//April 15, 2020
//link: https://www.hackerrank.com/challenges/java-date-and-time/problem
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
@Luhua-codes
Luhua-codes / question1.py
Last active February 11, 2021 20:14
APS106 Week 5 Practice Problems 2021-02-11
# Question 1
def opposite_day(stringy_boi):
''' (str) -> (str)'''
stringy_boi2 = ""
for c in stringy_boi:
if c in "qwertyuiopasdfghjklzxcvbnm":
c = c.upper()
stringy_boi2 += c
elif c in "QWERTYUIOPASDFGHJKLZXCVBNM":