« first day (1756 days earlier)      last day (2135 days later) » 

9:09 PM
IQ[1]=="H""2CH4+4O2>4H2O+2CO2";E O=*int(i[1]) 3 +1;C=*int(i[1]) 2;print"2"+i+" + "+str(O)+"O2"+" > "+i[3]+"H2O"+ " + "+str(CO2)+"CO2"
 
Yay! I have a Java answer for that question now!
 
this is pyth code translation of my Python answer...
what is wrong with it?
@Dennis
 
@TanMath How does your code handle the input CH4?
Or the input C12H26?
 
@TanMath That doesn't look at all like Pyth code.
 
@Dennis the if statement
 
9:14 PM
@TanMath, in Pyth, indexes are handled by @Q1, which is lookup(Q, 1). Q[1] is invalid in Pyth
 
@Adriandmen oh...
 
So are int, str and print.
 
@Dennis oops, the print is messed up...
@Dennis how do you do int and str in pyth?
 
@TanMath I think your code is a bit borked... Doesn't work in Ideone.
Oh, it's because you didn't change the second call of the variable CO2. :P
 
wait. what? it was working before
 
9:18 PM
..." + "+str(CO2)+"CO2"...
You need to change CO2 to just O.
 
@TanMath I'm hardly a Pyth expert. There s no int AFAIK, but you can use v (eval). Backtick is Python's repr which may or may not have like str (I have no clue).
 
oh.. my code doesn't work...
 
Just changing CO2 to O fixes it.
 
5 mins ago, by VoteToClose
You need to change CO2 to just O.
 
Can I leave a suggested edit even with the power of mod-editing?
 
9:25 PM
The byte count is also wrong
 
^ This is true.
 
@VoteToClose huhwhat i heard mod
 
XD I was just wondering if I can leave suggested edits even though I insta-edit.
 
@VoteToClose I say don't fix peoples problems for them. (Though hypocritically I did fix up the Paris flag challenge, but that wasn't really for the benefit of the user.)
 
I was mainly thinking changing the byte count. XD
If he hasn't taken my suggestion to fix the problem with CO2 yet, let him have it. xD
 
9:28 PM
@VoteToClose If you propose the edit from an incognito window, yes. Otherwise, no.
 
@VoteToClose The inconsistency with which you use "XD" versus "xD" confuses me.
 
@AlexA. XD is different from xD in that XD is more of a laugh for the sake of laughing, whilst a xD is more natural.
 
@AlexA. Maybe XD are his real life initials and he's signing the message
 
No, I know his real life initials. It was part of his explanation of his VTCdsfajasdf username in Minecraft.
 
You caught me. ¯\_(ツ)_/¯ I'm Xavier Donald. (not really, obvious sarcasm is obvious)
Ugh. I hate how they lock in votes.
I'm an idiot
 
9:38 PM
hey, @quartata, Perl is blowing my mind
:P
 
@Calvin'sHobbies Paris has a flag? /s
 
@Doorknob In a good way?
 
yes
 
Or its wretchedness is blowing your mind?
Oh noooo
 
:D
 
9:40 PM
What do you like about it?
 
@Doorknob \o/
 
the idea of scalar vs. list context is really interesting (and powerful)
 
for the alkane challenge, I wonder if there's some insane way to extract the number n from int(input(),36)
 
Hmm. Question: can we treat command line arguments as STDIN? My guess is no, but... just in case.
 
it's also similarish to Ruby in syntax which makes my inner Rubyist happy :P
 
9:42 PM
@VoteToClose Yes, it is an acceptable alternative to STDIN
 
@VoteToClose which CO2?
 
also, _ variables are magic
 
@Doorknob See? I told you if you like Ruby you'd like Perl
@Doorknob Yes they are.
 
24 mins ago, by VoteToClose
..." + "+str(CO2)+"CO2"...
 
Nothing makes me happier than being able to just type pop
 
9:42 PM
@Doorknob Uh what? I don't see any similarities. (Granted, I haven't looked into Ruby much.)
 
There's a lesson to be had here.
 
@VoteToClose you mean str(O)?
 
@quartata haha
 
@TanMath Correct.
 
