From 8690c489ff0a3469a001132803bd5f3ea6da68e3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 23 Oct 2021 15:35:21 +0200 Subject: yggdrasil-wg: ... --- accounts/gkleen@sif/zshrc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'accounts') diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 9fe88163..bcdc662a 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -399,6 +399,23 @@ ssh-installer() { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ } +dichotomic_search() { + min=$1; shift + max=$1; shift + + while [[ $min -lt $max ]]; do + # Compute the mean between min and max, rounded up to the superior unit + current=$(( (min + max + 1 ) / 2 )) + if $@ $current; then + min=$current + else + max=$((current - 1)) + fi + done + + echo $min +} + alias '..'='cd ..' alias -g L='| less' alias -g S='&> /dev/null' -- cgit v1.2.3