« first day (2367 days earlier)      last day (2480 days later) » 

Anonymous
6:09 AM
Proposed rules for Golf All The Eulers: 1. No hardcoding (you must actually compute the result value - follow PPCG loophole rules). 2. Output to STDOUT (for easy comparison amongst languages).
 
@Mego all PE are constant-output challenges so 1 is hard
 
Anonymous
@LeakyNun 1 is simple if you don't try to circumvent the rules
 
Anonymous
You know exactly what is meant by no hardcoding - you're just being difficult
 
16 mins ago, by Leaky Nun
@Qwerp-Derp but what counts as hard-coding? where's the line? can I, for example, precalculate which values to include in a cycle of 15?
@Mego I'm not being difficult.
 
Anonymous
That is being difficult. Use common sense.
 
6:12 AM
the region between optimization and hardcoding is really grey
@Mego answer my question then
I know that 0,3,5,6,9,10,12 will be included
their sum is 45
there are 7 numbers so the sum will increase by 15*7 = 105 each time
so I just have to keep incrementing i=45 by 105 and then add i to the sum
at which point is this hardcoding?
 
Anonymous
print(sum(x for x in range(1,1000)if x%3*x%5<1)) isn't hardcoding. print(233168) is hardcoding. There's a spectrum between them. Use common sense to decide if a solution is too close to hardcoding.
 
@Mego which is why I just included a specific case for you to judge.
Rather than actually using your common sense to judge it, you dismiss me as being difficult
 
Hello there!
 
Anonymous
@LeakyNun I'm not the judge here. You are. You're refusing to just use common sense and decide for yourself, and instead saying "well what about this corner case?".
 
6:17 AM
@Qwerp-Derp Do you solve PE problems?
 
@Qwerp-Derp please judge
 
@LeakyNun I honestly don't know, it would seem like it's kindof hardcoding, I'm not sure
Maybe we can have a vote?
 
What are you talking about?
 
Like if something's on the edge, maybe we can use GH issues as a voting system
@Mr.Xcoder Yup
 
@Qwerp-Derp I am glad to join. I've already starred and watched the Repo
 
6:19 AM
@Mego I'm asking for your opinion.
 
Anonymous
@LeakyNun And my opinion is "decide for yourself".
 
@Mego I'm asking your opinion, because you are one of the collaborators
 
Anonymous
I don't know how to make myself any more clear. My opinion is that you should decide for yourself if a solution is acceptable when adding it.
 
@Mego alright
 
@Qwerp-Derp I'll solve it in Swift, already added a file
 
6:24 AM
I don't think I get this question, what's wrong with lambda n:n*2+1?
 
@musicman523 not bijective
 
@LeakyNun Okay, what about lambda n:n+1
 
233168 is the correct solution for #PE1, right?
 
52 secs ago, by Leaky Nun
@musicman523 not bijective
@Mr.Xcoder you can submit it to verify it for yourself :)
 
why isn't that bijective?
I'm bad at math
 
6:27 AM
because nothing maps to 1
 
oh, positive integers
I thought it was all integers
 
@Qwerp-Derp Added print((1..<1000).filter{$0%3<1||$0%5<1}.reduce(0,+)) for Swift
 
@Mr.Xcoder doesn't $0%3*$0%5<1 work?
 
@LeakyNun I think it does, checking now
@LeakyNun Done
 
@LeakyNun does this work? lambda n:n+[-2,2][n%2]or 1
Sorry for interjecting
 
6:33 AM
@musicman523 yes
 
thank you
 
@LeakyNun I dropped another byte with ...999 instead of ..<1000
 
Anonymous
@Phoenix Done-ish
 
@Mego Wow that's pretty cool.
 
Anonymous
What, did you not expect anyone to actually do it?
 
6:41 AM
No
Not really
 
That's why I starred it :)
 
Anonymous
It's not nearly as powerful as Mathematica's Tr (I think), because I don't know if sympy.Trace works on vectors or tensors
 
@Mego Is it able to take a function f like Mathematica's?
> Tr[list,f]
finds a generalized trace, combining terms with f instead of Plus.
 