27
A: Default for Code Golf: Input/Output methods

Martin BüttnerPrograms may take input via command-line arguments

 
9:45 PM
@VoteToClose so there is no point for C=2*int(i[1])
 
o-o Which Python version?
 
@VoteToClose python 2
 
@TanMath I count 155 Bytes
 
/me head desks.
Please ignore me for all time. c: I'm an idiot
 
@VoteToClose there can be only one
2
 
9:48 PM
@VoteToClose so all the code is messed up?!
 
@quartata The question is... who's the real highlander.
 
Me
 
@TanMath You might need to replace O with C now, but it's your code. ¯\_(ツ)_/¯ I don't really know. What I do know is that it wasn't even running before the change.
 
:(
 
9:51 PM
 
@AlexA. That made me feel bad. I'm sorry.
 
@VoteToClose yeah. i checked cases where H was below 10 but forogt to take into account when it was above 10
 
Allow me to rephrase.
 
@TimmyD -.-
 
@VoteToClose If the question says "input", you can use whatever you like from the Meta post @quartata posted. "Back to the chemistry class" specifically requires STDIN.
 
9:51 PM
47
Q: Alex is sometimes right

Calvin's HobbiesThis challenge is to lift the spirits of our mod Alex A., who is usually wrong. Suppose you have a friend named Alex who needs help with basic logic and math, specifically mathematical equivalence. He gives you a list of equations of the form [variable] = [variable] where a [variable] is alwa...

That's better.
 
:)
 
> or the nearest equivalent if not possible.
Interpretation. I'll ask the OP, but I'm pretty sure that means I can use CLAs.
 
> if not possible
 
> possible
 
> si pas possible
 
9:52 PM
> nearest equivalent
 
Java can use STDIN, so it must. If there was no way for Java to use STDIN you'd be allowed to use command line arguments.
 
> ​
2
 
@undergroundmonorail Does barely being able to use it count?
 
@undergroundmonorail If there were no way! :P
 
@quartata unfortunately i think if you can at all, you have to
@Doorknob thanks, mom
 
9:54 PM
no that's Martin
 
@undergroundmonorail I can't use it. XD I've never used STDIN before, actually. XD
 
/me does a sick kickflip
 
@Doorknob Momtin and Dadknob
5
 
You can be Aunt Alex :P
 
ಠ_ಠ
 
9:55 PM
@Doorknob What about me and Dennis?
What are we?
 
@quartata Ahem, the mods are the parents.
 
@AlexA. OK, you're still excluding Dennis and gnibbler.
fix it
 
@quartata Dirty cousins?
XD I joke.
 
ew wth
 
@quartata qurazy qusin quartata
 
9:56 PM
I was thinking gnibbler could be like the mute grandfather
But I don't know what Dennis is.
Maybe annoying next-door neighbor?
 
I mod-veto "Aunt Alex." What are Dennis, gnibbler, and me?
@quartata No, Dennis is family and isn't annoying.
 
@AlexA. the joke
 
your head
Dennis the Menace is a daily syndicated newspaper comic strip originally created, written, and illustrated by Hank Ketcham. It debuted on March 12, 1951, in 16 newspapers and was originally distributed by Post-Hall Syndicate. It is now written and drawn by Ketcham's former assistants, Marcus Hamilton and Ron Ferdinand, and distributed to at least 1,000 newspapers in 48 countries and in 19 languages by King Features Syndicate. The comic strip usually runs for a single panel on weekdays and a full strip on Sundays. The comic strip became so successful that it was adapted to other popular medi...
 
9:58 PM
 
The gif that killed chat.
 
^ Me, on dates. Because I don't go to any. :c
 
Hello.
 
Mini-challenge: given a number n as input, print the first n Catalan numbers.
 
10:09 PM
n->for i=1:n println("Catalan number $i")end
 
@AlexA. ..
Hell, doesn't Julia have a builtin for Catalan numbers?
 
I think so
 
You could have at least been predictable
Anyways, I'm thinking of making that a catalog actually.
It would fit well with Fibonacci.
 
@quartata fit well
 
10:10 PM
(runs to make Catalan number builtin)
 
