Skip to content

Commit

Permalink
WIP: feat: Start 2024/22 part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleCJ committed Dec 25, 2024
1 parent bc5d5ad commit 278b1fd
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions 2024/22/code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,124 @@
"# print(downloaded['input'])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"bin(123)='0b1111011'\n"
]
}
],
"source": [
"# In particular, each buyer's secret number evolves into the next secret number \n",
"# in the sequence via the following process:\n",
"# Calculate the result of multiplying the secret number by 64. Then, mix this \n",
"# result into the secret number. Finally, prune the secret number.\n",
"# Calculate the result of dividing the secret number by 32. Round the result down\n",
"# to the nearest integer. Then, mix this result into the secret number. Finally, prune the secret number.\n",
"# Calculate the result of multiplying the secret number by 2048. Then, mix this\n",
"# result into the secret number. Finally, prune the secret number.\n",
"\n",
"# Each step of the above process involves mixing and pruning:\n",
"# To mix a value into the secret number, calculate the bitwise XOR of the given\n",
"# value and the secret number. Then, the secret number becomes the result of that\n",
"# operation. (If the secret number is 42 and you were to mix 15 into the secret\n",
"# number, the secret number would become 37.)\n",
"# To prune the secret number, calculate the value of the secret number modulo\n",
"# 16777216. Then, the secret number becomes the result of that operation. (If the\n",
"# secret number is 100000000 and you were to prune the secret number, the secret\n",
"# number would become 16113920.)\n",
"\n",
"print(f'{bin(123)=}')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0b1000000'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bin(64)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0b1111010111011'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bin(123*64^123)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0b100000\n"
]
}
],
"source": [
"len(bin(16777216))\n",
"print(bin(32))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0b1111011\n",
"0b1111010111011\n",
"0b1111001001110\n"
]
}
],
"source": [
"a=123\n",
"print(bin(a))\n",
"b=123*64^123\n",
"print(bin(b))\n",
"c=b//32^b\n",
"print(bin(c))"
]
},
{
"cell_type": "code",
"execution_count": 9,
Expand Down

0 comments on commit 278b1fd

Please sign in to comment.