Skip to content

Instantly share code, notes, and snippets.

View mllopart's full-sized avatar

Marc Llopart mllopart

View GitHub Profile
@mllopart
mllopart / gist:b4fb204fbbeb50f3162803edaf7270ca
Created February 19, 2024 11:06
Stability AI - reimagine your home's potential
import os
import requests
import io
import random
import time
import warnings
from PIL import Image
from stability_sdk import client
import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation
@mllopart
mllopart / gist:352fcf3701f4db3470c8d31ac021c026
Created January 14, 2024 09:22
Mortem in Abbatia - GPT Game
# 2024-01-14 MIT LICENSE
Mortem in Abbatia
A text-based adventure game inspired by Lucas Arts adventure games. The game is set in the hauntingly atmospheric Byland Abbey during the 12th century, a period ripe with history and mystery. The player assumes the role of Brother Aelfric who was born into a family of hunters and woodsmen in a small village on the outskirts of a great forest. Growing up, he learned the skills of tracking, hunting, and surviving in the wilderness from his father and grandfather. However, as he grew older, Aelfric began to question the morality of hunting and killing animals for sport. During a trip to a nearby monastery, Aelfric was struck by the peaceful and contemplative lifestyle of the monks he met there. He was particularly drawn to their devotion to God and the pursuit of knowledge and enlightenment. After much soul-searching, Aelfric decided to abandon his former way of life and become a monk himself. A amonk that likes to discover secrets and uses his haunting skills for sol
@mllopart
mllopart / flatten_array.py
Created August 23, 2017 09:23
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]
import unittest
#Function takes an array of arbitrarily nested arrays of int and flattens it
#into a 1 dimensional array containing the same integers.
def flatten_array(array_to_flatten):
new_array = []
#we check each element, if it's an INT we append it into the output arr
#if it's not an int, we recursively call the function to flattern it
for element in array_to_flatten:
if type(element) is int:
@mllopart
mllopart / substringCalculator.java
Last active March 21, 2021 06:42
Substring Calculator HackerRank test
using System;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
// your code goes here
// your code goes here
string s = "kincenvizh";
@mllopart
mllopart / birthday_cake_candles.py
Created June 16, 2017 16:59
Birthday Cake Candles - Hackerrank
#!/bin/python3
'''
Colleen is turning n years old! Therefore, she has n candles of
various heights on her cake, and candle i has height .
Because the taller candles tower over the shorter ones, Colleen can only blow out the tallest candles.
Given the n for each individual candle, find and print the number of candles she can successfully blow out.
'''
import sys
@mllopart
mllopart / mini_max_sum.py
Created June 16, 2017 16:43
Mini-Max Sum Hackerrank
#!/bin/python3
'''
Given five positive integers, find the minimum and maximum values
that can be calculated by summing exactly four of the five integers.
Then print the respective minimum and maximum values as a single line
of two space-separated long integers.
'''
import sys
@mllopart
mllopart / staircase.py
Created June 16, 2017 16:10
Staircase Hackerrank test
#!/bin/python3
'''
Consider a staircase of size n=4:
#
##
###
####
Observe that its base and height are both equal to , and the image
@mllopart
mllopart / plus_minus.py
Created June 16, 2017 15:46
Plus Minus Hackerrank
#!/bin/python3
'''
Given an array of integers, calculate which fraction of its elements are positive,
which fraction of its elements are negative, and which fraction of its elements are zeroes,
respectively. Print the decimal value of each fraction on a new line.
'''
import sys
@mllopart
mllopart / diagonal_difference.py
Created June 16, 2017 14:29
Diagonal Difference - Hackerrank test
#!/bin/python3
#Given a square matrix of size NxN , calculate the absolute difference between the sums of its diagonals.
import sys
n = int(input().strip())
a = []
for a_i in range(n):
@mllopart
mllopart / groupByOwners.php
Created June 14, 2017 20:16
Implement a groupByOwners function that: Accepts an associative array containing the file owner name for each file name. Returns an associative array containing an array of file names for each owner name, in any order. For example, for associative array ["Input.txt" => "Randy", "Code.py" => "Stan", "Output.txt" => "Randy"] the groupByOwners func…
<?php
class FileOwners
{
public static function groupByOwners($files)
{
$file_return = [];
$files_copy = $files;
print_r($files);