« first day (4331 days earlier)      last day (505 days later) » 

12:01 AM
0
Q: CGAC2022 Day 8: Fen The Wicked, Part 2

BubblerPart of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One of his inventions is the Wick spell. He likes this magic so much that he's cast it on every sing...

 
12:45 AM
@DLosc just scroll down to the bottom of p171 of my answers and look at the tags, I assume that's the one
 
1
A: "Creative" ways to determine if an array is sorted

NeilJavaScript var isSorted = function(array) { return "" + array == array.sort(function(a, b) { return a - b; }); }

 
 
2 hours later…
2:36 AM
look who i found while browsing hnq
 
Who VTC'd this? It has a clear OWC.
(I haven't read it in depth so it's possible (and given its age and nature, likely) that it could get count as unclear instead, but I'm not really a fan of unburying and closing old stuff that never would've been answered and never will be improved)
 
3:13 AM
@RadvylfPrograms not really - how do I tell if an answer is fully golfed at first glance? Sure, there's indicators like redundant whitespace, but there could be more subtle language things that means an answer that looks golfed may not be the shortest possible
 
Oh I didn't see that rule
I'd still go with unclear instead of no OWC but yeah
 
^
it doesn't look like the challenge itself says an answer has to be fully golfed (while the meta post does?) but there's some very confusing verbiage later on anyways
 
> Your code must be as short as possible for your programming language.
 
oh, for answers themselves
yeah no owc
could be hypothetically salvaged into a cnr but that would just be fucking stupid
and in any case it seems like the challenge itself is just maximum of minima with extra requirements on the i/o
 
 
2 hours later…
4:52 AM
0
Q: Highest(non-mate) evaluation that Stockfish can get?

NRONot sure if this should be moved to chess. What's the highest evaluation(Black or White) that Stockfish will generate? Example: Parameters: Any version of Stockfish allowed. All depth must be above 25. This is `code-golf`, so position with the least material total(excluding kings)...

 
All knooks for white
 
5:07 AM
@NewPosts This actually looks on-topic to me
There's a measurable winning criterion, and it can be solved with code using e.g. stockfish package for python
also chess has a huge number of possible game states, so how to narrow it down for the task is a nontrivial challenge
 
5:59 AM
^
question might need some work but there's nothing fundamentally un-cgcc there
 
 
4 hours later…
10:00 AM
0
A: Sandbox for Proposed Challenges

NoahTurn two dice into one die A neat trick is if you ever need a nine-sided die, it is possible to make one using two six-sided dice using the numbers below. This is assuming you either have a way to rewrite the faces on the dice, or use some algorithm to map the numbers on a normal die onto these n...

 
10:50 AM
0
A: Sandbox for Proposed Challenges

NeilHow much STAB do I get? With the new Terastal mechanic in Pokémon Scarlet and Violet, moves can now get a variety of Same Type Attack Bonuses. This bonus, known as STAB for short, varies depending on the type of the move and the Pokémon's type(s) (Pokémon can have multiple types) and Tera type, b...

 
 
1 hour later…
12:04 PM
@Ginger howdy
 
gah, why you gotta jumpscare me like that lyxal
I had my volume at max and opened my browser in the background
 
worth it
 
:|
 
I saw you joined the room and wanted to ninja your greeting :p
which I did
 
fool, I wasn't intending on sending a greeting today
I was just going to implant it directly into everyone's minds
 
12:07 PM
in which case you'd already won
 
exactly, I'm playing 5D Greek God Family Tree with Multiverse Time Travel while all of yall chumps are trying to sort out who your father-in-law is
 
But I don't want to play family trees. I want to play Chess 2.0
 
12:22 PM
Does 4d chess with multiverse time travel have knooks?
 
I don't think so
 
12:55 PM
0
Q: Santa's Shortest Path Problem

JvdVSanta's Shortest Path Problem Trying to be as time-efficient as possible Santa needs to plan his trips carefully. Given a 5X5 grid representing a map of villages it is your task to be Santa's flight controller. Show santa the shortest and therefor fastest route to fly his sleigh and give him a li...

 
 
