« first day (2611 days earlier)      last day (2248 days later) » 

12:26 AM
@ASCII-only pls see above code snipet for VSL
 
@Downgoat former
 
1:17 AM
CMC: Solve 8x≡-3 (mod p), 0<x<p, where p is a prime greater than 5
f(5)=4
f(7)=4
f(11)=1
f(13)=11
f(17)=6
f(19)=2
f(23)=14
f(29)=25
testcases generated by
for p in [5,7,11,13,17,19,23,29]:
	x = f(p)
	print("f(%d)=%d"%(p,x))
	assert(0<x<p)
	assert(8*x%p == -3%p)
where f is the function I wrote
 
@LeakyNun without bruteforcing? :P
 
@ASCII-only I wonder if brute-force would be shorter than my answer
 
1:36 AM
@ASCII-only are you in?
 
i have JS: f=(n,i=n)=>8*i%n-n+3?f(n,i-1):i
:/ it does look very ungolfy though
i'm probably missing something completely (or kinda) obvious
seems like it might be possible to use the euclidean algorithm?
 
@ASCII-only to be fair it is uber-golfy compare to VSL
 
2:14 AM
okay so you should be able to use the extended euclidean algorithm but i'm too lazy
 
So, 8 = 2³.
And 1/2 = (p+1)/2 (mod p)
So, 8x=-3 <-> x=-3*½³ <-> x=-3*((p+1)/2)³ (mod p)
JS p=>(((p+1)/2)**3*-3)%p probably?
 
ah
+p at the end too
 
... because it's JS. (truncated modulo)
and x!=0.
 
n=>-3*(-~n/2)**3%n+n
n=>-3*(-~n)**3/8%n+n also works
 
2:39 AM
@user202729 that's nice, but there's a small trick that you missed
it will save you... three bytes
 
1 byte down, 2 to go: n=>n-3/8*(-~n)**3%n
@LeakyNun is this a math trick
also i'm assuming it's not a modulus hack?
 
@ASCII-only yes, a math trick
what is it with factoring out the /2 lol
@DJMcMayhem hi
 
@LeakyNun idk, i think i prefer it because there's less nesting
 
you broke the integrity (integer-ness) of the code
 
2:49 AM
oh yeah >_> so just imagine the /8 is back at the end where it should be
i mean JS uses floats so that doesn't change anything, but it's probably more comforting
 
hence integrity
 
@Downgoat is x a class or an instance variable?
 
can't find the math trick yet. but found n=>n+(-n>>1)**3*3%n instead
 
@quartata instace
 
it's... Kinda weird to have your code split across the class "definition" and the proper constructor
the only difference is that one has access to the arguments
maybe you might want something like C++'s initializer lists if that's what you're going for, just a quick way to init fields
 
3:01 AM
k
 
e.g.
 
initializer lists are very different from lazy expressions
they are two very different things
 
...wait, lazy?
maybe we're not talking about the same thing here
 
no I don't think so idk what you're talking about :P
 
I mean the semantics of class X { let y = ... }
 
3:04 AM
so you are saying you like C++ initializer lists & duplicating code per constructor versus intial field values?
actually now that I think about it... this answers where they should go
 
my concern is that you're splitting the initialization into two separate places. You should be able to look at the constructor and see everything that happens when the class is instantiated
The fact that you had to ask that question is a tipoff that it's not clear, you're not entirely sure what the order of things is just by reading the code
Look at this:
 
@quartata so you also oppose inheritance where the super-class also performs initialization?
 
that's a separate issue
 
no not really
they have specific inheritance semantics
 
class X {
    let x, y : String
    init(y : String) : x=f() {
        self.y = y
    }
}
Now you can have it both ways, but it's all the same place
you don't have to scroll up and keep track of the order
 
3:10 AM
if you'd like that then sure I suppose you can do that
 
this is what C++ does, with slightly different syntax
 
@quartata this doesn't make sense, with deferred initialization you don't need to keep track of order because it is resolved on-demand without locally captures values
 
