12:19 AM
How do you override the [] operator in python, i.e. change what foo[bar] returns?

@ASCII-only You don't need the **.5

@Pavel if bar is a single operand, then you override the __getitem__ attribute

thanks

12:38 AM
@lirtosiast oh wait true
@EriktheOutgolfer wait. only single?????

well... if you have a : in everything changes... :P

@EriktheOutgolfer firstly... that's still a single parameter...
secondly... all that happens is it gets passed a slice object instead of a normal one...

actually, a[b:c:d] is just a[slice(b,c,d)]

exactly

but... overriding __getitem__ if you just want the b is easier ;)
if you want the b and c but not the d, there's a handy __getslice__ method you can override as well, but... __getitem__ also covers the case where you're given a slice
rant: why did you make a[b:c] separate from __getitem__...

1:35 AM
@ASCII-only should ??.getValue() + 1 compile to { $0.getValue() } + 1 or {$0.getValue() + 1 }

2 hours later…
3:37 AM

Anonymous
4:21 AM
@ASCII-only Golly doesn't yet support neighborhoods of radius 2

4:44 AM
@PhiNotPi actually on this topic I think PPCG's @AshwinGupta developed code for a cubesat for his school

4:56 AM
I really want to have a personal satellite someday. Launch prices are low enough that it wouldn't break any laws of finance... just difficult.

@PhiNotPi I mean it's a around 100K launch and then I'd expect 40K development costs not to mention cost of labs and other development resources. Though I think NASA does cover launch costs if you're selected

5:24 AM
check this guy out though... his channel is a quest to make a mini falcon heavy

Anonymous
I would appreciate any feedback

11:31 AM
@ASCII-only Oblong seems to be broken: ＵＯ¹χXO¶OX

12:13 PM
@ASCII-only RotateTransform seems to be very broken: ≔⮌⪪θ¶θ⊟θ⟲Ｔ⁵Ｍ→⮌θ

@Mego what if I told you... that LaTeX doesn't want to render a sum properly...

12:41 PM
@Mego alright, a question: since "summing over all..." looks a bit weird when converting the post to LaTeX, maybe I can rephrase it as (u,w)\in E under the \sum?

1:39 PM
@ASCII-only well you've literally got a built-in for it :|
but yeah Charcoal has a higher chance of beating Canvas on simple/line-y challenges

1 hour later…
2:46 PM
0

Introduction We all know the game of Go-Fish. Everyone has numbered cards, and on their turn they get to ask another play if they have any of (some number). If they do, they hand those to you. When you have four of a kind, you lay them down and continue. But today you won't be implementing Go...

3:07 PM
@Downgoat hmm I'd say expand till braces or parens probably?
@Mego wait wat are you serious
@Mego then... How do they do larger than life

@ASCII-only i assume mego meant that golly doesn't support custom rules for radius 2, not them in general

1 hour later…
4:23 PM
1

Golf a program or function which gives the \$n^{\text{th}}\$ location of the wildebeest who starts at square \$1\$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visit...

5:18 PM
@Doorknob hello

5:29 PM
@PhiNotPi o/

how's life?

pretty good, how are you?

I've been busy with med school interviews... not much else though.

ah, that sounds fun
good luck!

Thanks
Unfortunately I can't afford any of the cool space parts right now.

5:44 PM
I'd imagine they'd be rather expensive

6:02 PM
Why med school?

@feersum Basically I feel that it is a uniquely rewarding/"meaningful" career and I believe I have a lot I could contribute to the field.

Well I dunno, accounts I've seen usually suggest that contact with the actual medical system quickly crushes the notions of helping people, being meaningful or whatever.
Are you thinking more a practicing doctor or an academic, or what?

I'm focused mainly on the academic side of things... I'm actually applying mainly for MD/PhD dual-degree programs.
It's true that there are lots of issues with physician burnout, especially in the US system.

6:19 PM
I guess if you are researching there is perhaps less concern about that. I suppose you still have to the usual stuff like a residency though?

Yeah, residency will be intense.

