« first day (1299 days earlier)      last day (3548 days later) » 

6:00 PM
I'm just unhappy with O(n)
I'm not sure it's necessary. It would be best if all 3 operations were sublinear, rather than to have one O(n), one O(log n), and one O(1)
 
Yeah; you could do the actual adding to the list in the percentile function
 
@EricTressler You could also do a full sort (a quick one with nearly-sorted data) only if something's been added/removed since last percentile
 
The overall cost would depend a lot on the frequency of the operations, though.
 
That was kind of as far as I got in my thinking, but that was after I'd finished the interview
I guess you could maintain a number of "additions since last 'percentile' call", and if it's < log n, do the insertions; if it's > log n, add them all to the back and sort the vector
Anyway, I feel a bit better now, since nobody said "Why didn't you use a ____, you idiot?"
 
6:04 PM
:)
 
Speaking of which, why didn't you use a self-sorting autoinsertion randomaccess map?
 
A SARM? Of course...
 
@EricTressler Store the weights in a balanced tree.
 
Go on
 
6:06 PM
@PeterTaylor I thought of that too, but how does that help get the 47.3th percentile weight quickly?
 
You still need to track extra information to extract percentiles from that
 
All operations are O(lg n)
 
I thought of using a red-black tree, but I still don't see how to get the Xth percentile sublinearly
 
In each node of the tree you track how many items are to the left and to the right.
 
"get the Xth percentile" isn't among the standard operations on a tree
ah
But then writing is still linear
 
6:07 PM
Why?
 
You have to update each node when you add an element
 
No, it's an insertion into the tree.
 
Don't the other nodes need to know that the amount left/right changed?
 
Does each node report on how many items are to the left and right by querying its parents recursively?
 
If each node of the tree knows how many items are to the left and to the right, then you have to update them all when you insert a node
 
6:08 PM
It hasn't for most of them. Only the ones in the path to the node.
By "to the left" and "to the right" I don't mean "having smaller weight" and "having greater weight".
 
Won't every node in the tree be either left or right of every other?
 
I mean "in the left subtree" and "in the right subtree"
 
I'm trying to go with you on this, but I still don't quite see how it would work. Each node tracks its total number of L and R children, all the way down?
 
Ah - number of children?
 
Yes.
 
6:10 PM
Yeah, you're right, that could work
 
So log(n) nodes need to be updated. Got it.
 
I'm not sure I could implement that in an hour
But it does answer my question. Everything can be log n
@PeterTaylor Thanks
 
I implemented it in Python, lol.
class PercentileThingy:
	def __init__(self):
		self.tmp = []
		self.s = []
		self.i = []
	def add(self, v):
		self.tmp.append(v)
		self.i.append(v)
	def get(self, id):
		return self.i[id]
	def percentile(self, p)
		p /= 100
		j = int((len(self.s)+len(self.tmp))*p)
		i = 0
		r = -1
		self.s += [1e1000]
		while i < len(self.s):
			for k,c in enumerate(self.tmp): if self.s[i] > c: self.s.insert(i, c); del self.tmp[k]
			i += 1
			if i == j: r = self.s[i]
		self.s = self.s[:-1]
		return r
not sure if it runs, I didn't test it
 
@EricTressler Perhaps implement a non-balanced version and tell them that you know about red-black trees, but didn't have time.
The point of this kind of thing should be to see how you think about a problem and how much you know about the basics, not how quick you are at reproducing standard but non-trivial data structures from memory.
 
Yeah. Well, it's too late for that interview, obviously; I will keep this in mind, though
 
6:15 PM
wait, you can optimize it a bit by changing while i < len(self.s) to while self.tmp. facepalm
but still, O(1), O(1), and O(nm) :D
 
wow this chat is active today
 
O(nm) is horrible. xD
 
@MartinBüttner real world programming problems too...
 
That's not really better, O(n) is bad. @PeterTaylor's suggestion is the right way to go
 