@AlexA. >:(
 
Julia has catalan, which is Catalan's constant, but no Catalan number sequence generator or whatevs
 
sub c{say"Catalan number $_"foreach(1..$_[0])}
does that work? :/
 
@AlexA. Ooh nice.
 
Oh hey it does work!
 
10:12 PM
@Doorknob It does.
 
yay perl :P
 
\o/
 
>:O
 
oh I could golf that by replacing foreach with for because they're synonyms, right?
 
@Doorknob It would be shorter if you didn't make it a function and used -n instead tho
 
10:12 PM
Yes
 
oh right
 
In Pyth VQ/.!*2N*.!+N1.!N
 
@Doorknob Yes
I would recommend using foreach for readability in production code though.
Just one of those things.
 
But this is PPCG :P
 
No, this is Patrick
 
10:17 PM
@AlexA. THIS IS PATRICK
 
I'm not a Krusty Krab.
 
Sure look like one
 
...is anyone going to actually attempt my catalan number challenge or is Pyth going to be a lonely 1st place
 
Full program or function okay?
Julia, full program, 72 bytes: n=parse(readline());for i=0:n k=big(i);println(binomial(2k,k)÷(k+1))end
 
looking at it with Python, but that won't win of course
 
10:22 PM
@AlexA. Function's fine
 
If you're going to do an actual catalog I recommend a full program though
 
why?
 
Seems to be The Thing to Do™
 
How do we feel about insisting on full program only for a non-catalogue question?
 
Up to the OP
 
10:23 PM
@trichoplax No.
 
Is it frowned upon? Does it exclude anyone?
 
it's annoying
 
Calvin's done it
Yeah it's annoying
 
It seems like it is restrictive without reason in most cases (I don't object where it's relevant to the challenge)
 
def f(n):c=1;j=3;exec("print(c);c*=4-6/j;j+=1;"*n)
Python 3
 
10:24 PM
Is there precedent off site for only accepting full programs for catalogues?
 
@trichoplax Our defaults specify that full programs or functions are fine and often when a new user insists on one or the other, they're told about our defaults
 
Yes new users usually seem fine with functions once it's pointed out
 
@trichoplax Idk. What does Rosetta Code do? IIRC Martin's idea behind catalogs was to make us the Rosetta Code for golfy solutions.
 
Good point
 
@xnor That's a neat trick with the exec
 
10:27 PM
too bad it's Python 3 so it needs parens
but Python 2 will int-divide
actually, I could just do j=3.
i'm printing floats, which i hope is OK
 
@xnor That's fine.
 
If only there were a Python 2.5 to keep the golfiest features from each version. :P
 
i probably should recurse instead
 
@Doorknob "Python 2.5" is too much of a mouthful though. Let's call it "Pyth" instead.
 
Is it bad that I have 5 different versions of Python on my computer solely for testing code golf submissions?
3
 
10:28 PM
Yes
 
Wow.
 
@VoteToClose No, I had 6 before I even arrived at PPCG
 
I have got 2.
 
2.4 2.5 2.6 2.7 3.2 3.4
dammit python
 
I only have 2.7 and 3.4
 
10:29 PM
Can you guess what my favorite bash builtin is? c:
 
@VoteToClose which
 
compgen -c
 
Which isn't a builtin actually, but is often mistaken for one.
 
I would die without it. XD
 
@VoteToClose Oh, forgot that was a thing.
 
10:31 PM
llama@llama:~$ man compgen
No manual entry for compgen
whuzzat
2
 
python 2: c=1;j=3.;exec"print c;c*=4-6/j;j+=1;"*input()
 
I don't have a Manuel page for it either. Just do compgen -c, you'll figure it out.
 
llama@llama:~$ compgen
zsh: command not found: compgen
 
Oh.
Well then.
 
Apparently it's a Bash thing? Because it works on bash, but not zsh
 
10:33 PM
6
A: Understand `compgen` builtin command

cuonglmOptions for compgen command are the same as complete, except -p and -r. From compgen man page: compgen compgen [option] [word] Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, a...

 
@Doorknob This is why no one uses zsh. :P
 
[tag:logic] Logic questions are characterized by their rationality and pointy ears.
- glad this is being changed, lol
 
You're welcome. XD
 
I voted to approve
 
\o/
 
10:34 PM
idk why the Doctor put that
 
/me approves
 
/me me
 
I feel like tag edits should be more than 2 rep. You'd think people would go over with a fine-tooth comb with that stuff.
 
Well, it depends. If you fix a handful of typos, +2 sounds about right. If you create the thing from scratch...
 
Eh.
 
10:38 PM
I had a look at Rosetta Code and it does seem to have full programs, although I couldn't find a rule for that. I also learned that C++ should really have been named ++C...
 
@trichoplax --C++
Or C+- if you're fickle.
 
Now I have to go and learn enough C to get that joke...
 
I don't know any C.
 
I don't know any sea.
 
Does --C++ return C - 1 and leave C at the same value as it had beforehand?
 
10:43 PM
@trichoplax It's a syntax error AFAIK
 
no, it's a nonsense expression that's invalid syntax :P
 
Ah OK :)
 
