11:43 AM
room topic changed to Jelly Hypertraining: Practice your Jelly :) To be a student, request access. [class] [code-golf] [jelly] [practice]
Currently I've given him 3 challenges (I know it's many):
2. reduce square root
3. Given e.g. 4, output:
1  2  3  4
8  7  6  5
9 10 11 12
16 15 14 13
@LeakyNun How can you reduce a monadic function?
@EriktheOutgolfer you took it too technically
I mean "simplify a square root".
11:59 AM
Oh, so, for example, for input 8 you print 2 2 or something?
yes, that is what I mean
Basically I think that the title of the challenge is "Simplify a square root", and a very important keyword is in the title itself :)
@LeakyNun And the third one is to output a square snake of a number, right?
Yes.
Good. As a teacher, I will be preparing/copying golfed solutions now
user165474
Yay :) Thanks for making this room
12:13 PM
@HyperNeutrino yay you're back
user165474
Yes. I'd gone to bed when you pinged me.
user165474
Is the other challenge you said you had item 3 on the current list?
Yes
user165474
I see.
user165474
I kept working on item 1 for a while last night and then eventually the code just stopped making sense because I couldn't understand what the code I wrote before it meant :/
12:15 PM
I see.
user165474
For item 2, I figured out how to get b, but I just need to get a by taking [argument]/(b**2)
user165474
12:26 PM
Is there a built-in to iteratively take each element of an array until a certain condition is reached? (That is, if we make the condition x -> x != 0, it should give [1, 2, 3, 0, 4, 5, 6] -> [1, 2, 3])
user165474
Wait, jelly's i for array indices is 1-indexed?
@HyperNeutrino yes it is
Everything in Jelly is 1-indexed.
user165474
Ohh...that would explain why my code was broken yesterday. Wow. :P
@HyperNeutrino TḢ’ḣ@ is the best I can do (beware the unterminated dyad)
user165474
12:31 PM
Okay. Thanks.
I think that's the best possible.
user165474
Alright. I found an alternate way for my specific use for it which is a bit longer but doesn't require the extra helper link, but thanks.
I'm having a hard time doing 2 lol
user165474
lol
user165474
I figured out how to get the part under the new square root
user165474
12:39 PM
but every attempt at getting the other one gives me weird things which make no sense at all
user165474
For 1, is truthy/falsy fine as opposed to True/False?
my current solution for 2 has 12 bytes.
@HyperNeutrino sure
@LeakyNun Well, I have a hard time doing 1.
@EriktheOutgolfer let me try
Nah, concentrate on your 2 ;)
12:44 PM
@EriktheOutgolfer nah I'll do 1
user165474
I got a solution
user165474
For 1
that's ... long (but I haven't tried it so I can't comment)
user165474
user165474
Yes, I agree.
user165474
12:45 PM
But <shrug>
user165474
Should I golf it or start on 2 to keep learning new stuff?
why is it in a spoiler? who are you keeping that secret to?
For newcoming students I guess?
You know, students can come at any time.
user165474
Also in case Erik's trying I don't want to openly post the code
user165474
But yes, also for new students
12:46 PM
@EriktheOutgolfer not if you set this chatroom as private
This is a gallery not private. There is a request access button.
alright
@HyperNeutrino You should never use TIO v2 for production.
user165474
Oh right.
user165474
@EriktheOutgolfer Nexus then?
12:49 PM
Yes, there isn't any other TIO.
user165474
Did v1 get taken down?
Yes.
TIO Nexus link: Try it online!
user165474
Okay.
user165474
Thanks.
For the record, my code for 1 is 14 bytes
user165474
12:50 PM
Nice.
@HyperNeutrino so I guess you should golf it to keep learning new stuff
user165474
Yeah.
user165474
I'll share my method first I guess, and along the way I might see (code-length) optimizations.
I can read.
I know what your method is.
user165474
Alright. Yeah.
user165474
12:53 PM
I'll write out an explanation of my own code for myself to read and see if I see anything that can be shortened.
@EriktheOutgolfer have you tried 1/2?
I'm trying 1 right now, and I think I've found a better method than Hyper's.
user165474
@LeakyNun does this explanation look correct? I think this is how my code works:
user165474
ṚḌ+                Helper Link; adds a number to the number itself backwards
+                Addition
ṚḌ                 Reverses integer into decimal and undecimals

