« first day (1486 days earlier)      last day (3372 days later) » 
01:00 - 19:0019:00 - 00:00

1:07 AM
Is there a stack snippet to auto-create language leaderboards for golf challenges?
I feel like I've seen one before.
If not, there should be one.
 
1:20 AM
I know there is one.
9
A: Scraping answers and comments with a Stack Snippet

OptimizerSort answers by score snippet This is a version 1 2 of a snippet that can sort and list all answers to a question in increasing order of the score. This snippet recognizes various different style of answer headings, but suggestions welcome for the ones which are missed out by the snippet. The ...

 
 
1 hour later…
2:23 AM
@FUZxxl seems ok to me
 
 
5 hours later…
7:12 AM
@randomra Great!
 
7:59 AM
@PhiNotPi you can have the one I've been using on my challenges if you want
most recent version here:
23
Q: Print a Block-Diagonal Matrix

Martin BüttnerHere is a simple, bite-sized (byte-sized?) code golf: given a non-empty list of positive integers less than 10, print a block-diagonal matrix, where the list specifies the size of the blocks, in order. The blocks must consist of positive integers less than 10. So if you're given as input [5 1 1 ...

 
@grc hey
Thank you for your solution to the Devil's staircase problem.
Simplified my APL solution quite nicely.
 
grc
8:17 AM
haha no worries
APL always baffles me D:
domino character?
 
8:28 AM
@xnor I don't think answering questions that are admittedly from an external competition is a good idea.
 
8:41 AM
@MartinBüttner oh, didn't realize that was the case
is it verbatim text?
if so, we could paraphrase
given the choppy phrasing, I think it's not verbatim, in which case I don't think there's an issue
there are publically posted collection of problems from Putnam exams which are rephrased, for instance
the post should give credit though
 
well I don't know, but currently it might a) be a copyright violation and might b) provide a way to cheat for future participants for all we know
 
i'll flag it for mods
 
btw, I tried your matrix approach in mathematica, but surprisingly both creating tridiagonal matrices and matrix powers are really cumbersome (from a golfing perspective). I think matlab should actually beat mathematica with this.
@xnor I already did
 
there's no banded-matrix built-in?
 
there are tools for this, but they are not suited for golfing them
you can something like SparseArray[{Band[{1, 1}] -> 1, Band[{2, 1}] -> 1, Band[{1, 2}] -> 1}, {5, 5}]
even if you create that list with a map, that's horrible
 
8:52 AM
yeesh
 