it doesn't yet, I read his comment in the source code
and it also doesn't do the third form, where you stop after n rows
(I don't think)
 
Anonymous
@Phoenix Not yet
 
6:45 AM
That's still pretty good.
 
If you all agree and don't find a golfier way, I'll commit that
 
@Mr.Xcoder Yes, you don't need curly braces after an if statement if there's only one command.
if(i%3*i%4<1)r+=i;
 
@Phoenix Ok, I barely know C#, that's why I was asking. Thanks!
 
And same for for loops
 
@Mr.Xcoder Oh yeah, full programs only from now on
 
6:49 AM
@Qwerp-Derp My swift one is a full program
@Phoenix Ok, like in the other languages in the C family
 
int r=0,i=1;for(;i++<1000;)if(i%3*i%5<1)r+=i;Console.Write(r);
 
@Phoenix You forgot a closing brace after the if condition
 
@Phoenix Don't you need using System; at the start?
 
No
 
@Qwerp-Derp You do
 
6:51 AM
@Qwerp-Derp Well, Visual Studio puts that there automatically.
(You do need a main method and such)
using System;void Main(){int r=0,i=1;for(;i++<1000;)if(i%3*i%5<1)r+=i;Console.Write(r);}
 
using System;void Main(){int r=0,i=0;for(;i++<1000;)if(i%3*i%5<1)r+=i;Console.WriteLine(r);}}}
Oh, you don't need Line
@Phoenix That errors in C#(.NET core) and C# Mono on TIO
 
That would be because I accidentally spelled main with a lowercase m
 
> Unexpected symbol `void'
 
@Mr.Xcoder just fork my C program
 
And also because I forgot a class declaration
 
6:55 AM
@LeakyNun I changed your program to make it a full program
 
using System;class f{void Main(){int r=0,i=1;for(;i<1000;)if(i%3*i%5<1)r+=i++;Console.Write(r);}}
 
@Qwerp-Derp what do you mean by "full program"? It's already a full program without the include.
 
@LeakyNun ?
 
@LeakyNun Your C one
@LeakyNun Really?
Huh, didn't know, will revert
 
@Qwerp-Derp thanks
 
6:56 AM
That it must include everything in order to be ran in place, giving the correct results
 
@LeakyNun What should I do with that?
 
@Mr.Xcoder fork it into C#?
 
(I am relatively new to Github)
 
@Mr.Xcoder Try it online!
(It doesn't finish running because it takes forever, but it compiles)
 
6:58 AM
Sorry for my lack of knowledge, what does forking mean?
 
@Mr.Xcoder Creating a copy of the repo that you're an owner of
This allows you to make modifications.
 
nonono
@Mr.Xcoder I just mean translate the C code into C#
 
@LeakyNun Ok, I was confused
 
@Mr.Xcoder sorry
 
@LeakyNun Anyway, Phoenix did
Who's testitem?
This is definitely not Python: while(x[-1]<4000000) x.append(x[-1]+x[-2])
x=[1,1]
while(x[-1]<4000000) x.append(x[-1]+x[-2])
print(sum([i*(i%2+1) for i in x]))`
What's this?
 
7:03 AM
@Mr.Xcoder Fixed it
 
@Qwerp-Derp who the hell is testitem?
 
@LeakyNun Some kid, IDK, do you want me to kick?
 
3 mins ago, by Mr. Xcoder
Who's testitem?
 
@Qwerp-Derp I thought you added him in
 
@Qwerp-Derp Would be beneficial
 
7:03 AM
Like he was adding stuff to the repo
Should I kick?
 
@Mr.Xcoder Saved a byte: Try it online!
 
@Qwerp-Derp I thought only you can add people in
yes, kick
 
@Phoenix I didn't yet add c#
 
did you add him in? @Qwerp-Derp
 
Aight
Yeah
 
7:04 AM
@Mr.Xcoder I have absolutely no idea what you need this code for.
 
@Qwerp-Derp who is it then
 
I just wanted to golf some C#
 
@LeakyNun Some guy who used to be in my older projects, and he posted code, so...
 
What file extension should I add? csharp.cs?
 
I usually use the extension .code.tio
 
7:08 AM
@LeakyNun LOL what should I say? It sounds really bad if I kick him after like an hour
 
@Mr.Xcoder .cs
 
@Phoenix I have already added the file with .cs, thanks
 
@Mr.Xcoder that's valid python if you put in the : after the while
 
@musicman523 I know Python >_<
 
i know you know python
 
7:10 AM
Well, I'm for sleep. Cya guys.
 
i'm just saying it's 1 character off being valid
it may just be a committed typo
good night :)
 
@Phoenix Bye
 
Shit I made a bad decision, what do I do?
 
@Qwerp-Derp About what?
 
Inviting that guy
 
7:12 AM
@Qwerp-Derp Kick him
 
LOL, but what do I say?
 
