« first day    last day (18 days later) » 

grc
12:20 AM
I've found a few more code golf missions on Check iO if anyone is interested
 
1:04 AM
@MartinBüttner Wow nice! Ahaha (?1), noted for the future :P
@grc Sounds fun! We can slowly go through half of CheckIO over time I think :)
 
grc
top solution is 44 chars
 
:o
 
grc
that one could be hardcoded though
 
Not many test cases?
 
grc
I haven't checked
the next best is 55 chars, so 44 just seems a bit odd
 
1:13 AM
The small coin limits make it seem kind of simple
Hmm have you unlocked Mine?
 
grc
I think so
 
@MartinBüttner Ahaha given the spec I think this could be 39: ^(([^[-}()]|\((?1)\)|\[(?1)]|{(?1)})*)$
Hmm k, I might try and look at the test cases (haven't unlocked Mine yet though)
 
grc
this is an interesting one: checkio.org/mission/palindromic-palindrome
 
1:28 AM
Ahaha surely we have a question like that already
27
Q: Palindromic palindrome checker

marcogWrite a program to test if a string is palindromic, with the added condition that the program be palindromic itself.

Making it a golf question though, would be interesting :P
@grc pastebin.com/Ce7D3Q6v Hmm looks like if we ever need to use range(100), we can use range(99) instead :P
34th place with
from itertools import*
golf=lambda c:min(set(range(99))-set(sum(x)for i in range(11)for x in combinations(c,i)))
XD
 
grc
golf=lambda l:sum(l)+1 works for 5/8 of the test cases
 
D:
Maybe that's how the 44 works
 
i wrote a completely different type of solution for the brackets problem
checkio=lambda s:eval("s"+311*".replace('%s','')"%(tuple('0123456789+-/*')+('()','[]','{}')*99)‌​)==''
 
1:46 AM
Weird, I seem to have left out a test case @grc or golf=lambda c:[len(c)==4,4][len(c)in[3,6]]or sum(c)+1 would have worked
@xnor :o lambda-ified!
 
the magic of eval
letting you do loops in a lambda
i'll take a look at the coin problem
 
grc
[10,2,2,1] 6 is a test case
 
Added
@xnor I was wondering how to do consecutive .replace's efficiently when doing the 12 days of golfmas problem
But wow...
Hmm it seems to fail one of their test cases though, I wonder why
Oh. They have an insane amount of brackets
 
oops, that should be a 999
 
:P
 
1:55 AM
which means the 33 should be a 3*999+14
3011
 
2:08 AM
Hmmm how do you even get the first element not in a list efficiently, without min(set(range(99))-L)
Or do you think that's the wrong way to go about it
 
7
Q: Minimum excluded number

xnorThis is intended to be an easy, bite-size code-golf. The mex (minimal excluded number) of a finite collection of numbers is the smallest non-negative integer 0, 1, 2, 3, 4, ... that does not appear in the collection. In other words, it's the minimum of the complement. The mex operation is centra...

there's no a generally shorter way
 
:/ that's 21 bytes already
 
here's what I have so far:
def golf(l,s={0}):
 for x in l:s|={x+y for y in s}
 return min(set(range(99))-s)
yeah, that min is really the killer
we could be tracking the complement is s instead though
 
If only you could do x+s to mean "add x to every element in s" :P
 
what if we could ...
we could store the list of possibilities as a bit-string
def f(l,s=1):
 for x in l:s|=s<<x
 return s
this returns the bitstring of achievable sums from l
now how to find the index of the least 0 in a bitstring....
thanks for comments about x+s -- it was a great idea even if you didn't mean it!
 
2:21 AM
Speaking of << I was thinking of the lookup table idea from your golf tip
Not sure if that's short enough though
 
are there actually only 8 test cases?
 
At least 10 - I think only some are revealed when you solve the problem, and there's a few extras you hit when you fail
 
i see
this bit-string thing gives me an idea for a prime-finding golf...
 
2:35 AM
This doesn't even work properly and it's already 42:
golf=lambda c:(7247757764>>sum(c[:-3]))&7
:/
 
why doesn't it work?
 
I was trying to match the small cases, because as grc pointed out some of the larger ones can be done by sum(c)+1
[1,1,1,1] 5 is a test case :/
 
unrelatedly, here's my effort to find primes via bitstrings
b=0
N=4
exec("b|=N*N*~-N**99//~-N;N*=2;"*99)
after this is run, the bitstring b is a lookup table for composites up to 100
 
:o funky
 
grc
looks efficient :P
 
2:43 AM
i don't think it beats existing methods, unfortunately
unless maybe you actually want a bitstring as the result
 
Oh I see why I'm missing so many test cases now
There's two tabs for test cases, you can change the test case number, but also the test case set
... one of the cases is [1] 2
There goes that plan
Updated: pastebin.com/Ce7D3Q6v That looks pretty difficult to hardcode now
 
2:59 AM
is there a really short way to find the great power of 2 that divides a number?
like 48 -> 4
 
Looks like you want the log of that though
 
whoa, thanks
that's really cool
 
I swear we could almost have a Golf Practice: Bitwise
 
go write it!
 
XD too hard, I don't know many tricks :P
Maybe a golf tips: bitwise might be better
 
grc
3:10 AM
54 chars for coin golf :)
 