@EricTressler yeah i suck at algos
 
6:18 PM
The implication in the interview was that each of the 3 operations (write, getWeightById, getWeightAtPercentile) needed to be fast
 
Booyah! Spocot's comment on my post made me laugh hysterically codegolf.stackexchange.com/a/36524/18487
 
Is "daydreamer" a mistake he made when typing "DayTrader"
 
I don't think so.
I think the concept is that the bot is snoozing at its desk.
 
Daydreamer doesn't trade, so he didn't crash
 
Oh, I see the other bot
 
6:20 PM
Why is it called "Stack Exchange Stock Exchange?"
 
@Rainbolt you caused a market crash and a string of program crashes in one go...
 
why not just "Stack Market?"
 
@cjfaure suggest it in the comments...
 
You could make an accent pun and name this challenge "Stack Market". — cjfaure 12 secs ago
 
6:34 PM
The challenge has the same problem the other one had. If you buy, it increases after you buy it. If you sell, it decreases after you sell it. The only logical thing to do it buy, then sell, then buy, then sell, etc.
 
If you're the only trader, sure. If you buy, it increases so others sell, then should you then sell at a loss?
 
My way of thinking is kind of limited because other bots could make what I consider to be illogical choices.
@Geobits Jynx lol
 
I always write the stupidest bots I can, and watch as they beat 40% of the competition minimum.
 
You could say the same thing about the actual stock market if you break it down to its simplest.
 
Wow Jynx is a pokemon. Jinx is what I meant to say.
 
6:36 PM
42
A: Find the Smoothest Number

aditsuCJam - 13 q~,>{mfW=}$0= Try it at http://cjam.aditsu.net/ Example input: 2001 2014 Example output: 2002 Explanation: q~ reads and evaluates the input, pushing the 2 numbers on the stack (say min and max) , makes an array [0 1 ... max-1] > slices the array starting at min, resulting in [min ...

This has to be one of the fastest-gaining answers I've seen on a golf challenge
 
And a crap poke at that.
 
Yeah, nobody cares about Jynx
 
@Geobits The actual stock market could be thought of as having an unknown beginning. This one clearly has a beginning where everyone buys.
 
For any individual stock, it definitely starts somewhere, with a single trade/offer price.
 
Obviously a good strategy is to buy the fastest rising stock and sell the turn immediately after.
 
6:39 PM
BTW, "smooth" is an actual term; he didn't make that up
 
@cjfaure If you buy the fastest rising stock, that means many people bought it last turn(s). If they think like you, you'll be on the trailing end of a sellout crash.
 
The general number field sieve uses them
 
@Geobits The strategy is, nobody else will do this. :P
 
** bold **
 
What's italics? I forgot that the HTML tags only work on the main site
 
6:42 PM
strike italic bold wat
 
*italics*
italic + bold + strikethrough = IBS = gives me Irritable Bowel Syndrome
 
@Geobits
 
@FireFly Totally gonna overtake that with my regex solution :P
 
TIL one can see the source of chat messages in the history for the message
 
(as if)
 
6:46 PM
@Geobits I have another train of thought I need you to crush. Let's assume that you have no clue what other players will do. The only perfect knowledge that you have is what you are going to do. If you buy, you will positively affect the price. Likewise, if you sell, you will negatively affect the price. Without knowing anything about the other players, I think you should still max buy and max sell repeatedly.
 
@MartinBüttner haha
. o O ( now solve it in Thue )
 
I'm not even done with the regex :D
 
@Rainbolt Probably. If the chances of other players are 1)buy 2)sell 3)neither, with equal odds, your payout should be greatest that way.
Then, assuming other players are rational (doing the same on the same turn cycle), you'll all profit equally (I think).
 
@Geobits I guess you could argue that the other players selling, buying, or holding are not necessarily at equal odds
 
6:50 PM
Right, that's my basic argument.
 
But we can bank on one thing for round one.
 