and as a bonus I think it makes it clear what is a class and what is an instance variable. You init instance variables in the constructor, and nowhere else
@Downgoat I'm talking about how a person reads it. This has nothing to do with implementation, no one cares
Although lazily initializating instance variables sounds like seppuku tbh, I like to use impure functions occasionally in my constructors
 
@quartata are you seriously saying the semantics of a language dwarfs in importance to scroll distance?
 
hell yes
there's no semantic difference though
 
3:13 AM
.______________.
 
I think you have context I'm missing here, frankly
You're seeing something that you've implemented that I don't know
What's the difference between initializations going up there as opposed to down here
 
what do you mean by 'going up' and 'down there'
 
compare the two snippets
 
If you have something like (hypothetical example):
class BlueView {
    override public let backgroundColor = .blue
}

class View {
    public let backgroundColor = .transparent

    init(in controller: ViewController) { ... }
    init(in parentView: View) { ... }
    init(size: Size) { ... }
}
specifically, even if I were to override an initializer
I wouldn't need to make sure that backgroundColor is being set correctly
very useful for things like Views
 
not seeing your point tbh
View's constructor comes first, then BlueView
Assuming BlueView inherits and isn't a mixin
Right?
Mixins are pretty different
...although, this actually provides a great way to handle that
If you make a new constructor in the mixin then it gets that initializer list
Going off track sorry
FWIW here's how I'd structure View in pseudo-C++
 
3:27 AM
Can I find corresponding chat account of a main account?
 
class View {
    public let backgroundColor: Symbol;

    private init() : backgroundColor = .transparent { ...whatever is common to all three... }

    public init(in controller: ViewController) : init() { ... }
    ...
}
In C++ rather than init() it'd be just View() obviously. That's kinda the equivalent of Java's this(...) constructor but far less ugly. You don't have to repeat the initialization across all three that way
Plus there's inevitably going to be some other code common to all three constructors. Break that off into a private one
@user202729 go to chat.stackexchange.com/accounts/<network profile id>
That will redirect you
 
3:41 AM
@quartata What's ugly about Java constructors? I thought the functioned essentially just like in C++
 
"super must be first statement in constructor"
when you type that error message you should reevaluate things
also Java does not have initializer lists
which as previously alluded to are Good
 
Yeah fair enough
 
4:24 AM
0
Q: Given a grid, starting at the center and spiraling out, and an ID what is the Position?

Justin808Grid: +---------------+---------------+---------------+---------------+---------------+ | id: 20 | id: 19 | id: 18 | id: 17 | id: 16 | | pos: (-2, -2) | pos: (-1, -2) | pos: (0, -2) | pos: (1, -2) | pos: (2, -2) | +---------------+---------------+-----------...

 
 
2 hours later…
6:12 AM
@Downgoat well a patch that comes with a brick is still a patch :P
 
 
3 hours later…
9:28 AM
0
Q: "Hello, name!";

loladChallenge Your challenge is to make a simple program that takes the input and formats it as "Hello, !" Input Either a function call variable or STDIN, this is the name. Output Hello, ! Example Here would be a program in CJam: "Hello, %s!"[q]e% Probably not the most efficient... lolad ->...

 
 
1 hour later…
10:51 AM
hmm, I thought np.ones(N) would have faster accessing than [1]*N
 
11:13 AM
@TonHospel would you mind me asking some perl questions?
 
11:35 AM
@ASCII-only Sure, ask
 
11:57 AM
:| sorry internet died for a while
@TonHospel ok so just making sure of something: this doesn't look like it enables any features that may make things golfier, right?
according to here they have shorter quines than PPCG (same with perl 5) - I'm assuming they probably use some method other than q/qw/<>?
 
hi.. can I advertise this awesome answer codegolf.stackexchange.com/a/157980/9206
it deserves lots of upvotes and has only one
 
@ASCII-only only "say" looks useful and we allow that here too :-)
 
so the golfers there must be geniuses
 
@lembik yeah, i decided not to bother after seeing that c++ answer. The only way ot further improve it is to vectorize it
 
