« first day (1588 days earlier)      last day (3254 days later) » 

9:11 AM
hi all
 
Hi
 
codegolf.stackexchange.com/questions/51312/… please let me know if anything is unclear
(slightly edited just now)
 
0
Q: Number of strings without a prefix that matches a suffix

felipaIf a string of length n has a prefix of length less than n that matches a suffix we call it bad. If not, we call it good. For example 01011 is good and 010101 is bad. The task Your code should output the number of good strings of length 1,2,3,..., with alphabet size 1,2,3,4,5 one per line, and...

 
I don't get it, you should output bad/good or truthy/falsy?
 
@Katenkyo no you output integers
 
9:20 AM
hooo
then your exemple is false, isn't it ?
for n=1, everything is good
as your prefix/suffix size must be less than n
so the output should be :
1
2
3
4
5
Right?
 
hmmm...
let me see :)
a string of length 1 is bad if it has a prefix of length less than 1 that matches a suffix.
as no strings of length 1 do
thanks!
 
np ^^
@Optimizer wow, well done !
 
@felipa For the number of binary unbordered words, there's a recurrence formula: oeis.org/A003000
 
@Zgarb oh!
a[0]=1; a[n_]:=a[n]=2*a[n-1]-If[EvenQ[n], a[n/2], 0] ?
looks like I need to delete my question :(
@Zgarb thank you very much!
I will make a new version
 
9:25 AM
For three letters oeis.org/A019308 and four oeis.org/A019309
 
@Zgarb but you can easily compute the solution to that recurrence it seems
although I don't know what EvenQ[n] means
EvenQ[expr]
gives True if expr is an even integer, and False otherwise.
ok
@Zgarb oh.. is there a general formula for any alphabet size?
a(2n+1) = sigma * a(2n); a(2n) = sigma * a(2n-1) - a(n) it seems
 
Seems plausible
 
ok so I will make the question more difficult.. thanks
I have to admit.. I can't actually find the quoted formulae in citeseerx.ist.psu.edu/viewdoc/…
@Zgarb can you?
 
Not directly
But maybe it's not too hard to prove directly... let me see
 
that seems to be the solution for the binary case
 
9:40 AM
Good find! The general case is the same, but with 2 replaced by alphabet size
 
right.. I have given up on this question now :)
thank you for killing it so quickly
 
hi peoples
 
@sirpercival hi sir
 
i really need help trying to figure out this Cython crap. anyone have a working knowledge of both C pointers, and python?
 
@felipa No prob', was a pleasure :D
@sirpercival I have a working knowledge of both C and pointers if you want :troll:
 
9:44 AM
lol
well maybe you can help
 
I'm sorry that i can't help you on python ^^'
Isn't that the probleme you had yesterday?
 
@Katenkyo not exactly. i figured out that problem except for the (should be) relatively simple thing i'm stuck on right now
i'm trying to pass a pointer to a numpy array
and it's trying to convert it to a python object
and i don't know why
 
knowledge of Python + knowledge of C does not make knowledge of Cython
 
@feersum i'm aware, but it's the minimum requirement for being able to help me
 
@sirpercival Because numpy are awaiting python object, not? x)
 
9:48 AM
just ask for knowledge of Cython
 
i have a bit of knowledge about Cython. i don't have any knowledge of C pointers
 
I have hte first 2, but that is no help
 
@feersum Cython is much rarer
 
exactly
 
9:48 AM
@sipercival numpy.array wants an array-like object
Pointers aren't arrays, that should be the problem
 
what are you trying to do?
 
You would have to extract the datas referenced by the pointer with a for-loop I think
 
@Katenkyo numpy arrays are wrappers around memory arrays, and have pointers built in
 
@sirpercival The fact they use pointers doesn't mean you can construct them using C-pointers :3
 
@feersum i'm trying to extend scipy.ndimage.geometric_transform in cython, as per stackoverflow.com/questions/16441903/…
my "shift" is an ndarray of polynomial coefficients
so i need to convert that to a pointer
 
