« first day (1604 days earlier)      last day (3246 days later) » 

12:01 AM
Thanks, mysterious benefactor. :)
 
12:55 AM
@Lembik Linear or expected linear (i.e. is hashing okay)
 
Hashing strings?
 
Hmm just noticed xnor's comment about the constant alphabet above. Might not matter in that case...
 
Even with the constant alphabet, I don't see any possibility in doing this in linear time.
I can create all 26! different strings in linear time, but I don't see how you can check, if any of these strings is a substring of x.
 
The thing is you're not looking for strict substrings though
 
1:18 AM
@Jakube Oh right, I see. If you create all possible strings, then can't you KMP after that?
 
 
6 hours later…
6:52 AM
@Sp3000 linear!
:)
 
7:12 AM
Valid solution, yes? :D
 
7:51 AM
@Sp3000 Do you mind talking me through it? You make all possible strings of length 52?
then what do you do?
Call |X| the length of X and |Y| the length of Y
I am a little confused by your algorithm at the moment
 
Say our alphabet is ABCD and I have the string ABACD
 
ok
 
So the middle part maps each char to its index in the alphabet, i.e. [0 1 0 2 3]
 
that's easy so far...
 
Then you go through every permutation of the alphabet and perform KMP. So supppose you have the permutation DACB, then you're effectively doing KMP with the substring DADCB
 
7:55 AM
oh of course
 
(the only change from KMP is instead of X[i] you have p[b[i]], i.e. permutation[index[i]]
 
sorry.. that's obvious now you say it :)
you know there is a simple, linear time and fast solution too :)
 
I sure hope there is, but this was the first one that came to mind :P
 
:)
 
I tried seeing if I could use Python's built-in find, but apparently it's expected sublinear, and worst case quadratic
 
7:56 AM
I will give you a hint if you like
 
Specifically O(m/n) and O(mn)
 
that's bad!
 
I think my first thought (when I pinged you about hashing) was to keep track of the substitutions in a sliding window and counting how many unique ones there are
 
I don't know if that can be made to work
 
You'd need a deque or something, but I was too lazy to work out if it was fast enough
 
8:01 AM
@Sp3000 yeah, I checked Cpython too and that uses a similar algorithm, we have to find an implementation/language which uses KMP
 
let me know if you would like a hint for an easier fast. linear time solution :)
KMP in Haskell is an interesting challenge!
do we have any haskell gurus on ppcg?
 
@Lembik maybe emphasize the "substring in "Given two strings X and Y, with X no longer than Y, the task is to determine if there is a substring of Y which is an isomorph with X.", as it isn't obvious that you have to search for substring not somplete isomorphs\
 
@randomra how could you search for complete ones if they are different lengths?
 
you can't but the question's first half is complete ones
I was confused for a while
 
oh :(
 
8:04 AM
@Lembik I would bet proud haskeller is one.
 
cool!
 
Yeah I think keeping track how how many unique pairs there are works
Making use of the fact that the alphabet is constant again
 
@Sp3000 I would have expected find to change to KMP if the Boyer–Moore takes linear time already, but maybe that is too complex to be implemented
which was the username-related golf? I can't recall?
I can't think of a recent challenge that required this; could you link to one where having a specific username would give you an advantage? — M. I. Wright 8 hours ago
 
They probably prioritised find more on real life applications than theoretical bounds - few situations leading to worst cases, and better on average.
 
but if you are at ~100*(m+n) steps, it is quite sure that you are in some kind of a theoretical worst case
but it probably wouldn't have much use
if you need such O()/runtime guarantees you might use your own algorithms
 
8:23 AM
@Sp3000 well.. the worst case algorithms are also fast.. I think you are too kind on this topic
it's really not hard to write a fast, guaranteed linear time find
I don't think think there is any evidence that their find is faster on average is there?
 
As I said, O(m/n) expected
Apparently used in fastsearch.h
 
@Sp3000 yes but the worst case linear algorithms can also have O(n/m) expected time (assuming n >= m)
so I don't see any advantage in making the worst case worse
the first link is interesting!
I feel that they are wrong though :)
"After some tweaking, I came up with a simplication of Boyer-Moore, incorporating ideas from Horspool and Sunday.".. well. there is a famous algorithm called Boyer-Moore-Horspool!
I suspect they just don't know the field well
 
Hmmm maybe. I guess it works well enough that nobody's complained about it yet or something
 
@Sp3000 right.. or the complaints are lost in the general "Wow python is slow" background noise :)
 
Well they do update things for efficiency reasons from time to time...
e.g. Python 3.5 now has OrderedDict implemented in C (woo)
 
