« first day (2334 days earlier)      last day (2512 days later) » 

6:00 AM
@Phoenix brb seeing if can decompile x86 to LLVM
 
@Downgoat ?
 
> Why not just use erb
 
I still don't get it
The word "use"?
That doesn't have drug connotations in my mind
 
erb mean weed
 
6:06 AM
Question: if you do a type intersection should you take a root conformant base onto which you use as your primary type list?
 
" Yes "
 
@ATaco will jsd support routing
 
what do you mean by routing?
 
e.g. / -> Thing A, /goat -> Thing B
 
Yes, it already kind of does. Just not particularly well.
 
6:09 AM
CMC: A003602: if n = (2k-1)*2^m then a(n) = k.
 
I'll hopefully never release jsd into the public anyway, not till I write something better
 
@LeakyNun putt, 3 bytes:
 
@Downgoat what the hell
 
:D
 
link to language?
 
6:11 AM
idk if I still have >_<
 
unicode 3602
 
:| okay I never upload source: github.com/vihanb/Putt
 
I see what you did there
 
@ATaco Why not?
I want jsd
 
@LeakyNun :)
@Mendeleev why not webpack?
 
6:12 AM
idk what that is
 
oh it's basically rails but JavaScript
also because JSX you can have HTML in JS, and JS in Pug
 
@Mendeleev if I release jsd I'm doing it right. Which isn't how I'm doing it right now
 
@ATaco but what if I want to merge constrained candidates
 
" Yes "
 
I am thinking of posting codegolf.meta.stackexchange.com/a/12994/71001 unless anyone has any last minute comments?
 
6:20 AM
@ATaco 1) why in quote 2) that is not binary question
 
The spaced quote was supposed to imply a delayed and slow response, indicating that I don't understand the question at all.
CMC: Get the Prime Factors of a number without builtins.
 
posted.. fingers crossed there is no silly mistake
 
@ATaco Python, 64 bytes TIO
n=int(input())
p=2
while~-n:
	if n%p<1:print(p);n//=p
	else:p+=1
 
@LeakyNun oh hi
 
@Arthur hi
 
6:32 AM
the challenge is up in case you were interested
I mean the ppcg one
 
Oh, that's more efficient than what I wrote.
 
@Arthur I saw it, thanks
 
it will be interesting to see what people come up with
 
@ATaco what did you write?
 
