« first day (1881 days earlier)      last day (2965 days later) » 

12:00 AM
>>> g(1)
[3, 5]
>>> g(2)
[12, 25]
>>> g(3)
[144, 325]
>>> g(4)
[3456, 8125]
>>> g(5)
[41472, 99125]
 
@orlp Are there any performance differences in Python using named lambdas versus def'd functions?
 
@Doorknob git clone https://github.com/orlp/dotfiles
python3 -m pip install ptpython
then dotfiles/pcalc/pcalc
 
@AlexA. You know, when rendered small it does look like the french flag. But that's fine too :)
 
@HelkaHomba :)
 
@orlp ptpython looks nifty
 
12:03 AM
@Doorknob also very handy functions I have pre-defined are copy and paste
copy(2**1024) and bam you're done
17976931348623159077293051907890247336179769789423065727343008115773267580550096‌​313270847732240753602112011387987139335765878976881441662249284743063947412437776‌​789342486548527630221960124609411945308295208500576883815068234246288147391311054‌​0827237163350510684586298239947245938479716304835356329624224137216
 
What is ptpython?
 
no need to muk around with selecting the right thing :P
 
@orlp that's definitely a whole lot easier than <mod+'>irb<cr>2**1024<cr><alt-esc>kbve<cr> :P
 
or let's say alex's msg needs to be double spaced
>>> " ".join(paste())
'W h a t   i s   p t p y t h o n ?'
>>> copy(_)
 
What's this magic?
 
12:06 AM
@CᴏɴᴏʀO'Bʀɪᴇɴ you can use it yourself
 
@orlp What is it though?
 
@CᴏɴᴏʀO'Bʀɪᴇɴ scroll up to git clone and follow the instructions
@CᴏɴᴏʀO'Bʀɪᴇɴ a python interpreter on crack :P
 
@orlp for that kind of stuff I use cVim's "pop out vim instance" feature. If a textbox contains asdf, I can hit Ctrl+I to get a gvim instance with the text inside of it, :s/./& /g or similar, then ZZ drops the modified file back into the textbox
 
@orlp Uhhh nevermind I don't want to know anymore
 
