Skip to content

Instantly share code, notes, and snippets.

View Tohr01's full-sized avatar
:octocat:
Time to get SWIFTy

Carl Tohr01

:octocat:
Time to get SWIFTy
  • Hamburg, Germany
  • 22:20 (UTC +02:00)
View GitHub Profile
@Tohr01
Tohr01 / diff.swift
Created July 31, 2022 21:20
Swift Array<Int> custom diff
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
}
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}
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