Nothing
 
@musicman523 What
 
@Qwerp-Derp Sorry, but this repository is for PPCG users only. You can say that
 
Do you have to say anything?
 
7:14 AM
@musicman523 Well yeah, otherwise it seems super rude
Augh I feel pretty bad
 
I mean, I personally would just say nothing and rebase over his commits
But you are probably not as abrasive as a person than I am :P
 
@musicman523 Good point :P
It would honestly come off as super rude IMO, if someone did that to me
I'm considering wiping the entire repo and starting again
 
@Qwerp-Derp Just explain that his kick is for the * greater good *.
That would be even ruder though :/
 
@Qwerp-Derp why?
 
Another option: revoke write access for everyone and force people to fork and pull request
(and quietly rebase over his commits)
 
7:17 AM
@Qwerp-Derp actually... I don't see the need for kicking him
 
@LeakyNun Exactly...
 
What repo are you talking about?
 
just tell him not to mess with other people's things without asking
because he added back the line to my c program
 
@Dennis Qwerp-Derp created it such that we have an archive with all the PE problems, golfed
In as many languages as possible
 
@Dennis Do you want to join?
 
7:22 AM
Not at this point. I have yet to solve a single PE problem.
 
CMC: Given a list of (positive) integers, find its median.
[1,2,3,2,4] -> 3
 
@Mr.Xcoder 3 is far from the median
 
[1,2,3,4,5,7,8,9] -> 4.5
@LeakyNun The median, not the average
 
@Mr.Xcoder I know
 
@Mr.Xcoder Look at your list again
[1, 2, 3, 2, 4], the sorted list is [1, 2, 2, 3, 4]
 
7:25 AM
@Mr.Xcoder The median is 2, not 3. You have to sort first.
 
@Qwerp-Derp Oh, sorry :)
@LeakyNun Sorry, forgot to sort
Corrected Test case: [1,2,3,2,4] -> 2
 
Python 2: lambda l:sorted(l)[len(l)/2]
 
@musicman523 IDK
 
@musicman523 doesn't work if the length is even
@Mr.Xcoder what?
 
Oh
I forgot about the rule for even lengths
 
7:27 AM
@LeakyNun I don't know, as in "I am convinced that's incorrect".
 
@Mr.Xcoder that's a weird thing to say
 
@LeakyNun NVM then
@musicman523 That would be Python 2-specific, anyway
 
@Mr.Xcoder why?
 
@musicman523 Because in Python 3 you cannot subscript a list with a float
// is integer division in Python 3
 
@Mr.Xcoder I'm surprised you can in Python 2
@Mr.Xcoder That's why I specified 2 (even though it was wrong)
 