9:52 AM
what do you mean 'shift'?
 
look at the first answer to that SO question
i'm using the same variable names for simplicity
 
I have no idea what shisft is supposed to mean there
 
ok so geometric_transform accepts a 2D image, and a transformation function which is applied to the pixels in the image
 
ok
you want to makee a transformation function?
 
i originally had my transformation function written in python, and it was super easy. except that it was horrendously slow
you can pass geometric_transform a pointer to a PyCObject
that SO question is trying to do basically the exact same thing, and the answer shows how to do it in Cython. the problem is that i can't figure out how to properly pass my coefficients as a pointer
i don't even need it to be a numpy array
 
9:56 AM
man that is a terrible doc
 
yes
it's awful, i actually opened an issue about updating it
 
they can't even call the parameter the same name twice
 
it uses deprecated python code, even
PyCObject is now PyCapsule
but this kind of stuff (the C side of python) is way outside my competency
so i was happy to find someone had already done the cython part of it
 
what is your problem again?
can you run their example?
 
i didn't try, actually
my problem is that i'm trying to pass my poly coeffs to shift_function, and i can't figure out how to make the numpy array of coeffs into a pointer
 
9:59 AM
see if you can get it into a compilable form...
 
yeah i'm gonna try that directly
 
10:16 AM
ok i got the pointer thing to work in the toy example
i'll see if i can do it in my version
 
hi phi
@PhiNotPi do you know cython
 
10:35 AM
@sirpercival SO is normally pretty helpful wrt cython
 
Nope. :/ ​
 
yeah, but i know people here
@PhiNotPi no worries just checkin
 
@sirpercival makes sense
 
I should probably start pinging less often after that massive ping battle last night.
 
Do you think having a rule in the Samurai KOTH disallowing "strategic duplicates" (that is, two entries with different source code that implement the exact same strategy) is a good idea?
 
10:37 AM
Yes.
 
Thanks
 
What's the rules for entering more than one bot?
 
I think I'll allow it
Not sure how you would exploit it, since if you make one really weak bot to boost your other bot's score, it's going to boost all the other bots too
 
It's probably not exploitable in this type of game.
 
fun fact about Fission Numbers: N = 11 is the only number up to 10k for which F(N) > N. The only numbers (up to 10k) for which F(N) = N are 1, 3, 5, 6, 23
 
10:41 AM
That is not fun at all
 
I feel sorry for you.
 
@Katya the only way round that would be for a bot to have a unique starting combination which tells the other bot who they are and then one can roll over and die
 
Ahh true. The "secret handshake" method
 
But because the game is quite short it'd probably not be a very good idea
you'd probably dead before you'd realised the other bot was an enemy :)
 
@MartinBüttner its not like I don't find math facts fun at times. This one is particularly useless :P
 
10:44 AM
@TheE I agree, as you need a long sequence if you want to be sure it's your ally
 
@Optimizer useless math facts tend to be more fun than useful ones.
 
and if it's a shorter sequence, then there can be the possibility of a "spy" bot that pretends to do the secret handshake
which could lead to some interesting developments
 
Or a random bot which accidentally does it
And given that everyone will be able to read everyone else's source code...
 
Yeah, I think we've established secret handshake doesn't work for this koth
I should keep it in mind for future ones though
 
@MartinBüttner I feel sorry for you ... :P
 
10:47 AM
WHOO i got it
 
I'm actually trying find an upper bound for the sequence.
 
congrats sirpercival :D
 
@C0deH4cker oh, hello there! :)
 
@sirpercival Well done !
 
@MartinBüttner imgur.com/XIcqJGW
 
10:50 AM
haha, thanks :D
 
do you get another badge ?
 
Sure. Was a great answer, and had to put it to 200.
 
@Optimizer no
 
good
:P
 
14 hours ago, by Calvin's Hobbies
^ sour about badges
 
10:51 AM
I'll try to be in this chat room to talk more later. But now I need to go to sleep because it's super late here
 
that arrow points to Calvin himself
or, otherwise, it bypasses mine, and points to Martin
 
