[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: aoc.jpg (252 KB, 2048x1365)
252 KB
252 KB JPG
Find the digit at position `k` in a string consisting of numbers (1, 1e18] appended in increasing order, i.e.:
123456789101112131415161718192021222324...

Constraint: 1 <= k <= 1e18

Example 1: input: 20, output: 1
Example 2: input: 123, output: 6
Example 3: input: 5318008, output: 9
Example 4: input: 1000000000000000000, output: 3

Your Input: 560981764105518902

You will be able to save Christmas, right anon?
>>
File: jenkem.jpg (83 KB, 800x1130)
83 KB
83 KB JPG
Can't wait for jeets to get the first 100 leaderboard spots with sub-10 second times because they all used chatgpt or github autopilot.
>>
>>103232556
won't be a problem after day 5
eric will just require the solution be derived from a world model, which makes it impossible for an LLM to solve
>>
>>103232542
5
sixth digit of 33652522071566471
>>
>>103232635
5 is correct
>>
>>103232640
yeah fuck off now
>>
FIRE FIRE LIGHT THE FIRE
>>
>>103232688
i'll be back in 6 days and post something harder
you are todays goodest goy
>>
>>103232542
your problem/examples doesn't make any sense, fuck you
>>
>>103232765
in the string - which is too big to actually store in memory - find the digit at position `k` (1-indexed)
so for index 20:
123456789101112131415161718192021222324...
^
>>
File: day1gbavfc.webm (183 KB, 1228x532)
183 KB
183 KB WEBM
Implemented double dabble for binary to BCD conversion. My old method (a LUT) was ending up slower than the FC solution (because it was doing more work per frame which overcomes the CPU difference).
>>
How many people here seriously care about the leaderboard? Seems really stressful
>>
>>103232556
I used chatgpt to ask syntax
>>
>>103232542
I don't even understand the assignment
numbers appended in increasing order?? but some numbers are smaller than others in the example
what does 1e18 even mean? is this some autistic math expression?
why does 20 give 1, and 123 give 6? none of this makes sense or even remotely explained
>find the output of this blackbox function that I just made up xdd
>>
>>103233669
>How many people here seriously care about the leaderboard?
Approximately 0.
>>
>>103233693
>but some numbers are smaller than others in the example
It's like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 etc without spaces, and it goes to 1^18
20 gives 1 because the first digit of 15 is in the 20th position.
>>
>>103233693
>why does 20 give 1
1 is the 20th character in 123456789101112131415...
>>
>>103233729
>1^18
that's 1 you idiot
>>
>>103233737
Yes. I am an idiot.
>>
File: ez.png (25 KB, 368x626)
25 KB
25 KB PNG
>>103232542
5
>>
>>103232542
No, I don't even understand what you are asking from me
>>
>>103233669
i'd like to get on it one day just for the sake of it
>>
>>103233811
similar to mine:
cache = [None] # index of 1st i-digit number
tmp = 1
for p in range(1, 18+1):
cache.append(tmp)
tmp += p * 9 * 10 ** (p - 1) # 1*9, 2*90, 3*900, ...

k = int(input())
for i in range(1, 18+1):
if cache[i+1] > k:
k -= cache[i]
print(str(10 ** (i - 1) + k // i)[k % i])
break
>>
I won't participate because now after work the last thing I want to do is more coding
>>
>>103233669
>How many people here seriously care about the leaderboard? Seems really stressful
We only have one guy good enough for the global leaderboard. Competing for the top 3 of the 4chan leaderboard can be fun. I've never been first, but I've been second and third a few times.
>>
>>103232542
you should have made the problem be
>string consisting of numbers: 0123456789101112131415161718192021222324...
>0-based index
your problem statement makes the solution dirty for no reason
>>
>>103233811
Very impressive, may I ask why you learned bc?
>>
should i learn a new language this year
or stick with good ol reliable
>>
>>103233693
>why does 20 give 1, and 123 give 6?
yeah honestly 20 should give 2 as far i as can tell. Because 2 and 20?
unless we dont count the first number in the sequence, only how many bigger numbers we can interpret from its position, but then 123 = 6 would be wrong. 1, 2, 3, 12, 23, 123 which is 6 but if we dont count the first number then it should be 5.
>>
>>103238713
in the string - which is too big to actually store in memory - find the digit at position `k` (1-indexed)
so for index 20:
numbers (1, 1e18]: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
appended: 123456789101112131415161718192021222324...
^
|
+--- 1 is the 20th digit in the string
>>
File: web.png (77 KB, 1156x1292)
77 KB
77 KB PNG
The elves, having been busy fucking everything up for the last 9 years, have neglected sanitary conditions at santa's workshop and now you have a critical fly problem. To manage the flies the elves have brought in some spiders but they need you to install them in the workshop's spider web. The spiders must each be placed at a node in the web and each node will allow a spider to capture a different number of flies per day. You may place any number of spiders in the web however no more than one spider can occupy each node and no two adjacent nodes can have spiders occupying them or the spiders will try to eat one another. The web (your puzzle input) is represented as a table of node ID, flies that can be caught per day at that node and connected nodes. What is the maximum number flies the spiders can catch in the given web?

Example input: https://0x0.st/XnSG.org
Solution: 3147

input: https://0x0.st/XnSD.org
>>
>>103240190
thinking of tackling this as a bitmask dp problem
2^30 is scary, but at most half the nodes can be picked? so i'm thinking it's more like 2^15
>>
>>103240190
6746
>>
>>103240591
Correct.
>>
>>103238121
Do it in Lisp
>>
File: flies.png (116 KB, 1016x934)
116 KB
116 KB PNG
Cleaned up the original solution from >>103240591 a bit.
>>
>>103242011
post unwashed ass please
>>
>>103233669
prob none, I'm in for the rush of just completing it all
>>
>>103242011
holy shit how do you manage to make python an unreadable mess?
>>
>>103242582
you don't know python as well as you think you do
>>
>>103242643
nta but it IS an unreadable mess
>>
>>103242657
you don't know python as well as you think you do
>>
>>103242582
>>103242657
How is THAT an unreadable mess?
>>
>>103240190
A big(ger)boy input https://0x0.st/XnjN.org
>>
File: 1726079513994345.png (10 KB, 259x295)
10 KB
10 KB PNG
>>103232542
This will be the first year I don't participate at all
The schizo retard ruined it years ago and I can finally say I have better things to do
>>
>>103242787
11259, took 6 min 30 seconds with the Python solution on my 10 year old laptop
>>
>>103242731
you don't know how to write good code
>>
>>103243301
Rewrote it in Rust, now it takes 22.7 seconds, so 17 times faster than the Python.
But it was incredibly painful to write lol.
>>
>>103243568
C is typically 60x faster than Python for numerical tasks
>>
File: 1701096861801261.png (191 KB, 1358x1158)
191 KB
191 KB PNG
>>103240190
Already starting this year off well.
>>
>>103244539
The right tool for the job, nice
>>
File: 1720034836418872.png (108 KB, 1037x834)
108 KB
108 KB PNG
>>103240190
>>
>>103232556
Doubt. It didn't happen last year.
>>
>>103242582
Set-builder notation is the most cancerous garbage construct to ever infect programming languages like python. Even in haskell I hate they added that shit. do notation is a superior construct.
>>
>>103248791
Filtered by mathematics
>>
File: 1732129586391.gif (1.18 MB, 303x307)
1.18 MB
1.18 MB GIF
>>103240190
Graphs filter me hard. Every year i brute force them and then prune branches until it executes in less than 5 minutes. How would I learn how to do these problems in a non retarded way?
>>
>>103249086
Learn the following common patterns:
"Painting" nodes to mark them as visited, accepted, rejected, etc. This is usually done not on the graph itself but in a separate structure. For example this problem looks like each node can have two states: on and off; but actually while searching for the solution you use three states: on, off, and not processed yet.
Keeping a "frontier" of nodes, for example for breadth-first search. If you are starting from some node, then everything between the node and the frontier is visited, and the frontier is the set of all nodes directly accessible from what you have visited. Not really necessary in this problem, but usually comes up.
The rest is judicious use of recursion (sometimes iteration in the final code, but recursion conceptually). Recursion is finite because you only go to nodes that you haven't already visited.
With these things in mind, go learn and actually understand the A* algorithm and you are all set.
>>
>>103249086
Every graph problem has already been named and studied. Just google around until you find the name.
This (>>103240190) is the maximally weighted independent set problem.
Once you know the name of the problem, just use python and import solution.
>>
>when part 2 is sort of like part 1 but adding both code paths in the same loop looks shitty so you copy/paste and make minor tweaks instead
I hate when that happens.
>>
>>103249278
Thanks anon for the effortpost. I am fine with the basic a* search type problems, but usually the hardest problem of the year soft filters me. I get a solution, but it takes me over three hours, and execution takes an order of magnitude longer than the best solution.
>>
File: 1722586888763979.png (361 KB, 1710x1587)
361 KB
361 KB PNG
>>103240190
yo fr this sml shit is fire
>>
>eric will just require the solution be derived from a world model, which makes it impossible for an LLM to solve
That sounds interesting, what does a "world model" mean here?
>>
>>103251497
i would define it as an internal representation of the environment which can be used to make inferences
e.g. ask an LLM to imagine a short series of actions with an object (e.g. a cup of water) and ask which way the base of the cup points, or if the cup still has water
older models would e.g. fail to understand that if you are in a windowless basement, you can't see the sky
companies try to fix these mistakes by e.g. CoT reasoning, but they're not true fixes and the lack of a world model remains a fundamental limitation of LLMs
>>
File: 1731098096214823460.png (2.71 MB, 1920x1080)
2.71 MB
2.71 MB PNG
i don't think i'll do it this year
>>
>>103232542
Anyone know what the thing like advent of codd but for logic was called.
>>
>>103254722
this one?
https://hanukkah.bluebird.sh
>>
>>103254774
No it was with logic gates, and nors etc
>>
>>103254820
https://nandgame.com/
>>
File: aoc stars.png (176 KB, 1022x1851)
176 KB
176 KB PNG
how's your progress?
>>
You don't even need a string though, do you? the same result can be obtained easily.
>>
>>103255618
This task can and probably should be performed entirely with integer operations.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.