8:31 AM
@Sp3000 that's interesting. I did know about the ordereddict thing. Not wanting to start a flame war, but I still remember their reasons for banning tail recursion elimination
that just seemed bonkers to me
 
Hmm I haven't about that
 
the real issue with python is that there is a whole subset of users, including me, who never use its dynamic features
and we complain :)
but the python experts say "But you can't do that because of feature X, Y, Z which are crucial to the language"
it's like there are two languages in practice
for example. docs.python.org/2/library/inspect.html ... I will likely never use it but it stops all kinds of optimisations
 
"proper tracebacks" Well admittedly, that does make sense, for debugging
 
@Sp3000 yes in a sense... I mean you could turn off the optimisation you would have thought for debugging. And python is essentially impossible to debug in any case due to its dynamic typing :)
 
How does that make debugging harder?
 
8:37 AM
@Sp3000 because you can't catch simple typos!
x = 4 x = "tree"
that's perfectly fine in python
when you meant y = "tree"
also list comprehensions in python 2 are just broken!
 
?
 
x =2 print [x for x in range(100)]
guess what value x has now?
 
2
 
no! :)
print x
99
which is just plain wrong
 
Too used to Python 3 :P
 
8:40 AM
:) to be fair they did fix that in python 3
but the dynamic typing really stops it being usable for anything serious especially with >1 coder I feel
 
There's a lot of things which I have problems with in Python 2 myself, so I'm glad I made the switch
 
on the other hand.. I love it for my little scripts that I write for myself :)
@Sp3000 sorry to be dumb but does your code actually work? :) I just tried cat test|python3 SP3000.py
how do you use it?
 
I run using IDLE normally, but you can probably do py -3 prog.py < input.txt or python prog.py < input.txt from command line
 
python3 SP3000.py < test
it just hangs
I think there is a problem with the input() lines
 
Are you trying a smaller alphabet?
 
8:48 AM
oh I see! :)
 
I wasn't kidding about O(52! n) :P
 
got it :)
let me know when you want that tip please :)
 
It's only been a day, what about others? :P
 
:)
 
9:15 AM
Is it just me, or does Beta Decay's answer look cubic?
 
It looked circular to me.
But that can be just me
 
9:27 AM
@Lembik That may be confusing, but... what kind of person writes code like that?
 
@Doorknob sorry.. like what?
 
the message I'm replying to
 
I am completely lost :)
 
48 mins ago, by Lembik
x =2 print [x for x in range(100)]
@Lembik Click the arrow to the left of my message.
 
@Doorknob Oh I see... It's perfectly reasonable to use a list comprehension isn't it?
what part is odd?
clearly I didn't show a full piece of interestnig code :)
the point is just that the bound variable in the list comprehension turns out to be a free variable!
which is plain broken
 
9:29 AM
@Lembik Using the same variable name in two completely different situations.
 
@Doorknob you would expect to be able to use any variable name you like in a list comprehension. It is meant to be a bound variable
imagine the two lines are not right next to each other but in a large piece of code
 
Then the variable outside the comprehension should have a more descriptive name than "x".
 
@Doorknob You could of course give all bound variables unique names which I think is what you are suggesting
x is a perfectly descriptive name if you are implementing a mathematical formula
f(x) = x^2 + 3 for example
 
@Lembik Yes, so in def f(x): return x*x + 3, there is no issue. But if you start to use variable names like x for variables with a larger scope, then... the problem is with your code, not the language.
 
@Doorknob I completely disagree!
@Doorknob just to check... do you really think print [x for x in range(100)] should change the value of a global variable x?
because if so, our disagreement is solidified :)
 
9:36 AM
I'm saying that if you have a global variable named "x" then you have much, much bigger problems.
 
@Doorknob ok so that is a slightly different point
 
10:07 AM
python question for local experts :)
I am reading in fractions from a file such as 20623301489160484898386347807648462579888062871284623537673785753013075597709499‌​381880261630599472336428908317945297813351826285322243488749696071006104926532024‌​21704420391651/810452259547068937209454660877179912307118404734850957030401822205‌​205627229083622343692782997481209821913649728769685387186552944416362364821655241‌​0378835326291370709768573288448
what's the simplest (and most accurate) way to convert them to decimals?
so I really need to split it into two ints for example first?
eval(fraction) works
but seems dangerous
 
10:31 AM
@Lembik fractions.Fraction(string) docs.python.org/3.1/library/fractions.html
 
^^ If you want to work in rationals that's the best way
 
@Doorknob I'm impressed. :)
 
11:05 AM
thanks
 
11:33 AM
2
Q: Rotate a Chinese checkerboard

