Skip to content

Instantly share code, notes, and snippets.

View hugot's full-sized avatar

Hugo hugot

View GitHub Profile
#!/usr/bin/env perl
# This is a short script to play rock paper scissors
use strict;
use warnings;
my @rps = qw(rock paper scissors);
my %weakness = (rock => "paper", paper => "scissors", scissors => "rock");
my $score = 0;
my $npcscore = 0;
@hugot
hugot / divisors.sh
Created February 13, 2017 23:09
calculating divisors the bash way
#!/usr/bin/env bash
# This script asks the user for a number and then provides the user with
# all even divisors for it
#----- functions -----
evenDivision() {
local result=$(( $((100 * $1)) / $2))
[[ "${result#*0}" == 0 ]]
}
@hugot
hugot / compare_array.sh
Created February 13, 2017 22:32
another python tutorial in bash :)
#!/usr/bin/env bash
#This script asks the user to provide a number and then compares that number to the numbers in an array
array=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
otherArray=()
echo please provide a number to compare
read number
for ((i=0; i<${#array[@]}; i++)); do
@hugot
hugot / odd.sh
Last active February 13, 2017 20:14
I am doing python tutorials in bash, call me crazy
#!/usr/bin/env bash
#----- Functions -----
divide() {
echo $(( $(($1 * 100)) / $2))
}
multipleOfFour() {
result=$(divide $1 2)
[[ ${result#*0} == *0* ]]
}