« first day (1466 days earlier)      last day (3360 days later) » 
00:00 - 20:0020:00 - 00:00

12:04 AM
@Sp3000 I was thinking pawn promotions and such, but I wouldn't go so far to require that the state is actually reachable with alternating moves from white and black
 
Ahaha okay
 
I'll set up rigorous rules for it, but the rules will be guided by "the board has to look believable"
so if there are two pawns in the same column but the opponent still has all pieces, that's weird. but I doubt most people would be able to see a board state and think "that's impossible, white must have made 40 moves, and black only 38 to get here!"
 
12:21 AM
Woo Pokem... I mean Codemons
2
@Geobits Can we use any language?
 
As long as it takes command line arguments and can output to STDOUT.
 
kk
 
and now, sit back and wait for three gold badges :)
 
Congratulations Geobits, I'm not getting any work done today
3
 
@Martin Yea, we'll see. The name/concept is probably a huge draw, but the long-winded spec might put people off.
 
12:32 AM
It didn't for lab rats :P
 
@Sp3000 That was my whole plan, I work for the Illuminati and have been tasked with bringing production to a halt in major Western countries.
I mean... I don't work for the Illuminati. I'm pretty sure they're not even real... >_>
Now that that's posted, though... time to resume my shiny Eevee hunt.
 
Can I use the same stats and moves for all three?
 
You can, sure. Just no repeat moves on the same monster.
 
k, just something I wanted to try :P
 
12:48 AM
@Geobits Do you have an example battle state string I can try parsing?
 
Yea, let me grab one from debug mode...
This is DummyTeam fighting BitterRivals, as it appears to DummyTeam midway through a fight:
DummyTeam:0|Dummy810:0:50:50:50:-24:0:0:-2:3:5:0:1:0|Dummy701:1:50:50:50:100:0:0:-1:3:5:0:1:0|Dummy882:2:50:50:50:100:0:0:-1:3:5:0:1:0#BitterRivals:0|Greenosaur:3:80:50:100:76:4:0|Searizard:4:100:50:80:100:2:0|Blastshield:5:80:100:50:100:3:0
 
1:05 AM
Thanks :)
Hmm I can't seem to get players.conf to read correctly...
 
Are you running it from the command line or an IDE?
Eclipse at least is a pain with working directories. If you toss all the .class files along with the players.conf in a single folder, it should run from the command line fine.
Otherwise you could play with paths and settings :)
 
... damn, can I just post my submission and hope it works? ;D
But nah, I'll try command line instead of Eclipse, thanks
 
You can, but my controller likes to throw non-conforming competitors out and continue on its merry way ;)
 
I'll post it for now then, and fix it later if it's broken :D
 
:D
 
1:31 AM
Hmm it seems to be hanging on input, weird...
 
A few things I'm fixing on my local copy:
Input comes in sys.argv[1], not input()
You have an otherstate where it should be otherstats.
Line 44 has otherstats)[1] where it should be otherstats[1])
 
Oh argv...
 
Oh, and in "choose active", you shouldn't do if codemon.hp:, but if codemon.hp > 0:, since negatives are true apparently.
That appears to be everything, though
 
Ah thanks - yeah nonzero is truthy, but I didn't think that HP would go negative
 
Here's my patched up version, running a sample tournament of two now: pastebin.com/zeX0pJnQ
 
1:36 AM
Yep, just made those changes - thanks for going through that :)
Seems to be a close fight with BitterRivals on my end
 
