Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Advent of Code 2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Regler
Advent of Code 2024
Commits
2a2c5d6c
Commit
2a2c5d6c
authored
8 months ago
by
BoB
Browse files
Options
Downloads
Patches
Plain Diff
Renaming of file day_7
parent
02e7a932
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
day 7/day_7_bob.ipynb
+28
-28
28 additions, 28 deletions
day 7/day_7_bob.ipynb
with
28 additions
and
28 deletions
day 7/day7_bob.ipynb
→
day 7/day
_
7_bob.ipynb
+
28
−
28
View file @
2a2c5d6c
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
...
...
@@ -35,34 +21,48 @@
},
{
"cell_type": "code",
"source": [
"# part 2 (in part 1 skip last case in return statement)\n",
"def solve(x, s, target):\n",
" if not x or s > target: return s == target\n",
" return solve(x[1:], s + x[0], target) or solve(x[1:], s * x[0], target) or solve(x[1:], int(str(s) + str(x[0])), target)\n",
"\n",
"sum(target for target, elements in zip(*readdata('input07.txt')) if solve(elements[1:], elements[0], target))"
],
"execution_count": 16,
"metadata": {
"id": "n41e8HbQgZ7R",
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "n41e8HbQgZ7R",
"outputId": "aca2ad7d-3dcb-400f-99a3-8719bfa8917e"
},
"execution_count": 16,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"162987117690649"
]
},
"execution_count": 16,
"metadata": {},
"
execution_count": 16
"
output_type": "execute_result"
}
],
"source": [
"# part 2 (in part 1 skip last case in return statement)\n",
"def solve(x, s, target):\n",
" if not x or s > target: return s == target\n",
" return solve(x[1:], s + x[0], target) or solve(x[1:], s * x[0], target) or solve(x[1:], int(str(s) + str(x[0])), target)\n",
"\n",
"sum(target for target, elements in zip(*readdata('input07.txt')) if solve(elements[1:], elements[0], target))"
]
}
]
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment