virtualenv -p python3 ./env
This file contains 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
# A function that shows the results of running competitions consisting of 2 to 4 runners. | |
def save_ranking(first, second, third=None, fourth=None): | |
rank = {} | |
rank[1], rank[2] = first, second | |
rank[3] = third if third is not None else 'Nobody' | |
rank[4] = fourth if fourth is not None else 'Nobody' | |
print(rank) | |
# Pass the 2 positional arguments | |
save_ranking('ming', 'alice') |
This file contains 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
[ | |
{ | |
"name": "Alberta", | |
"abbreviation": "AB" | |
}, | |
{ | |
"name": "British Columbia", | |
"abbreviation": "BC" | |
}, | |
{ |
This file contains 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
defmodule RobotSimulator do | |
alias RobotSimulator, as: RS | |
... | |
# Simulate robot position advancement | |
defp do_sim(r = %RS{direction: :north, position: {x, y}}, "A"), do: %{r | position: {x, y + 1}} | |
defp do_sim(r = %RS{direction: :east, position: {x, y}}, "A"), do: %{r | position: {x + 1, y}} | |
defp do_sim(r = %RS{direction: :south, position: {x, y}}, "A"), do: %{r | position: {x, y - 1}} | |
defp do_sim(r = %RS{direction: :west, position: {x, y}}, "A"), do: %{r | position: {x - 1, y}} |
This file contains 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
// ==UserScript== | |
// @name Exercism panel expand | |
// @namespace Exercism | |
// @version 0.1 | |
// @description Expand coding panel by hiding the comment panel | |
// @author Tim Austin | |
// @match https://exercism.io/*/solutions/* | |
// @grant none | |
// ==/UserScript== |
This file contains 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 | |
EXERCISES=$(cd exercises; ls -d *) | |
for EXERCISE in $EXERCISES | |
do | |
echo "* Attempting mixify: ${EXERCISE}" | |
./mixify_exercise.sh ${EXERCISE} | |
done |
This file contains 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
# save this in the PATH as docker-clean | |
docker ps -aqf status=exited | |
xargs docker rm | |
docker images -qf dangling=true | |
xargs docker rmi |
This file contains 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
test_results=$(echo "$test_results" \ | |
| grep "* test" \ | |
| sed 's:\r:\n:' \ | |
| awk 'NR % 2 == 1' \ | |
| sed -r "s:\x1B\[31m:$(printf " -- \\033[31mFail\\033[0m"):g" \ | |
| sed -r "s:\x1B\[32m:$(printf " -- \\033[32mPass\\033[0m"):g") |
This file contains 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
defmodule Say do | |
@doc """ | |
Translate a positive integer into English. | |
""" | |
@ones_names %{ | |
1 => "one", | |
2 => "two", | |
3 => "three", | |
4 => "four", |