I'd do it for the first one or two. The 10th one will have to fix it up himself :P
Yea, about even here
Well, not really. The longer I watch the better your team does :(
 
I think it needs more attack rather than speed
Since after a while it goes 5HP vs 6HP against Blastshield
 
That's what I did with my water guy.
The logic for them seems about the same. Shield up, heal up, blast.
 
Changed speed -> attack, let's see how this goes :)
 
is ok if my Codemod team name is 27 million letters long?
 
1:41 AM
@feersum That depends. Do you want to compete or troll?
You can't do both unless it's subtle.
 
It gives a competitive advantage, since another team might want to store the name in a data file and then lose
 
Ah, in that case let me consult the judges.... no.
 
(does much better now that it can routinely beat Blastshield - I guess in the long run speed means nothing if the battle drags out)
 
Yea, it's more important at the start of battle, and later on in the tourney. If you're fast(er) and can one-hit KO an opponent (due to bonus stats), you don't need def at all.
 
So wait, burn and poison never stop? Or do they stop after a while? (can't seem to find it in the spec)
 
1:48 AM
How is it possible to switch monster after doing a "choose battle action"?
meh this is clearly impossible if you haven't played the other game
 
@Sp3000 never stop (well, until end of battle)
 
... should have totally gone for the poison/sleep combo instead
 
@feersum You can choose switch as your battle action. it will switch at the "optional switch" phase, before attacks.
 
is deciding the attack done in a different message than battle acton?
 
1) If a guy is dead or it is the first turn of battle, choose an active fighter. This is "mandatory switching"
2) Choose battle action (move or switch)
3) If switch was chosen as action, switch takes place ("optional switching")
4) Maybe wake up
5) Fast guy attack if move was chosen
6) Other guy attack if move was chosen
7) Effect damage
You'll get a C at step 1 (if needed, not every turn) and an A at step 2 (every turn). That's it during the battle itself.
 
2:03 AM
Wow, this 60% wake up...
 
:P
I tried it with a few lower values, it was just too damn powerful.
 
There goes the Poison/Confusion/Sleep plan :P
 
Sleep is (somewhat) counterproductive to Confusion anyway. I'd rather Burn/Poison/[Sleep|Confusion].
 
Well it was meant to be if used if sleep ran out :P
Since things kept waking up so much
 
 
1 hour later…
3:35 AM
@Geobits I think with only 3 teams things are only close because byes only score 1. If I take out the dummy team things are a lot less close :P
 
 
9 hours later…
12:07 PM
why would anyone downvote the koth o.O
 
which one ?
 
codemon
 
12:52 PM
Got 126 four-letter words left to golf out before I go and learn Ruby...
 
Oooh 680, so close
Got it, now to stalk Martin's Ruby posts to learn tricks
 
lol
let me know if you've got any questions
if you want to really learn crazy ruby golfing tricks you should rather look at histocrat's and Doorknob's Ruby answers
 
I have a capacity X, and a set of objects of A,B. I can carry the objects as long as the sum of all of the objects' A is equal to or under X. Maximize your sum of B
How would you approach this problem?
 
Is that the knapsack problem?
 
1:04 PM
I don't know
 
(If so, then dynamic programming - see wiki)
 
mmm, it is
thanks
 
@MartinBüttner Is 0 truthy or falsy in Ruby?
I think I need to convert <any int> -> 1 and nil -> 0 somehow...
 
@Sp3000 truthy
only nil is falsy
(well and false)
 
Oh? Interesting...
 
1:14 PM
and annoying more often than not :D
 
Well in this case it's awesome
Now how to write a test program in Ruby...
 
what do you need?
 
I've got a function which takes in a word and returns true/false if it's probably a word or not
Just need a test program to run on the data set provided to make sure there's <15% misclassifications
looks up how to map in Ruby
 
list_of_words.map{|word|check word}
(where check is your function)
or check[word] if the function is a lambda
 
Oh is that how lambdas work
Was trying round brackets XD
k got it, thanks :D
 
1:24 PM
you can probably just do s[/regex/]
it returns the match if there is one (which is truthy) or nil otherwise (which is falsy)
 
Oh? :o
c=->s{not s[/[^aeiou]{3}|[jqvxz]|u$/]} like that? I need the not though
 
oh, and you don't need to name the function (unless the challenge requests it?)
@Sp3000 !
this isn't Python :P
 
Ah.
:P
 