@TonHospel Oooh that would be cool!
but I am really impressed more than one person could actually understand the paper!
it's not an easy read
 
12:06 PM
@lembik: Yeah, I didn't get it either without seeing the code. They explain very badly
 
I definitely couldn't understand it without the codegolf answers
 
@ASCII-only Or they found a good cheat. These automatic online judges (does that site use one?) are sometimes easy to fool
 
@TonHospel I am still hoping to pose a challenge with complex arithmetic to see how well people can vectorize it
as compilers do a terrible job currently
 
@TonHospel easy to fool?
 
@ASCII-only calling external stuff (shell commands), reading your own scource code, that kind of thing
or only working for the cases tested while you know there are subtle things where your program is wrong etc.
 
12:16 PM
oh yeah i think that site allows errors (only checks STDOUT), not sure if that changes anything though
 
I never played on them for that reason and that their penalty for commandline options is way too high (lthough here the commandline option penalty is too low)
 
1:14 PM
@ASCII-only Ok, after a bit of searching I found the quine (see me on the scoreboard). It's in fact a fair one
It is indeed say that makes it possible
 
2:03 PM
is (((a+b)%n+c)%n+d)%n faster or ((a+b)%n+(c+d)%n)%n?
 
2:16 PM
I would expect (a+b+c+d)%n to be fastest :-)
since add is fast and modulus is slow
 
@ASCII-only did I mention that MapAssignRight doesn't like to be followed by a separator? Try it online!
 
2:45 PM
0
A: Sandbox for Proposed Challenges

SobszMinimal viable file corruptor Your totally legal ROM collection, as vast as it may be, has started feeling a bit mundane recently. Why not spice it up a notch? Write a program that takes in the following arguments: Path of the file to be corrupted (or the contents of the file itself, if your l...

 
how do computers even calculate modulus
 
A division algorithm is an algorithm which, given two integers N and D, computes their quotient and/or remainder, the result of division. Some are applied by hand, while others are employed by digital circuit designs and software. Division algorithms fall into two main categories: slow division and fast division. Slow division algorithms produce one digit of the final quotient per iteration. Examples of slow division include restoring, non-performing restoring, non-restoring, and SRT division. Fast division methods start with a close approximation to the final quotient and produce twice as many...
some decent reading there
 
3:14 PM
(especially Jelly atoms)
I don't pronounce what I don't need to pronounce.
 
0
A: Sandbox for Proposed Challenges

MichailRoguelike pathfinding Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold pieces the rogue can collect without waking up any monsters. The elements of the array are as f...

 
3:34 PM
@user202729 how does this work?
unless you meant 1/2 ≡ p+1/2 (mod p)
 
So now I'm able to boot into WinRE, what next?

(1) chkdsk /f /r --> https://social.technet.microsoft.com/Forums/office/en-US/2527e82d-e4d7-44d9-a5a6-a1fad3b49743/chkdsk-unspecified-error-75736e6a726e6c2e-4fa?forum=win10itprohardware
(2) sfc /scannow --> found bug but can't fix (I don't remember the exact details)
(3) a partition is undetected
(4) I read somewhere https://www.kapilarya.com/fix-page-fault-in-nonpaged-area-bsod-in-windows-10 that I need to disable Windows automatically managing pagefile.sys but I can't boot so how can that help?
@Cowsquack Yes, but I can't find congruent symbol on my keyboard...
 
so 1/2 is the modular multiplicative inverse of 2 and not the fraction?
or is ½ the inverse?
 
... Yes, modular multiplicative inverse.
(as F_p is a field, dividing 1 by 2 automatically produce the inverse of 2 modulo p, anyway...)
 
what is F? where does F come in?
 
3:49 PM
Looks like my mathematical notation is a bit rusty. The set of integers modulo p.
 
4:12 PM
-1
Q: In a C ++ programming language, when you use a word (void) in the function

Mohmmed Qassem SalehIn a C ++ programming language, when you use a word (void) in the function

 
4:49 PM
0
A: Sandbox for Proposed Challenges