6:32 PM
@EriktheOutgolfer hmm, odd - if I run my code with a knight or camel the generator raises a StopIteration at the correct point, while I ran it for a wildebeest and got to 150 million, posted and called next(g) and got a StopIteration. I made a mistake somewhere but am not yet sure where... I've done it again and had the same at ~22m - unsure what's going on.

are you sure it's wrong?

I dunno, maybe it always gives the StopIteration once I kill a loop and then try to call __next__?

first of all, you're using list.append and you're calling a function extend... :P

and?

nah, just a little remark, haven't looked at it thoroughly yet

6:37 PM
I think I just cant kill (ctrl-c) a loop and expect the iterator to still work. I just killed one and called next and it gave me 1.
:p

wait, are you killing stuff? ;P

yeah when counter got to 150m
btw - code at TIO is slightly wrong - I didn't edit in to use deltas. This is fixed for that: tinyurl.com/y9omfeve

hm, so, I'm pretty sure the extend function is correct
not checking that
also, yeah, just noticed lol
@JonathanAllan can I see how you're testing the iterPath function?
(not link, obviously won't work :P)

I was doing a while 1: and printing a counter every 100k, and calling _=next(it) where it=iterPath(). It raised at end of Knight & Camel, so I think that there probably are > 150m terms for wildebeest :)
(it=iterPath() before entering while that is)

(heheheh)
so, looks like your extend function adds four sides :P

6:51 PM
it does.

as to why it might raise a spontaneous StopIteration, well, that's really weird

and that yield 1 line makes me wish Python had do...while...

can do a for too, but that doesn't leave the iterator around to continue. I guess I could collect all the results and just look at resulting length & end values to check...

here's the thing... we don't know if it will ever end...

6:54 PM
no, but if it does end within 150m we should :p

also... another creepy thing I noticed... not isn't a function!!

no, the parens are for eval-order
kicking off:
res = []
for n, v in enumerate(iterPath(), 1):
if n%100000==0: print(n/1000000)
res.append(v)

@JonathanAllan but... the parens don't do anything
comparison operators have higher priority than not
anyway, I'll reformulate that piece of code a bit and continue trawling

LOL oh yeah - they are now redundant - used to be more in there :)

not all(0 <= row + deltaRow < len(spiralArray) and 0 <= column + deltaColumn < len(spiralArray) for deltaRow, deltaColumn in deltas)
^ simpler version
yeah I like simplifying things

7:01 PM
Is there a generally accepted way of authenticating API endpoint access?

@JonathanAllan umm... ok, what does this part do?
            row += 1
column += 1

simpler = better :)

and, talking about simplification, you can then remove the and and make a nice choo choo of comparison ops over there :P

if we extend the spiral by a layer we are now one further down-right (as it extends in every direction)

ah, right
so, that might be a bit optimizable, let's see further down...

7:10 PM
@EriktheOutgolfer except that does not simplify anything as one more comparison op is required - just becomes harder to read for no gain, right??

0 <= row + deltaRow < len(spiralArray) > column + deltaColumn >= 0
you can also swap the end terms with the middle term and change the direction of the ops, but you want the larger one (if possible) to be in the middle

oh, ok - no extra :) still harder to read

yeah, that's why I didn't include that above
you avoid calculating the length twice though

that's mostly golf though - how much does it actually improve? (length is not calculated, it's a property of the underlying list object)

yeah, it just fits in all in a line where I avoid
    this
stuff happening to
me
anyway, I'm a bit more down now already
yep, just finished reading, everything looks fine
@JonathanAllan so, are you still receiving spontaneous StopIterations? hm...

7:21 PM
not using ctrl-c in the repr with a while loop - just collecting terms. Will see when I reach 150m
(at 100m now)
...meanwhile Arnauld is golfing his solution

oh huh lol

but that solution uses recursion so cant be used for 150m :p

so... I just spotted he's been golfing that for about an hour

Why is this sitting at 0 votes :\ codegolf.stackexchange.com/questions/121731/…

7:31 PM
I'm guessing people might see "factorial" and "modified X mins ago Deadcode" and assume I'm just editing the regex post.