Ç6Ð¡µọ11TḢ’ḣ@ÆPÐfȦ Main Link
Ç6Ð¡               Calls the last link on the input 6 times, collecting all intermediate results
µ              Starts new monadic chain
TḢ’ḣ@      Takes all elements up until the condition is first satisfied
ọ11           Checking for divisiblity by 11
ÆPÐf  Filters to only keep primes
@EriktheOutgolfer but have you outgolfed me?
1:01 PM
Well, not, but I think I've tied you, if my code is valid ofc.
@EriktheOutgolfer have you tried your code then
Still implementing it.
@HyperNeutrino yes it is correct
@EriktheOutgolfer do you need a template?
user165474
Okay, thanks.
@LeakyNun No. I think I've outgolfed you.
1:03 PM
@EriktheOutgolfer congratulations
Running test cases now to confirm.
user165474
Does your code start with:
user165474
ṚḌ+
Ç6Ð¡
no it doesn't
user165474
Alright. Is there a better method to that too?
1:04 PM
Yes there is
My code does but it's a one-liner, although that doesn't save any bytes.
user165474
Okay. So wait, does the better method completely change the way the code works or does it just have a shorter way to get the first 6 iterations?
Mine completely changes the way it works.
mine changes partially the way it works.
@LeakyNun Testcases seem correct, although I think there would be an issue when hitting more than 1 prime in the first 6 iterations.
1:07 PM
@EriktheOutgolfer truthy is truthy
and I was stupid, I'm at 11 bytes now.
@EriktheOutgolfer have you out-golfed me?
user165474
Oh, I think I found an optimization.
Mine was 11 bytes too.
@HyperNeutrino congratulations
I don't think it can get shorter than that.
@EriktheOutgolfer my md5 hash is 1f938eb9edd736e6cebd4e0cef09e8c9. yours?
1:09 PM
050c7e6ee8c8923aa811c294bc90e1c2
Maybe similar algorithm?
oh, lol
user165474
Once it's hit a multiple of 11, it will always be a multiple of 11.
user165474
(I think)
Yes
because a reverse of a multiple of 11 must also be a multiple of 11
(corollary of the divisibility algorithm for 11)
user165474
Right.
user165474
1:10 PM
Yes.
user165474
Alright. That makes sense. Might be able to use that for something.
user165474
Wait, I just realized that prime numbers can't be multiples of 11 (excluding 11 I mean)
user165474
lol that was obvious >_>
YEAH!!!11
OK golfing 2 now.
user165474
haha >_>
1:12 PM
@EriktheOutgolfer that's fast
@LeakyNun May I link a spoiler?
Alright
user165474
Alright. Won't click :)
Me neither
but I don't really see a way to optimize any part of my code
1:14 PM
Mine either.
I'd say golfing 3 instead of 2.
Do you mean that your answer is now 8 bytes?
What?
...
user165474
I think he means golfing the snake-matrix problem.
user165474
(item 3)
1:17 PM
@EriktheOutgolfer I completely misinterpreted this
I thought you golfed 2 bytes
@EriktheOutgolfer what does this contain?
I won't spoil it here ;)
I mean, which item
the 11-byte solution?
1:18 PM
lol, I can click it then
NO! You will be a quitter then!
lol, our solutions are the same
almost the same
OK now you can put your spoiler.
we just differ on the first 4 bytes
spoiler for item 1 (added 3 bytes to verify all test cases at once)
user165474
Do you have a hint that might help me shorten it a bit?
1:21 PM
@HyperNeutrino hint: you don't need to care about 11 at all
user165474
Oh really. Hm. I'm thinking of this the wrong way then. Thanks, I'll rethink the algorithm.
user165474
Wait I can just completely delete part of my program xD
user165474
14 bytes:
the last part can be golfed.
@HyperNeutrino Please remove and repost (don't edit) this as a spoiler link :)
user165474
1:23 PM
Okay. :)
user165474
user165474
And I'll work on the last part.
user165474
I'll give you a hint: 2 is also truthy
user165474
Hm.
user165474
1:26 PM
Oh...
user165474
Well I don't seem to need the link separator at least, so 12 bytes
good, one byte to go
user165474
Yep :)
user165474
Is empty falsy or invalid?
falsey
1:28 PM
[] is falsy.
user165474
@HyperNeutrino that would work
user165474
Yay
Congratulations!
you can click our spoilers then
user165474
1:36 PM
Yay :)
@LeakyNun Does 3 need to have formatted output?
@EriktheOutgolfer yes it does
Then I have a looong 11-byte solution ready. How much do you have?
@EriktheOutgolfer the official answer is 9 bytes, and I cannot golf it down any further
Got to work!
user165474
1:49 PM
Can you explain what \$ does? I don't fully understand it.
@HyperNeutrino combines the two links before it to form a single monad
e.g. ḅ10\$ is equivalent to
user165474
Oh. Hm. But in your program, it looks you only have 1 link, or am I reading it incorrectly?
where?
user165474
+ṚḌ\$\$
ṚḌ\$ is one monad
user165474
1:52 PM
Or ṚḌ\$+\$
user165474
Oh? Hm.
That's from my solution, right?
user165474
Okay, but what's wrong with just ṚḌ?
ṚḌ is two links, not one.
user165474
Yes. The two are very similar but you have the plus sign in different places :P
user165474
1:53 PM
Okay. I think I might not understand what a link is then.
a + b is a commutative math operation.
user165474
Yes.
@HyperNeutrino a monad is a link
a dyad is also a link
user165474
Oh. I thought a link was like a line in the code or something like that.
The docs are a bit confusing about that.
1:55 PM
I agree.
user165474
Alright.
user165474
That makes some sense now.
user165474
Oh, that would make a few of my coding attempts easier.
user165474
That gives a fourth 11-byte answer which is pretty much identical to my first solution except using the same first 5 bytes as Leaky Nun
user165474
(Or a fifth using Erik's method but I won't bother)
2:00 PM
Or a sixth using your multi-line method but with S instead of T at the end.
user165474
So there are 3 methods for the start and 2 for the end, giving 6 total solutions that are pretty much identical?
user165474
17 bytes for item 2 This is horribly long. My first successful attempt.
@LeakyNun Damn item 3 is so difficult to golf to 9.
@EriktheOutgolfer I agree
The lowest I've been to is 12. Horrible.
2:14 PM
not very horrible really
What challenge has the 9-byte solution? (spoiler link again)
The challenge I linked to you on TNB
user165474
How short can item 2 be?
@HyperNeutrino my solution is 12 bytes
user165474
Alright. I'll try to get down close to that.
2:17 PM
@LeakyNun That's a CnR.
Anyways I'll look into it.
Wow that's... clever.
user165474
@LeakyNun In your code for item 2, are you using ÆF?
yes
user165474
Alright.
user165474
So I'm not sure about the Ḣ*HḢḞ helper link; is that a good idea, or is it longer than necessary?
don't know what it does
user165474
2:22 PM
[x, y] -> x ** (y / 2) (integer division) (monadic)
oh I didn't use ÆF
I used Æf
user165474
Oh.
user165474
I see.
user165474
That might help shorten it. I'll see if I can change my algorithm to use the pure prime factorization instead.
user165474
Do you use ċ anywhere?
2:29 PM
not really
user165474
Hm? What do you mean by not really?
I didn't use that anywhere.
user165474
Okay.
user165474
I'm trying to use it but it doesn't seem to be working the way I want it to.
user165474
Darn, I can't figure out where to go using the Æf atom. Can you give me a hint?
2:42 PM
œ^/
user165474
Multiset symmetric difference?
user165474
Hm.
user165474
Can you explain that?
user165474
Also, can I add an answer to the reverse and add degeneracy problem, or will you because you got it first?
@HyperNeutrino I won't add
user165474
2:45 PM
Alright.
@HyperNeutrino well, it removes pairs
user165474
@EriktheOutgolfer Will you add your Jelly answer to the degeneracy problem?
Yeah.
user165474
Hm. I'll play around with it on TIO and see if I can figure it out.
user165474
Alright.
2:46 PM
@EriktheOutgolfer can you explain how œ^/ works?
user165474
I'm pretty sure ours are too similar so I won't add my own.
Yeah they are.
@LeakyNun It means "reduce by multiset symmetric difference".
@EriktheOutgolfer please explain to @HyperNeutrino how it works
I'm not really sure how his code works...
user165474
After playing around with it, I think it does something along the lines of "for every element, if it's not in the list, add it to the list, otherwise, remove it from the list"
2:49 PM
...anyways I'll explain.
user165474
Alright. Thanks.
user165474
Oh well sorry, I have to go now. I'll load back to here later and read the explanation. Thanks! :D
Let's say you have the list [[1, 2], [1, 3], [3, 4]].
Since we are reducing, we first examine the first two elements, [1, 2] and [1, 3].
Since 1 is contained in both sets, we remove it, so we get back [2, 3].
Then, we take the result and the next element and do the same (2,3œ^3,4).
Since 3 is contained in both sets, we again remove it.
The final result is [2, 4].
@EriktheOutgolfer what's the significance of that?
I am explaining how œ^/ works here.