Bye
 
@Optimizer tell yourself that. ;)
@C0deH4cker see you
 
@Katya I am slightly concerned that 2 matches per pair-up may not be enough.
 
Hmm... that's a good point
I could just change it to 3 or 4
not sure how it would effect the running times though
 
10:58 AM
@Katya as it shouldn't be long to run matches, you could run 10, no? ^^
By the way, I have a question
 
yeah I could
What is it?
 
Why does this chat room is called as it is? x)
 
It's to do with golf courses
 
Ho, removing that 19th byte... okay x)
 
The club at a golf course where the golfers relax is sometimes called "The Nineteenth Hole"
 
11:00 AM
(were wrong xD)
Ok, thanks for the intel :)
 
In addition, "The Nineteenth Byte" has 19 bytes
I think
 
It does :°
 
yeah it does
okay, I've changed it to each player plays each other player 8 times
with an additional note at the bottom that says it is viable to change if there a lot of contestants and 8 times becomes impractical
 
Did you write some basical samuraïs?
(Random etc)
 
Yeah, I have the two that I'm posting on the challenge (one that acts randomly, one that just waits)
and I have another two which I used during testing which won't be posted (one that acts randomly but doesn't kill itself, one that tries to "charge up" to the sword of the gods)
 
11:07 AM
I think you could at least put the randomButNotSelf instead of the purely random one :3
 
I expect someone to implement randomButNotSelf as an answer themselves
Anyway, the actual logic behind pure random is actually "bow on first turn, act randomly afterwards"
 
Ho, I see.
 
the idea is to show the reader how to handle the first turn
but I want to make the bot as weak as possible apart from that
 
Having competitive base bots can be funny
Base bot just have to be simple, but can be strong
 
yeah, I'm not expecting any extremely complex strategies for it
maybe the most complicated thing someone might do is a markov model
 
11:11 AM
I plan on submitting a bot that the simply uses the SotG by bowing 9 times and alternating bowing + random attack. If the SotG is a viable strategy, then that bot might be competitive.
 
Yeah, that's one of the ones I had during testing
Internally it was called "Spirit Bomb"
 
Did it actually work at all?
 
@Katya I love the name x)
 
With the current parameters Spirit Bomb beats Even Striker
(Even Striker just striked on every even turn)
Interestingly, with the original ruleset (same types of strikes cancel out, even if one is the SotG), even striker usually won
 
Is the SotG the ultimate strat? :x
 
11:14 AM
Probably not.
 
I don't think rushing to SotG is the most optimal
Not sure what is the most optimal though
I think I'll play around with a few more strategies and see if I can find a nice balanced value for the SotG cutoff
 
@sirpercival If there's anything else you want to speed up in python, have you tried pypy? It's much more likely to work with existing python code without needing modification, but also provides a significant speed improvement for most code
 
Let's say that both players are alternative bowing and SotG. Then if they attack/bow in unison, then the SotG inflicts 4/3 damage per 2 turns and the normal sword inflicts 1/3 damage per 2 turns.
If they perform opposite actions (one bows while the other strikes) then SotG does 2 damage per 2 turns and normal weapon does 1 damage per two turns.
The SotG player prefers the first scenario, the normal player prefers the second scenario.
(Looking at the ratios of the damages to each other)
Now let's look at the number of "free" strikes that the normal player would get while the SotG player is charging up.
In the first situation it is 4, in second it is 5.
 
So he dies in both case
 
Then let's see who would win, "flattening out" the average 4/3 damage / 2 turns into exactly 2/3 damage per turn.
 
11:27 AM
@Katya Is the 100ms per turn time limit to allow for slower languages/complex strategies? Decreasing it could make a big difference to how many games you can run.
 
1
Q: Tips for golfing in sed

Toby SpeightWhat general tips do you have for golfing in sed? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to sed (e.g. "remove comments" is not an answer). Please post one tip per answer.

 
@Katya Just noticed that the player code is called each turn, rather than staying running, so I guess a longer time limit is necessary
 