that nobody can know for sure :P
also, the front page here doesn't have that much demand tbh

Drawing attention to your own posts isn't forbidden, but can look like a request for upvotes even if only implicit. In answer to your question, it's hard to tell - it's possible very few people have seen it yet as 10 hours isn't a long time. I wish there was a view counter on answers instead of just questions, but I can't see how that could be reliably implemented...

very hard to implement, what if I'm just scrolling by?
@JonathanAllan so, reached 150m yet? :P

I was only curious as to why this is happening. I wouldn't be upset at all, were it not for the fact that a new C++ answer to the same question, of much more bytes and much slower execution speed, got 1 upvote about 10 hours ago.

@EriktheOutgolfer yes exactly

7:37 PM
@Deadcode no need to be upset, votes aren't objective, might be bad luck, might be some other surprising reason... move on! ;)

@Deadcode I wouldn't take +/-1 vote too seriously - there's a lot of noise in the system so until there's a significant difference it's fairly meaningless which answer is higher

^ regarding that, well, even Tim Post has done that by mistake :P

Accidentally voted?

lol don't you know the infamous meme?

I live in a bubble and don't see many memes...

7:43 PM
Tim lost his keys and blah blah blah and a golf ball went into an innocent user's house and made him click a downvote button while the user didn't have time to undownvote as he had to, er, scavenge for and remove that stray golf ball off his house!
oh wait I might have altered it a bit...

Yikes! Right, because you can't undo a downvote after a certain amount of time unless the post has subsequently been edited?

That does sound vaguely familiar - I may have heard it and then mostly forgotten it...

Thanks.

@EriktheOutgolfer That confirms it - I already upvoted so I must have seen it at some point

7:47 PM
well, the actual story is a bit more terrifying

3

LOL.
Touché.

@feersum but isn't a proof of the opposite too...

@Deadcode some of the delay in upvotes may be due to declaring zero to be a natural number :P

@trichoplax Hm, really? Is there actually any disagreement about that?

7:51 PM
In mathematics, the natural numbers are those used for counting (as in "there are six coins on the table") and ordering (as in "this is the third largest city in the country"). In common mathematical terminology, words colloquially used for counting are "cardinal numbers" and words connected to ordering represent "ordinal numbers". Some definitions, including the standard ISO 80000-2, begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, …, whereas others start with 1, corresponding to the positive integers 1, 2, 3, …. Texts that exclude zero from the natural...
For this reason I recommend challenge authors always specify explicitly whether zero is a possible input

Well yeah, to be complete it has to say that :) But in practice, does anybody use the 1,2,3,... definition?

It's what I was taught in the UK, but I just generally try to avoid the term and say "positive integers" or "non-negative integers" to be explicit

@Deadcode The 1,2,3 definition is the more commonly accepted... so yes?

I would expect it might be taught that way in elementary school (primary school), but surely not at later stages of education?

The challenge isn't very clear because of that, and also it says "Your program must not produce errors for any input" despite also saying "You can assume that the input number will always be in the range of numbers supported by your language"

7:57 PM
I do vaguely remember being surprised the very first time I read a definition of natural numbers including zero, because the very first definition I'd learned excluded zero.
But since then, I've only ever seen natural numbers being treated as including zero

@trichoplax I have it as an example here lol
the first example, no less

@trichoplax Wow, that is surprising. In what context, may I ask?

@Deadcode Same question to you, in what context?

@Quintec Number theory; formal systems of expressing true statements of number theory
The Peano axioms
1. 0 is a natural number.

@Deadcode Actually, Peano originally wrote 1.

8:01 PM
@Quintec Seriously? :O
But then you have no additive identity!

@Deadcode I remember it from a lecture course on conjecture and proof, rather than a course specifically on number theory

@trichoplax What do you mean by that? You have subtraction. And in a formal system with no subtraction symbol, you can just say things like ∀a:∃b:∃c:a=b+c
But that statement is no longer true if 0 is not a natural number. It won't be true for a=1