There's a really interesting easter egg in C++14 though: If you type trichoplax with nothing else in the file, you get all sorts of errors.
3
 
@flawr I dunno, maybe something like "given a non-convex polygon, partition it into convex areas".
 
@AlexA. Um, I don't think that's new for 14 :P
 
10:46 PM
No, I heard they added that functionality. Should work fine in C++98.
 
@VoteToClose VoteToClose.next = new Date();
 
@mbomb007 \o/
 
@quartata Fastest code would be interesting if we had large, complex examples. So, code golf will likely be more interesting, ultimately, and fastest code is harder to score anyway.
 
@AlexA. Now I'm hesitant, which makes me feel gullible...
 
@mbomb007 Side note: I was totally joking. XD preserves face
 
10:47 PM
lol
 
llama@llama:~/code/misc$ cat > tricho.cpp
trichoplax
llama@llama:~/code/misc$ g++ tricho.cpp -std=c++98
tricho.cpp:1:1: error: ‘trichoplax’ does not name a type
 trichoplax
 ^
 
@trichoplax Well, it should at least yield the desired behavior in C++98.
@Doorknob This is the expected behavior in 98.
 
I wonder what color trichoplax is in CSS?
 
How has the ><> online interpreter not been at least linked on this question?
 
So 14 introduces a slew of new errors?
 
10:49 PM
/me looks for a C++14 compiler that I may or may not actually have
Neither my clang++ nor my g++ has it :P
 
Does have C++17?
 
llama@llama:~$ g++ -std=
Completing standard
c++03    c++11    c89      c++98    gnu++03  gnu++11  gnu89    gnu++98
c11      c++1y    c90      c99      gnu11    gnu++1y  gnu90    gnu99
What's 1y?
 
One year
 
Is it like 0x?
 
oh apparently that's C++14
ok then
 
10:51 PM
1*y = 14 when y = 14
 
same error :P
 
I said you get errors.
You have not been misled.
 
I have nothing to say in this comment
 
8 mins ago, by Alex A.
There's a really interesting easter egg in C++14 though: If you type trichoplax with nothing else in the file, you get all sorts of errors.
 
10:53 PM
¯\_(ツ)_/¯
 
"all sorts of errors" != one error.
 
That's not true
 
Indeed. There exists more than one sort of error.
 
ok Perl's wantarray is also magical
 
Anonymous
Length 11 snippet has been added to the showcase popcon for Seriously - this one isn't much of a secret, since I showed it off yesterday
 
10:55 PM
@Doorknob Do not want
 
Anonymous
@Doorknob Dark magic
 
@AlexA. backstroke of the west
 
@Doorknob wut
My backstroke is not fast
 
Anonymous
Perl is the Avada Kedavra of programming languages
 
My breaststroke is faster
 
10:56 PM
ok come on you can't just reference backstroke of the west and not know what backstroke of the west is :P
 
I can and I did
 
go read that ^^ :P
 
Anonymous
wee woo fun police here no more memes unless you know the source
 
...
 
@quartata Haskell f n=scanl(*)1[4-6/i|i<-[2..n]]
 

« first day (1756 days earlier)      last day (2135 days later) »