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
extension Array where Element == Int { | |
struct difference { | |
var added: [Int] | |
var removed: [Int] | |
} | |
func diff(from arr: [Int]) -> Array.difference? { | |
if Set(self) == Set(arr) { | |
return nil | |
} |
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
func left_slide(_ arr: [Int]) -> [Int] { | |
// Check if arr is empty | |
if arr.isEmpty { return [] } | |
// Make arr mutable | |
var mutable_arr : [Int] = [] | |
// Seperate 0's and other numbers | |
var zero_arr = arr.filter{$0 == 0} | |
mutable_arr = arr.filter{$0 != 0} |
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
from argparse import ArgumentParser | |
# Parse args | |
parser = ArgumentParser(description='Pyramide Calc') | |
parser.add_argument('n', help='Highest number of hits', type=int) | |
args = parser.parse_args() | |
n = args.n | |
# Sums all numbers from 1 to n |