1 hour later…
user165474
4:14 PM
@EriktheOutgolfer Ohhh That makes a lot of sense now. Thanks! :)
user165474
4:46 PM
@LeakyNun I've figured out this much: 10 bytes, which gives the part under the square root. I can't seem to figure out how to get the other value concatenated properly in 2 bytes.
4:59 PM
@HyperNeutrino use µ instead
user165474
@LeakyNun You mean in place of the start_dyadic_link?
yes
well no
@HyperNeutrino your method should work
but if you had used the proper square root, you would need one more byte
(Æ½)
user165474
Using µ causes it to behave weirdly.
well you would need to change the logic as well
monadic chains and dyadic chains are drastically different
user165474
Yeah
user165474
5:02 PM
Oh okay.
user165474
Whoops, I have to go now (class). Thanks, I'll ping you if I figure it out. TTYL!
I'll post a spoiler here.

2 hours later…
user165474
7:26 PM
@LeakyNun I got this which does the same thing as before for the same number of bytes, and it uses a monadic chain instead of a dyadic chain.
user165474
9:19 PM
@LeakyNun Figured it out!
user165474
It does k -> [a, b] where a**2 * b == k for maximum a.
user165474
Our solutions turned out almost identical, except the last byte. :P
user165474
@LeakyNun Can you quickly just scan over this to make sure I understand the code correctly? Thanks!