Skip to content

Instantly share code, notes, and snippets.

View valdergallo's full-sized avatar
🏠
Working from home

Valder Gallo valdergallo

🏠
Working from home
View GitHub Profile
@valdergallo
valdergallo / cloudSettings
Last active November 4, 2020 20:01
VSCodde config for python
{"lastUpload":"2020-11-04T20:01:03.058Z","extensionVersion":"v3.4.3"}
@valdergallo
valdergallo / boxstacking.py
Created September 19, 2017 12:58
Stack boxes on top of each other
"""
Problem Statement
=================
Given different dimensions and unlimited supply of boxes for each dimension, stack boxes on top of each other such that
it has maximum height but with caveat that length and width of box on top should be strictly less than length and width
of box under it. You can rotate boxes as you like.
1) Create all rotations of boxes such that length is always greater or equal to width
2) Sort boxes by base area in non increasing order (length * width). This is because box
with more area will never ever go on top of box with less area.
3) Take T[] and result[] array of same size as total boxes after all rotations are done
<code_scheme name="Default (1)">
<option name="RIGHT_MARGIN" value="80" />
<Python>
<option name="NEW_LINE_AFTER_COLON" value="true" />
<option name="DICT_NEW_LINE_AFTER_LEFT_BRACE" value="true" />
<option name="DICT_NEW_LINE_BEFORE_RIGHT_BRACE" value="true" />
<option name="FROM_IMPORT_NEW_LINE_AFTER_LEFT_PARENTHESIS" value="true" />
<option name="FROM_IMPORT_NEW_LINE_BEFORE_RIGHT_PARENTHESIS" value="true" />
<option name="FROM_IMPORT_PARENTHESES_FORCE_IF_MULTILINE" value="true" />
<option name="FROM_IMPORT_TRAILING_COMMA_IF_MULTILINE" value="true" />
@valdergallo
valdergallo / sublime3_keys.json
Created May 18, 2017 14:05
sublime3_keys.json
[
{ "keys": ["alt+shift+d"], "command": "find_under_expand" },
{ "keys": ["alt+shift+a"], "command": "find_all_under" },
{ "keys": ["ctrl+g"], "command": "goto_definition" },
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+delete"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete to Hard EOL.sublime-macro"} },
{ "keys": ["shift+super+w"], "command": "close_all"},
{ "keys": ["ctrl+shift+r"], "command": "goto_symbol_in_project" },
{ "keys": ["ctrl+alt+'"], "command": "auto_docstring" },
{ "keys": ["ctrl+alt+shift+'"], "command": "auto_docstring_all" }
@valdergallo
valdergallo / sublime3_settings.json
Last active May 18, 2017 14:04
sublime3.settings
{
"auto_complete": true,
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
}
],
"auto_indent": true,
@valdergallo
valdergallo / eight_queen.py
Created October 8, 2016 03:06
The best eight queen that ever in the world !!!
from itertools import permutations
n = 8
cols = range(n)
for vec in permutations(cols):
if (n == len(set(vec[i] + i for i in cols))
== len(set(vec[i] - i for i in cols))):
print(vec)
@valdergallo
valdergallo / SudokuAI.py
Created September 29, 2016 19:08
Sudoku AI
n = 3 # Size of inner region
n2, n3, n4 = n**2, n**3, n**4
def show(flatline):
'Display grid from a string (values in row major order with blanks for unknowns)'
fmt = '|'.join(['%s' * n] * n)
sep = '+'.join(['-' * n] * n)
for i in range(n):
for j in range(n):
@valdergallo
valdergallo / reset_migrations.py
Last active May 6, 2016 13:20
Delete migrations and create one new migration for Django 1.7+
from django.core.management import BaseCommand
from django.core.management import call_command
from django.db import connection
import os
import shutil
import re
import tempfile
__doc__ = """
@valdergallo
valdergallo / Vagrantfile
Last active December 5, 2015 14:59
Vagrantfile default file to install default pacakges to python developer
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# proxy config
{
"disable_default_element_completions": true
}