dat c= though :(
 
I was having trouble figuring out which part I could scrap to make it unnamed
:P
Just the c=?
 
1:31 PM
yes
at this point, you can also change it to a full program for the same bytes: p !gets[/[^aeiou]{3}|[jqvxz]|u$/]
 
Ahaha k, surely it's not golfable any more now? ;D
(thanks a lot btw, Ruby's syntax has a lot more to it than I thought)
Interesting... you can't lose the space between the p and the !?
 
@Sp3000 wow, I couldn't guess that that regex is so efficient
 
I did say regex golfing in the sandbox post :D
 
neither for words nor nonwords
I meant specifically that one you posted
 
@Sp3000 I don't think so
because ! is valid in identifiers (at least at the end)
 
1:40 PM
Usable in identifiers eh, interesting...
 
it's used for members which mutate the object they're called on
like, there's .gsub which does global regex replacement and gives you a new string, or there's .gsub! which instead changes the string it's called on
it's actually quite a nice convention
 
Ah I see, allowing similar function names for similar functions
That's pretty nice
 
you can also use ? at the end of identifiers, which is used for members which return a boolean
 
I think I saw something like .is_a? for Rails when I was trying to convert nil to false and was confused for a moment :P
 
@Sp3000 btw I added "Generate a random hole-free polyomino" to the Random Golf of the Day ideas
 
1:51 PM
Ahaha why hole-free?
 
because that's more interesting, I hope ^^
also otherwise it's almost a duplicate of that code golf that asks to generate all polyominoes of a given size
 
Ah k
Trickier :P
 
do you think #1 is good to go?
I think I'll probably just post that one today, and then work out the details for the others as I go along... I've got enough ideas lined up to be confident that I'll manage to find 8 ones that work well
 
Hmm looks good, unless you want to do Marbelous :P
 
2:06 PM
@MartinBüttner Whoever downvoted it recently retracted (and possibly upvoted instead). It mysteriously went from 13/1 to 14/0 without me seeing a notification o.0
 
well that's good :)
 
I've long since given up trying to figure out random downvotes, though.
 
btw, I'm really sorry, but I can't bring myself to read through the protocol today :(
 
lol, no problem. I don't think you're required to enter every challenge posted ;)
 
Martin doesn't have the KOTH bronze badge yet though :D
 
2:08 PM
@Geobits I haven't really participated in KotHs in ages
@Sp3000 there are no KotH badges yet ;)
we need more koths...
 
... ah.
(Hopefully now that Geobit's clarified the rules we'll see a few more Po... Codemons)
 
I'm just trying to work my back up the asker list. I used to be at 5th there :(
 
There's an asker list? :o
Actually, is there a full list of special pages somewhere?
 
For each tag. Check the link :)
Not that I know of. I just keep running across stuff every now and then, even after years on SE.
 
0
Q: Random Golf of the Day #1: Shuffle an Array

Martin BüttnerAbout the Series I will be running a little series of code-golf challenges revolving around the theme of randomness. This will basically be a 9-Hole Golf Course, but spread out over several questions. You may participate in any challenge individually as if it was a normal question. However, I ...

 
2:41 PM
@MartinBüttner Is the 500 rep bounty repeatable?
As in, if I hold for 28 days, and then someone else holds for 28 days after that, do we both win?
@Geobits Do you want to compete on the 9 hole thing in Java with me?
I'll write my submission and you write yours and we both post at the same time
That sounded really.... gay for some reason.
 
In Java? Sure, I'm golfing my shuffle now, but I don't think it's getting much smaller than it is.
 
Cool let me catch up. I don't want anyone calling me a copycat
@Geobits What are the rules for golfing in Java? Does import java.util.random; count towards my total?
 
Yea, unfortunately. If you're only using it once, it's usually shorter to just fully qualify it when using instead of importing.
 
meh
 
2:59 PM
Oh wow, there's a regex golf game
3
 
3:14 PM
@Rainbolt Let me know when you're ready ;)
 
@Geobits Alright sure
I'll let you know
Give me 5 minutes or so
 
@Rainbolt in principle, I've intended it to be repeatable (once per person), hence the long time frame. But I'll stop doing it if I think people are trying to game it
 
Damn I had too much fun Codemon'ing and regexing and whatnot today I forgot I was going to work on the fortnightly challenge :/
Guess I'll have to do that tomorrow (hope it's not too late...)
 
@Geobits I'm ready. You are going to slaughter me for a couple of holes but I will catch up. Second time golfing in Java
 
3:31 PM
Cool, posting now.
 