jimmy23013A Chinese checkerboard looks like this (based on this question, but this time it has a fixed size): G . G G G G G G . G B B B B . . Y G . Y . Y Y B B B . . G . . . Y Y Y B . B . . . . . Y . Y B . . . . . . . . Y . . . . . . . . . . P . . . ....

 
 
2 hours later…
1:50 PM
The GolfScript website is no more. o.O
 
Oh? That was sudden
 
2:02 PM
0
Q: Computer Arrangement Problem

AsheshLanguage: PHP A Company went to a college campus for hiring purpose. Various candidates participated in the recruitment exam conducted by the employer. There are 10 final candidates left who qualified for the vacancy. Employer maintains the marks of the candidate in the first test. Given a numbe...

 
 
1 hour later…
3:23 PM
@trichoplax Is the idea that, until someone posts an efficiency, the JS snippet will be very slow?
 
@Sp3000 Yes - I know it's painful at the moment but I will update it after the first answer arrives, and there is a lot of room for improvement so I expect at this point it will be much quicker
 
Can I name an improvement (namely precompute the prime filter)? I tried a random image and it's still running :(
 
@Sp3000 It takes about 5 or 10 minutes on my machine. You mean loop over the required offsets rather than looping over all the pixels? Is that sufficiently obvious to not wait for the first answer?
 
1
Q: Prime Nerd Sniping Pattern

trichoplaxLongest day of the year - here's something to waste the extra time... Overview Note this is not a popularity contest and not a graphical output challenge - you are only required to output a string of 65,536 zeroes and ones. The Stack Snippet at the bottom of the question will display this as ...

 
Yeah, so that you don't need to compare all pairwise possibilities, since the filter's shape doesn't change
Personally I think it's obvious enough, and I think your question would get more attention if it didn't take 10 minutes for a test to run
(You can obfuscate the JS if you wish though)
 
3:30 PM
Fair points - I'll edit now before anyone else gets stuck in that tarpit. I don't want it obfuscated - it's there as a baseline implementation. If it's obvious enough there's no point in hiding it.
 
k :)
(my random string was worse, awww)
 
lol that strategy is guaranteed to beat the existing answer eventually...
 
Well I can say you've sniped me. There's a strategy I really want to try now...
 
I can only apologise
I've lost quite a lot of time on this one myself so I thought I'd share the suffering...
 
3:54 PM
Huzzah, implement score and it's much faster. Only problem is it's slightly off... hm...
Think I've got it. Few decimal places off but that's probably just floats
 
4:18 PM
@Sp3000 Thanks for your suggestion - I've got it to give the identical score and edited the question
 
:) k - well I've implemented said suggestion anyway, so yeah
 
I think it's a good compromise - there's still plenty of room for efficiency improvements but it only takes a few seconds to calculate a score now
I guess even if your implementation doesn't give the exact same score as long as it's close enough it should still take you in the direction of images which will also score well in the snippet
 
It's correct to 10 sig fig, which is good enough :P - and yeah, I'd like to see efficiency improvements too. I can only really think of one more for calculating the score atm
 
@Sp3000 I linked to your profile and just noticed that the first person to take an interest in my "longest day" challenge is in Australia where it's the shortest day...
 
Oh, it'll be a long day alright - just in a different way...
 
4:22 PM
I hope you don't hate me too much when you look back on all the wasted time...
 
I've been doing basically this all semester :P
 
But I assume people are on PPCG because they want to be Nerd Sniped
 
Bets are someone's going to come in with some really awesome algorithm though
 
I'm looking forward to seeing what directions this goes in
 
Hah. Is that optimal?
 
4:29 PM
Yes lol - sorry
I was trying to find a scoring method that would not have a trivial solution, but it took me so long to spot the trivial solution for this scoring method that I thought I'd post it and see how long it takes. Thanks to Jimmy only an hour...
 
I guess the odd numbers thing helps
 
The results I was getting were converging on tangles and weaves, and not heading towards the checkerboard pattern, so I only realised it was a solution when I read up on pythagorean triples: The non-hypoteneuse sides of a primitive pythagorean triple are always one even and one odd, so the scoring pixels of a black square on a chess board are always all white.
 
Oh right. Primitive.
 
That proves that nothing can score higher than the checkerboard pattern, so even if there are other patterns with the same score the question is over.
@Sp3000 yes - and having a prime hypoteneuse automatically makes them primitive
 
I thought about both, but didn't make that connection :/
 
4:38 PM
I took a long time to notice it myself, which is why I thought it would be worth posting...
The same checkerboard pattern would be optimal for any subset of primitive pythagorean triples, even if it wasn't restricted to just primes. It left me struggling to think of a scoring method that wouldn't become trivial.
 
:P
 
Damn, I saw the Gaussian prime question on mobile and wanted to post the checkerboard answer once I got home... :/
 
