From: Brett Parker Date: Mon, 14 Dec 2020 13:17:29 +0000 (+0000) Subject: Day 14 - implemented in bash, because, well, I could X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/commitdiff_plain/c526bc47733dd9abefd93635326c58344966878f?ds=inline;hp=61a73a00535337fa5b2780440d643052877ca036 Day 14 - implemented in bash, because, well, I could --- diff --git a/day14/dockingdata.sh b/day14/dockingdata.sh new file mode 100755 index 0000000..2cb150b --- /dev/null +++ b/day14/dockingdata.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +filename="${1:-p1_165.txt}" + +declare -A mem + +parse_line() { + line="$1" + key=${line% = *} + value=${line#* = } + + if [ $key == "mask" ]; then + mask_part1=${value//X/0} + mask_part2=${value//1/X} + mask_part2=${mask_part2//0/1} + mask_part2=${mask_part2//X/0} + else + # it's a memory instruction, yay + loc=${key%]} + loc=${loc#*[} + value=$((value | 2#$mask_part1)) + value=$(( ~ $value & (2**36)-1 )) + value=$((value | 2#$mask_part2)) + value=$(( ~ $value & (2**36)-1 )) + mem[$loc]=$value + fi +} + +exec 3<"$filename" +while read -u 3 line; do + parse_line "$line" +done + +total=0 +for key in ${!mem[@]}; do + total=$((total+${mem[$key]})) +done + +echo "Total: $total" diff --git a/day14/dockingdata_v2.sh b/day14/dockingdata_v2.sh new file mode 100755 index 0000000..08aed81 --- /dev/null +++ b/day14/dockingdata_v2.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +filename="${1:-p2_208.txt}" + +declare -A mem + +parse_line() { + local line="$1" + local key=${line% = *} + local value=${line#* = } + declare -g cur_mask + local base_mask + local mask + + if [ $key == "mask" ]; then + cur_mask=$value + else + # it's a memory instruction, yay + unset masks + get_masks $base_mask + + loc=${key%]} + loc=${loc#*[} + base_mask=$(get_base_mask $cur_mask $loc) + unset masks + get_masks $base_mask + for mask in "${masks[@]}"; do + loc=$(get_value $mask $loc) + mem[$loc]=$value + done + fi +} + +get_base_mask() { + local mask=$1 + local value=$2 + local newmask="" + + # here we literally translate the string to contain X if + # it's an X, and then check against the value and if either + # value or mask has a 1 in that position set it to 1 other + # wise set it to 0 + for (( a=0; a<36; a++ )); do + if [ ${mask:$a:1} == "X" ]; then + newmask+="X" + elif [ ${mask:$a:1} -eq 1 ] || [ $((value & 2**(35-$a))) -gt 0 ]; then + newmask+="1" + else + newmask+="0" + fi + done + + echo $newmask +} + +get_masks() { + local string="$1" + local test="${string/X/b}" + local mask1 + local mask2 + declare -g -a masks + + if [ "$string" == "$test" ]; then + masks+=( $string ) + return 0 + fi + + # do the 2 potential replacements and run them through + mask1=${string/X/1} + get_masks $mask1 + mask2=${string/X/0} + get_masks $mask2 +} + +get_value() { + local mask="$1" + local value="$2" + local mask_part1=${mask//X/0} + local mask_part2=${mask//1/X} + mask_part2=${mask_part2//0/1} + mask_part2=${mask_part2//X/0} + value=$((value | 2#$mask_part1)) + value=$(( ~ $value & (2**36)-1 )) + value=$((value | 2#$mask_part2)) + value=$(( ~ $value & (2**36)-1 )) + echo $value +} + +exec 3<"$filename" +while read -u 3 line; do + parse_line "$line" +done + +total=0 +for key in ${!mem[@]}; do + total=$((total+${mem[$key]})) +done + +echo "Total: $total" diff --git a/day14/input.txt b/day14/input.txt new file mode 100644 index 0000000..e7977bf --- /dev/null +++ b/day14/input.txt @@ -0,0 +1,576 @@ +mask = 00110X11X0000110X0000001000111010X00 +mem[39993] = 276 +mem[23021] = 365 +mem[59102] = 45645 +mem[30606] = 2523 +mem[38004] = 4503 +mem[47790] = 1221939 +mem[24194] = 3417 +mask = 00X10011000001X00X1010XX11X000011000 +mem[61385] = 13441 +mem[44092] = 46615 +mem[14640] = 11081 +mask = 100X01110X000110XX11X100X0111000XX01 +mem[14433] = 189475544 +mem[64841] = 3883 +mem[4069] = 144204 +mem[5170] = 5792 +mem[25427] = 1964230 +mask = 0110100100000000X00X000000010X0X1011 +mem[35438] = 52679760 +mem[34307] = 9317256 +mem[6470] = 209486 +mem[26430] = 534922265 +mask = 00X1X0X10000X11001100011X01X1X0X110X +mem[41736] = 426776809 +mem[25126] = 35833440 +mem[11780] = 753 +mask = 00110X11000XXXX0110XX00X000001110101 +mem[57910] = 364 +mem[62893] = 40679789 +mem[35161] = 14855 +mem[58135] = 811747892 +mem[4593] = 5704 +mem[19917] = 426377 +mem[10939] = 13720296 +mask = 01110011X0XX001X01100110101000111X00 +mem[49208] = 3791 +mem[5202] = 64942111 +mem[11788] = 756 +mem[29268] = 23261551 +mask = 0X110011X0000X1001100010001X001110X0 +mem[11306] = 51811618 +mem[39974] = 1197590 +mem[31813] = 5989606 +mem[21215] = 25665 +mem[11780] = 69453544 +mem[39432] = 974 +mem[51730] = 1753761 +mask = 01111X11X010X1101011X10000011000101X +mem[57467] = 303811 +mem[3619] = 43533 +mem[24649] = 65 +mem[57938] = 673428 +mem[35983] = 762324 +mem[53753] = 220608750 +mem[56343] = 20780764 +mask = 00X0100X00110X110101010110000X011101 +mem[15325] = 582 +mem[56283] = 3587012 +mem[17506] = 5008610 +mem[23689] = 699422813 +mem[58192] = 184520 +mem[11790] = 280477068 +mask = 000X00010001X1X011001X1111X101010100 +mem[12126] = 1370 +mem[19917] = 798054 +mem[16463] = 81889099 +mem[19502] = 1208125 +mem[62502] = 28996053 +mem[59832] = 11583256 +mem[62653] = 41447256 +mask = 0XX1X0010000011X01001101X11100011X01 +mem[3474] = 29351 +mem[48682] = 118578 +mem[5119] = 7070455 +mask = X011101101000110011010X10X10001X1010 +mem[26228] = 42448 +mem[4405] = 165485096 +mem[19948] = 495733 +mem[19917] = 950689 +mem[1342] = 3928 +mask = 00XX00110000001X01X000XXXX00011010X0 +mem[12742] = 190173218 +mem[16011] = 78978 +mem[8444] = 1013 +mask = 00111111000000101000110XX0X001X10010 +mem[15064] = 4146529 +mem[5074] = 1944 +mem[30343] = 850813 +mask = XX1100110X000XX0001000X0X000X0000101 +mem[18316] = 8163 +mem[64715] = 15571290 +mem[1214] = 1713 +mem[61047] = 64709 +mem[20756] = 1147352 +mask = 00110001000X0X10011X001X10001X0X1101 +mem[3681] = 850069711 +mem[5973] = 1125998 +mask = X001X0X1000000100100X00101100XX100X0 +mem[1929] = 14146987 +mem[13059] = 8779 +mem[42005] = 567 +mem[60928] = 265 +mask = 001X00110000X110101000100X00X10X1XXX +mem[13504] = 14255518 +mem[51994] = 233872 +mem[10991] = 973591 +mem[35474] = 24432220 +mask = 00110XXX00010X1011010X010X0X1101X10X +mem[4192] = 110876960 +mem[4950] = 94274 +mask = 1001001X000000100X00X0X1011110011001 +mem[45254] = 108909 +mem[1243] = 42640 +mem[11540] = 1287588 +mem[1435] = 101075962 +mem[55422] = 2489605 +mem[27943] = 237052 +mem[13919] = 322879 +mask = 001110XX0X1111100001X1011001X001X0XX +mem[22850] = 20403 +mem[5085] = 699192 +mem[795] = 12220 +mem[15000] = 533734472 +mem[24156] = 1559 +mem[58987] = 30566 +mask = 0X11XX1100000X10X0XX10101X1010X11000 +mem[45569] = 409625967 +mem[57938] = 65950 +mem[51493] = 15020 +mem[3658] = 49142096 +mem[61554] = 1715 +mem[21280] = 62875 +mask = 001100X10X000010010010101110XX000010 +mem[13312] = 180240 +mem[18063] = 163048 +mem[61345] = 3681 +mem[19515] = 70772 +mask = 0011X01X0X000XX001101001001000001100 +mem[8507] = 831 +mem[30799] = 3945225 +mem[43021] = 38069025 +mem[8616] = 6336 +mem[42508] = 3881 +mem[45701] = 291464663 +mask = 11110XX10X000X100010X000000000X000X0 +mem[59117] = 1890 +mem[15170] = 9191049 +mem[25487] = 1912118 +mem[55290] = 37016118 +mem[59202] = 1014 +mem[59954] = 2563775 +mask = 000X0001X00100100100X010X110100X0011 +mem[4836] = 7617 +mem[47275] = 2228407 +mem[65165] = 1522 +mask = X01110110XX00110011000110000100011X0 +mem[7621] = 296673 +mem[17506] = 16935 +mem[63093] = 3615 +mem[11916] = 621 +mem[28656] = 680078 +mask = X1110011000001X0XX1001X00011X0XX1010 +mem[34586] = 30085 +mem[16813] = 2168 +mem[34601] = 35895 +mem[24803] = 5778196 +mem[35258] = 821331 +mem[14101] = 211836855 +mask = X01101110X00011X000X100101X1X110XXX0 +mem[33761] = 33198459 +mem[22161] = 321 +mem[51493] = 46379 +mem[1690] = 31082 +mem[56363] = 2140768 +mem[32820] = 2372 +mask = 100X001X00010110X1X0000X10101001111X +mem[37121] = 41426 +mem[54579] = 1404300 +mem[30203] = 13421546 +mem[8416] = 97191816 +mem[11543] = 400 +mem[54537] = 3977 +mask = 1X11X0X10000010011X0011X1X1XX0111000 +mem[43930] = 2943829 +mem[55989] = 980 +mem[40086] = 3544935 +mem[15470] = 20240516 +mem[55262] = 2905 +mask = 001100110000X1100X10X01XX00X100100X1 +mem[31135] = 253828651 +mem[24090] = 678221 +mem[60327] = 97259969 +mem[55343] = 15817621 +mem[40424] = 5231731 +mem[46338] = 66393 +mask = 0X1111110X00X0XX0X111111101X1011100X +mem[57938] = 168093095 +mem[65010] = 124 +mem[824] = 949416 +mem[33479] = 59626746 +mem[12404] = 255489211 +mem[48500] = 1887 +mask = 0010100X00110X1XX101X0X111X001001001 +mem[61047] = 1737698 +mem[51408] = 214082306 +mem[12504] = 12416442 +mask = 001X100100X1X1100X01X0111X1X1X0110X1 +mem[63754] = 33335770 +mem[18348] = 859493 +mem[58299] = 1250593 +mem[5451] = 921477 +mem[45756] = 2133 +mask = 0X1XX001X00000X00X001000X100X00010X1 +mem[1821] = 128635964 +mem[23027] = 875178 +mem[33673] = 649 +mem[26141] = 99067 +mask = 101101110XX10110X0100X00001001110X01 +mem[33831] = 618529 +mem[25128] = 991279383 +mask = 00X1100000101X10X1XX1101010XX1X00100 +mem[63253] = 268 +mem[52232] = 216465 +mem[42043] = 5905706 +mem[8751] = 132566 +mask = XX110011X000011001X001000X00X0001010 +mem[63384] = 1706 +mem[1762] = 161 +mem[59954] = 1850009 +mask = 00111X01X0001110X11010111X1111001XX0 +mem[54740] = 30662 +mem[2700] = 1281 +mem[21215] = 335 +mem[28127] = 13197 +mem[44108] = 4437085 +mem[11384] = 823 +mem[17046] = 8187086 +mask = 00X10010010001X001X0010110X110111000 +mem[40883] = 16674851 +mem[46228] = 2507 +mem[26744] = 1863 +mask = X00XX011000000100100000X0011X1100011 +mem[36388] = 3511 +mem[14194] = 12399516 +mem[23021] = 124697 +mask = 000110010001X1X001X100000X110X0X0000 +mem[48126] = 883934 +mem[33479] = 97083 +mem[33726] = 25752888 +mem[23103] = 6517 +mem[14640] = 2093310 +mask = 00110X1101X0X111000100XX000XX0010110 +mem[34550] = 61257 +mem[7986] = 1426 +mem[22379] = 13364 +mask = 0001001X0X00011001000100XX0X1110XXX0 +mem[22026] = 85877539 +mem[47661] = 14501 +mem[1342] = 1445 +mem[32088] = 3647786 +mask = 10010011000XX0100X100000X0001X011010 +mem[24227] = 10435012 +mem[58203] = 670756 +mem[21449] = 164149 +mask = X011010X0000X1000001001XX000X0001001 +mem[41589] = 24160 +mem[15421] = 273923 +mem[25992] = 3492 +mem[64180] = 466 +mem[5022] = 487154 +mem[37319] = 3415593 +mask = XX1X0001000001110100010X10X010110101 +mem[56949] = 5258979 +mem[11118] = 511 +mem[15407] = 68406 +mem[28684] = 1830666 +mem[40414] = 579757347 +mask = X01101X1000001X00X0100X1010X100X1X00 +mem[43416] = 11 +mem[26901] = 961 +mem[1243] = 157807197 +mem[36027] = 19575946 +mem[35438] = 2032 +mem[38761] = 785 +mask = 00110011X0000110000000X010X0010100X0 +mem[23936] = 131273 +mem[32250] = 103180884 +mem[24677] = 857528 +mem[63384] = 28869743 +mem[59102] = 16387091 +mem[3728] = 1554 +mask = 00111X110XX00110X1101101101010010010 +mem[33309] = 28221348 +mem[48561] = 2083820 +mem[46739] = 8163 +mem[33761] = 127116816 +mask = 011XX111X0X00110101X00X0X00010001XX0 +mem[12742] = 132493 +mem[43900] = 88228616 +mem[63861] = 1437 +mem[5451] = 720 +mem[35578] = 2817839 +mask = XXX1001XX10X0000001010100110X0X10111 +mem[58454] = 76647097 +mem[29150] = 944 +mask = X01X01110000011100000XXX000X11100100 +mem[60923] = 22109903 +mem[38868] = 106087 +mem[17765] = 119357 +mask = 0X0111X1X00X0010010110XX1X0101X1001X +mem[62893] = 50 +mem[49594] = 5927931 +mem[13666] = 1327697 +mask = 1X01001000XX0110001011X001X1010X01X0 +mem[16472] = 13341 +mem[45283] = 3714606 +mem[6470] = 18908 +mask = X011011101X0011100X1X1000X10101011X1 +mem[14618] = 8208185 +mem[18071] = 443979262 +mem[37845] = 1669414 +mem[61643] = 645819046 +mem[16813] = 2459221 +mem[19338] = 2679 +mask = 0X11111X0X001X0X0X111X1110101100X00X +mem[16170] = 28844 +mem[14304] = 619904 +mem[49274] = 357683641 +mem[16557] = 530 +mem[27360] = 1888 +mask = 00110011000001100XX00X0X0110X00X1XX0 +mem[17819] = 761 +mem[60100] = 35804 +mem[45183] = 27290500 +mem[6470] = 43199598 +mem[47790] = 267 +mem[27203] = 514 +mem[29139] = 233 +mask = X1X10111110X0X10101X11XX10001X0101X1 +mem[58246] = 671 +mem[62565] = 8080 +mem[61223] = 7938455 +mem[15182] = 14008978 +mem[7671] = 80450 +mem[2177] = 31228566 +mask = 00110X1X0100011X000100000100111010X1 +mem[37293] = 15109044 +mem[35385] = 6191200 +mask = 00011XX100010X10X101X0X0000101110XX0 +mem[4719] = 28188 +mem[15398] = 1042847981 +mem[3265] = 866517 +mask = 0X11X0110000011001101110X1100X11XX1X +mem[23021] = 14305158 +mem[8507] = 975 +mem[3730] = 9185151 +mem[53044] = 10995 +mem[45498] = 90339105 +mem[48682] = 63450985 +mask = X0110011X0000110001001001X11110110X0 +mem[23188] = 49324288 +mem[63384] = 78110998 +mem[44309] = 96353816 +mem[56415] = 3693910 +mask = 0010100100111X100001011XX010X0010X00 +mem[58071] = 226920 +mem[15001] = 62196 +mem[19406] = 6446 +mem[48757] = 214 +mem[1588] = 4269459 +mask = 10110X11X00001100010011XX10011XXX001 +mem[45262] = 898066400 +mem[32757] = 128312164 +mem[51994] = 47881 +mem[47628] = 4260948 +mem[8616] = 26844 +mem[56654] = 6502607 +mask = 00010001000000100X0001XXX1XX010X1101 +mem[51090] = 71071 +mem[56791] = 999397616 +mem[32678] = 1006 +mem[61864] = 198837 +mem[22106] = 1085 +mem[40441] = 407881805 +mask = 0111X11100100X10X011X0X100010100X111 +mem[17898] = 65188 +mem[48736] = 9807 +mem[3265] = 77937 +mem[12945] = 12393 +mem[30805] = 5328372 +mem[33309] = 874 +mask = 01X1101100X00X10X00110111X0011111X10 +mem[28288] = 6469 +mem[46228] = 417227912 +mem[54160] = 14918153 +mem[25407] = 761 +mem[25075] = 154341 +mask = 00XX1001X001111001010X0X000100X1X000 +mem[54263] = 59757 +mem[56693] = 431013 +mem[4214] = 91351325 +mem[31232] = 43516 +mem[37563] = 30520 +mem[47761] = 11088 +mem[23142] = 41590584 +mask = 0111011X1XX00110X01X10X01000XXX00101 +mem[53694] = 109623913 +mem[18737] = 615 +mem[2947] = 1300365 +mem[34516] = 872678 +mem[55345] = 36487080 +mem[60504] = 8609 +mask = 10X10X11000X0X1X001X0X00001X0000X011 +mem[8123] = 61329 +mem[27793] = 505707 +mem[50807] = 20350526 +mem[671] = 7492988 +mem[24879] = 1834 +mask = 101100110X00011X0X001100X1101010X101 +mem[23372] = 490861 +mem[34213] = 18446 +mem[46919] = 12820036 +mem[1037] = 94 +mem[59289] = 5698817 +mem[9246] = 6369951 +mem[44175] = 1022 +mask = 00X1100X00X011100XX010X11X00X1001100 +mem[15244] = 150895487 +mem[4382] = 2034 +mem[23689] = 13824429 +mem[53832] = 66 +mem[60616] = 8670 +mask = 01110X010000010101000X0X01001111X101 +mem[61442] = 31208 +mem[24575] = 58731 +mem[3794] = 65157 +mem[47566] = 717369 +mask = 00110011000X01X00010010X0X1X1X011XX0 +mem[43732] = 558 +mem[54174] = 199024688 +mem[16067] = 21241 +mem[47566] = 35858 +mem[38280] = 58237 +mem[29588] = 68845 +mask = 01X11XX10000011010X10010000011X01010 +mem[12554] = 11888832 +mem[36307] = 3774 +mem[15027] = 3330 +mask = 0X111111100X0X1010X10001010000001001 +mem[4544] = 214688486 +mem[41589] = 551947 +mem[17831] = 7102892 +mem[6419] = 6209 +mem[51730] = 136655518 +mask = 01110XX10000011001XX11111X01X11100X0 +mem[18280] = 4784 +mem[52507] = 1422040 +mem[37826] = 32 +mem[56693] = 2071 +mask = 1001X0110000X1100X0X1XX0101X10101X00 +mem[6048] = 404771 +mem[29139] = 805240 +mem[43827] = 850198 +mask = 1011X01X01000000001X000000X01X111011 +mem[5784] = 5804365 +mem[24803] = 11278142 +mem[4069] = 599 +mem[46705] = 4208955 +mem[24156] = 8304 +mem[1037] = 491457387 +mem[58203] = 2637430 +mask = 0XX1X00100010110X10X00010011X1X10X01 +mem[63802] = 17278483 +mem[1435] = 40050 +mem[39638] = 84832833 +mem[59545] = 11052657 +mem[671] = 81865 +mask = X01100110000X110011001100XX011011000 +mem[23936] = 91965703 +mem[42570] = 9138 +mem[40640] = 198926 +mem[35396] = 130233 +mem[13312] = 1566 +mask = XX010111000X0110X01101001100001XXX11 +mem[45594] = 215458 +mem[19244] = 32591 +mem[24193] = 42172 +mem[49817] = 2028 +mask = 0011X01100X0011XX0X00111011001001010 +mem[27713] = 3933 +mem[31764] = 1123 +mem[27360] = 7350 +mem[17819] = 370397713 +mask = 00X1001XX10001X0010X0111001XX110X001 +mem[10544] = 8239404 +mem[26653] = 435 +mem[28032] = 7113 +mem[31135] = 440352137 +mem[18852] = 107163784 +mem[62121] = 75937434 +mask = X0X100X1000X0X100100000X01101XX01011 +mem[13423] = 135389 +mem[53044] = 5752 +mem[40299] = 71200 +mem[16067] = 8902343 +mem[63631] = 620503 +mem[5074] = 6398 +mask = XX1X001100X001100X101X1X11X00101111X +mem[49782] = 116187 +mem[55567] = 18423 +mem[27243] = 94093 +mem[10700] = 1629004 +mem[27260] = 846554 +mask = 1XX10011000001X0010011X0110X10001X0X +mem[37121] = 23863458 +mem[32680] = 93207 +mem[14763] = 743440178 +mem[17125] = 6145 +mem[35256] = 8386766 +mem[34491] = 500 +mask = 01110XX1000001XX0100X10X1010X111X000 +mem[23599] = 12706141 +mem[41736] = 142454 +mem[53248] = 32654570 +mem[49974] = 5849425 +mem[31261] = 235163561 +mem[58224] = 195171 +mask = 000100010X01011X110000X1X01XX1011111 +mem[1891] = 122340 +mem[7977] = 3547751 +mem[64715] = 5987 +mem[65347] = 142696506 +mask = 0X1100X10XX1011X01X00000111011101101 +mem[40640] = 364032486 +mem[26393] = 19961298 +mem[10444] = 29458337 +mem[7908] = 7672 +mem[39989] = 26162 +mask = 1XX1001X0000X110001001X001X1X0X1101X +mem[30901] = 220690365 +mem[23027] = 223104229 +mem[30343] = 128442725 +mem[49886] = 27135842 +mem[34353] = 3523425 +mem[7277] = 711863 +mask = 1XX100100100000000X0101X01100X100111 +mem[50807] = 39698 +mem[44788] = 7177995 +mem[33750] = 114972 +mem[38868] = 170666 +mask = 1011001000001X1000X0X00000X1X1111011 +mem[59642] = 2340 +mem[64014] = 57896 +mem[50588] = 1014812 +mask = 0X100111X010011010X110100001111X1000 +mem[45498] = 1948666 +mem[15407] = 4448778 +mem[63541] = 799098 +mem[61798] = 8671931 +mem[5880] = 16223788 +mem[29467] = 235434 +mem[13444] = 50684587 +mask = 01X101X1000X0X100111110110010110X011 +mem[40727] = 112801751 +mem[41331] = 174 +mask = 011110110000X01000010010001X1000X0X0 +mem[28796] = 2129 +mem[671] = 406992 +mem[13709] = 920 +mem[35056] = 1781 +mem[39993] = 12612 +mask = 00X11111X0000X1X1000X111101110X11000 +mem[33221] = 354442 +mem[17428] = 491 +mem[51456] = 16477783 diff --git a/day14/p1_165.txt b/day14/p1_165.txt new file mode 100644 index 0000000..e15150a --- /dev/null +++ b/day14/p1_165.txt @@ -0,0 +1,4 @@ +mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X +mem[8] = 11 +mem[7] = 101 +mem[8] = 0 diff --git a/day14/p2_208.txt b/day14/p2_208.txt new file mode 100644 index 0000000..2e961e3 --- /dev/null +++ b/day14/p2_208.txt @@ -0,0 +1,4 @@ +mask = 000000000000000000000000000000X1001X +mem[42] = 100 +mask = 00000000000000000000000000000000X0XX +mem[26] = 1