@Doorknob sure, but pasting into a vim I have open somewhere is no problem
lowering the boundary to use a Python interpreter is glorious
I also use it constantly while programming
(1 << 18) // 3
hrm, what if I sum all 5 dividends? sum((1 << 18) // i for i in range(1, 1+5))
 
12:12 AM
> 1+5
 
@CᴏɴᴏʀO'Bʀɪᴇɴ it's a mental thing I do
 
hey, I'm struggling with how to design the following code:
 
whenever I want an inclusive range starting on 1 in Python I do range(1, 1+n)
 
In my KoTH controller, a user can create a class with methods that are the "user" methods
 
12:14 AM
I guess that makes sense, using less mind to put something down
 
so, for example, in Good vs Evil, they would make a class with a "boolean vote()" method
how would my controller automatically detect such methods, and autofill them with an implementation that communicates over STDIO
 
@CᴏɴᴏʀO'Bʀɪᴇɴ post yourself to twitch so we can watch you
 
@EasterlyIrk XD I'm already dead
 
12:24 AM
Are there always at least n primes less than n^2?
 
For n > 1, yes if I remember correctly
 
Nice, thanks!
 
15
Q: The n-th prime is less than $n^2$?

WarrenLet $p_n$ be the n-th prime number, e.g. $p_1=2,p_2=3,p_3=5$. How do I show that for all $n>1$, $p_n<n^2$?

Just so that Alex can't blame me if maths breaks some day :P
 
Perfect, thanks for the link.
Now I know who to blame. :P
 
12:45 AM
Doctors remove wrong body part. Sounds worse than it is.
@CoolestVeto I have dubstep on autoplay now. :P
 
@AlexA. I said n>1 :P
 
Yes?
 
Does f(1) work?
 
@AlexA. did you try iTerm2?
It crashes for me. :(
 
@Sp3000 Ah crap. Easy fix but it costs two bytes: change n^2 to n^2+1
 
12:54 AM
Where is this?
 
You can do it in 1 with 2n^2 :)
Also, Rational's kinda bulky, gimme a bit
 
true
 
@Sp3000 Oh but it works so well :P
 
n->prod(1-2.//-~primes(2n^2)[1:n].^2) maybe?
 
o_O
I didn't know about .//
 
12:56 AM
What is .//?
 
Elementwise rational construction
 
1/2 gives a float, but 1//2 gives a rational. .// is just element-wise over a vector
 
@AlexA. cool
 
12:57 AM
[1,2,3] .// [5,6,7] is [1//5, 1//3, 3//7]
Yes, very cool. Thanks a bunch, @Sp3. :D
 
(Yay, I learnt something useful :P)
 
Oh, overflow
I need a big in there somewhere
 
... Ah :/ right that.
 
n->prod(1-big(2).//-~primes(2n^2)[1:n].^2) seems to work :D
oops
Copied the wrong thing
 
That'll probably work until the n is big enough such that the nth prime overflows
Which would be quite a while, but I dunno if orlp wanted it to work for all inputs :/
 
1:00 AM
@orlp For your challenge, do submissions have to work theoretically for all inputs? (I'd be surprised if many of the current submissions do.)
 
@AlexA. yes
otherwise the submission is obviously incorrect
not sure why people keep asking this on every single question I post
why would your answer suddenly not have to work for n+1 when it does for n? does the question say so? no
 
Overflow
Limits of the language
 
too bad?
work around it
 
Probably because, for a lot of questions, there's a difference between "working for all practical inputs" and "working for all inputs theoretically"
 
I usually assume the former applies when unspecified.
 
1:03 AM
the only thing that's excusable is not having enough runtime or memory
but given an all-powerful machine that's really really fast with tons and tons of memory your program should just work
 
Not all languages have arbitrary precision integers
 
@HelkaHomba that doesn't matter
 
@orlp That is hardly the case with any challenge.
 
code-golf competes within their own language
 
The usual assumptions is always within the language's limits (with rare exceptions like 8bit langs). Otherwise we'd have to delete hundreds of answers from this site.
3
 
1:05 AM
^
 
To reiterate that not all of the current submissions do that: "Fails for large inputs because only integers up to 2^52 can be accurately represented internally." (from Luis' MATL)
 
@AlexA. Which is reasonable tbh.
 
well, I'm in the camp that allows invalid submissions if they're interesting
but they just won't get accepted
 
@mınxomaτ Yeah, I think so
 
if you want my checkmark, your program should work, no exceptions
unless I specifically mention otherwise
 
1:06 AM
Per our policies, any submission that doesn't fully comply with the spec should be removed.
 
@AlexA. Beyond that, it would just be a requirement for the requirement's sake.
 
So if the spec is that it must theoretically work for all inputs, then answers that don't work that way should be removed.
 
@orlp Then mention that in the challenge, else people will follow the rule minx just mentioned and be confused when you don't accept them
 
It's a bit ridiculous to expect C answers to import arbitrary precision arithmetic libraries
 
1:08 AM
Also, requiring all inputs to math challenges will just add the overhead of including a BigInt lib to any language that doesn't have it. Which is neither interesting nor does it add anything to the challenge.
 
@AlexA. Side note: you can probably replace primes(2n^2) with filter(isprime,1:2n^2) and assume n is a BigInt, because otherwise there's no practical way to input anything like f(2^100) anyway :P
 
@Doorknob it's a bit ridiculous that C can just hardcode n=1 to 5 and ignore the rest
 
@orlp except that's a loophole
 
@Doorknob well it'd be a fully functional implementation, by your rules
 
yes, and it would also be deleted as it violates site policy
 
1:09 AM
^
 
but why? it has the exact same behavior as the other implementation
 
because it's a loophole
 
@Sp3000 isprime is probabilistic for BigInts
 
I just find it weird that every languages has to solve it's own challenge, depending on how crippled it is
 
wget goo.gl/asdf; python asdf is also fully functional
 
1:10 AM
all these languages are turing complete
 
@AlexA. ... D: damnit didn't know that
 
they can be implemented
the question is - how many bytes does it take?
if your language does not have built-in multiprecision, well, then it's going to take more bytes
it's that simple
that's the core of code golf: kolmogorov complexity
 
It would really be prohibitively obnoxious to implement arbitrary precision in a language that doesn't have it. It's basically language restrictions for no good reason.
 
@orlp But few will want to write a BigInt library for a language that doesn't have one, and won't bother answering at all.
 
1:11 AM
there's no point to it if language A gets a free pass because it's a less powerful language
 
@orlp No, because you shift the focus from actually solving the problem to creating a limited BigInt implementation for the challenge, which is likely bigger than the actual code.
There's no benefit.
 
and all this is still too vague, do we have an unambiguous policy of how broken a program is allowed to be because it's a less powerful language?
 
Insisting on arbitrary precision is analogous to insisting on a certain I/O format. Your language can't do file I/O? Too bad, you don't get a free pass because your language isn't powerful enough.
 
@Doorknob I/O is well defined though
so far this isn't
 
@orlp You consider it broken. To prevent the ambiguity, many challenges set an upper limit for inputs, which is what you should do instead of just assuming everyone thinks how you think (which, as we already established, is not the case ... in this case) IMO.
 
1:15 AM
Arbitrary precision isn't well-defined?
 
@mınxomaτ but we need a default
I didn't set a limit for my challenge
 
@orlp "the maximum representable integer range in your language"
 
to my knowledge the default was 'no excuses'
@Doorknob so.. does the input have to be representable in that?
the output?
all intermediate results?
 
yes
 
@Doorknob The only problem is boolfuck
 
1:16 AM
which is it?
 
@CᴏɴᴏʀO'Bʀɪᴇɴ what about it?
 
@orlp It wasn't. As is implied by the before mentioned hundreds of answers that would suddenly all be invalid by you "rules".
 
@orlp all of the above?
 
5
Q: Integer range defaults for challenges

MegoWhen writing challenges involving integer I/O, I always find myself having to type the same thing: You may assume that the input and output will not exceed the maximum representable range in your language. I think it would be useful if we had a default for integer ranges in challenges, to avoid n...

 
1:16 AM
@Doorknob Trivial solutions.
 
Related - note that this never got resolved
 
19
A: Loopholes that are forbidden by default

DennisAbusing native number types to trivialize a problem It is common practice to restrict challenges to cases where input, output and/or intermediate values of the algorithm of choice fit into the language's native number type. At least for input and output, this is generally assumed even if not sta...

 
@Doorknob so is my answer automatically OK for any range, as long as my implementation at some point does some massive exponentiation?
 
@Doorknob I've seen it before though.
 
@CᴏɴᴏʀO'Bʀɪᴇɴ seen what?
 
1:17 AM
Boolfuck trivializing the problem
 
@orlp if the algorithm wouldn't theoretically work should the integer type be larger, it's a loophole
@CᴏɴᴏʀO'Bʀɪᴇɴ why aren't you using your flags
 
I just found out about this loophole today
 
@Doorknob but how do you distinguish that from legitimate tricks?
 
like unsigned(-56) to get some specific large number
 
1:19 AM
unsigned(-56) can be turned into unsigned_type::max_value - 56 without breaking the algorithm
it really should be quite evident if someone tries to abuse what you're describing
 
@Doorknob not if there is some 'magic' assumption where integer types get larger
 
what do you mean?
 
w/e I don't care enough to argue about this
I'll just be specific on my challenges
 
Fair enough
 
the community consensus is clearly in favor of allowing people to not implement obnoxious arbitrary precision. You're allowed to do that, but don't be surprised if it attracts downvotes
 
1:22 AM
This is a bit of a grey area, unfortunately :/ - I think I remember seeing a Python answer which had exec""*99, with the argument that "that was large enough for practical inputs". I thought about arguing against it, but I don't think I did.
 
I just feel that the current rule is vastly more ambiguous than you guys try to make it seem.
 
@Sp3000 That's a whole different can of worms. That's not a language restriction.
@orlp You do bring up a valid point—the rule could benefit from clarification and formalization
 
which has an integer limit of 100
 
7 mins ago, by Doorknob
19
A: Loopholes that are forbidden by default

DennisAbusing native number types to trivialize a problem It is common practice to restrict challenges to cases where input, output and/or intermediate values of the algorithm of choice fit into the language's native number type. At least for input and output, this is generally assumed even if not sta...

 
go above that it and shuts down your PC
@Doorknob no no, it's a new language
and as long as I make that language before a challenge gets posted, it's k
 
1:24 AM
read the loophole
 
@orlp Better x3
 
btw @orlp if you're clarifying, could you also clarify specifically that the implication is that probabilistic primality methods aren't okay?
 
@Doorknob so where does it become deliberate? 100? 300? 2^16?
 
Friggin ping.
 
@CᴏɴᴏʀO'Bʀɪᴇɴ Is there yet to be a language that no one has any form of animosity towards?
 
1:27 AM
Are the stars being cleared?
 
Yes
 
@orlp If probabilistic prime check are out, most submissions to your challenge are invalid. Most languages that handle big integers use probabilistic prime checks, since the chance of a false positive is negligible in practice.
 
M'kay
@HelkaHomba Hmmm... PHP? :3
 
@orlp it becomes deliberate when it's deliberate. There's really not much to explain. The answer I linked describes exactly when an answer violates the rule.
 
@HelkaHomba On a more serious note, maybe Mathematica.
 
1:28 AM
@Doorknob how does one objectively score 'deliberate', as it's a guess to the writer's intent
 
@CᴏɴᴏʀO'Bʀɪᴇɴ No. People don't like that it's not free
 
@orlp it's not intent, it's the algorithm
 
@HelkaHomba Ah, any form ,right.
 
@Doorknob how does one define 'the algorithm' if the code is apparently insufficient to describe it?
 
@HelkaHomba Rust?
 
1:29 AM
is it some 'magical' extended language where we act as if the integers were unbounded?
which brings me back exactly to my point of tricks like unsigned(-56)
 
@HelkaHomba C?
 
@orlp have you read the loophole post? It answers all your questions
 
@Doorknob also, that post seems to suggest it is not the default
> It is common practice to restrict challenges to cases where input, output and/or intermediate values of the algorithm of choice fit into the language's native number type.
 
keep going...
> At least for input and output, this is generally assumed even if not stated in the challenge specification.
 
in 2016 Programming Puzzles & Code Golf Moderator Election, 8 mins ago, by Helka Homba
To all candidates: Explain why you want to be mod in 12 chars instead of 1200.
 
1:31 AM
@Doorknob I'm blind
 
2:10 AM
0
A: Solve the Secretary Problem

user52414I think this is actually how people choose a marriage partner.

@Doorknob ^
pls hammer to death doom and destruction.
thankee
It came up in the first posts review.
 
He's basically wrong too. There is a well-known variant of the Secretary Problem that's exactly the same, except that instead of choosing a secretary, you're choosing a partner.
I'm pretty sure that's not how people pick partners in real life though...
 
> now
 
The difference a single letter makes. >_<
 
hey, if any of you are interested in helping my KoTH framework along, I'd appreciate an answer here:
0
Q: Code Design: Delegation of arbitrary functions

Nathan MerrillOn PPCG, we frequently have King of the Hill challenges, which pit different code bots against each other. We don't like limiting these challenges to a single language, so we do cross-platform communication over standard I/O. My goal is to write a framework that challenge-writers will be able u...

 
@Dennis for your base -i+1 answer, it's nice how "carrying" every 2 at once lets you avoid getting digits above 3
i had been trying a similar approach with carrying from right to left, but it eventually messed up the base 10 representation by having digits go above 9
 
2:25 AM
Yeah, that worked out nicely. Doesn't stand a chance against feersum's binary approach though...
 
Personally I'm pretty impressed with the answers so far, although I do wish the papers I've seen had proofs for the not-so-obvious tidbits :P
 
though it works on the test cases, i'm unclear if all cycling cases reduce to 11+111
i mean, all cases where the sum would be 0 and so digits keep getting pushed left
 
we've had quite a few of these unorthodox base challenges
it'd be cool if a language had builtin support for it
 
Pytek will have built-in base conversion support. Maybe not to the point of having -1+i as a base though...
 
Jelly has support for negative bases, but it stops at integers...
 
2:28 AM
I'd like to see a language support any arbitrary base, although it'd probably be pretty non-trivial to implement :P
I mean, not even Mathematica has that (I don't think?)
 
I still don't completely understand how anything besides positive integer bases work
 
They work in exactly the same way.
 
I mean the base is the number that it "wraps" over, which doesn't make sense for negative numbers
 
Well, if you think of it that way...
a_n*x_n + ... + a_1*x + a_0 is the general form.
 
right, but a_n has a maximum value of the base
 
2:30 AM
Well, that doesn't have to be the case...
 
@xnor Not sure about this either, although I have no idea how to prove either way
 
@Dennis I think you can save a little by not computing the input length
s=sum(input());L=1
for _ in`s`*8:s+=1098*int(str(s).translate('0011'*64));L*=10
print s%L
 
so, 3*10^1 + 23*10^0 is still base 10?
 
Technically, yes.
 
@Doorknob Have you worked with Shoes before?
 
2:31 AM
It's just convention that we simplify it.
It's like saying that multiplication is repeated addition, which falls apart when you get to imaginary/complex numbers.
 
@Sp3000 if checking for (3,7) does work, what's the shortest expression that's 0 only for it?
 
@Doorknob Ahem, you put user:me.
 
... whoops
 
2:32 AM
>_<
 
I saw the user id number and I was like "...wait, that's mine." :P
 
@xnor Sorry, only for it?
 
OK. I just figured since you're into Ruby things that you might know it and be able to answer a question I had but anyways
 
@xnor Oh, iterating over the input never occurred to me... Thanks!
 
i mean an expression in a and b that equals 0 when a=3,b=7, but is nonzero for any other pair (a,b)of non-negative numbers
except possibly a=7,b=3
 
2:34 AM
@Sp3000 Um, bold question: Can the single non-alphanumeric separator be a plus sign?
 
Oh, you mean for golfing purposes
 
yup
@Dennis i see where this going :-)
 
@Dennis I was waiting for that question :) The answer is yes, and it was "non-alphanumeric" on the offchance someone needed that + sign :P
 
Great! :)
 
arithmetic coder!
all I gta do now is load up the Pyth probabilities and I can compress Pyth effectively!
@Dennis let's see if Pyth can compete with Jelly again, if we remove the advantage the custom codepage brings
 
2:38 AM
Well, the custom code page by itself isn't an advantage. Pyth uses ISO 8859-1 by default, so there are 96 more printable characters (and 63 unprintable one) that it could use but doesn't.
 
@Dennis Pyth intentionally limits itself to printable ASCII, with that limitation lifted inside strings
 
Yes, I know. That's a design choice though, not a code page thing. Both Jelly's and Pyth's code pages have exactly 256 characters that can be encoded as a single byte.
 
@Dennis it is a code page thing, Pyth's builtins are limited to the ASCII codepage
 
Pyth uses ISO 8859-1, not ASCII.
 
@Dennis inside strings, not outside of it
 
2:42 AM
You cannot use different code pages inside the same source file.
 
@Dennis you can :)
 
How?
 
Pyth switches code page when it encounters "
 
o_O
 
@Dennis at least in Pyth5 the whole input file is never decoded in one chunk, it stays binary until a character is needed
 
2:43 AM
@xnor ... this is surprisingly tricky
 
@Dennis the distinction is rather pointless though
 
@orlp OK... That's seems unnecessarily complicated, seeing how ISO 8859-1 and ASCII are perfectly compatible. Unless Pyth 5 doesn't use ISO 8859-1 for string anymore.
 
Can't think of anything apart from a==7>3==b atm :/
 
you can say that brainfuck uses ISO 8859-1, UTF-8, ASCII, because anything except it's syntax is ignored
 
oh hey this exists
 
2:45 AM
@Sp3000 that works, though i dunno if you'd allow the output False for 0
 
@LockOpeners your profile picture has a nice top note, pure vanilla, it's a 10
 
thanks
i've got that cream
that top milk
 
Oh wait, we want 0 when it's (7,3) don't we :/ nvm
 
@Sp3000 oh, right, you want the negation
 
2:46 AM
I'm the friendly neighbourhood perl6 golfer
 
a-7|b-3 maybe?
... nope
 
what's wrong there?
 
@Dennis for now I'll focus my compression only on printable ASCII Pyth (so no funni string business), just because it makes the code eaiser
 
thinking of posting a question, it's pretty basic and is related to one that's already been well received. is the sandbox necessary for that?
 
@Insane yes.
 
2:49 AM
@Insane The sandbox is never necessary.
 
The sandbox will help determine whether it is too similar.
@Insane don't trust @Doorknob.
 
@Insane It's not necessary (it almost never is), but if you're at all uncertain about your challenge idea, it might help.
 
since it's pretty simple and you guys could probably tell me right now if it's too similiar
 
The Sandbox is a very, very good idea for anyone that's not Calvin Helka or Doorknob.
 
can i just ask for ya'lls opinion
 
2:49 AM
sure
 
@Insane just post for like 5 min.
@Insane okay
shoot
 
@xnor f(0b1, 0b11101) only reaches 3,7, not 7,3
 
i might have said it switched, you want to check 3,7
so a-3|b-7
 
@EasterlyIrk Posting to the sandbox for less than... say, at least a few days is somewhat meaningless
 
codegolf.stackexchange.com/questions/75979/full-width-text this reminded me of my favorite fullwidth latin text. i was thinking of posting basically saying "inspired by (above), ouput in fullwidth latin".
 
2:51 AM
since 7,3 goes to 3,7 but not the other way
 
Oh, right. Probably my fault - I thought they were interchangeable for some reason
 
@Doorknob @AlexA. once posted for like 15 minutes.
 
might add a bit of a twist
 
@Insane Difference between latin and normal?
 
@Insane It's definitely not a duplicate, but it's kind of boring (not that the original question wasn't either).
 
2:51 AM
@EasterlyIrk >_>
 
gonna call you in to testify.
 
@EasterlyIrk the latin uses the latin fullwidth characters
 
is there a code page that has fullwidth latin contiguously?
 
tr a-z a-z
 
2:52 AM
@Doorknob Not as a staging area
 
I think to similar.
 
boooooring
 
^^^^
 
@xnor UTF-8 does
 
2:52 AM
and ^^^
sorry
 
Actually tr !-~ !-~, but yeah.
 
Yeah a-3|b-7 seems to work
 
@Doorknob i was thinking that too, but it adds a tad bit of complexity i guess
 
@Sp3000 that's gonna be hard to beat
 
Too similar, sorry.
 
2:54 AM
@EasterlyIrk i already got your opinion
 
It's not similar at all.
 
@Dennis do you have a pyth program I should compress?
 
Closest other I have in mind is a*b-21 which obviously does not work :P
 
@Sp3000 i forget that bitwise operators have precedence below arithmetic ones, that makes the | useful as an arithmetic or for nonzeroness
 
Sometimes useful, sometimes annoying :P
 
2:55 AM
@Sp3000 nor does a/b-3/7 in Python 3
 
@orlp _shM.u,%J/eMeN\12-+PMeNm.B6/J2k,kQ
 
@Dennis thanks
 
I guess I'll just post it and see how it goes. I'm more inclined to take a mods opinion that it's not too similar to be considered a duplicate, and I'll hope the community as a whole doesn't think it's too boring.
 
@Insane do you even have a PPCG account?
 
@Dennis it seems to be, but just to make sure, that's a real program, right?
 
2:56 AM
@Insane i'm pretty sure most of us think it's boring
 
@Insane IMHO it's overly trivial.
 
^ and ^^
 
@Insane if you're going to solicit opinions then ignore them, why ask?
2
 
@orlp Yes, Jakube posted it today.
 
2:57 AM
@xnor But I didn't, and I can take the opinions into my own accord in any way I please.
 
@Insane of course, you're free to, just don't be surprised if there's downvotes
 
@orlp Context, although I think compressing a more comparable answer might be more useful, since Jakube's used quite a different algorithm to Dennis here
 
for dupe checking there's Small Caps Converter, which is similar in task but different in implementation because there's no contiguous range
 
@xnor There'll probably be more downvotes if I post it now than if I had just posted it originally. It's not a duplicate, and it's less boring than the question that inspired it
 

« first day (1881 days earlier)      last day (2965 days later) »