hi all
@Sp3000 I see there was a useful comment to my question :)
 
@MartinBüttner Was it immediately obvious to you? I thought the time it took me to realise would make it a worthwhile question but that's 2 people in the first hour or so...
Were you just going to post it as a competitive answer or did you already know it was optimal?
 
@trichoplax I wasn't sure it would be optimal, but I thought it would be fairly decent.
but yeah, looking at the Pythagorean triples now, it's clearly optimal
 
4:49 PM
I don't think it hurts to mention that it's optimal now though - anyone using the checkerboard pattern as the starting image for their code will find that out immediately...
Lol I thought I might get a few days out of this question, rather than an hour.
And the images could have been interesting to see too
 
@trichoplax is there a tie breaker that I can't find, or why would anyone else post an answer?
 
@MartinBüttner I can't see there being any more answers. I'll understand if the question needs to be closed on that basis, but I'm hoping it will stay open until I can assign a bounty to Jimmy. Will the bounty survive the question being closed afterwards?
 
@trichoplax I'm pretty sure it will
but I'm not aware that we close questions that have an optimal answer
 
There doesn't seem any point posting a bounty for second best/best suboptimal answer, as finding one would just require changing a single pixel from the checkboard. My hope was that there would be a series of gradually improving answers narrowing down on the optimal one, but it's dead in the water now :)
 
btw, if you haven't retracted it already, I believe you upvoted my procedural noise on the sphere question on the computer graphics proposal. that just hit 11, so you could reuse one of your votes now.
 
4:54 PM
Excellent - thank you. Will do that now
 
@trichoplax the problem in this case is that this isn't only optimal... I even would have posted this first even if it merely beat the random submission, just because it's the simplest thing anyone could think of
 
@trichoplax Here you go
 
@Sp3000 If you post it you'll be in second place...
 
XD
 
@MartinBüttner Looks like I moved that vote already :(
 
5:01 PM
ah okay, nevermind then
 
Still down to 2 questions needed though - there's hope
 
do you have upvotes on any other of my questions that I should notify you about? ;)
 
No I check all the answers every so often (every few days recently)
 
D: "What mathematics do I need to study in order to program graphics?" is up to 11
 
I'll put that down to the current desperation - hopefully meta in beta will define what's on topic well enough that the example questions won't be too relevant. Hopefully...
 
5:06 PM
yeah hope so too
 
5:24 PM
@Sp3000 @MartinBüttner do you think a proof of optimality of Jimmy's answer would be best edited into the question, posted as a self-answer, or left out?
 
best left up to him
 
OK I'll leave it as is
Yay! My question is still getting upvotes after being obliterated :)
Lol it's 5th on the HNQ page. Seems a waste but I suppose it can still bring new people to the site to see the other questions
 
 
2 hours later…
7:18 PM
0
A: Sandbox for Proposed Challenges

Stretch ManiacStretching Words Write a program or function that stretches a word by an array of letters to duplicate. For example: input: chameleon, [c,a,l,n] output: cchaamelleonn Input The starting word (e.g. chameleon) An array of characters ([c,a,l,n]) or a string to represent an array (caln), or som...

 
 
1 hour later…
8:46 PM
hi @Sp3000
how do you write hints in questions so they only show if you click on them?
 
>! text
@Lembik this will only show when you hover
Or does it need to be specifically when you click?
 
thanks
hover is fine
 
no problem :)
 
@Lembik if you're talking about the isomorph problem, i'm looking into an idea, please no hints yet
 
0
Q: mtDNA mutation tree

PlarsenBackground: MtDNA is a part of the human DNA that is passed from a mother to a child and it rarely mutates. Since this is true for all humans it is possible to create a huge tree that visualize how all humans is related to each other through their maternal ancestry all the way back to the hypoth...

 
8:54 PM
@MitchSchwartz heard and understood :)
 
I am still hoping feersum will update his answer... although he sounded like he might not last time :(
I mean to my prob question
 
 
2 hours later…
10:34 PM
0
Q: Covering Array Validator

RyanA covering array is an N by k array in which each element is one of {0, 1, ..., v-1} (so v symbols in total), and for any t columns chosen (so an N x t array) contains all possible v^t tuples at least once. The applications of Covering Arrays range from software and hardware testing, interaction ...

 
0
A: Sandbox for Proposed Challenges

TNTcode-golf ascii-art A MIDI Track Display Background MIDI files are quite different from WAV or MP3 audio files. MP3 and WAV files contain bytes representing a "recording" of the audio, while MIDI files have a series of MIDI messages stored in MIDI events informing a MIDI synthesizer which virt...

 

« first day (1604 days earlier)      last day (3246 days later) »