#!/usr/bin/env bash

taskset -p $$ | sed -e 's/^.*: //' | awk '
    BEGIN {
        split("0 1 2 3 4 5 6 7 8 9 a b c d e f", hex_chars, " ")
        split("0 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4", vals, " ")
        for (i in hex_chars) {
            ones[hex_chars[i]] = int(vals[i])
        }
        total = 0
    }

    {
        split($0, chars, "")
        for (i in chars) {
            if (chars[i] in ones) {
                total += ones[chars[i]]
            }
        }
        print total
    }
'


# 0 0000 0
# 1 0001 1
# 2 0010 1
# 3 0011 2
# 4 0100 1
# 5 0101 2
# 6 0110 2
# 7 0111 3
# 8 1000 1
# 9 1001 2
# a 1010 2
# b 1011 3
# c 1100 2
# d 1101 3
# e 1110 3
# f 1111 4

