Skip to content

Instantly share code, notes, and snippets.

Avatar

Levi Lesches Levi-Lesches

View GitHub Profile
@Levi-Lesches
Levi-Lesches / word_search.py
Created Oct 22, 2020
LeetCode word search
View word_search.py
class Solution:
# Allows us to do "for coordinate in self"
def __iter__(self): return (
(row, column)
for row in range(self.rows)
for column in range(self.columns)
)
# Allows us to do "self [coordinate]"
def __getitem__(self, coordinate): return self.board [coordinate [0]] [coordinate [1]]
@Levi-Lesches
Levi-Lesches / credits.dart
Created Sep 30, 2020
A prototype of the credits page for RamLife
View credits.dart
import "package:flutter/material.dart";
// 1. Create a Programmer class to store the right data
// 2. Create a ProgrammerWidget to represent the data
// 3. Create a CreditsPage widget to show all the credits
// Each one of these classes can be modified reasonably without breaking the other widgets.
// 1. The Programmer class defines all the data.
class Programmer {
@Levi-Lesches
Levi-Lesches / Game of Life.dart
Last active Sep 25, 2020
Conway's Game of Life, demo in the comments
View Game of Life.dart
import "dart:io";
class Position {
static int rows = 13;
static int columns = 13;
static Set<Position> offsets = {
Position(-1, -1), Position(-1, 0), Position(-1, 1),
Position(0, -1), Position(0, 1),
Position(1, -1), Position(1, 0), Position(1, 1),
@Levi-Lesches
Levi-Lesches / nytimes_headlines.py
Last active Sep 2, 2020
Scrapes headlines from the front page of nytimes.com
View nytimes_headlines.py
import requests
from bs4 import BeautifulSoup
import json
URL = "https://www.nytimes.com/"
START_OF_JSON = "window.__preloadedData = "
def get_html():
response = requests.get(URL)
return response.text
View password_generator.py
from random import choice
import string
alphabet = string.ascii_letters
uppercaseAlphabet = alphabet.upper()
symbols = string.punctuation
numbers = string.digits
characterSets = [alphabet, symbols, numbers, uppercaseAlphabet]
View yesterday.dart
import "package:flutter/material.dart";
// -------------------- Pick your colors! -------------------
// There are two ways to make colors here:
// 1. Use Color(<code>).
// The "code" is what's called a "hex color code" -- it's that 6 letter code
// Except, you need to start it with "0xff". So, for example, pastel pink is:
// "fdd0e4", so "pastelPink" (below) is "Color(0xfffdd0e4)". These color codes
// can be taken from anywhere (try Googling "hex color picker")
@Levi-Lesches
Levi-Lesches / battleship.py
Created Apr 19, 2020
A Python implementation of Battleship (deliberately avoiding OOP)
View battleship.py
"""
Battleship
Concepts used:
- constants
- functions (I/O)
- if on one line
- random.choice and random.shuffle
- printing with an `end`
- tuples
@Levi-Lesches
Levi-Lesches / schedule_search.dart
Created Mar 3, 2020
Searches for class in schedule
View schedule_search.dart
void main() {
for (int i = 0; i < 5; i++) {
print('hello ${i + 1}');
}
}
Map<Letters, List<int>> getSubjectInSchedule() {}
class Subject {
@Levi-Lesches
Levi-Lesches / sports_builder_admin.dart
Created Feb 21, 2020
Ram Life admin sports builder
View sports_builder_admin.dart
import "package:flutter/material.dart";
enum Sport {baseball, basketball, hockey, tennis, volleyball, soccer}
const Map<String, Sport> stringToSports = {
"baseball": Sport.baseball,
"basketball": Sport.basketball,
"hockey": Sport.hockey,
"tennis": Sport.tennis,
"volleyball": Sport.volleyball,
@Levi-Lesches
Levi-Lesches / sports_page.dart
Last active Feb 21, 2020
Ram Life Sports Page
View sports_page.dart
import "package:flutter/material.dart";
@immutable
class Time {
/// The hour in 24-hour format.
final int hour;
/// The minutes.
final int minutes;