@Geobits We both went fisher yates
Except you knew the name and I didn't lol
@Geobits Can you explain for(int i=s.length,t,x; to me?
 
It's just declaring ints and assigning only one of them. Not much different than your int g,j,i,x;, but since you only need them inside the loop scope, you can do it the init part.
 
I see
I didn't know you could do multiple assigns in Java
And the syntax is odd. In Python it's a,b,c=1,2,3
in Java that's int a=1,b=2,c=3 I guess?
 
Yep
 
In that case I can lose some bytes
I can haz all your tricks
 
3:36 PM
If you reverse the loop (go from length to 0), you can get rid of x, also.
 
oooo
Taking my answer down so it doesn't get a billion downvotes before I fix it
 
lol, I didn't even notice the issue until pointed out. Should be an easy fix, though.
 
Yea. One letter change
But I have other improvements too
 
Go for 100 or better. I was just happy beating python :D
 
I'm a little confused at the biased bit
I have to do more reading
 
3:53 PM
I've been working on this problem: codeforces.com/problemset/problem/3/C
It's really a fantastic problem
there are so many edge cases
(basically, you verify a tic tac toe board, whether it is legal, who's turn it is, or who won)
 
@Geobits Do you understand @PeterTaylor's comment? The requested range of Math.Random is 0.0 to 1.0. How is that a power of 2?
 
@Rainbolt it returns a float, and the number of floats in that range is a power of 2
 
@NathanMerrill There can't be that many - there's only 19683 possible different inputs.
 
I understand what he's saying, but disagree with the ruling.
 
well, sure but in coding, you have to account for all of the edge cases
they don't give you the progression, simply the current board
 
3:56 PM
@Geobits Can you explain it in English?
 
so, you need to verify X is bigger or equal than 0 (by max of 1)
and verify that both teams haven't won
 
The number of floats in that range is a power of 2. Therefore, _____.
 
and verify that the person that did win isn't to move next
 
@Rainbolt basically, you can't uniformly choose one out of 3 possible numbers from 2^n possible random results.
(where 3 could be any number that's not a power of 2)
 
^
 
3:57 PM
@MartinBüttner But... you can pseudo uniformly choose.
 
I don't understand
anyway, I need to sort out how I rule on approaches like this
but I'd probably say they are fine... cases like this were part of the reason why I added the rule in the first place
 
My reading of the rules: 1) The range of random() is [0-1]. 2) I may assume my built-in generator gives me a uniform number from that range (regardless of the vagaries of FP).
 
I don't want this to become a "generate rand(5) from rand(7)" challenge
 
Yea, Peter is diving into the workings of the PRNG and finding a flaw. And your challenge pretty much says we can ignore that flaw. What was the point of that rule if not for this case?
And what language has a PRNG that generates random numbers from a random range?
 
The range of random() is a set of doubles which is a finite subset of the infinite set of reals [0, 1).
 
4:02 PM
@Rainbolt well the other point is that rand(5) is actually not uniform either.
@Rainbolt ummmm... many?
 
Name one?
Is it even possible in java?
 
I don't know enough java
Ruby
Mathematica, CJam, Marbelous...
probably Python too
yeah, that's what Sp3000 does
 
...the java spec says that random is uniformly distributed
 
java.util.Random.nextInt would be suitable.
 
@NathanMerrill true, but that doesn't mean that int(random()*3) is still uniform in practice
 
4:07 PM
@NathanMerrill uniformly distributed between what and what?
 
They have nextInt(n) which is between 0 and n (exclusive)
 
@NathanMerrill To be precise, it says that the random double is selected "as if by" (((long)next(26) << 27) + next(27)) / (double)(1L << 53)
 
@PeterTaylor From the Javadoc on java.util.Random.nextInt(): All 2^32 possible int values are produced with (approximately) equal probability.
Is that not also a power of 2?
 
FWIW, I agree that in practice, nextInt() is more suitable. I used random() because the OP specifically stated I could assume it's perfectly uniform over the documented range [0-1], not perfectly uniform among the doubles [0-1].
@Rainbolt It is, but nextInt() rejects some to overcome the bias.
 
I was under the impression that Math.random was built on top of java.util.random
So would it not also overcome the bias?
I guess I won't repost my answer since I can't clearly understand what random functions I am allowed to use.
 
4:13 PM
@Geobits Yes, this is the intended reading of the rules. The spirit of the challenge is to golf down an algorithm which is unbiased in principle, but not having to worry about the details of the underlying implementation of your language's PRNG.
@Rainbolt any that claim to be uniform. don't let the others confuse you :P
 
What if it claims to be approximately uniform, as Math.random() does?
 
I claim nextGaussian() to be uniform :P
 
Math.random() generates a uniformly random double from a set of doubles which is a subset of the interval [0, 1). java.util.Random.nextInt(1) generates a uniformly random int from a set of ints which is a subset of the interval [0, 1). So if you're going to talk about intervals rather than ranges (in the sense of the image of the function), you still need to address the issue of what the image of the function is.
 
@PeterTaylor changed it to "interval"
oh
just saw this messages
 
Why not just omit it altogether. Assume the distribution is uniform. (use this one) Assume the distribution is uniform over the interval. Assume the distribution is uniform over the range. Assume the distribution is uniform over the Foo.
 
4:24 PM
wow, it really can't be that hard. I swear everyone in this room is perfectly aware of the intended ruling of this challenge. how it can be this hard to come up with an unambiguous meaning that no one will challenge?
@Rainbolt it's still ambiguous, because of the power of two thing.
 
@Martin Have fun with your other 8 holes ;)
 
