For unwrap spam, I'd guess you can't do much other than writing out what might go wrong in each step (mostly "unexpected IO error" of some kind maybe?)
@graffe Hi. You should probably also stipulate that if two posts have the same strategy, the eariler one wins. Btw, maybe I am not fully getting it, but it's not clear to me why you wouldn't just always move the agent farthest to the right. And together with the "0 always move right" rule, also not clear to me why 4 agents would be any better than 1 agent?
Maybe a short explanation like that to the post. Anyway, now that i understand, I wonder if moving the agent whose expected final number of moves is least would be optimal?
"The actual problem is that calculating it is not easy" @Bubbler Is that true? Is there not a closed form solution for the case of expected number of moves for a single agent at any position? Or at least a markov chain that boils down to multiplying a matrix some number of times? I agree calculating the solution to the overall problem would be hard (maybe impossible) to do exactly...
true, but from that you'd get a distribution of probabilites with tuples (numMoves, prob), with a tail that falls off fairly fast (I think), and you could use those to estimate with good accuracy for each agent "expected cost to finish from where he is now"
i guess i'm wondering if there is some weird unintuitive thing where "move the bot with lowest expected cost to finish from where is now" is not the same as "optimal move for the entire group"....
So actually running it is effectively changing the mathematical question to something like "choose the strategy that has the lowest EV when restricting to trials that finish in fewer than N moves". Reminds me of the st petersburg paradox.
@Jonah for hard probability questions we can often get very good answers by simulation of course
@UnrelatedString are you referring to symmetric randomly walks? My random walk reflects off the origin so the mean number of steps is definitely finite and computable
"the mean number of steps is definitely finite and computable" doesn't necessarily imply in the general case that the EV of the cost is finite though... eg, you could imagine some faster-than-exponential-growth cost function. But with your cost function pretty sure it is.
@Bubbler :) if instead of reflecting off the origin you just stay still if you try to move left at the origin it is x(x+1) so it is a little less than that
That is the expected time to reach x from the origin
i am still really curious if the greedy strategy of "move the guy with lowest expected cost to finish" is optimal. it's one of those things that seems "obvious" but i've been burned by before in probability.
I mean the formula would involve three variables if such a formula exists - the current position, distance to the goal, and the number of steps already spent
I have this challenge to make a prime factorization tree, and I got this far with golfing it:
b=int(input())
c=d=0
for i in range(2,b):
if b%i==0:d+=1
if d==0:print('/ \\');print('1',str(b))
else:
while b!=1:
for i in range(2,b):
if b%i==0:print(c*' '+'/ \\');print(c*' '+str(i),str(b//i));...
So the golf question was like this:
You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no.
The following constraints are promised for ea...
In Wordle, you try to guess a secret word, and some letters in your guess are highlighted to give you hints.
If you guess a letter which matches the letter in the same position in the secret word, the letter will be highlighted green. For example, if the secret word is LEMON and you guess BEACH, ...
Polyglot quiz
code-golfcops-and-robberspolyglot
In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty string S. You are then going to write 4 programs:
A program which outputs exactly S when run in both A and B.
A program which outputs S in A but n...
> It is tempting to think we should always move the agent that is closest to 10. However, if agent 1 has moved 10 steps but is at position 1 and agent 2 hasn't moved at all, it costs 11^2 - 10^2 and 1^1=1 to move agent 2. In this case it looks like you should move the agent that is further away from 10.
Shouldn't the cost to move agent 1 be 11, not 11^2?
> The cost is the sum of the square of the total number of moves (left or right) taken by all four agents until the first agent gets to 10. You want to minimise the expected cost
all four agents seems to be a little confusing here
the scoring system makes me nostalgic for a KoTH I once answered - it was rock paper scissors but you could inspect the opponent's code. The riffing on other people's strategies and incremental improvement this challenge should have reminds me of it :)
This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other!
Leaderboard
1. Chaos Bot (by Aiden4) - 27 Points, 168 bytes
2. Anti-99%-of-posts (by Lyxal) - 24 Poi...
@thejonymyster well I can explain what the "Anti-99%-of-posts" bot does - it just checks for certain characteristics within the source code of the bots and returns the winning letter
@Adam oh, then I don't see what "generate the range yourself" adds to it, but also i'd like to see the challenge we do have since I can't find it for some reason oops
Challenge:
Output all distinct permutations of a, potentially long, list of positive integers. You may assume that the vector has less than 1,000 numbers when testing, but the process should in theory work for any vector with more than one number regardless of size.
Restrictions:
You must res...
@Adam do you have a moment to implement a naive solution to my sandboxed challenge? I feel it should be fast but some concern has been expressed that 1000 is too much
CMQ (chat mini quiz): What is the rule for the following sequence: [1,11,111,1111,11111,111111,410256,1111111,11111111,111111111,1111111111,111111111111,410256410256,1111111111111,8101265822784]
Consider four agents sitting on four different number lines, all starting at the origin. In this game your only move is to choose one of the four agents to move.
When you do that the agent you have chosen moves left or right by 1 with prob 1/2. You must choose which agent to move at each step.
If...
Consider four agents sitting on four different number lines, all starting at the origin. In this game your only move is to choose one of the four agents to move.
When you do that the agent you have chosen moves left or right by 1 with prob 1/2. You must choose which agent to move at each step.
If...
@NewPosts Disappointing that this is far too specific for QBasic to handle. I'm tempted to write a knockoff question that doesn't require inputting a color or handling transparency.
@graffe In general, yes (though I'm not sure whether that question allows it; I didn't read it very carefully). However, QBasic basically only has 16 colors.
Longest N-Sum Sub-Array
Write a program or function which when given an array of non-negative integers and a number N, output the longest contiguous sub-sequence of said array whose sum adds up to N.
Constraints
If there are multiple such sub-sequences, output any of them or all of them (duplica...
@graffe I think maybe in theory? I've never figured out how to have more than the standard 16 in practice. Part of the issue is that QBasic's graphics commands are specific to the type of display hardware you're using, so not all of them are usable on any given setup, and I'm never sure how they're going to map to a modern setup.
Let us assume that we have number X.
Let us assume that we have components (C) of this X number.
We can add these components together like C1+C2+...+Cn = X.
We have N as limit of number of components.
We have B as limit of biggest component
Examples
X = 17
N = 3
B = 8
Then possible component ...
@graffe I ran a modified version which may or may not be faster (because that version is clearly not optimized for speed), and after a million iterations I got an average of 5427.119384
The modified code is onecompiler.com/python/3ycemc9hf, in case you are curious -- there are probably other changes one can to speed it up, but whatever
@thejonymyster CMC: given a list of posints, return every contiguous slice of the list which includes the length of that slice. example: [2, 1, 2, 3, 4, 7] => [[2, 1], [1], [1, 2], [2, 3], [1, 2, 3], [2, 3, 4], [3, 4, 7], [1, 2, 3, 4], [2, 3, 4, 7]]