SparseArray[Band@# -> 1 & /@ {{1, 1}, {2, 1}, {1, 2}}, {5, 5}]
 
can you create a matrix by a formula a_ij = 1 if |i-j|<=1, otherwise 0?
(and tweaking one entry)
 
yeah I did that earlier. that is actually shorter, but still quite long.
Array[Boole[Abs[#-#2]<2]&,{5,5}]
but even if you do that, then you need a=...;a[[-1,-2]]=0;
and then there's no operator for matrix powers
so you need a~MatrixPower~t
hm, matlab doesn't seem to have a built-in for tridiagonal matrices either though...
but I believe it has a matrix-power operator
 
 
4 hours later…
1:14 PM
no coding or algorithm is involved at all
or are we considering executing certain commands as a code ?
"How to save a MS word file "
"convert a file from windows EOL to unix in shortest keystrokes"
 
@Optimizer How about a 50 byte penalty for having the word list as a variable. (Based on how python needs around 40 bytes.)
 
@Calvin'sHobbies NOOOO
even JS can do it in less than that :/
require("file...").read("f")
 
Right, you can just read the file if it's less.
 
ughh, you are going to make me use node js
:/
will try once back home if no one else has done it by then
 
L=open("f").read().split() is 26 if there's no whitespace between the words
 
1:30 PM
@Sp3000 Yeah, I'm adding a penalty of 35.
 
the current format is actually better. list(open('f'))
 
@Calvin'sHobbies that seems reasonable
 
Oh you can do list on an open?
 
Here's an idea for a Rosetta Stone scoring rule: each langiage is its own mini-golf competition, for each language category you win, you gain a number of points equal to the number of entrants in that language.
 
Categorizing the languages sounds hard :P
 
1:32 PM
(Each language is its own category)
 
rosetta stone is just bad
 
How does one unwrap an array to stack in CJam?
 
list(open('f')) has the words with trailing newlines, hmmm
 
trying to learn it here :D
 
This most recent one had a bad scoring rule.
 
1:34 PM
~ ? I think
 
I want to write a CJam or J solution to it and win.
 
all right
 
all rosetta stones are bad
 
@Optimizer have you tried "file:///path/to/file"g
 
1:39 PM
no, but still
online interpreter
plus, CJam would need extra logic as no regex
 
@MartinBüttner Working on a Retina solution for Calvin's question yet? :P
 
2:33 PM
@Sp3000 nah, I was at uni... I did think about it though ;)
ugh, a Perl regex answer already... then there's no point trying Ruby
 
I'm thinking of doing a "pretty-print a tree" challenge somewhat similar to this (additionally requiring that edges are non-crossing straight lines), but I can't decide a scoring system. Pure golf, aesthetics-based popcon, or a challenge to cram the tree in as small a space as possible...
 
@Zgarb the latter sounds really interesting but could be about as successful as Domino Circuits due to its complexity
 
@Zgarb Would printing this be a loophole?
 
no, just NAA
 
2:41 PM
Wow I am dyslexic this morning.
I swear that said print a pretty tree.
 
I'm pretty sure the actual spec would make clear that it's about graph theory :P
 
@Rainbolt :D
 
What if you crammed the picture to 1x1 pixels?
 
I was thinking ASCII art
 
I was thinking ASCII art.
 
2:42 PM
:D
 
:D
 
I was thinking ASCII art
 
I was thinking ASCII art
 
:D
 
@Pietu1998 now that's a lie ;)
 
2:43 PM
How about printing 🎄 (U+1F384 CHRISTMAS TREE)?
That's a tree in quite few bytes
 
@Pietu1998 I already have a clear spec for the input and output, but scoring is open.
 
@Zgarb Right, just speculating of all the possible loopholes/NAAs/too literal interpretations :D
 
Pretty ASCII tree: jsfiddle.net/og85w5cg
(you might have to click run)
 
The troll face in the chat caught my eye and so I read his profile and it reads "I usually try to avoid using third-party libraries; I code my own ones instead if possible in a reasonable amount of code & time."
 
2:51 PM
I guess there is a trade-off between minimising dependencies and reinventing the wheel
 
If you write your own, you are still dependent on your own library.
 
yeah, but that's different from an external dependency
 
Sure. But the trade off just wasn't as simple as you wrote it.
 
sorry, "minimising external dependencies"
 
Anyway, if that troll face guy ever ends up working for some companies, they'll be required to use third party libraries in order to remain STIG compliant.
 
2:58 PM
What I mean with that is I don't want to add a library and its dependencies like Apache HTTPClient and its 5 JARs, if I just want to fetch a webpage.
I have no problem using libraries if there is actual reason to do so.
 
That makes sense.
 
Might as well change my profile pic sometime, the trollface looked great with some hats :D
 
Does Java not have way to fetch a webpage using stdlib?
"Real world" Java is one area on Java that I am weak on.
I can do all the useless things though.
 
Oh yes. I did this for an interview once. I had to interact with Stack Exchange API in order to get the job I currently have
I forgot it right after apparently, because I only use C# here
 
3:04 PM
Another thing is using Commons just for FileUtils.copyFile, since while Java has no one-method way for this it is extremely simple to do with Channels.
That is, for Java <6.
 
Whoah. I've never seen FileChannel before. This is cool: "attempts to initiate a second such operation while the first is still in progress will block until the first operation completes"
That reminds me, I need to write a controller for a deadlock KotH challenge that has been sitting in the sandbox for ages.
Maybe I can use files as forks
And the players can be philosophers
Some smartass will find a way to eat his dinner without waiting for both forks though, and ruin the challenge.
The weather here sucks i.imgur.com/940lJQq.png
 
3:24 PM
Hey ho
any APL buff here?
 
0
Q: Random Golf of the Day #3: Integer Partitions

Martin BüttnerAbout the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post. Alt...

let's how this goes :/
 
hm…
The challenge looks quite complex
 
Not really in the mood to work out an algorithm for this one
the O(n) is going to be the hard part here
 
@Pietu1998 polynomial, not linear
 
Oh right
 
3:29 PM
there's a formula for total # of partitions, but not for partitions with maximum size/maximum number of elements
so it's tricky
 
I tried to use Google to get a grasp on what I'll be working on the next three weeks. So I searched for "high availability padawans jedi master cli" and got a page about Yoda.
 
Knuth vol 4a might help
chapter “generating all partitions”
(not a joke)
 
Here, for the lazy.
 
11
Q: How do I generate a uniform random integer partition?

cdfA Google search reveals plenty about generating all possible partitions of an integer n into m parts, but I haven't found anything about sampling a uniformly distributed random partition of n into m parts.

 
Here for even lazy.
 
3:39 PM
So §7.2.1.4-5
 
cheaters ;)
 
The question is not really related.
It restricts the size of the partition artificially.
 
well, that and the above onebox ruined it for all
:D
 
Missed the "into m parts" :(
 
@MartinBüttner Would it be okay if the distribution is only asymptotically equal? E.g. if for small values of n a slight skew might exist that vanishes as n goes to infinity?
 
3:42 PM
> Mapping a uniform distribution over a larger range onto a smaller range via modulo. The larger range has to contain at least 1024 times as many possible values as the smaller range.
 
@FUZxxl that depends on what causes that skewing
 
Does this mean that you've intentionally banned mapping a smaller range to larger (via multiplication)?
 
I ask because then I might be able to approximate certain things to get a solution in polynomial bounds.
since the approximation has non-zero error that vanishes as n goes to infinity, this might result in a slight skew.
 
@Geobits how do you uniformly map a smaller range to a larger? if you map n values onto m values for n < m, then you'll only ever hit n distinct of the m values, no?
@FUZxxl there's no need to approximate anything for a polynomial solution
 
@MartinBüttner I assume you have a solution in polynomial time ready?
 
3:44 PM
the only skewing that's allowed is due to imperfect PRNGs and remapping of uniform ranges
 
For instance, floor(random()*10) (where random() returns 0-1) returns one of ten values from many more than 10 possibilities. So the range has more values, but a smaller absolute range.
 
@FUZxxl yes, I know that one exists
@Geobits right I should clarify that the size of the range refers to the number of values, not its extent on the real line
 
Yea. The modulo wording made me think it was explicitly one way.
 
@Geobits is this better?
 
Looks good
 
3:49 PM
Let me go through that when I'm at home and have access to a copy of TAOCP vol 4a
 
@FUZxxl the accepted answer doesn't comply with that rule
(cc @TheBestOne)
 
indeed.
@MartinBüttner How good are your APL skills?
 
nonexistent
 
zoro
 
hm…
 
3:56 PM
no, I'm not Zorro
 
anybody else speaking APL here?
 
I think there is no way you can speak those characters
 
Zgarb, I think
 
okay write down this code "triangle, square with a dot, wavy lines..."
 
yes, definitely. @Zgarb you APL, don't you? your skills are needed (by @FUZxxl)
 
4:00 PM
@Optimizer Oh, there is. They all have names.
For instance, this: ' ⌹'[(∪∘.=⊖){⍵/⍳≢⍵}⊃(⊢,,)/3*⌽⍳1+⎕]
would be pronounced as:
 
no please dont
 
k…
 
:)
but i am curious . tell
 
Quote space domino quote left bracket left-paren down-shoe jot dot equals circle-minus right-paren left-brace omega slash iota inequal-underbar omega right-brace right-shoe left-paren right-tack comma comma right-paren slash three star circle-stile iota 1 + quad right bracket
 
"right shoe left"
 
right-shoe is this thingy: ⊃
down-shoe is this thingy: ∪
' ⌹'[(∪∘.=⊖){⍵/⍳≢⍵}⊃(⊢,,)/3*⌽⍳1+⎕] is hard to read because it's not displayed in an APL font.
 
hey guys, what are your favorite monospace fonts (for code)?
 
I use Ubuntu Mono. I think it's easy to read.
Source code Pro looks nice, too, but APL385 looks great for APL.
 
@aditsu I like Consolas
there's also Inconsolata, I think
 
Consolas is not free, is it?
 
4:14 PM
I doubt it, but available on all modern Windows machines
 
@MartinBüttner I do APL a little.
 
@Zgarb Do you also do J?
 
@FUZxxl Nope, sorry. Haven't had time to learn J yet.
 
okay.
 
Are you trying to translate something between them?
 
4:18 PM
Maybe you can help me anyway.
Kinda.
You know the reduce operator /
and scan \
 
Sure
 
Now, scan implicitly applies reduction. In J, this implicit reduction is removed. So where you write +\ in APL, you write +/\ in J.
Now, J also has suffix scan \. which works like \ but applies the function to suffixes instead of prefixes.
 
I found a J app for iDevice. Does anyone know if it is any good? Edit: itunes.apple.com/us/app/j-programming-language/id532587550?mt=8
 
Ok so g\ in J would map g to the list of prefixes, and g\. to the list of suffixes?
 
I'd like to have something like f/\. y in APL. That is, a vector of all intermediate results when you reduce y by f.
Exactly.
For instance, +/\. 1 2 3 4 would be like (1 + 2 + 3 + 4) , (2 + 3 + 4) , (3 + 4), 4
 
4:22 PM
How about ⌽+\⌽ 1 2 3 4
 
Inconsolata looks great, source code pro is not bad, ubuntu mono is kinda weird
 
The J interpreter recognizes the /\. idiom and fuses the reduction with the suffix scan, yielding linear-time behavior.
Zgarb: This doesn't have the same semantics where f isn't associative.
and it doesn't run in linear time.
{(⍺f⊣/⍵),⍵}/ y has the right semantics but probably doesn't run in linear time either.
 
seems like every font has at least a little imperfection :p
 
@aditsu How about the APL385 font? aplwiki.com/…
 
it's a bit obscure..
 
4:27 PM
Looks a bit Comic Sans'y
 
@FUZxxl And it seems to incorrectly box the result too. Hmm, let me think...
 
0 and O look quite similar
 
Unboxing afterwards shouldn't be that much of a problem.
@aditsu Indeed. They should've put a dot inside.
 
I kinda prefer the slash
 
hm… slash is problematic as this could be confused with an overstrike
(many APL characters come from overstriking some characters)
 
4:30 PM
ah, the Ø
 
I prefer an interpunct in the middle if needed.
APL also uses 0 overstricken with ~; the result is called “zilde”
 
@FUZxxl I think in most non-APL contexts this not an issue ;)
at least not in the context of a CJam interpreter
 
indeed.
 
How about {(⍺f⊃⍵),⍵}/
⊃ is "first" for 1D arrays
Faster than ⊣/ but I don't know whether it makes the whole thing linear time.
 
4:48 PM
I guess I'll use this font list: Inconsolata, Source Code Pro, Consolas, DejaVu Sans Mono, monospace
 
you might want to include Inconsolata as a web font... I don't think many people will have it
 
don't need to force it upon everybody :p
windoze people will probably fall back to Consolas
 
@aditsu "force it upon everyone" or "provide a consistent user experience" ;)
 
