Skip to content

Instantly share code, notes, and snippets.

View palcu's full-sized avatar
🚒
Responding to a pager alert

Alex Palcuie palcu

🚒
Responding to a pager alert
View GitHub Profile
@palcu
palcu / checklist_probleme.md
Last active August 29, 2015 14:14
Sa fie de folos!

Checklist pentru a propune o problemă de informatică

Before

  • Care e publicul care îți va rezolva problema?
  • Ce cunoștiințe au?
  • Cât timp trebuie să ia rezolvarea?

During

/***************************************************
* Alex Palcuie
* Romania - 2013
* alex [dot] palcuie [at] gmail [dot] com
* http://palcu.blogspot.com/
****************************************************/
#include <vector>
#include <list>
#include <map>
@palcu
palcu / vagrant_blog_post
Created February 27, 2014 18:03
Blog post Vagrant
Do you hate coming at the office, opening your text editor, looking over the Github issues, seeing a bug you can easily fix and bang... you forgot to open Vagrant. So, you type like a robot <i>vagrant up</i>, you wait 90 seconds for the beast to load and bang... you forgot to connect to the VPN and Puppet cannot sync your packages.
You code the whole day at work, pack your things, arrive home, start browsing threads on Hacker News and bang... you have low battery because you forgot to close Vagrant. Damn the technology stack is too big to fit my tiny brain cache. Well, for those of you on OSX, I made <a href="https://github.com/palcu/dotfiles/tree/master/applescripts">some tiny little AppleScripts</a> that solve these annoying little pesky problems.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-tBswMBVY02k/Uv-1LjKELxI/AAA
import math;f=open('i');r=f.readline
for _ in range(1,int(r())+1):
m=[];s=b=0
for i in range(int(r())):m.append([1 if j=='#' else 0 for j in r()]);s+=sum(m[i])
a=int(math.sqrt(s))
while not filter(None,m[0]):m.pop(0)
l=[i for i,x in enumerate(m[0]) if x];x=l[0];y=l[-1]
for v in m:
if a!=sum(v[x:y+1]):break
else:b+=a
import math
f = open('input.in')
cases = int(f.readline())
for case in range(cases):
m = [ ]
lines = int(f.readline())
# read and convert the matrix
@palcu
palcu / slices.py
Last active December 29, 2015 11:49
# sum up the portion of the matrix where the square
# should be
new_sum = 0
for line in range(sum_on_a_line):
if sum_on_a_line != sum(line[left : right]):
break
else:
new_sum += sum_on_a_line
@palcu
palcu / enumerate.py
Last active December 29, 2015 11:49
# get left right indices
l = [i for i, x in enumerate(m[0]) if x]
left = l[0]
right = l[-1] + 1
# get first row with a black cell
while not filter(None, m[0]):
m.pop(0)
# read and convert the matrix
s = 0
for i in range(lines):
m.append([1 if j == '#' else 0 for j in f.readline()])
s += sum(m[-1])
@palcu
palcu / first.py
Last active December 29, 2015 11:48
import math
f = open('input.in')
cases = int(f.readline())
for case in range(cases):
m = [ ]
lines = int(f.readline())
# read and convert the matrix