Ah I see. Good point

@EriktheOutgolfer was busy cooking, computer ran out of memory but had reached 175m

8:17 PM
@JonathanAllan The exact opposite of "was busy coding, cookies burned" xD

Could you extend the search by removing squares that are no longer reachable? Keeping a set of only those which might be visited in future?
It sounds like it'll still run out of memory eventually but hopefully will go for longer

@trichoplax almost certainly, it's pretty naive code (see the tiny url to TIO of code ^)
tinyurl.com/y9omfeve

@JonathanAllan ouch...
time to rent an EC2 :P
@trichoplax @JonathanAllan how do you define "no longer reachable" though?

visited + islands I guess (although I don't think there are any islands yet, but if there are it would prove the path is not a permutation of the natural numbers!)
mind you the data structure to store the pruned space might end up being quite memory hungry itself

8:32 PM
islands like patches of unvisited squares with a thick enough border so that the Wildebeest can't jump in?

yeah
but look at what I said about when 1 million is reached - all the unvisited squares are pretty near the outside
(although not amazingly near...)

well... yeah, although tri's suggestion is actually removing the ones that are "no longer reachable"
having a set of visited squares is kind of necessary...

visited squares are also "unreachable" right?

not always
a visited square might be the one Wildebeest was on at the previous step

she doen't revisit squares, so once visited they become "unreachable"
she could get there by move rules, but not by "wildebeest path rules"

8:37 PM
yeah, but if you don't keep a reference to them she will actually start visiting them... that would be a guaranteed 1 → 10 → 1 → 10 → ...
as I read it, tri is suggesting that you remove ones that are "no longer reachable" from the set of visited squares to save memory

if we remove squares that are unreachable by that metric then we remove no squares and save no memory :/
but if we remove ones she may not revisit, and if the code only allows her to move to existing or outwardly extended space then we remove loads.

well... maybe we can remove squares that have been "islanded", but, while that might free some memory, it will definitely not be nice regarding the time...

agreed. What we really want is a formula :p

inventive mode on... turns off after 0.1s

LOL
at least my curry is delicious

8:46 PM
bon appetit! :P

9:07 PM
reached 150099999 squares. 150 millionth square visited was 150276947. While the final 10 I found were [148644237, 148693005, 148644231, 148692999, 148741775, 148790559, 148644221, 148692989, 148644216, 148692984].
...also verified that all 150099999 visited square are unique.

then it ran out of memory?
150099999 doesn't sound very promising... :P

no I had a break point

Interesting coincidence then

@JonathanAllan ah the every 100k breakpoint? :P
probably not a coincidence, his tester stops every 100k steps

every 100k (mod == 0) was printing and then if > 150m I broke

9:12 PM
well... the numbers are only ~1.3m off so far as it seems... :P

huh?
oh
she was visiting smaller numbers at the end, yes

wait how would all 150099999 squares be unique then

because she has also visited higher numbers
the results are in res and len(res) is 150099999 and len(set(res)) is also 150099999
max(res) is 151015140
smallest as yet unvisited is 148145652

9:48 PM
If (1, 0) is not visited after 1 million terms isn't that awfully suspicious (that not all cells are visited)?

@feersum (1,0) there means layer 1 has zero unvisited squares (i.e. square 1 has been visited)

I see

(2,0),...,(494,0) means all the squares of the inner 494 layers have been visited
...and when we complete 150.1m we find all those unvisited at 1m were, indeed, visited at some point (probably fairly quickly)
I feel like there's probably a really simple geometrical argument that proves she never gets trapped (and maybe one that proves she leaves no square unvisited)

OTOH, maybe there's no clean proof and not getting trapped is only caused by high mobility.

yep, and maybe she eventually does

9:59 PM
Okay, made a C++ implementation of this... it keeps going and going. For example Step 381681664: Position 382822186
Step 776994816: 775033811
Step 1429209088: 1426568391
What's the highest any of you have got to so far?

@Deadcode Nice, can you first confirm step 150m is 150276947?

I'll have to restart it... I'm only printing every 1048576th
I'll run a second instance

being C++ it's probably fast! Are you pruning the space as you go?

Step 150000000: 150276947

nice

10:04 PM
Nope, not even pruning
Just using 8 GB

yeah Python lists are heavy :(
and indeed each int is an object

Bit or byte vectors?

One bit per position
Here's the coordinate-to-position function I came up with. Did you come up with a simpler one?
int64 coordToPos(int64 x, int64 y)
{
int64 m = max(abs(x), abs(y));
int64 a = 2*m-1;
return a*a + (-y == m && x <= -y ? 3*m + 2*a + 1 + x
: x == m ? m + y - 1
: 4*m - 1 - x - y);
}
ah, indentation was removed

I wouldn't think you need to use the position numbers at all for the actual simulation.

10:06 PM
click "fixed font" button

Of course you do. You need the smallest
You need to go to the smallest position-index at each step. So how can you do it without this?

^ yep that :)

Instead, you could compare by ring and then break ties by using knowledge of which quadrants have the smaller numbers.

@JonathanAllan Woah, i've somehow never seen that button before until now

Maybe I should restart this with a 21 GB array... looks like it's going to be going for a while

10:08 PM
def f(x):
print("test")
how have I never figured this out before

I don't know the button but I do know Ctrl+K

Ctrl+K
also works in rooms?

Step 8630829056: 8599687906
Restarted it with a 21 GB array

8.6b :o
doesn't prove she will go forever but she goes far!

def f(x):
print("wait I knew Ctrl+K before but for some reason thought it did something different")

10:20 PM
Alrighty, reached the point I was at before.
Holy shit
Step 12899581952: 12878593430
Trapped!
the trapped position could be up to 1048575 after that

in that version I didn't print it
I'll make it save the array to disk this time

this is awesome!

and print the trapped final position
YES IT IS

10:35 PM
inb4 "oops, I printed the wrong position." waits another 5 minutes repeat

Heck, I'm happy that my implementation of handling being trapped worked

10:54 PM
Trapped at step 12899744968 at position 12851850257!

@Deadcode Nice - I'll add this info to the post and the proposed OEIS entry! (if the entry at OEIS gets created it may be worth sharing your code... would you place it in a TIO?)

I'll put it on github

cool, thanks

The bits are in little endian. Position 1 is little endian bit 0 of byte 0.
The 1,618,769,739 byte file compressed to 404,052 bytes.
(That file is the boolean map of visited positions.)

11:19 PM
Now that we've found this, we open the question: what's the relationship between the pattern of possible moves of an arbitrary leaper and its time to get trapped?

11:30 PM

@Pavel Yes.
Davidebyzero = my alternate nick.
So what should a solution to the PPCG challenge return for steps > 12899744968? 12851850257 for all values there onward? And do the submitted solutions do that? :)
(Assuming enough memory and time for them to get there)

@Deadcode I had already stated that if there was a trapping position the code behaviour afterward could be undefined

Ah yes, I see that.
@JonathanAllan Please edit it. My first comment was off-by-1.
I since then deleted the comment and made a new one

11:45 PM
K

It's position 12851850258

ah just the square number?

And here I quoted my own mistake above :(
Yes, the step number is correct
Because that's actually 1-indexed in my code.
But I zero-indexed the position and did +1 every time printing it.
And forgot for the Trapped case.
(The github code already has that fixed.)

thanks!

Welcome :)
I'm almost finished with a verification run now.
Oops, made my array too small in the github-committed version, somehow.
Oh
I had maxVisitedPos but what I actually wanted was maxExaminedPos
My result is correct because I was using a much larger array size than necessary
but I shrunk it for the commit
with no safety margin, because I got cocky

11:53 PM
you can always fix up the git hub code with another commit

I'm on it
Pushed a fix, and am currently testing it
oops, disregard that commit
There, pushed a fix that is probably correct. Now testing it.

I've replicated the result of stopping after the 12899744968th step.

@feersum Awesome. In what language?

My code or yours?

11:59 PM
Mine.

Awesome.