11:54 AM
How about Tips for golfing in bed ?
5
for times when you are too lazy to golf.
 
do you golf differently when you are in bed?
 
Best positions for golfing?
 
@trichoplax i haven't used pypy, no. but the gui & packaging frameworks i'm using are designed to work w/ cython
 
@MartinBüttner you are at your best even in bed feeling lazy ?
 
12:03 PM
Ah OK. It's useful if you started coding something with just python, but it sounds like that doesn't apply here then
 
12:19 PM
all this time I've been making KoTHs on a torus, and nobody told me that that was impossible!
 
@NathanMerrill Your KotH are pretty like torus, so what's the problem? x)
 
because they are actually on a corrugated torus
 
and what's the difference with a torus...?
 
imagine turning a piece of paper into a donut shape
the part of the donut that is on the outside
is shorter than the inside
so the "squares" in my torus are are stretched
 
Ho, I see where you wanted to come
Dealing with a true torus would be just overcomplicated
 
12:25 PM
nah, I just need to say its a corrugated torus
 
You will only confuse people...
Say torus-like instead, it's easier to understand
 
Th.e usual word is 'topological'
 
my enum is 42 lines long ! \o/
 
1:10 PM
my enum is only 1 line long..
 
Why condense it that much?
(it's not 42 constant by the way, only 9)
 
2:11 PM
1
Q: Count the crossing words

NinjaBearMonkeyConsider the following standard 15×15 crossword puzzle grid. We can represent this in ASCII art by using # for blocks and (space) for white squares. # # # # # # # ### ## ## ## # # # # ## ## ## #...

 
@MartinBüttner I just came up with the same solution.
wait no.
 
I found a lot of 19 byte solutions, but this is the only 18 byte one I could find
 
its a bit different , but same bytes
qN/_z+Sf%:+{,(},, - 17
 
oh, nice
should I use that?
 
Academia has all the most interesting people o_O
 
2:19 PM
@MartinBüttner sure.
 
thanks :)
 
At least you guys are all sane :D
 
@Compass I have no idea what are you talking about
 
One of our questions is probably going to hit the "Hot Network Questions" thing soon.
on Academia
6
Q: Could not get along with any advisor, is it ego?

academicwastelandDuring my academic studies, I have always been ambitious in pursuing academic research with no luck. All the professors whom I came across with or I attempted to set up an advisor-advisee relationship with, in some way kicked me from the deck of the ship. This was not due to my lack of knowledge ...

Basically, a guy has been saying that all his potential advisors have been rejecting him and he blames them all for being incompetent. He even claims his love life is a disaster but he is not to blame.
 
@MartinBüttner I get 76 for the first example.
 
2:22 PM
Meanwhile, on ppcg, I just read funny BrainF___ and other relaxing puzzles :P
 
(instead of 78)
 
@Optimizer SE strips the spaces on the two empty lines
 
which ones are those ?
 
how do I type...
 
is it a DAS keyboard ?
 
2:23 PM
WASD
also blank though
 
DAS is a brand :|
 
oh, so it is a blank one
 
How long as Peter Taylor been gone... and why?
 
coz he hates everyone
in here..
 
2:26 PM
@TheNumberOne he's just busy at the moment
 
@TheNumberOne you are the number one in his list.
 
Which list?
 
hate list
f, doesn't work ? :(
 
why would it?
, is unary
actually , is a bit of an anomaly
it doesn't have fixed arity
@aditsu what happened there? ^
 
f% f/ both work
 
2:30 PM
% and / are always binary though
 
so its easy, no ? f, should act like the binary one
 
@MartinBüttner I copied it from golfscript without thinking much about arity :p
 
@aditsu you are the worst :P
 
thanks, I try :)
 
u are succeeding
 
