Skip to content

Instantly share code, notes, and snippets.

View clbmrls14's full-sized avatar

Caleb Morales clbmrls14

  • NICE CXOne
  • Salt Lake Area
View GitHub Profile
@clbmrls14
clbmrls14 / tourist_routes.py
Last active March 13, 2022 17:45
A Python implementation of the algorithm proposed here: https://arxiv.org/abs/2104.07663 by Cristina Maria Pacurar, Ruxandra-Gabriela Albu, Victor-Dan Pacurar [April 15, 2021] Implementation by Caleb Morales
''' A Python implementation of the algorithm proposed here:
https://arxiv.org/abs/2104.07663 by Cristina Maria Pacurar,
Ruxandra-Gabriela Albu, Victor-Dan Pacurar [April 15, 2021]
Implementation by Caleb Morales
'''
from typing import Tuple, List
from operator import itemgetter
@clbmrls14
clbmrls14 / judy's_galaxy_vacay.py
Last active April 19, 2021 17:28
A solution to problem 19a in chapter 18 of 'Algorithms' by Jeff Erickson (http://jeffe.cs.illinois.edu/teaching/algorithms/book/Algorithms-JeffE.pdf)
from functools import lru_cache
from typing import List, Tuple
def flatten_list(fat_list: List[List[int]]):
if len(fat_list) == 0:
return fat_list
if isinstance(fat_list[0], list):
return flatten_list(fat_list[0] + flatten_list(fat_list[1:]))
return fat_list[:1] + flatten_list(fat_list[1:])
#include <iostream>
#include <fstream>
#include <Windows.h>
LONG WINAPI CrashHandler(EXCEPTION_POINTERS* e)
{
std::string file = "./output.txt";
std::ofstream out(file.c_str());
out << "### CRASH OCCURRED ###";
out.close();
'''
You are driving a bus along a highway, full of rowdy, hyper, thirsty students
and a soda fountain machine. Each minute that a student is on your bus,
that student drinks one ounce of soda. Your goal is to drop the students
off quickly, so that the total amount of soda consumed by all students is as
small as possible.
You know how many students will get off of the bus at each exit. Your
bus begins somewhere along the highway (probably not at either end)
and moves at a constant speed of 37.4 miles per hour. You must drive theb
from fastapi import FastAPI, Query
import random
app = FastAPI()
scrambled_words = []
words = []
@app.get("/getscrambles")
async def get_scrambled_words():
import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, tap, map } from 'rxjs/operators';
import { ISession } from './session';
@Injectable({
providedIn: 'root'
})
@RestController
@RequestMapping("/api/v1/sessions")
public class SessionsController {
@Autowired
private SessionRepository sessionRepository;
@GetMapping
public List<Session> list() {
return sessionRepository.findAll();
}
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
import java.util.List;
@Entity(name = "sessions")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Session {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
spring.datasource.url=jdbc:postgresql://localhost:5432/database
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.show-sql=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
def day2Part2(lines):
validPasswords = 0
for line in lines:
x = line.split()
locations = x[0].split('-')
first = int(locations[0])
second = int(locations[1])
character = x[1]