Skip to content

Instantly share code, notes, and snippets.


Ruyi Li RuyiLi

View GitHub Profile
RuyiLi / d1p1.jl
Last active Jan 21, 2020
AOC 2018 Solutions For Google Code-In
View d1p1.jl
# Author: weCryOpen (Ruyi Li)
function d1p1(file)
open(file) do f
total = 0
for line in eachline(f)
# Iterate through each line in the file
# Convert it to an integer,
n = parse(Int, line)
# and add it to the total.
RuyiLi / main.jl
Last active Jan 21, 2020
Calculating the value of Pi in Julia - Google Code-In
View main.jl
# Author: Ruyi Li (weCryOpen)
function mypi(n::Int)::Float
total_sum::Float = 0
for i = 1:n
total_sum += 1 / (i * i)
(total_sum * 6) ^ 0.5
RuyiLi / index.html
Created Dec 9, 2019
Soldier simulator application for my Math Extended Essay.
View index.html
<button onclick="josephus()"> Start </button>
<button onclick="eliminate()"> Kill </button>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const SIZE = 640;
canvas.width = canvas.height = SIZE;

Keybase proof

I hereby claim:

  • I am ruyili on github.
  • I am wecryopen ( on keybase.
  • I have a public key ASBErN8SGkckrb14D073PzIuuJUwbAoEmXSnAFQKiNEYFgo

To claim this, I am signing this object:

View goosegen.js
g=a=>`:goose-${a}:`;[g('top'),...Array(+prompt('Length of goose neck:')).fill(g('middle')),g('bottom')].join`\n`
RuyiLi / index.html
Created Sep 4, 2019
argebe - A fun and unique browser game smaller than 3kb (uncompressed, without comments)
View index.html
<canvas style="position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);"></canvas>
w - The width of the canvas in pixels.
h - The height of the canvas in pixels.
s - The size of the character in pixels.
c - The canvas element.
t - The graphics context.
u - The available colors.
q - The player's current colors.
RuyiLi /
Last active Aug 7, 2019
Big Assignments

Make sure to use styles!

Choice 1 - Rock Paper Scissors Poker

Rules of the game:

Each player draws five cards (either rock, paper, or scissors) from an unlimited deck. Both players will pick one card, and if one player's cards beat the other (rock beats scissors, paper beats rock, scissors beats paper) then that player wins. If there is a tie (e.g. both play rock) then whoever has more of the chosen card in the hand wins. If they both have the same amount, it is counted as a tie.

As an extra challenge, modify the game so that there are 5 rounds, with a point being awarded each time a player wins. At the end of the five rounds, print the status of the game (either a win, tie, or a loss).


Assignment 1 - Age

Create an input with type="date". When a button is pressed, the program should write "You are $(age) years old" into a paragraph element. Replace $(age) with the number of years since the date entered.

Use the MDN Docs for the Date object to complete this assignment:

You can get a date object from the input by doing new Date(input.value).

Assignment 2 - Move a Square

RuyiLi /
Last active Aug 5, 2019
Lesson 6 Assignment

For all assignments, make sure to clearly label your local and global variables. Use functions to make your code more easy-to understand.

Assigment 1 - Shopping Cart

Create an application with an input field and a submit field. When the submit button is pressed, the text in the input should be added to a "shopping cart" (an unordered list). This is similar to your wishlist application. Try not to just copy code from the wishlist project, as there's literally no point in cheating on this.

Assignment 2 - Color a Square

Create 5 buttons labelled "red", "blue", "green", "white", and "black". When pressed, the background of a div element

RuyiLi / .eslintrc.json
Last active Jul 1, 2019
my eslint and ts config
View .eslintrc.json
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
"parser": "@typescript-eslint/parser",
"plugins": [