user56656Title needed proof-golf Well I think it is about time we have another proof-golf question. This question is about Łukasiewicz's third Axiom Schema, an incredibly elegant set of three axioms that are complete over propositional logic. Axioms Łukasiewicz three axioms are: φ → (ψ → φ) (φ → (ψ ...

3
 
Looks like WW starred their own sandbox post.
 
@Cowsquack "1/2" is the unique solution to 2x=1 (mod p)
and note that (p+1)/2 is an integer, and it satisfies that modular equation
btw my python solution is lambda p:(~-p>>1)**3*3%p
@TonHospel hmm, interesting
 
is there a way to make make stop when a command in $(shell ...) fails?
 
@LeakyNun nice, do you have any more similar CMCs?
 
5:08 PM
@Cowsquack given prime p>3, find 1/3 mod p
 
so 1/3 mod p is the solution to 3x=1 (mod p), right?
 
yes
 
5:24 PM
0
Q: Is it a valid 7-seg solution?

l4m2Background Download and save as .rar A save is 140 characters, each two be a group, the ith(0-based) group mean the cell a[(i div 7) + 1][i mod 7]. Let x mean (ASCII(first byte in a group)-48)*64 + (ASCII(second byte in a group)-48), then the k+4th(0-based) lowest bit of x means it takes a[i di...

 
6:13 PM
@Downgoat neither of those ways. ma-l-uk
 
6:28 PM
/mɑɫɫot͡ʃ/ for me because the letter c makes the t͡ʃ sound in my language
 
well, I think you forgot where to stress it...
 
6:44 PM
ಠ_ಠ I just calculated that I need to ask 46 more questions that aren't deleted, closed or have a negative score to get the Curious badge
 
@EriktheOutgolfer /ˈmɑɫɫot͡ʃ/ ?
 
@betseg ... I thought your velarized lateral approximants were lateral fricatives at first.
 
wow
 
My reaction was: what language is THAT?
 
7:23 PM
CMP: I'm currently doing a thing where you have different content that has various tags assigned to it. I'm currently working on the part that allows you to look up content by tags (match things with all listed tags). Should all user-entered tags do fuzzy find or partial (start with) match or should only the last one (the one the user is currently typing) do semi-match?
I'm probably not going to do fuzzy find because that might confuse my users lol. I'm probably just going to stick with partial matching (either start-with or contains). Should it be last-tag-only partial or all-tags partial?
NVM figured it out myself, so much more natural to do All Partial Find.
 
7:51 PM
@cairdcoinheringaahing Ouch
Pro-tip: Don't delete your challenges
 
Hey there
I haven't been here in a while
 
 
1 hour later…
9:03 PM
@DJMcMayhem ... ?
 
9:23 PM
@Zacharý It's really buggy
 
Ah, so it isn't an actual hate, I presume
 
It's close lol
 
 
1 hour later…
10:41 PM
CMC: Given prime p>3, find 1/3 (mod p)
 
print(1/3)?
 
Anonymous
@LeakyNun Actually, 5 bytes: ;¬3ⁿ%
 
Anonymous
In a finite field GF(p^n), 1/a = a^(p^n - 2)
 
@Mego oh right, there's this trick that I forgot, lol
 
10:58 PM
1
Q: A running gene crossover algorithm

CarcigenicateYour task is to accept as input two gene sequences, and a sequence of "cross over points", and return the gene sequence that results from the indicated cross overs. What I mean by this is, say you have the sequences [1, 2, 3, 4, 5, 6, 7] and [9, 8, 7, 6, 5, 4, 3], and cross over points of 2 and ...

 
@LeakyNun Does it have to be in the range 0..p-1?
 
@H.PWiz yes
 
@LeakyNun Python 2, 20 bytes: lambda p:p-p*(p%3)/3. I chose Python because in Haskell, Mego's formula wins
 
@H.PWiz 19 bytes: lambda p:-p%3*p/3+1
 
11:13 PM
Nice
 

« first day (2611 days earlier)      last day (2248 days later) »