:o how the!?
 
grc
studying the test data ;)
 
Ahaha figures :P
A legit solution doesn't seem to be able to break 55...
 
i have 63 for a legit sol'n
 
grc
nice
 
3:12 AM
is there a fast way to take the log base 2 of a power of 2?
 
Have you unlocked the challenge? You should post it :P
 
i haven't unlocked it
len(bin(n))-3 seems really silly...
 
:P k well I don't think it takes long
45
A: Tips for golfing in C

LowjackerUse bitwise XOR to check for inequality between integers: if(a^b) instead of if(a!=b) saves 1 character.

D: damn
Never thought about that before
Oh there's already a "Tips for golfing in <all languages>"
 
3:29 AM
oh, where?
that sounds useful
 
18
Q: Tips for golfing in <all languages>

ajax333221The aim of this post is to gather all the golfing tips that can be easily applied to <all languages> rather than a specific one. Only post answers that its logic can be applied to the majority of the languages Please, one post per answer

... they're mostly quite general though
 
@grc, do you have a list of the test cases?
 
thanks!
 
That should be all of them
 
grc
3:40 AM
hint: the answer is always the sum of reachable numbers plus one
 
... that makes sense, right? Or by "reachable" do you mean something other than values that can be formed by summing any subset?
Sub-challenge: Can we beat the current leader (Python only, 44 bytes) on checkio.org/mission/coins-golf knowing the test cases are pastebin.com/Ce7D3Q6v ?
 
grc
you can use the test cases to simplify the definition of reachable
 
sum(c[i:j])? :o
 
grc
I was thinking of the gap between reachable and unreachable numbers (e.g. 1, 2, 3, 8)
 
Oh, my one fails on [1,2,3,4,5] 16 anyway
 
3:51 AM
oh, are they all one plus the sum of numbers you can reach without crossing a gap of 2?
 
grc
yeah 2 or 3
 
4:05 AM
i can tie 44 chars if you give me a few hundred thousand tries: golf=lambda c:1+sum(x*(x<4&id(0))for x in c)
 
XD
I'm still not sure about id(0) though
 
what about it?
 
I don't think it gives a random number, if that's what you're doing
 
do you mind giving it a try?
i know it gives different numbers each time
 
... oh I see
 
4:07 AM
if it can get through 3 test cases, that would be promising
 
I need to do it in different sessions
 
oh, no
each test case has a separate one
it seems to reset id(0) each time
 
Yeah I meant I was just trying id(0) consecutively in the shell :P
 
oh, i see
 
grc
id(x) always seems to be divisible by 8 on my computer
 
4:12 AM
Seems to be 4 mod 8 on mine
Maybe id(0)>>3?
Too many chars though :P
Hmm only 5 of the test cases aren't sum(c)+1
 
this works golf=lambda c:1+sum(x*(x<4 or 4 in c or 5 in c)for x in c)
unfortunately, both 4 and 5 are relevant
 
grc
that's basically mine:
golf=lambda l:sum(x for x in l if{4,5}&set(l)or x<6)+1
 
{4,5}&set(l), nice
That should be a golf tip for a in L or b in L or c in L :P
 
4:39 AM
Just unlocked Hubspot ... it's not a place of good golfing challenges D:
 
5:34 AM
 
 
3 hours later…
9:03 AM
@MartinBüttner Or maybe even [*-9]
 
9:38 AM
@Sp3000 yup :)
 
10:17 AM
Hmm I wonder if I should put up what people have come up with so far somewhere. Not sure how to do that well though (preferably so that everyone can add their own solutions)
Github?
 
github then
 
10:51 AM
A Github has been made for keeping track of solutions! github.com/Sp3000/Minigolf I'll try and keep it updated
(I've only ever used Github for my own purposes so I've never had to deal with any fancy problems like edit conflicts :P)
@xnor for square roots - nice, I didn't think of that :o
 
 
2 hours later…
12:41 PM
Hmm I have a question picked for the next one but I think it might just work as a PPCG question itself...
 

« first day    last day (18 days later) »