Time after time I write technical blogs and articles that describe and
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
# | |
# This is a recursive solution of Problem B, Manage your Energy, | |
# of Round 1B 2013 on Google CodeJam. | |
# | |
# * Problem description: | |
# https://code.google.com/codejam/contest/2418487/dashboard#s=p1&a=1 | |
# * Solution Description: | |
# https://code.google.com/codejam/contest/2418487/dashboard#s=a&a=1 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
# | |
# This is a fast, linear solution (complexity O(N)) of Problem B, | |
# Manage your Energy, of Round 1B 2013 on Google CodeJam. | |
# | |
# * Problem description: | |
# https://code.google.com/codejam/contest/2418487/dashboard#s=p1&a=1 | |
# * Solution Description: | |
# https://code.google.com/codejam/contest/2418487/dashboard#s=a&a=1 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solution to the problem B of Round1B of CodeJam: | |
# https://code.google.com/codejam/contest/2434486/dashboard#s=p1 | |
# Number of diamonds on a piramid of 'i' full layers. | |
def f(i) | |
2*i*i + 3*i + 1 | |
end | |
# Find the layers of the full piramid. | |
def find_i(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solution for Problem A (Osmos), of Round1B, CodeJam 2013: | |
# https://code.google.com/codejam/contest/2434486/dashboard#s=p0 | |
def solve(a, mots) | |
# If the list of mots is empty, we are done. | |
return 0 if mots == [] | |
# If a is 1, the only way to make it solvable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem A. Consonants, of Round 1C 2013, of CodeJam | |
# https://code.google.com/codejam/contest/2437488/dashboard#s=p0 | |
$vowels = ['a', 'e', 'i', 'o', 'u'] | |
def vowel?(c) | |
$vowels.include?(c) | |
end | |
def consonant?(c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem A. Consonants, of Round 1C 2013, of CodeJam | |
# https://code.google.com/codejam/contest/2437488/dashboard#s=p0 | |
$vowels = ['a', 'e', 'i', 'o', 'u'] | |
def vowel?(c) | |
$vowels.include?(c) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Setup a wifi Access Point on Ubuntu 12.04 (or its derivatives). | |
### make sure that this script is executed from root | |
if [ $(whoami) != 'root' ] | |
then | |
echo " | |
This script should be executed as root or with sudo: | |
sudo $0 | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 1em; | |
border-right: 5px solid #bbb; | |
border-bottom: 5px solid #bbb; | |
padding: 0; | |
background: #ddd none repeat scroll 0 0; | |
border: 1px solid #000; | |
margin: 0; | |
padding: 2em; | |
color: #000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rawurlencode() { | |
local string="${1}" | |
local strlen=${#string} | |
local encoded="" | |
for (( pos=0 ; pos<strlen ; pos++ )); do | |
c=${string:$pos:1} | |
case "$c" in |
OlderNewer