2:32 PM
Python needs switch statements :(
 
it has switch statements
they are called if.else
its simply a play of words
 
^ boo, not good for golfing
I'll just use exec
 
^ sed every python user
 
3:05 PM
^ gawk every sed user
 
^ eval every gawk user
 
^ grep every eval user
 
nvm, I'll use java instead. The scoping is giving me a headache.
 
ok, I wrote a subleq interpreter in python, and it now interprets multiple programs one instruction at a time in sequence.
now I just need to write the generator, and I think my first entry to the halting challenge will be ready to golf
 
3:34 PM
0
A: Evaluating Parentheses and Brackets as Integers

TheNumberOneJava, 349 characters A simple recursive approach. import java.util.*;class K{int a=0,b;String c;public static void main(String[]a){K b=new K();b.c=a[0];System.out.print(b.a());}int a(){switch(c.charAt(a++)){case'(':b=0;for(int a:b())b+=a;break;case'[':b=1;for(int a:b())b*=a;}a++;return b;}List<...

First answer that doesn't use eval in any form.
 
SotG health, 1st scen. = 16 - 1/6 * (t - 9)
normal health, 1st scen. = 20 - 2/3 * (t-9)
in second scenario it is y=15 - 1/2 * (t - 9); y =20 - 1 * (t-9)
In both scenarios, I think the SotG player will win.
But the second is a closer match.
^ A direct continuation of my previous conversation completely ignoring everything everybody has said since then.
 
3:52 PM
Wrote the first complete specs for Time Travel Coin Tossers:
2
A: Sandbox for Proposed Challenges

randomraCoin Tossing Time Travelers king-of-the-hill In the future when time traveling (TT) will be common coin tossing will become a serious mind-sport. To prepare for the future we create a competition for programs where time traveling will be really happening from the viewpoints of the entries. The...

controller is ready too: github.com/randomra/Coin-Tossing
 
4:26 PM
woo!
I can generate a list of [relative addressing] subleq programs that halt
 
@Katenkyo Yeah, sorry about that. We were performing an experiment. It appears you can ping a user based on the first 3 letters of their username and I was trying to figure out what happens when usernames are not unique on the first 3 characters. As it turns out, it just pings everybody with those 3. In this case both you and @Katya were pinged.
And then of course I forgot that it might be pinging you too so I kept pinging Katya using Kat.
Sorry
 
(this is why you use the reply button)
 
@Doo
 
can you reply with keyboard shortcut?
 
@DoorK
 
4:30 PM
@randomra There's a userscript on StackApps (sorry, can't link it now, about to get on a plane).
 
@Phi
 
@Doo What fun is that when you can experiment?
 
^ that is literally opposite of you
 
@Doo How are you exchanging stacks on a plane?
Snakes on a Plane 2: Stacks on a Plane
 
> about to
 
4:31 PM
My first three letters of my username are actually reasonable.
 
@AlexA. <-- bad at reading
Mine implies some kind of beer. I'm okay with that.
 
I don't have speakers or headphones plugged into this computer, so your pings are useless! Muahaha
 
We just to ping harder.
2
 
Yes, We just to ping harder
 
4:33 PM
(^"have to ping"?)
 
we just to english harder too
3
 
You ruined it!!!!!
 
^We just( have)? to ping harder.$
 
4:49 PM
@AlexA. No problem, I did read the conversation and figured out that you were experimenting. I was just surprised because I didn't think someone would ping me :p
 
@Katenkyo Well that was a silly thing to think. :)
 
Such chain breakage. Wow.
 
Amaze
 
This reminds me of something that happened at another website, which I've moderated on before.
 
screeps.se?
 
4:52 PM
Literally an entire thread was "moderated" leaving nothing but hundreds of "response moderated" labels.
 
Wow. Such.
 
Can someone buy ppcg.se or codegolf.se and have it redirect to codegolf.stackexchange.com
 
Let me find the page.
 
@ThomasRoss Why?
 
4:54 PM
because typing codegolf.stackexchange.com is a pain
@PhiNotPi lol what
"The CIA is onto us! Everyone lets run to
*Remainder of comment removed by Fluther moderators."*
why does the italics not work
 
Formatting doesn't work on multi-line chat messages.
 
Why not
 
don't know.
 

« first day (1588 days earlier)      last day (3254 days later) »