it also comes at a cost - it usually takes about a second (sometimes longer) for the browser to get the font and update the page
 
@Zgarb Dyalog APL recognizes ⊣/ so that's not really a concern.
 
5:18 PM
@TheBestOne would you mind including a link to ideone with a little test framework, where I can generate a number of partitions at once? I don't Java much.
 
The copy-and-pasted SO text is such a poor explanation that I think the answer would be better without it
 
@Optimizer Translation?
 
community wiki it .
 
Why?
 
5:24 PM
coz its a direct copy paste ?
no ?
 
it's a translation
and it's golfed
 
the "explanation" is the copy paste
 
only the explanation is copy pasted
 
oh
 
@TheBestOne looks legit
 
5:33 PM
I should probably do your first one.
 
5:47 PM
@FUZxxl I'm trying to do something like {(⌽{a⊣a←⍵ g a}¨1↓⍵),a⊣a←⊃⍵}⌽ but it doesn't seem to work... I don't really understand APL's scoping rules.
 
hmm I forgot what I was doing when I wrote this answer I just posted
now I need to figure out what it does so I can see if the distribution is actually correct
 
lol
 
@feersum can I just run it in a loop to produce multiple partitions or is there some global state that would break consecutive runs?
 
I just remembered. Yay!
sure, you could put in a loop
@FUZxxl @Pietu1998 that Knuth text was helpful, thanks :)
 