1 hour later…
2:10 PM
The path may be the shortest, but the time taken to find that path sure ain't the shortest!
If Santa were to use my answer for calculations, he'd probably need to start running it a few years ago to even have a hope of finding more complex paths I reckon :p
 
is there a way to define an object in JavaScript that has a getter for any arbitrary property? like I want a _ such that _.anything always exists and returns something based on a function of what that anything is (should be the same as overriding _[x] to a function call)
 
isn't that proxies or whatever
try to find that one cursed snippet from a few days ago :P
 
@hyper-neutrino Proxy
 
Nov 26 at 4:30, by Radvylf Programs
They're sorta like wildcard getters/setters
 
oh
yeah I heard about those just earlier this week funnily enough
i'll look at that thanks
> [3, 11, 24].sort()
[ 11, 24, 3 ]
what
JS sorts numbers lexicographically or smth?
 
2:20 PM
yep
converts to string
 
jesus christ this language xD
 
@hyper-neutrino Use .sort((a,b)=>a-b) to sort normally
 
ye ik I'm just confused why the default behavior of sort is even like this lmao
 
They must have passed the balmer peak
 
@hyper-neutrino [] is one
(And unlike most semi-malformed regexes, it doesn't just match the literal string [])
 
2:31 PM
@RadvylfPrograms In most regex variants a []] matches a literal ] and [] is invalid
 
Well not JS ones
 
 
2 hours later…
4:32 PM
0
A: Sandbox for Proposed Challenges

Radvylf ProgramsKotH: Don't Kill the Curve! In this KotH, you will take a test at school. Your goal, of course, is to get the highest grade, up to a maximum of 110%. This score consists of your actual grade, curved, as well as 10% which is the average of other students' scores, since your teacher wants to encour...

 
^ A bit of an odd KotH backstory-wise but I think it would be interesting
 
4:52 PM
@hyper-neutrino JS is cursed
fb?
 
5:29 PM
Fun fact: is a single Unicode character
 
Yup, so why doesn't that work in JS?
@mousetail Or .sort((ᅟ,ᅠ)=>ᅟ-ᅠ) if you want it to look cooler.
 
those are valid identifiers?
 
ofc
 
Well I mean not "ofc" there's a large number of characters that aren't
 
Every PCRE \pL character is.
 
5:39 PM
And this is seems to be a filler/whitespace character in the language it's from so it'd be reasonable to assume it's counted as that
 
Yeah, Korean letters are composed of two or three parts, so there are fillers for when slots are otherwise not used.
 
0
Q: Find the representative submatrix

Jordan Note: This is a more limited version of a challenge from 2014 that only received one answer. That challenge required participants write two programs; this challenge is essentially one half of that. The text here is original, but credit for the idea goes to Matthew Butterick, who is no longer act...

 
@Adám You could define your own sort function so you can do [].((,)=>-)
 
Not sure what you're trying to say.
 
That you could make [].ᅟ a custom method that does the same thing as sort, making it look even 'cool'er
 
5:58 PM
CMC Write a Fibonacci program using the least number of visible characters. Invisible characters are unlimited.
 
@RadvylfPrograms Nah, define Array.prototype.ᅟ=function(){return this.sort((a,b)=>a-b)} so [3,141,59].ᅟ() gives [3,59,141]
@mousetail Whitespace, 0:
 
They must be not have any width as well
 
Or wait, spaces, tabs, and newlines count as one each?
 
süs
 
@mousetail Or hight, I presume.
 
6:01 PM
Exactly, no newlines allowed. \r is fine since it would do nothing if you are in the left column anyway
 
Well I mean in what application
In terminals yes but in most places they're treated like newlines
 
Hmmm I think a terminal is a standard way to run code so consider a terminal environment
 
Fun fact: Although Unicode did designate a newline to rule them all, everybody merrily keeps using carriage returns and/or line feeds.
 
Nobody wants to use a two byte newline that comes from EBCDIC that nobody else supports in the first place
 
Actually having a "line feed" that just moves the cursor down one without moving it left is actually really useful sometimes
Like Telnet has
 
6:04 PM
Vertical tab
\v
 
TIL
 
@mousetail Dyalog APL uses LF to do that.
 