@MartinBüttner What does that even mean?
 
@Rainbolt well the PRNG could still be uniform over a set of 2^n values the PRNG might return
 
Assume the distribution is uniform (even if the range or the interval is a power of two).
 
4:26 PM
which wouldn't help you at all
 
@MartinBüttner, just wait until someone posts something which uses a random() function that returns a float in the range [0, 1).
There aren't enough of them to properly Fisher-Yates shuffle an array of 2^31 entries.
 
Shoulda limited it to a reasonable size. (That's why I asked)
 
what I'm trying to say, these fiddly details are not supposed to be a concern for this challenge. if I wanted to ask a challenge about creating perfectly uniform integers in an arbitrary range from Math.random() then I'd have asked about that.
 
If you did that then I would close as impossible. (Unless we are allowed to use physical phenomena as our seed)
 
@Peter I'm pretty sure it was you who said at some point that a good challenge isolates the problem in question. burdening people with these PRNG details is no better than having them parse their input for a fibonacci challenge from a partially invalid HTML page.
 
4:30 PM
I can plural apparently.
 
I don't think anyone has yet attempted the question in a language which doesn't have a built-in function to uniformly generate an integer from 0 to n-1 where n is a positive integer, so I don't see a burden.
The O(n) requirement is a bigger burden, because it rules out lots of esolangs.
 
Does Will It Shuffle take into account the ordering, or just the position?
As in, if I rotate the list a random number of spots, will it pass?
I'm going to test this
 
Isn't it 2D, showing the intersection of in and out? If so, you'll probably see a nice dark green line.
 
5:12 PM
Oh, cool. I've never been serially downvoted before. I guess I'll find out how well the detection script works :)
 
5:22 PM
@Geobits Alright, spit it out. Who did you make mad? What site?
I don't understand why this shift thing isn't working out. If I rotate the array a random number of times (between 1 and array Length times), it should have an equal probability of each element ending up in each position, right?
I'm obviously doing something stupid
Take [1,2,3] and randomly rotate it 1, 2, or 3 times.
 
Paste the function you're trying?
 
If you rotate once, you get [2,3,1]. Twice gets [3,1,2]. Thrice gets [1,2,3].
 
(it was puzzling, btw. no idea who, though. maybe because I closed a question? haven't done much else in the last day or so)
 
Oh, I figured it out.
function shuffle(array) {
    rand = Math.random()*array.length
    for(i=0; i < rand; i++)
        array.push(array.shift())
    return array
}
It's pretty gray. Has gray streaks
Some red
I'm kind of colorblind so maybe some of the gray is green
Oh, if I run it again then I see the green
Anyway, I just wanted to show that Will it Shuffle is pretty poor choice of test.
It doesn't see relative position, only final position.
 
6:01 PM
@trichoplax thank you for the answer!
 
@Lembik You're welcome!
I'm hoping to see some more answers - it's an interesting question.
 
I hope it was fun to write
 
It was fun to write, but then there was the debugging...
 
@Rainbolt well a rotation algorithm won't comply with the spec in the first place in that it won't be able to produce all possible permutations
 
I'm reasonably happy that it is correct now
 
6:06 PM
Will It Shuffle was only intended to find biases in methods which do
 
@MartinBüttner Right. Not everyone here is trying to break your challenge.
I'm trying to break Will it Shuffle
 
haha, nice
 
@trichoplax maybe we should add the sequence to oeis :)
 
