Skip to content

Instantly share code, notes, and snippets.

View Parihsz's full-sized avatar
🥶

Ace9b4 Parihsz

🥶
View GitHub Profile
export type SnapshotData<T> = {
t: number,
value: T,
}
export type CircularSnapshot<T> = {
cache: { SnapshotData<T> },
pivotIndex: number?, -- to make math easier, this is stored as 0 indexed, then 1 is added whenever it's used for indexing
lerp: (T, T, number) -> T,

Summary

This RFC proposes the adoption of Backpack instances in place of traditional Folder instances for container organization.

image

Motivation

As a roblox game scales, developers continually seek new paradigms for organizing code, modularity, and runtime clarity. Traditional Folder usage, while functional, lacks semantic weight and provides no affordance beyond being a generic instance container. Backpacks are specialized containers with actual implicit utility. Although they are deisgned to hold tools, it can be recontextualized as a general purpose container for scripts, services and components. Notably:

  • better developer ergonomics: a "Backpack" intuitively implies it "holds useful things", making it easier to conceptualize its contents as essential runtime modules.
  • visual distinction: differentiating functional containers from traditional folders make critical components much easier to prof

Array:

  • Fixed size
  • Contiguous memory block
  • Constant time access

Efficiency

  • Modifying: O(1)
  • Find (using iterator or index): O(1)

Can't insert in middle since the size is fixed.

@Parihsz
Parihsz / Approaches.md
Last active February 20, 2024 23:42
Competitive Programming advices

Some Standard Approaches for Competitive Programming

  • Brute force
    • Will earn partial marks, as it is usually too slow
    • Do it if
      • The solution space is easy to define (easy to code)
      • You are out of time
      • You might as well do it to earn some quick marks before thinking of a more optimal solution
    • In a brute force solution, there is one level of nested loop for each solution space dimension
    • You may also want to check out itertools
@Parihsz
Parihsz / Counter.md
Last active February 12, 2024 20:15
comp programming common libraries

to be done

@Parihsz
Parihsz / 2019J5.py
Last active February 20, 2024 23:37
Standard Graph Approaches
# question can be easily framed into graph pathfinding
# parse inputs
def generated_nexts(current, rules): # has to return rule_id, index and result
for rule_index in range(len(rules)):
a, b = rules[rule_index]
a_length = len(a)
for i in range(len(current) - a_length + 1): # we add one because a is the from
if a == current[i:i + a_length]: # this is a match, we found a position to apply the rule
result = current[:i] + b + current[i + a_length:]
yield rule_index + 1, i + 1, result # very special, but ugly syntax (sorry D:)
@Parihsz
Parihsz / main.md
Created January 27, 2024 01:54
Adjacency matrix implementations

Adjacency matrix implementations

2d list implementation

class adjacency_matrix_1:
    def __init__(self, N):
        self.matrix = [[False for _ in range(N)] * N]
    def connect(self, a, b, bidirectional=True):
        self.matrix[a][b] = True
 if bidirectional:
@Parihsz
Parihsz / main.md
Created January 27, 2024 01:46
Common graph forms for competitive programming (BEGINNERS)

General forms of graph traversal

Unweighted edges

  • 1, path existence
  • 2, shortest path
  • 3, number of paths
  • 4, shortest path to every other location

Weighted edges

  • 5, shortest path (a little different)
@Parihsz
Parihsz / HomogenousEquationSolver.lua
Created December 7, 2023 16:03
HomogenousEquationSolver
function find_pivot_positions(matrix)
local m, n = #matrix, #matrix[1]
local pivot_positions = {}
for i = 1, m do
for j = 1, n do
if matrix[i][j] == 1 then
table.insert(pivot_positions, {i, j})
break
end
end
@Parihsz
Parihsz / r6.lua
Created November 25, 2023 00:53
r6 character
type R6Character = Model & {
BodyColors: BodyColors,
Humanoid: Humanoid & {
HumanoidDescription: HumanoidDescription,
Status: Status,
Animator: Animator
},
Animate: LocalScript & {