Because people be trippin.
 
Players WILL buy or hold on round one
My logic after that was "Who the f*** would buy more on round two? Are you crazy?"
 
My question seems to be dying
Maybe it's too much work or too hard
@MartinBüttner did you ever check out the graphical version in action?
 
@EricTressler Don't feel bad, I recently had a 16 or 18 score on one before it got a single answer, six days after posting.
 
6:52 PM
@EricTressler No, didn't get around to downloading it yet.
 
@MartinBüttner Please do try it sometime; it's run identically to the original one
 
I'll have a look if I finish the regex in a reasonable amount of time :D
(which is entirely your fault, btw)
 
Hah. Alright.
For those who don't intend to do the challenge, it's still kind of neat to download the visual controller and watch Martin's solution
I use Tudwell as an alias because one of my students called me that on a final exam years ago, because apparently he had never been to class or something.
 
I think Sparr was working on a submission
 
He was; I'm still holding out hope
I'm going to write a solution too, but I think it will do pretty well, and I don't want to code/post it until some other people have responded
 
6:58 PM
okay, I've got a regex which I think should be working. it doesn't though. so it's time for debugging one horror of a regex now :D
 
Should I create a new account, "Derek Dressler" so I can upvote it twice?
 
maybe not
 
T'reric Essler?
 
(you'd also need 15 rep first)
 
What's the regex
 
7:00 PM
This just isn't working.
 
Charles Dodgson
 
@EricTressler for the smooth number question, I believe
 
@EricTressler I'm not going to spoil it :P
okay, the prime factor finding bit is still working, that's reassuring
 
@FireFly what?
 
so it's the check for the smoothest number that fails
 
7:02 PM
@FireFly I know it's for the smooth number problem; I goaded Martin into spending all this time. I want to see the regex. :)
@MartinBüttner That's just a max() operation, right? I don't know how to do that either
 
@EricTressler I think I know how to it, but there's still a problem ^^
basically the idea is to make sure that you can't find a smaller match of the same form anywhere further down the line
 
Aha
 
So it's some kind of equivalent of short-circuiting
?
I really don't know enough about regular expressions to help off the top of my head, but if you can isolate the problem, I'll try
 
not really. it's rather the opposite. for each N I have to find the largest prime factor of all M < N to make sure that theirs isn't smaller than N's
 
why M<N?
 
7:05 PM
I'm probably just missing a special case for prime numbers again like yesterday
because I'm checking long numbers first
 
But the largest prime factor is irrespective of the size of the number
the smallest number might itself be prime, etc.
(7,11)
 
@EricTressler I don't think I have the flexibilitiy not to check them in order :D
 
No, probably not
 
I tried something with a recursive regex in PCRE and it gave me an error saying that the recursion was unterminated.
I don't know why: the only base case was ^.
 
okay I found one problem, but it doesn't solve everything yet
okay it currently works, unless there's a prime number in your range that is itself larger than smallest largest prime factor
I'm onto it
 
7:13 PM
Who sees edits of non-CW posts?
non-OP edits
 
People with sufficient rep, I guess
At least I see it
 
I was just curious who I'm annoying by editing things
 
Community auto-rejected it because I fixed the "And" typo at the same time :\
 
I thought everyone could see edits, rep or no. Do you mean who is pinged by them?
Or who can review them?
 
Who can review/accept them
 
7:16 PM
On beta sites, 1000+ rep. Graduated, 2k+
Same level that can edit without going through review.
 
Oh. I'm close
ish
 
There is a cheaty solution using J's . for that task, btw (it implements matrix multiplication using a given function for "addition" and another for "multiplication", more-or-less)
I think I'll implement it "for real" in J and include it as an aside
 
Or I guess it's arguable whether it's sufficiently cheaty to count as a built-in that essentially solves the task at hand
 
The problem definitely seems language-driven
 
7:20 PM
I'VE GOT IT!
post coming in a minute
 
I.e. strongly typed languages will find this tedious, and weakly-typed languages might have shortcuts
 
need to a) golf the actual submission and b) complete documentation of the ungolfed version
 