@Rainbolt I think you did
 
@Lembik It's already there, which presents a problem.
 
6:07 PM
If Will It Shuffle were the ultimate test, then this would pass
def f(l):a=random.randint(0,len(l)-1);l=l[a:]+l[:a];return l
It slices the array at a random point and concatenates the slices in the reverse order
 
@Geobits I hope that's without self intersection. If so, my numbers are correct. If not, I have a problem.
 
Yea, I'm not sure. I think visualizing them for n=5 would show that pretty clearly one way or the other.
 
@Geobits wow!
 
@Lembik if the oeis sequence is excluding self intersection, then you have a problem as it gives an explicit formula for finding the nth term...
 
@Geobits I am very surprised if they consider reachability!
@trichoplax yes!
@but surely they can't be considering reachability
 
6:12 PM
@Lembik Otherwise, I have to debug my code again... :)
 
@trichoplax :)
 
@trichoplax for n = 5 you have (2, 2, 2, 2) in you solution set, I think that one is not possible. Furthermore you have (2, 2, 2, 1) and (0, 0, 0, 2) which I think are the same.
 
@DominikMüller good point - I can find out a fair bit without a visualisation. I'll try and track down how those incorrect ones are getting through now
@Lembik this means my answer is wrong and your question is safe...
 
@Lembik so a n=4 snake with all 90 degrees (0, 0, 0) or (2, 2, 2) is not possible because 0 and 4 would be on the same position?
 
This one is similar but excluding self-coincidence (still allows crossing). So if your next result is that one, keep trying ;)
 
6:17 PM
lol
 
6:34 PM
@trichoplax phew :)
 
6:52 PM
@DominikMüller if n = 4 and you bend in the same direction at all three possible places then you get a square which is not allowed
@DominikMüller "Two points that touch are counted as overlapping in this problem."
 
@Lembik Ok, so the sequence starts with 1, 1, 2, 4, 9. After that I think 23, but I could have missed something. But so far I have no smart idea for a solution.
 
@DominikMüller I was slightly surprised the previous one had a nice closed form!
@DominikMüller I don't think it grows too fast so I am hoping you can get a long way by slightly smart brute force
I wonder if Keith Randall's answer to codegolf.stackexchange.com/questions/45257/counting-k-mers is beatable
I had an idea that if you can computer the maximal length repeat then you know all the answers for k large than that
I think
 
@Lembik I think it is this sequence: oeis.org/A001997 minus all the self touching layouts.
 
@MartinBüttner Dangit I was just in the middle of submitting an empty program.
 
@DominikMüller what does "May cross itself but is not self-coincident over a finite length." mean?
 
7:03 PM
@Rainbolt please continue
 
Nah you beat me
 
@DominikMüller I don't think it can be the same thing
 
hm, not exactly
 
The way I see it, as soon as he specifies a dictionary, it's an exact dupe. Until then, it's unclear.
Oh, I guess the target challenge makes you use all of the letters while this one doesn't
 
@Rainbolt it's not an exact dupe either. he doesn't ask us to find the input that generates the most words. he asks us to find as many words as possible in a given input.
 
7:15 PM
Oh, I read the question backwards I guess
 
7:39 PM
@Martin Does the topic of your meta post include answers that depend on any of the previous answers, and not necessarily the one directly before it?
I was thinking that answer-chaining sounds weird because each link is only attached to the previous link
But "answer bubble diagram" is too long
Anyway, I wasn't sure what the topic was because there are multiple answers like "ordered" and "chronological" and they all imply that each answer depends on the one directly before it.
And feel free to let me know if you have no idea what I'm talking about lol
 
@Lembik That still gives larger numbers than your question requires. It means no two unit lengths of wire are in the same place. They can cross like an X as long as they don't share a path of length 1 or more
 
@Rainbolt answer-tree is better?
 
7:58 PM
@Rainbolt Yeah a tag name that could cover both would be great
 
00:00 - 20:0020:00 - 00:00

« first day (1466 days earlier)      last day (3360 days later) »