7:32 AM
@musicman523 lambda l,s=sorted:[(s(l)[len(l)//2]+s(l)[~-len(l)//2])/2,s(l)[len(l)//2]][len(l)%2]
A lambda is not the best choice here
 
You can actually save bytes by shortening len to k
I think that's the first time I've actually seen that
 
@Qwerp-Derp did you test your solution before uploading it?
 
@LeakyNun nope :P
 
@Qwerp-Derp god almighty
 
@LeakyNun Which solution are you referring to specifically?
 
7:35 AM
@Qwerp-Derp PE02
 
@Mego I don't think you need the do in your Haskell solution to Euler problem 1, it seems to work fine without it
 
@LeakyNun You mean the Python one? That wasn't me
But I didn't test any of my solutions :P
 
Python 2 is much better for this:
a=sorted(input());l=len(a)
print[(a[l/2]+a[l/2-1])/2.,a[l/2]][l%2]
 
@Qwerp-Derp can I rewrite it then?
 
@LeakyNun If you can make it golfier, sure
 
7:36 AM
@Qwerp-Derp the one there doesn't even work
 
@LeakyNun I think I was the one that broke it :P
I was trying to make it golfier, but it backfired
 
mamma mia
@Qwerp-Derp is it hard-coding if I use the fact that f(n) is even iff n is divisible by 3?
 
@LeakyNun Oh no, not this again :P
Uhh post an issue on GH, and we can vote there
I need to finish off my homework, so... no time
 
@Dennis wonderful
 
7:40 AM
@Dennis Beautiful
BTW I started learning Jelly
 
Nice. :)
 
@Qwerp-Derp should we put the answer in the readme?
@Dennis you'd be more pleased to know that there are already very many learners in our jelly hypertraining room :)
 
@LeakyNun Good idea. That way we woudn't need to submit to PE
@LeakyNun 13?
 
@Mr.Xcoder I didn't count
 
CMC: n -> n/1,n/2,n/3,n/4,...,n/n=1
 
7:45 AM
@Mr.Xcoder float or integers?
 
@LeakyNun I prefer floats
2 bytes in Jelly
 
@Mr.Xcoder Python 3, 34 bytes: lambda n:[n/-~i for i in range(n)]
@Mr.Xcoder not really
gtg
 
4 bytes in Pyth
 
8:28 AM
damn I have school tomorrow
 
@DestructibleLemon I have another 1+1/2 month free :)
 
@Mr.Xcoder ... meanie
 
 
1 hour later…
9:59 AM
The next sequence is hard and easy
easy because it can be brute-forced
hard because you need to think of a way to store 3d coordinates
and the definition might not be obvious at the first glance
We already have 68 answers; we're coming close to half of the goal.
After 150 answers there can be a thousand more.
 
ayyy
 
apparently you can get that badge more than once
 
nice new username
 
"new"
 
new
/nju:/
2. already existing but seen, experienced, or acquired recently or now for the first time.
 
 
2 hours later…
11:46 AM
I'd like to get some feedback on this challenge: codegolf.meta.stackexchange.com/a/13404/24877
Are there any classes of examples and non-examples I should add?
(I'm surely going to add some larger examples.)
 
@flawr My feedback is an upvote! I think you should allow to optionally take the size of the set as well.
 
@EriktheOutgolfer Because it does not have advanced list slices?
 
@EriktheOutgolfer why python in the first place?
 
@Mr.Xcoder doesn't seem to be the case (otherwise it would've been a syntax error anyways)
 
11:57 AM
@Mr.Xcoder thanks!
 
@cairdcoinheringaahing do you still need help with Mathematica?
 
@flawr for the challenge dude, for the challenge
 
@Mr.Xcoder Dyalog APL, ⊢÷⍳ (argument divided by range)
 
@Cowsquack Wow, someone solved it!
 
do you have another cmc?
 
12:17 PM
CMC: make an NxN checkerboard out of a given char C
e.g. N = 5, C = X
X X X X X
 X X X X X
X X X X X
 X X X X X
X X X X X
 X X X X X
X X X X X
 X X X X X
X X X X X
 X X X X X
 
that is a 2Nx2N sized checkerboard
 
it seems like that
X X X
 X X
X X X
 X X
X X X
this is ugly though
 
@EriktheOutgolfer SOGL, 8 bytes: @+*.«{T« (expects character input on stack & number input in the input :p)
@EriktheOutgolfer SOGL, 10 bytes: @+*.{:.mP«
 
that wasn't a cmc lol
 
I know, but I solved it :p
 
12:29 PM
Dyalog APL, {∘.(⍺' '⌷⍨∘⊂2|-)⍨⍳2×⍵}
 
3
A: I double the source, you double the output!

Borka223><>, 7 bytes 0\ln;   Try it online! (note the trailing newline and space) Explanation I used a 0 but I could have also used 1-9, a-f because they all push a single value onto the stack. The trailing space is there to align the 0 in the second copy of the code under the \ of the first. Not...

Great first answer ^
 
12:52 PM
Yaaay, I write the documentation before I create the language itself.
 
1:03 PM
@Mr.Xcoder Why would you write the language before the specification? That's how we got javascript and php!
 
and English...
 
@BlackCap That's what I am trying to avoid. I will first write the docs, and then I'll design the language. I currently have the operators done.
If anyone is interested in the development of this language, here is a room dedicated to it:

 Development of Cthulhu

Room for the development of Cthulhu (github.com/Mr-Xcoder/Cthulhu
 
I'll beat you to implementing it
 
@BlackCap Why beat me >_<?
 
@Mr.Xcoder As in I'll hurry up and implement it before you
 
1:09 PM
@BlackCap I wouldn't use your code anyway :)
Cthulhu is mine!
Bye!
 
@Mr.Xcoder Oh you have to; I'll flood you with pull requests
 
@Mr.Xcoder I wrote the plan for my language before implementing it
*trying to implement it
 
1:24 PM
* considering to try implement it
 
1:38 PM
@Mr.Xcoder I think you should have implicit output, but only if nothing else has been outputted by the end of the program
@MartinEnder no I solved it, but thanks anyway!
 
@Qwerp-Derp I'd like in
 
@Mr.Xcoder Compliant with the current specification: goo.gl/GeJ74E
 
@LearnHowToBeTransparent you haven't heard of GoT?
 
1:53 PM
@LearnHowToBeTransparent you have or haven't heard of it?
 
i havent heard of game of thrones
 
Game of Thrones is an American fantasy drama television series created by David Benioff and D. B. Weiss. It is an adaptation of A Song of Ice and Fire, George R. R. Martin's series of fantasy novels, the first of which is A Game of Thrones. It is filmed in Belfast and elsewhere in the United Kingdom, Canada, Croatia, Iceland, Malta, Morocco, Spain, and the United States. The series premiered on HBO in the United States on April 17, 2011, and its sixth season ended on June 26, 2016. The series was renewed for a seventh season, which premiered on July 16, 2017, and will conclude with its eighth season...
Its one of the biggest shows ever
 
@cairdcoinheringaahing so it isnt a game
 
@LearnHowToBeTransparent not even close
 
theyre playing to get the throne
 
1:59 PM
@cairdcoinheringaahing have you watched game of thrones?
 
@LearnHowToBeTransparent yeah, I'm a big fan, why?
@LearnHowToBeTransparent you know the room you linked to? There's some drama going down
 
2:21 PM
Does anyone understand A333?
 
@Downgoat Were you going to make last nights binary CMC a real challenge? I'd love to see it
@BlackCap Look at the xomments and example sections.
They have some useful information, particularly the example
 
I don't understand how a(n=3)=15
I am getting 768 different ways of writing 3 as n^(1/2)
 
jeez
could I see them?
 
1^(1/2) + 3^(1/2) for instance is not listed, but is <=3
 
That is listed
1^(1/2)+3^(1/2)<=3,
It is the 5th one
 
2:27 PM
hey finally I wake up and I'm not close to capping for once
 
768 is a lot, are you sure that you are no counting any of them twice?
@HyperNeutrino I know that feeling, its awful when you rep cap in your sleep.
Order does not matter for this sequence
 
@WheatWizard yeah like I woke up two days ago and was already losing rep xD. and the funniest thing is I haven't even been trying to cap, it's just been the OEIS challenge :P
well rip i just got here and i gtg now ._. o/
 
@WheatWizard dunno what he means by repeat...
basically does [1, 0, 1, 0, 0, 1, 0, 1] repeat?
like, in terms of [[1, 0, 1, 0, 0], [1, 0, 1]]
 
@WheatWizard I did count repetitions, I got it now
 
@EriktheOutgolfer Huh? I don't know why lists are involved
 
2:34 PM
the binary representation of the number
that's a list of binary digits
 
.10100101 would not repeat because there are only zeros after the last 1
This is pretty simple. We were rather pedantic last night but that was mostly for fun.
 
@WheatWizard huh?
oh it's a decimal not just integer
 
.10100101 (2) does not repeat
Oh yes, these are not integers
 
12 hours ago, by Downgoat
CMC: given a decimal string representation of a number, determine if its binary version would repeat
we're talking about this one right?
I think that "decimal" refers to the base here
 
yes it does
but the numbers are real numbers.
 
2:39 PM
11 hours ago, by Downgoat
@musicman523 i.e. has repeating decimal (0.2 is 0.0011 in decimal for example)
oh
tfw a question is so clear that there are no deleted answers
 
@EriktheOutgolfer There was a deleted answer earlier
But I undeleted it later
 
and it was never invalid, so that doesn't speak much to the clarity of the post.
 
I can see it wasn't...yeah so it doesn't "affect" clarity
 
@Qwerp-Derp the JS project euler submission can be golfed to console.log([...Array(1e3).keys()].filter(x=>x%3<1|x%5<1).reduce((a,b)=>a+b))
 
3:14 PM
TIL: If sound traveled through space, the sun would be 100 dB loud (the sound of a small rock concert) at all times
 
-1
Q: Is it a Sphenic Number?

GryphonA Sphenic Number is a number that is the product of three distinct primes. This is sequence A007304 in the OEIS. Your Task: Write a program or function to determine whether an inputted integer is a Sphenic number. Input: An integer between 0 and 10^9, which may or may not be a Sphenic Nu...

 
3:53 PM
People who know pyth, how do you get the nth prime?
 
@BlackCap I'm afraid I'll reject them all and block you if so, don't bother
@musicman523 There is no built-in, you have to do it manually
 
Sad!
 
@musicman523 I am trying to give you a solution, I am on mobile
 

« first day (2367 days earlier)      last day (2480 days later) »