Yea telnet is the same. It used to be like that everywhere I think, then linux came and ruined it
Unpopular opinion: windows style line endings are better
 
 
6:07 PM
@RadvylfPrograms i considered that useless and stole it as a number digit in one of my compression schemes :P
 
@mousetail Well, they are certainly more correct.
 
@Adám ouch, does it use crlf
 
No, strangely, it treats CR as CRLF.
 
@mousetail I mean, we have \v for the old \n behavior. Makes way more sense to use \n as a CRLF IMO.
 
So really, it uses the convention of old MacOS.
 
6:08 PM
@Adám AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
@RadvylfPrograms Vertical tab is a really confusing term though, you'd expect it to do something similar to a tab
 
Yeah, CR should be "home".
 
@mousetail If you think about it, it does. "Tab" stands for "tabulator," used for formatting data in tables. Horizontal tab goes to the next column of the table; vertical tab goes to the next row of the table.
 
Always fun when BS does what it says:
 
There are so many odd codes in low value ASCII that haven't had any use for 30 years. Like WTF is Synchronous Idle
 
6:10 PM
 
I find it kinda funny that for probably the rest of time we'll be stuck with typewriter commands for this stuff
 
What's the last time someone used \x1D as a group seperator?
 
IIRC it's still used internally for some stuff by UNIX/Linux right?
 
Used or used specifically as a group seperator?
 
@mousetail ah yes, device control 3 and shift in
i use em as digits for numbers in base 29
 
6:13 PM
@Seggan In SBCS though right? So it's the byte values but not actually those characters?
 
@mousetail ? did you reply to the wrong one
 
Probably
 
yeah its byte values. i.e. SOH is 0, STX is 1, DEL is the last digit
at least i think its base 29 i use
i just scrape a bunch of control codes together
 
Well yeah but what mousetail's saying is you're not actually using SOH, GS, DC3, etc., you're using their byte values
It doesn't really make sense to say you're "using DC3 as a digit" since you're kinda repuposing its slot entirely
 
6:20 PM
Basically I'm asking, has there been anyone who used the low ascii values for their intended purpose in the last 20 years? Excluding \n\t\v\b\r\0
 
FF and Esc are used.
I've used BL.
 
Wikipedia doesn't even list the intended purpose of FF
 
To feed a whole page
In a terminal it clears the screen, for example (^L)
 
Oh makes sense, yea I'd consider that intended use
 
@RadvylfPrograms No, the rest of the page. It is simply a hard page break. I believe Word uses if for that.
 
6:25 PM
XOFF and XON continue to (annoyingly) exist
Ctrl+S and Ctrl+Q
Used by remote desktop tech scammers if that counts
 
Are there still devices that turn something on or off in response to these?
 
Yes, terminals
If you hit ctrl+s in most terminals they'll stop sending stuff
Then when you hit ctrl+q it all sends at once
 
Oh that seems useful
can use use it in SSH to prevent lag while typing?
 
Probably, idk
I'm almost certain there're obscure CSV/TSV-style formats that use US/RS/FS/GS
 
That's their intended purpose, yes.
 
6:30 PM
Makes a lot of sense actually, since it allows pretty much all reasonable characters to appear in records without need for escaping
 
Dyalog's ⎕CSV can parse those.
 
Although I will always be a length-prefixing fan
 
How long do you prefix the length though?
 
No escaping, supports any type of data, nice and compact
 
6:31 PM
Oof, that's horrible for humans.
 
@mousetail Break the length into 7-bit chunks. Prefix all but the last with a 1-bit.
 
UTF-8 style.
 
ish
@RadvylfPrograms So 0 bytes is 0x00, 12 bytes is 0x0c, 127 bytes is 0x7f, 128 is 0x81 0x00 (or 0x80 0x00 if you want maximum density), etc.
 
Makes sense, a bit slow to parse though but if it's for transfer that's acceptable
 
@mousetail Alternatively just use 32 or 48 bits
Probably unlikely that more than a terabyte will need to be encoded
 
6:33 PM
Rust uses 64 which is a lot
 
But the 1-bit-prefixing is more elegant
@mousetail for what
 
length of arrays and strings
 
I'd imagine it'd use usize
 
yes, usize is 64 bits
 
No, it is machine-dependent
 