@MartinBüttner cool!
I don't think that problem should be at -3, it's a legitimate post. He just needs to decide how to choose a winner.
Someone please change the tag to code golf
And let him know why. I can't do it, it's too minor a change
Thanks
 
0
A: Find the Smoothest Number

Martin BüttnerRegex (.NET flavour), 183 bytes This is not really a contender for the win. But Eric Tressler suggested solving this problem with nothing but a regex, and I couldn't resist to give it a go. This might be possible in PCRE as well (and even shorter), but I chose .NET because my solution needs arbi...

 
Witch!
 
7:34 PM
Thank you :)
 
You couldn't use the method of the original regexp I pasted to take the input in decimal?
 
Which original regex?
 
/^1?$|^(11+?)\1+$/
 
that's unary
and I've used this several times in the solution
 
It uses unary as a device, but takes decimal input
 
7:37 PM
outside of the regex though
"1" * n
"the function first generates “1111111″ (from “1″ * 7)"
 
I see
So you'd have to embed your regex into a language like perl or ruby that supports them to do the same
 
yes
but that's boring :D
 
Yeah, I applaud your effort. I upvoted it immediately
 
Ugh. I hate it when I'm writing something and the same word ends up in the exact same place on two lines in a row, directly above/below.
 
@Geobits especially at the beginning of the line (or end if it's block justified)
there's probably even a term for it
 
7:40 PM
It's not even a monospace font!
 
@Geobits that is the least bad kind of obsessive compulsive disorder
 
I hate it when that happens and they're slightly misaligned.
 
@MartinBüttner I like how your regex solution beats some of the serious entries
 
:D does it? I didn't even bother to check
 
@cjfaure I'd much rather see them misaligned by even a pixel.
Words just shouldn't stack like that.
 
7:42 PM
Hm wait, maybe I'm mixing questions up
but at least it gets close :p
 
lol I can golf it down by one byte (or probably more), but I can't be bothered to edit the ungolfed version now
I'm beating C# LINQ
 
I think you beat 1 submission
 
"I'm beating C# LINQ" <- gets my vote for underwhelming achievement of the day.
 
Yeah, but it's not bad!
 
7:44 PM
but I'm quite close to a bunch of others
 
(no disrespect meant, regex wizardry is still wizardry)
 
You came out really low on bytes for a gimmick entry
 
@EricTressler I've won a code golf with something like this before :D
 
You know a language is bad (from a readability point-of-view) when you write up your golfy solution formatted normally, and then you begin removing whitespace only to find there's (almost) none to be removed
 
I think this is my third regex answer on a non regex-golf question here
 
7:46 PM
I always appreciate (but rarely understand) crazy crap done with regular expressions
 
Christ, my lua is only 10 bytes smaller than the regex. I need to quit lua... or get better at it.
 
ah, here's the one where I was eventually beaten by GolfScript (but not before starting quite a discussion whether regex solutions aren't even valid :D) codegolf.stackexchange.com/a/28612/8478
 
@AndoDaan Nah, I agree with the comment on your post. Weight classes.
 
@EricTressler Btw, thanks a lot for the idea, that was fun! :)
 
7:50 PM
It's also just becoming unpleasant. And it'd be fun to learn something new.
 
Well those are much better reasons to change languages :)
 
Sometimes I kinda miss regex from my active SO times... I almost never use it in real-life problems (except some search-replace-fu) and it's also quite rare that it's useful on PPCG.
 
Obviously new here: "Example code: (Shortened to make it harder to read and more likely for people to come up with their own ideas)"
 
lol
What's even the point of providing example code if you don't want people to read it? :D
 
Obviously nobody will figure it out, though, since all the variables are just single letters. Right?
 
7:56 PM
pretty gif though.
 