What is up with codegolf.stackexchange.com/a/46954/2718 ? is that malware?
 
5:59 PM
I don't know... I found it weird, too
 
Perhaps we should edit it to be unrunnable just in case?
 
Deleted?
 
yess
@captncraig I think these snippets should be well sandboxed, but I don't know.
wouldn't harm though
done
 
6:19 PM
hmm, inconsolata is smaller than other fonts (at the same font size)
 
that's odd
 
and "font-size-adjust" has very little support
ah, setting the line height helps somewhat
 
Yay! I'm in first place!
 
what does that mean?
 
Random Golf of the Day :)
I have the highest score too :D
 
6:41 PM
so you are TheBestOne ?
 
that's the best "1" I've seen in a long time :p
 
does this look good to everybody? jsfiddle.net/umh4kutn (regarding monospace font rendering)
 
Inconsolata is rendering a bit blurry for me on Windows :(
I think I had that problem before which is why switched back to Consolas in my Sublime Text
 
ok for me
but Consolas can be in front
 
6:56 PM
hmm, if consolas looks better than everything else in windoze, and is generally absent in <s>other OSes</s> Linux, I guess I could put it in front
rats, no strike
 
oh wait
i dont have inconsolas at all
it was rendering consolas only, thus ok :D
 
if you don't have inconsolas, maybe you have consolata? ^^
 
01:00 - 19:0019:00 - 00:00

« first day (1486 days earlier)      last day (3372 days later) »