Skip to content

Instantly share code, notes, and snippets.

View lomnom's full-sized avatar
💭
Duh Ta an be web fox do has dan no eh Ta so VHS TN bc so it’s damn ya so thx sag

lomnom

💭
Duh Ta an be web fox do has dan no eh Ta so VHS TN bc so it’s damn ya so thx sag
View GitHub Profile
@lomnom
lomnom / Solutions.md
Last active August 6, 2025 08:38
Pset 9 solutions

Dijkstra

#include <iostream>
#include <queue>
#include <vector>
#include <limits.h>

using namespace std;

typedef long long int ll;
@lomnom
lomnom / Hints.md
Last active July 30, 2025 08:48
Pset 9 hints

Hints

Subgraphs

Hint #1 Use DFS for this. Approach is the same as with BFS (refer to session 7 slides), except that you use DFS.

Dijkstra

Hint #0
@lomnom
lomnom / Answers.md
Last active July 29, 2025 07:13
Code for subgraphs

2 Solutions for Subgraphs

Smart loop

Uses the vector visited.

Special optimization:

  1. With the vector visited,
  2. for (int i = 0; i<nodes; i++){
  3. if (!visited[i]){do bfs and increment the counter by 1}

This avoids iterating through the whole visited vector every time. It only does so once.

@lomnom
lomnom / Solution.md
Last active July 5, 2025 14:15
NYRCS pset 7 - Hints

Hints & solutions

Wormholes

Hint 1 When defining a DP function, think about all the possible ways to get to where you are from ONE step before.

Also assume that if your cases are correct, all your dp results are correct.

@lomnom
lomnom / Download.js
Last active May 4, 2025 14:36
Tapermonkey script that adds the download button to lectures on NYJCPortal/NYPortal
// ==UserScript==
// @name NYJC download
// @namespace https://tampermonkey.net/
// @version 2025-03-02
// @description Adds the download button to lectures on the NYJCportal. https://gist.github.com/lomnom/a0c51d25a65198eba13333d6395e9bb1
// @author lomnom on github
// @match portal.nyjc.edu.sg/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==

Noi notes

Boilerplate

Template

#include <iostream>
#define num long int

using namespace std;

int main(){
> v
1 #
2 vtv#<
3 # # t
4 v<v< >#vtv
5 t t # #
6 v<v<
7 t t
8
SXY vvvv vvvv
@lomnom
lomnom / Yes.py
Last active February 12, 2024 22:54
Hello world landscape
'The peaks of Mt. CodeMore are carpeted with an impenetrable armour of snow.'
"""Below that snow lies sparkly logic."""
#
#-##
##-#.
@print ###
@ ( ##-###.
lambda ###=# ##
a ## #=