Not at all golfed, but:
function primeFactorise(n)
	local factors = {}
	for i=2, math.sqrt(n) do
		if n % i == 0 then
			local a = i
			local b = math.floor(n / i)
			a = primeFactorise(a)
			b = primeFactorise(b)
			for k, v in pairs(a) do
				factors[#factors+1] = v
			end
			for k, v in pairs(b) do
				factors[#factors+1] = v
			end
			break;
		end
	end
	return #factors==0 and {n} or factors
end

facts = primeFactorise(1325687)
for k, v in pairs(facts) do
	print(v)
end
Which is a recursive implementation.
 
6:34 AM
I feel there is always a risk that a challenge either has a trivial optimal solution or is way too hard so that all the answers are the same. I hope this is somewhere in the middle
 
@ATaco why would you use local
 
Why wouldn't I? Local variables are indexed first.
As I said, this isn't golfed.
 
@ATaco What do you mean?
Oh, of course you should replace math.floor(n / i) by n//i.
There is no justification for converting to float and then back to integer
 
The way Lua's memory works, in the current scope it first sees {MY_LOCAL_VARIABLES, MY_PARENTS_LOCALS, THEIR_PARENTS_LOCALS, ..., GLOBALS}
 
oh wait, I thought it is python, sorry
brain fart
 
6:36 AM
Oh, and // surprisingly does work.
That was added in 5.3
 
oh...
 
local sqrt = math.sqrt
local pairs = pairs

function primeFactorise(n)
	local factors = {}
	for i=2, sqrt(n) do
		if n % i == 0 then
			local a = i
			local b = n // i
			a = primeFactorise(a)
			b = primeFactorise(b)
			for k, v in pairs(a) do
				factors[#factors+1] = v
			end
			for k, v in pairs(b) do
				factors[#factors+1] = v
			end
			break;
		end
	end
	return #factors==0 and {n} or factors
end

facts = primeFactorise(1325687)
for k, v in pairs(facts) do
	print(v)
end
That offers a small but noticeable speed boost.
 
1
Q: Finding the smallest sets

ArthurConsider three sets A, B and C each containing n integers. From this we can make the set S_n = {a * b + c | a in A, b in B, c in C}. Given an n, there are one or more minimal sized S_n which depend on which sets A,B and C have been chosen. The sets can contain any n distinct integers (pos...

 
I would use table.insert(factors,v) instead of factors[#factors+1] = v
 
That actually takes slightly longer, firstly due to the fact that table.insert needs to index table, and secondly due to the fact that table.insert is internally implemented almost identically to factors[#factors+1] =, but with a function call now wrapped around it. I'd be better off keeping track of the table's size.
 
6:42 AM
oh, ok.
9 mins ago, by ATaco
Oh, that's more efficient than what I wrote.
I don't see how my version is faster at all
 
My version's slower, because it needs to confirm that each prime is prime, there's a few wasted cycles as the end of each prime.
 
I see
 
Although my test implementation seems much less efficient... Perhaps I'm wrong.
On 3000 tests, it preforms 5 times as slow.
Ah, it's exponentially less efficient.
At 30000, it took 30 times as long as the other tests.
I wonder...
Well I don't understand what's going on well enough to tell you why this algorithm's faster.
 
if anything is unclear in my question please ping me. I will leave this window open
 
I have a 72MB text file. How do I upload it?
Oh, google drive.
 
6:57 AM
VPS?
 
0
Q: The sequence is too meta

Leaky NunWe start with a blank 1-indexed sequence: _,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,... In the nth step, we fill in every a(n) blanks with the integers greater than 1, where a(n) is the nth entry in the sequence. After the first step: 2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,10,_,11,_,12,_,13,_...

 
Here's a neat thing, the prime factors will always be in ascending order.
That is a lot of numbers.
 
7:17 AM
1
Q: "As a child, I was told Spiders felt no emotion."

Kevin CruijssenThe challenge: output this exact ASCII art of a spiderweb in a window: _______________________________ |\_____________________________/| || \ | / || || \ /|\ / || || /\'.__.' : '.__.'/\ || || __.' \ | / '.__ || ||'. /\'---':'---'...

 
local sqrt = math.sqrt
local pairs = pairs

function primeFactorise(n)
	local factors = {}
	local size = 2
	for i=2, sqrt(n) do
		if n % i == 0 then
			factors[1] = i
			for k, v in pairs(primeFactorise(n // i)) do
				factors[size] = v
				size = size + 1
			end
			return factors
		end
	end
	return {n}
end
A much improved version.
It occurred to me that i had to always be prime.
 
7:44 AM
has anyone here heard the binding of isaac soundtrack?
if you haven't heard it, you probably should because it is good
 
7 votes 0 answers ;_;
 
8:06 AM
@ZacharyT Ubuntu 14.04
 
@LeakyNun Currently golfing down 126 bytes of C. :)
 
@Doorknob nice
Hope it doesn't take 10 minutes to do a(20)
 
It can do a(10000) almost instantly, although more digits than that starts to slow it down.
 
so is this like reverse lucky numbers?
 
@Doorknob nice
 
8:44 AM
@LeakyNun Now you have 8 votes and 2 answers :)
 
quite certain your answer is wrong @Mr.Xcoder
 
Why?
 
I see no self reference
And small divisors
 
Better test it.
 
meaning that it would only work for small numbers
 
8:46 AM
Again, Let's test it
 
alright, just let me test it
 
You should be right
 
It disagrees with mine, anyway.
First at a(20), for which it gives 6 but should give 3 (according to the test data and my answer).
 
I tested it myself, and got wrong result for over a(20)
I removed it
 
Now I've got 8 votes and 1 answer.
 
8:49 AM
Sad :P
 
24
Q: Shortest terminating program whose output size exceeds Graham's number

r.e.s.Write the shortest possible program (length measured in bytes) satisfying the following requirements: no input output is to stdout execution eventually terminates total number of output bytes exceeds Graham's number Assume that programs run until "normal" termination on an ideal computer1 abl...

Well, this is a really cool old challenge. I want to see more competition here ;;
 
0
Q: LU decomposition (linear equation solver)

Max OberbergerConsider a matrix A and a linear equation A*x = b To solve this we can use LU decomposition as described here: https://en.wikipedia.org/wiki/LU_decomposition https://en.wikipedia.org/wiki/LU_decomposition#C.23_code_examples Your task is to write a program that computes the matrices L, U and P f...

 
9:12 AM
So I spent several hours code golfing at work today, and became enlightened that it's not really important to formally have code golf as part of my job description.
 
@feersum You mean that you can just golf anyway, even though it isn't part of your official job?
 
9:32 AM
0
Q: Uncommon Between Common

Mickey JackNote Rows will be represented as arrays. Input Format You will be given a function which will take 2 arrays as arguments. Output Format Return the uncommon elements from the function in the form of the string where each element is separated by $. Constraints 3 < n < 10,00,000 where n is th...

 
local sqrt = math.sqrt
local pairs = pairs

function primeFactorise(n)
	for i=2, sqrt(n) do
		if n % i == 0 then
			return i, primeFactorise(n // i)
		end
	end
	return n
end
Further optimized. I think I've nearly hit the point where this is just the other algorithm, strangely.
 
9:47 AM
@ATaco yes, but slower
because every time you check from 2 again
you should start at i
 
This is running magnitudes faster, for some reason.
 
try starting at i
 
That can't work based on the algorithm.
 
Because it's often the case that it needs to return a conga line of 2, 2, 2
 
9:49 AM
I think you mistook me
 
Perhaps.
 
would storing the list of prime numbers be any faster?
 
I mean, the smallest possible prime factor of n//i is i
not 2
@KritixiLithos 1. pointless 2. doesn't work for larger numbers
 
I mean, once you got a list of them, you only need to iterate through this list and bot go through every integer from 2 to sqrt(n)
 
I know
but I'm trying to do it without storing a list of prime factors
 
9:51 AM
I still don't understand what you mean by, "Start at i"
 
well, for optimizations we can check 2 3 and 6n-1 and 6n+1
1 min ago, by Leaky Nun
I mean, the smallest possible prime factor of n//i is i
 
then how is it pointless?
 
I still don't understand what you mean by that.
Oh, wait now I get you.
 
what does he mean?
I don't get it
 
Yep, tests show a noticable increase in speed.
local sqrt = math.sqrt
local pairs = pairs

function primeFactorise(n, i)
	for i=i or 2, sqrt(n) do
		if n % i == 0 then
			return i, primeFactorise(n // i, i)
		end
	end
	return n
end
 
9:53 AM
@ATaco how did you implement it? using a global i?
 
Just passing i down the chain.
 
interesting
Could you show me your tests?
 
local sqrt = math.sqrt
local pairs = pairs

function primeFactorise(n, i)
	for i=i or 2, sqrt(n) do
		if n % i == 0 then
			return i, primeFactorise(n // i, i)
		end
	end
	return n
end

function primeFactorise2(n)
	for i=2, sqrt(n) do
		if n % i == 0 then
			return i, primeFactorise2(n // i)
		end
	end
	return n
end

print(primeFactorise(12))

local TESTS = 300000

local c = os.clock()
for i=1, TESTS do
	primeFactorise(i)
end
print(os.clock()-c)

local c = os.clock()
for i=1, TESTS do
	primeFactorise2(i)
 
oh cool
But seriously, 12?
You should use a larger test
 
Probably, but I like 12.
It covers the basic functionality.
 
9:55 AM
seriously
 
ooh, I get you now
 
For convenience, 64 does correctly return 2 2 2 2 2 2
Also, the outputs are:
1.507
1.626
Where test 2 isnt optimized, shows a confident increase in speed.
 
Seriously, you should optimize for large inputs.
 
Well my tests are up to 300,000 so I'd say I've got plenty of testing room at large numbers.
 
oh wait, sorry, I thought the test was on 12 lol
 
9:59 AM
I'm not just running 12 300,000 times, don't worry.
 
@ATaco how does , work?
 
What do you mean? It's a thousands digit separator.
 
rust is the bane of my life... .Can anyone compile codegolf.stackexchange.com/a/127417/9206 . I get bpaste.net/show/2d84321ed6d7
 
@ATaco no, I mean in return i, primeFactorise2(n // i)
 
Oh, that's a lua thing, because return values are kind of like arrays.
It appends the results of primeFactorise to the return.
 
10:07 AM
@ATaco yes, that's the basic, but it's stranger than that
so could you expand on that
 
In this case, Although I can't see it much different, it's returning i, aswell as, the return value of primeFactorise2, which will similarly return i aswell as it's next factor, until n is prime, in which it will simply return n. This then chains back to make a sort of pseudo array, which is faster than working with tables recursively.
 
0
Q: urgent solution required meshed up in doing this code

DipanshuHackers love bits, so does Alex. Alex has just started his career as hacker and found a special binary array A A (containing 0 s 0s and 1 s 1s). In one operation, he can choose any two positions in the array, and can swap their values. He has to perform exactly one operation and maximize the ...

 
Jim
10:24 AM
@Lembik For finding out which lib you're missing: stackoverflow.com/a/21647591
And I think that's the GNU MP Bignum Library
That would be the package libgmp10 on Ubuntu I think
 
How to make a quine

Make a cell. A biological cell. Now that duplicates itself. It's a quine.
 
Jim
Not forever
 
eventuslly they will figure out how to work with each other and create multi cellular organisms
 
@betseg D-Bus?
 
@SIGSEGV so a cell is a biological quine
 
10:38 AM
@Mayube right, or is it a forkbomb? MUAHAHAHAHA
 
actually yeah, 2^n cells in n time
 
%0|%0
 
:(){ :|:&};:
 
A cell just isn't very radiation hardened, is all.
 
Anyone else having problems with the userscript disabling Stack Snippets in the editor?
 
10:44 AM
3
Q: A crowd of blank stares

LiefdeWenProblem Given no input write a program or a function that outputs or returns the following string: (<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>) Rules Shortest program wins. Trailing whitespace allowed. Trailing newlines allowed. Unused parameters for functions allowed.

 
11:00 AM
I think we can use the Google Assistant SDK with api.ai using node
 
btw how do programs get mouse input (like click, position, etc) on console
 
or something like that
 
@KritixiLithos um no
Thats actions
Its different
 
@Jim Thanks.. I will try that
 
11:02 AM
That thing is embedding your program on the assistant, while this is embedding the assistant on your soft/hardware
Speaking of actions
Heres a challenge officially from google
 
11:18 AM
I'm trying out Kotlin but IntelliJ triggers me
It's sooooooo slow
And it eats up your battery like a hungry child wolfing down cake
 
@Qwerp-Derp sounds like you need a pc that isn't from 2008, I've never had any problems with IDEA performance-wise. Is it because your machine doesn't have a dedicated GPU? If your computer can't support hardware acceleration IDEA ends up using the CPU to render the UI, which can make it pretty slow. (Which is why you shouldn't use IDEA on a VM without some amount of GPU passthrough)
 
@Mayube I'm on a 2012 Macbook Air running Windows
 
well there's your problem
 
LOL, that's so true
IntelliJ was built for desktops I think, with laptops they're not that good
 
I can count at least 3 problems with that sentence
 
11:24 AM
Because it's slow and it drains your battery
 
@Qwerp-Derp my IntelliJ takes 5 minutes to start
 
11:34 AM
@KritixiLithos that sounds like windows start times
 
I wanted to just do my Java development in VIM like I do with everything else, but I quickly discovered that working in Java without an IDE is an act of insanity, so I use IdeaVIM with a custom color scheme instead
 
@Mayube Programming in Java with vim is not different than C
 
I don't particularly like C
 
who does?
 
C is still wayy beter than assembly for embedded systems
 
11:44 AM
Dennis Ritchie?
 
ppcg is awesome.. more accurately the quality of some of the answers is awesome!
I am still trying to find an easy way to get fast simd complex arithmetic! gcc and clang are terrible at autovectorizing complex math it turns out
someone should make an optimized library
just saying :)
 
11:59 AM
Is there a way to simplify a AND NOT (b AND c)?
 

« first day (2334 days earlier)      last day (2512 days later) »