I'm still not sure if I understand the question. My take is: Draw a 3D random walk that forks and doesn't intercept itself. Do this until there are N forks of M length (or no path is possible for that fork).
Sound right? If so, there's way too much unclear explanation going on.
 
"Here a sandbox we should play in. We're going to plum the depths people. COME PLAY."
N dimensional lighting. Why?
 
8:25 PM
I think that's right. I've written up some notes on stuff which needs clarifying. Over 3kB. I'll see whether I can fit it into 10 comments.
6 comments. Not bad.
Anything I've missed?
 
8:50 PM
@Doorknob Do you know if we can change the behaviour of Community♦ on PPCG? It says "I do things like ... randomly poke old unanswered questions every hour so they get some attention ..." (which I doubt - "every hour" seems a bit off imho). If we could change that to "randomly poke old (unclosed) questions" it would maybe also attract new answers for older questions. If we can we may open a discussion on meta whether we should do so or not.
 
I'd second that.
(Also, hey, I think I've never seen you on chat before.)
 
@Howard I don't recall that that's been done on any SE site before, but it could be possible. I'll check to see whether that would be viable (by poking more people with sticks, of course).
 
@MartinBüttner I am rarely on chat - mainly because I'm doing most of the golfing when I am offline (or even without any computer at all - thinking about my code over and over again). I try to limit my time with PPCG to a few minutes which would be almost impossible when I am around in these chat rooms ;-)
 
@Howard Yes it's possible, but it's a bit... unusual. If you post a feature request with what criteria you would want (and why!), the team might consider it
 
@Doorknob What do you mean by "unusual"? I'd like to know that before "poking more people with sticks" and earning "unusual" returns ;-)
 
9:05 PM
@Howard It's never been done before, and it seems strange to want to do it.
 
It makes sense for PPCG since a question being answered means something different for us than for "usual" SE sites
 
@Doorknob Ah ok. I'd suggest to formulate a meta question and when we get consensus about what the feature request might look like we can ask then.
 
Yep, meta post would be perfect.
 
9:22 PM
0
Q: Change behaviour of Community user to poke more "old" questions

HowardOn PPCG also old and already answered questions provide a valuable source for attraction of new answers and new users, which also supports growth of the site. Moreover, there are several barely noticed questions (often with only few answers) which are examples of good and noteworthy challenges. ...

 
@Howard Ping me again when you're ready to ask the SE team for input.
 
Ok - may take some time, depending on the discussion, but of course I'd be happy if you could assists with this issue.
 
I'll probably comment on / answer that sometime later today; I'm somewhat busy with other stuff right now
 
@Howard I think I know what you mean :D
 
I'm just a silly bot
3
 
9:45 PM
Oh, a fake "self" aware bot ;-)
@MartinBüttner And here the proof again - it is already very late and spent less time on "productive" work than intended. Not that it isn't pleasant to waste time with PPCG but I fear that I regret it somehow tomorrow morning.
 
just yesterday I stayed away from the chat all day and still wasn't any more productive :D
but I guess that was just coincidence of having a bad day...
but I totally get you. kodus if you have that discipline despite obviously being very fond of PPCG :D
 
I come back here when I get frustrated with whatever I am doing.
Frustrated may be a bad word to use there...
Pretty much every time I have to do any research I end up on Stack Overflow
 
My PPCG activity has been... sporadic
 
@FireFly I can tell :P
 
10:00 PM
Haha
 
@FireFly Have you lost your light?
Now I hate your ways, 'cause they're just like mine.
 
This graph is even more telling, I think
 
10:32 PM
@PeterTaylor Just finished reading that thesis on growing penrose tilings. Thanks a lot, that was very interesting. :) ... I don't think I'll get around to start working on my own GoL submission this week, but I might give it a shot on Monday.
 
I hope some of these feature requests end up happening.
 

« first day (1299 days earlier)      last day (3548 days later) »