6:33 PM
on most platforms
Still on a typical desktop PC most a third of a strings storage will be taken by it's length
given most strings are short
 
No longer than null termination typically
If you use the 1-bit thing
Unless it's long enough than an extra byte wouldn't really matter in the first place
 
The one bit thing good for transfer over internet or long term storage when parse speed isn't the bottleneck
 
Encoding/decoding speed is absolutely negligible
 
Indeed, if you do it just once to convert to a faster format
If you keep it like that in memory and need to read it every access it adds up
branches are very slow and prevent the CPU from optimizing much
 
What no I'm not talking about storing it like that in memory
You'd just keep the length as a usize or whatever
Same way as any other string/array type
This is for transmission and storage, like where you'd use a unit separator or whatever
 
6:39 PM
Ok yea it makes sense in that case
At leat better than HTTP which transfers the length in decimal for some reason
 
The time it takes to decode a couple of bytes with bit prefixes is probably in the like, nanoseconds
 
Agreed
 
7:03 PM
How can I compute exactly the integer closest to 2^x/x when x is approx 1000 in python?
 
>>> 2 ** x // x
173132120514199248386775108518728497674931523027450321739234776756014118556518278411524282431127819916790050503759277688203808563715807428898591044362782494662390491541144181918282925374104426813144380000390052708215982766987240047030935179499533134903682922179897738535452152230568637035444553910896110
>>> 2 ** x % x
844
It's 173132120514199248386775108518728497674931523027450321739234776756014118556518278411524282431127819916790050503759277688203808563715807428898591044362782494662390491541144181918282925374104426813144380000390052708215982766987240047030935179499533134903682922179897738535452152230568637035444553910896111 for 1014, for example
You literally just type it in, see what the remainder is, and see if you should round up (add 1) or down (do nothing)
 
It's the mysterious integer division is again!
How does python implement that?
 
you can also do (2 ** x + x // 2) // x i believe
 
@graffe ...the what now
 
wait no you can't I am dumb
 
7:06 PM
@RadvylfPrograms python has a way to divide large integers exactly
 
@graffe Probably something similar to the grade school long divison algorithm
@graffe "Exactly" as in to a float, or "exactly" as in perfectly accurate floored int division
 
@RadvylfPrograms it does it exactly
 
which exactly
 
The second
 
Ah
Well yeah, so does long division
Python 3 uses bigints
 
7:10 PM
So . If I multiply a large integer by a float (say, pi) how can I get floor of the correct answer exactly?
 
You'd need to use fixed point
 
you probably want to use sympy or something similar in that case
 
@hyper-neutrino :(
I was hoping school multiplication would help
 
Well you could use that with fixed point
It's annoying but you can do it
 
@RadvylfPrograms sounds like a cgcc challenge :)
 
7:16 PM
you'd have to watch out for "do X without Y" but it could be
 
Oh wait. In python I just multiply the float by 10**10 (or something) and then multiply integers don't I ?
 
The result of multiplying will still be a float, so you'll have to truncate it to integer
Because this is binary floating point, I think your best bet is to multiply by a power of 2 (someone correct me if I'm wrong)
Yeah. Multiplying by a power of 10 can lose some precision, while multiplying by a power of 2 doesn't.
 
@DLosc very interesting
 
7:31 PM
 
I wish python had quad precision as an option
is it possible to predict when you get False? tio.run/…
 
Yes
But not very elegantly
 
7:47 PM
@graffe If you don't care about accuracy, it's easy: random.choice([True, False]) :P
 
@cairdcoinheringaahing Why not True?
that's more accurate
 
You asked about predicting False
 
yes...Never is not a terrible answer
and is more accurate than random.choice([True, False])
 
8:25 PM
well, caird did say if you don't care about accuracy
 
:)
 
it's even more accurate than False :D
 
 
1 hour later…
9:55 PM
is it?
 
 
2 hours later…
11:26 PM
Technically, no, I guess? False correctly identifies every False in the list, whereas random.choice can miss a False
So, if you only care about identifying the Falses correctly, False is the best option. If you care about identifying each element, random choice is better, so long as more than half the list is True
 

« first day (4331 days earlier)      last day (505 days later) »