Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View NobodyXu's full-sized avatar

Jiahao XU NobodyXu

View GitHub Profile
@NobodyXu
NobodyXu / pasca_triangle.py
Last active March 28, 2019 06:47
challenges -- A place where I save the solutions to challenges which I think is beautiful
#!/usr/bin/env python3
import sys
# rowList is a list who the first and last element is 0(which will not be printed)
def print_pascal_triangle_row(row):
print(" ".join([str(each) for each in row[1 : -1]]))
# @parm n denotes how many rows should it print
def print_pascal_triangle(n):
@NobodyXu
NobodyXu / R.md
Last active May 20, 2019 06:13
About R
  • Semantics:
    • assignment:
      • When assigning a variable to another name, eg, a = b, a new object is created. However, no data is copied due to the [copy-on-modify][ref1]
    • In order to xor booleans, use xor(a, b).
    • reminder and quotient
      • %% for reminder and %/% for quotient.
    • For accessing list inside list, [[index]] must be used.
    • For returning a vector from a data.frame or data.table, df[[one_list_index]] must be used.
    • slicing:
  • Slicing happens when you [] a container (vector, list, etc) using more than one index, generated by seq or : or c(). The index used can be integers or charaters.