« first day (1908 days earlier)      last day (2938 days later) » 

3:00 AM
what language is this?
and what does Math.sign do?
 
I was exercising for 4 hours and I'm really tired right now :( And I have 2 hours of economics homework :(
So I'm pretty dumb right now
 
1 or -1, depending on sign.
 
@NathanMerrill gets the sign of the variable. e.g. -3 -> -1 or 21 -> 1
 
@NathanMerrill x/|x|
 
I don't understand why you are doing Math.abs, and then Math.sign
 
3:02 AM
@Downgoat Is it because f is off from the true value by a large amount? (i.e. 0.1 ≠ 6.674EE-11)
 
shouldn't both grav and dist be positive?
 
@NathanMerrill that's just from the algorith, I read on the internet
 
@NathanMerrill I agree. Unnecessary assuming this
 
What I'm wondering is why the initial delta-v is so high
 
Ok, suggestions: I'd remove the Math.abs and Math.sign from the velocity equations, and f and 1e5 from the planet movement functions
 
3:08 AM
So Math.abs(grav * (dx / dist)) * Math.sign(dx); -> grav * (dx / dist);?
 
Shouldn't the distance changed depend on a time interval somehow? (i.e. distance = rate * time)
 
@HelkaHomba that function is run every frame
@NathanMerrill ^^^
 
okay
 
you don't even need the parenthesis
 
3:11 AM
Y'all are discussing the gravity when the real problem is that planets have zero initial velocity.
I even hacked it to allow a max of 50,000 and still nothing.
 
#hax
 
@El'endiaStarman stop hacking the universe :P
 
@El'endiaStarman the equation still works with zero initial velocity
@Downgoat that said, you are assuming that the sun doesn't move
 
ohhhhhhh
 
@NathanMerrill Yeah, that's the point.
 
3:13 AM
I forgot to account for the scales
the simulator takes in the real values in terms of weight but scales them down about a billion times so they actually fit on the screen
I forgot to account for that in the velocity equasions
 
@Downgoat The sun has spots, not scales...
 
I am a fucking idiot
 
@Downgoat your equations should have nothing to do with the rendering
 
@NathanMerrill they shouldn't but they do
 
do the scaling after the equations
 
3:15 AM
I will try to refactor this better but first I want to get grabity working
 
@NathanMerrill The velocity actually is appropriate, it's just that it's on the order of billions, which is what he was talking about.
 
\o/ \o/ \o/ \o/ \o/ \o/ \o/ \o/ I think It's actually working
 
Masses are in the 10^20s or something.
 
@Downgoat And you should do something about that cold
 
@HelkaHomba I am thinking you spelled something wrong
 
3:17 AM
no
 
@Downgoat Looking at the console output, I agree.
 
> grabity
 
@Downgoat Only problem now is that, because it's totally realistic, you can't see anything move. :P
 
D:
 
You need to scale the time up a billion times
 
3:21 AM
1
A: Can I string all my cords and adapters together?

TimwiUnreadable, 3924 bytes This is the first time I implemented somewhat of a call-stack-like structure in Unreadable. (The first version of this was over 5300 bytes, just to give an idea of how much I golfed this.) '"""""'""'""""""'""""""'"""'""'""'""'""'""'""'"""""""'"""'""""""'""'"""'"""""""...

no kidding
 
Unrelated to anything but this is a really good white bread recipe.
 
-1 not Richard
 
@Dennis pretty sure this would win the "most bytes golfed" award
 
Who's Richard?
 
Astley
 
3:23 AM
WHY DOES THE EARTH KEEP FALLING INTO THE SUN
 
Um, should I be worried?
 
yes, very
 
@Downgoat Initial velocity isn't high enough.
 
@NathanMerrill Oh?
Hahaha +1 just for "Golfed out 9.097887e+87 unnecessary characters." — Doorknob ♦ Aug 6 '14 at 9:15
:P
 
I've increased it by a 150 billion and it's still not working
 
3:25 AM
@NathanMerrill coughs
 
I think Sp wins :)
 
Even for a "normal" golf challenge, there's still stuff like Martin's Prelude quine
 
Sp always wins :/ (except when he doesn't)
 
^ Truer words have never been spoken
 
ok, shoot this idea down. I'm considering not having a main method in my language, but have code outside of any class/function be executed
but if you import that file, it doesn't execute the code
 
3:30 AM
confusing
 
^
 
simply because nobody does it that way?
 
how about a runIfNotImported block if you really want that behavior?
 
I mean, when was the last time you imported a file, and you wanted the root level code to execute?
 
@NathanMerrill Yeah. For me it's just behavior I totally wouldn't expect (barring any reading of documentation).
 
3:32 AM
imports are pretty much exclusively used for importing classes and functions
 
@NathanMerrill Dynamically generated imports
 
How would you call a necessary setup method in the imported file? (You could do importFile.setup(), but really?)
 
@HelkaHomba init/main
 
@MarsUltor I don't see the use of dynamic generated imports on a static language
@HelkaHomba what's a setup method?
oh, do you mean "how would you execute the code if you wanted to"?
hmmm, good question
 
my computer is so hot right now I could probably cook my breakfast on it...
... someone just starred it again ...
 
3:36 AM
5?
 
Anonymous
I count 8, broski
 
@NathanMerrill I mean anything that might require some initialization before any of the imported methods are called
 
Anonymous
@Quill userscript to make strawpoll links go away
2
 
Unless there's a main that's auto called like Mars said
 
@HelkaHomba are you talking like static blocks?
 
Anonymous
3:38 AM
@QPaysTaxes Sorry for not responding earlier, I had to cook dinner. Make a class hierarchy that all inherits from one base class and make a your_lang_class_definition -> C++_class_definition transpiler.
 
Anonymous
@NathanMerrill So like Python with if __name__ == '__main__'
 
@NathanMerrill Kinda. I just mean any bit of code that needs to be run before the library's methods can start being called
 
@Mego I'm not going to do something like that. I'm either going to make a main method, run root level code on initial file only, or require files to either have root level code or only have classes
 
Yeah, Python's if __name__ == '__main__' is gross.
 
Anonymous
@AlexA. A little, but it's very necessary. I'd rather it be wrapped in a builtin function like is_main_module().
 
3:44 AM
Yeah, the functionality is fine, but the implementation is bs.
 
#geometry.py
PI = 3.14
def area(r):
    return PI * r * r

#myProgram.py
import geometry
print(geometry.area(6)) #ERROR - PI not defined
@NathanMerrill ^ maybe I'm misunderstanding but wouldn't this be an issue?
 
ah, but my language is compiled
so your PI variable would be static const
but that is a good thing to bring up
because it would appear that classes would be inside of the scope of PI
(assuming it wasn't a static variable)
 
nonconstant nonstatic x = 1;
That's not really relevant, I just wanted to write it
 
yeah, that's a really good point
it breaks the current scoping rules, so I'm not going to do it
 
@AlexA. This could be said after many of your posts ;)
 
3:48 AM
>_<
 
so my second choice is to require files to either have root-level code or to have classes
but not both
 
@NathanMerrill What's wrong with both?
 
imports
 
hm?
 
I don't want the ability to import other code, and have it run on import
@QPaysTaxes are a bit different because they are explicity static
 
Anonymous
3:54 AM
@QPaysTaxes The confusion never ends
 
hmmm, I think I'm just going to make a main {} block
I really don't want to, because being able to write code without any framework is super nice
 
Don't feel pressured to go with main {}. This could be your chance to break the mold and set a new precedence!
 
0
A: Sandbox for Proposed Challenges

Are Wojciechowskiking-of-the-hill Tron Bot Racing It's time to begin annual Tron Racing Tournament. Create a bot that will steer your cycle to a victory! Glossary Board is a 100x100 square that wraps around its edges. Game Bots leave impassable trail. In the beginning of the game, all the bots participating ...

 
4:10 AM
Just make root level code run only when run directly, and have explicit export that only works for static objects
 
Star Wars Facebook page just posted a picture of Anakin from Episode 3 with a caption wishing the actor a happy birthday. Top comment is this:
> Too bad those younglings won't have any more birthdays
 
4:27 AM
@Downgoat D: JS is good
 
Anonymous
@MarsUltor Lying to yourself is not good
 
Anonymous
JS is adequate at best
 
@Mego ಠ_ಠ
JavaScript is best script
 
Anonymous
ShapeScript is best script
 
@Downgoat I don't think that it's that JavaScript is bad, it's just that it's a lot easier to write bad code in, and the node debugger may not be the easiest to use
Also, cheddar Grammars are hard to debug because of the large amounts of iterations
 
4:34 AM
@MarsUltor yes
 
It's annoying for me to set a breakpoint in expression and have it stop at every operator check
on the plus side, It's really easy to debug values in JS
 
Writing a language sounds fun
 
oh shit I lost the sun
@Quill no it's not
imagining it is fun
making it is not
 
@Downgoat That's bad, right.
@Downgoat It is
the parser is not
 
@Downgoat It's called Night?
 
4:37 AM
@Quill I said that last night! :P
 
No, the sun itself is missing from existence.
 
yesterday, by El'endia Starman
@Downgoat (It's nighttime.)
 
@El'endiaStarman bad jokers great minds think alike
 
Hopefully once I finish what I'm working on, creating a new language will just be adding a new set of grammars
 
4:39 AM
I still see it, incidentally. Also, thanks for properly centering the sun, @Downgoat. :P
 
now I lost the earth, can you make a joke from that
@El'endiaStarman yeah, I just fixed it
 
It's called Moon?
Wait what no earth = no gravity = no orbits
 
@Downgoat No. that's a deathly serious matter and you shouldn't joke about that
 
ugh, since velocity is not proportional to time, I think I have to scale it every frame which is also going to be a problem...
 
@Downgoat I've worked on numbers and string parsing, not sure if you want me to add that to Cheddar
 
4:42 AM
@MarsUltor there was already number and string parsing?
 
Better parsing
 
I found the problem
 
That's a black hole
 
yeah, pretty much
and you can't exactly orbit a earth around a supermassive black hole only a few miillion km away
 
That should not be able to form, and would evaporate almost instantly
 
4:45 AM
yeah. But this is just a gravity simulator
 
@Downgoat That's really light, just it's miniscule
 
I might spice it up with particles later
 
@Downgoat Particles?
 
@MarsUltor the mass is actually in quadrillion kgs
@MarsUltor yeah each body would be made out of a certain amount of particles which would allow planets to smash togehter and rings to form
that would be really cool
 
The earth's mass is in the order of 10^23 iirc
Wait, my bad
 
4:47 AM
or trillion kgs I'm not sure
 
It's 5.97 x 10^24
 
Can you create a GitHub repo?
 
not yet
but the ES6 code is here: vihan.org/p/SSS/system.es6
 
Then I can just save the html, right?
 
4:50 AM
uh, not really... I should make a .zip
vihan.org/p/SSS.zip are all the files
 
Need to go now, gonna download it later
 
@MarsUltor okay, bye!
I found another problem...
the delta-v is craaaaaazzyyy high
like supermassive blackhole high
OH MY GOSH IT WORKS
 
@orlp ( ͡° ͜ʖ ͡°)
 
@Downgoat where do downgoats come from?
how do they reproduce?
 
4:56 AM
downward
 
^
@orlp this is supposed to be a family-friendly chatroom so I can't describe that
 
@Downgoat I think you've got the polarity reversed. :P
 
@El'endiaStarman ?
 
Earth starts out going downwards, curves to the right, and speeds up, exiting through the bottom right corner of the screen. :P
 
what's wrong?
 
5:02 AM
It goes on a parabolic path with almost no initial velocity. :P
 
oh
I know
 
 
@El'endiaStarman hm :/ I don't know why that's happening
@orlp looks like a sumo wrestler squatting
 
That's Buddhabrot, so you're not too far off. :P
 
does anyone know how to fix:
let dx = planet.x - Sun.x;
let dy = planet.y - Sun.y;
let dist = Math.pow(dx, 2) + Math.pow(dy, 2);

let grav = f * planet.mass * Sun.mass / dist;

planet.velocityX -= Math.abs(grav * (dx / dist)) * Math.sign(dx);
planet.velocityY -= Math.abs(grav * (dy / dist)) * Math.sign(dy);

planet.x += (f * planet.velocityX / planet.mass);
planet.y += (f * planet.velocityY / planet.mass);
 
5:08 AM
is your order of incidence correct?
 
Well, for one, you should take planet.mass out of the calculation for grav, and also take that out of the position updates.
 
@Quill I think
 
Also, yeah, you can replace Math.abs(grav * (dx / dist)) * Math.sign(dx) with grav * (dx / dist).
 
@El'endiaStarman but Newton says I'm supposed to
@El'endiaStarman oh yeah, I already did that
 
@Downgoat F = ma. F is grav, and m is planet.mass, and what you're really interested in is a since that's what you're using to update the velocities.
 
5:10 AM
If I take out planet.mass the planet just goes straight
 
Did you take it out in all 3 places?
It doesn't even make sense in the position update lines.
 
Nice! I can join the cool guys club
 
@El'endiaStarman yeah
maybe in:
            let dx = planet.x - Sun.x;
            let dy = planet.y - Sun.y;
should planet and Sun be swapped?
 
Okay, checking it out.....hmm, I see.
I think you need to scale gravity back up.
@Downgoat No, I think those are right.
 
@El'endiaStarman what do you mean by that?
 
5:15 AM
Put a constant multiplier of 1e4 in, like grav = 1e4 * f ...
It still exhibits problematic behavior though.
 
okay
I have no idea what else it could be... everything seems correct
 
Oh, another problem is that you've got dx / dist when it should be dx / Math.sqrt(dist), and once that's done, the constant multiplier is totally unhelpful now.
 
Why do I need to sqrt dist?
 
Still doesn't go on the right trajectory though. >:(
'cause you should be dividing by the true distance, not it squared.
 
@El'endiaStarman But the formula uses distance squared.
 
5:21 AM
In the calculation of gravitational strength, yes.
Do you know trigonometry?
 
I will offer a +500pt bounty to if anyone can solve this problem :/
@El'endiaStarman yeah, but is it necessary here?
trig functions would be very computationally expensive (I think)
 
what formula are you using
 
@Quill there is only one gravity formula in the universe
 
Y'know how x = r * cos(theta) and y = r * sin(theta)? What's cos(theta)? It's adjacent over hypotenuse. x / r. That's exactly what is being used here - dx / sqrt(dist).
 
15 mins ago, by Downgoat
let dx = planet.x - Sun.x;
let dy = planet.y - Sun.y;
let dist = Math.pow(dx, 2) + Math.pow(dy, 2);

let grav = f * planet.mass * Sun.mass / dist;

planet.velocityX -= Math.abs(grav * (dx / dist)) * Math.sign(dx);
planet.velocityY -= Math.abs(grav * (dy / dist)) * Math.sign(dy);

planet.x += (f * planet.velocityX / planet.mass);
planet.y += (f * planet.velocityY / planet.mass);
@El'endiaStarman okay :/ but even after sqrting it, it still goes off path ;_;
 
5:25 AM
@Downgoat Yeah, I'm working on it. You still had planet.mass in the position update functions, so I took those out, and now I'm using a multiplier of 1e-10 and that's not small enough. :P
 
This is like a real star simulator as it makes my computer the temperature of a star ._.
 
I'm actively debugging it using the console tools. :P
 
@El'endiaStarman D: if you want to try it locally there's a zip here
 
No need. I can edit the JS in my browser.
 
oh, cool, what browser are you using?
Safari doesn't let me do that I don't think
 
5:27 AM
......I fixed it. Sorta. It now goes in an elliptical orbit, but it's fastest at the outermost end and slowest when closest to the sun. That is SO weird...
var f = 0.1; // speed up factor

var dx = planet.x - Sun.x;
var dy = planet.y - Sun.y;
var dist = Math.pow(dx, 2) + Math.pow(dy, 2);

var grav = 10 * f * Sun.mass / dist;

if (f2++ < 3) console.log(planet.x, planet.y, planet.velocityX, planet.velocityY);
planet.velocityX -= grav * (dx / Math.sqrt(dist));
planet.velocityY -= grav * (dy / Math.sqrt(dist));

if (f2 < 4) console.log(f / planet.mass);
planet.x += f * planet.velocityX;
planet.y += f * planet.velocityY;
 
._.
 
Oh, y'know what? The sun's gravitational center is off to the right and downwards.
 
oh...
 
So all along, your code was rightish, and it just went flying towards that corner because the sun was really over there. :P
 
:|
I should add the trails...
 
5:32 AM
yeah
 
okay... it's definitely elliptical
 
And that's just the amount of precession I'd expect. :D
 
that's true... now I have make a perfect elliptical orbit and I'm done for today...
 
Gravity isn't quite aligned with the sun.
And that's a darn close-to-elliptical orbit.
 
if (f2++ < 3)
 
5:36 AM
There's a way to make it perfect, but it requires more math.
 
-_-
 
@El'endiaStarman yeah, I think I'll leave that for tomorrow, that's enough gravity for today...
 
@El'endiaStarman also, I did say I would give a +500 bounty so how to whoever helped me get this working so how should I award it?
 
Well, gee, I've never gotten a bounty before...or even tried for one.
Y'know what? You keep the rep. I don't feel like my help was worth that much, and I was perfectly willing to do it for free anyway. :P
I like gravity simulators, so I had an itch to fix yours... :P
 
5:44 AM
@El'endiaStarman are you sure? Regardless of the rep, I greatly appreciate your help in helping me get this to work, but it's almost 11:00 for me so I should be going to get some sleep :)
 
Yeah. It's mostly my challenges that I'm most proud of, and you can't award bounties to those. :P
 
5:57 AM
@Downgoat will you accept additions?
Are planets supposed to be unlisted?
 
@MarsUltor they should be listed but I haven't gotten to that yet
@MarsUltor sure
 
All Downgoat was trying to do was to get gravity working. :P
 
So it's working fine now, right?
 
Yay
I'm thinking of adding linked slider/numeric inputs with mass and exponent
 
6:01 AM
Oh, that reminds me, : text box inputs along with the sliders.
 
as in <slider> <input> (for number) <slider> <input> (for exponent)
Um
Can I work on it for a while?
wait
@Downgoat Am I allowed to change it a lot?
 
Anonymous
6:24 AM
@Maltysen This is why I'm confused about your solution being unable to result in circle or parabola - even though Sage does some magical stuff with numerics behind-the-scenes, it still ultimately uses floating-point calculations to solve the linear system, and it is capable of correctly identifying each of the test cases.
 
Hello
 
6:40 AM
@AshwinGupta Use Remix OS for PC
@Quill Only if you go from programs and features. If you uninstall directly from program files, you can uninstall as many as you want
Wait
PPCG doesn't use LaTeX for all documents? D:
@HelkaHomba wait you actually like windows' taskbar? It's so cluttered IMO, they try to put everything in a 50px bar
@HelkaHomba Cmd+W or Alt+F4 is faster than mouse
@Downgoat Giving up on SSS for now
 
@MarsUltor What is SSS?
 
Downgoat's solar system gravity simulator
 
@MarsUltor Ah, ok.
 
6:57 AM
@MarsUltor Should be DSSGS
 
*Solar System Simulator
 
7:37 AM
@MarsUltor don't leave the D alone
 
@feersum remember this problem? codegolf.stackexchange.com/questions/77947/…
I think I just solved it elegantly
or at least, the circumradius problem
def total_angle(line_segments, r):
    return 2*sum(math.asin(c/(2*r)) for c in line_segments)

def find_radius(line_segments):
    line_segments = sorted(line_segments)
    lo, hi = max(line_segments) / 2, sum(line_segments)
    while hi - lo > 1e-9:
        mid = (lo + hi) / 2
        largest_angle_left = 2*math.pi - total_angle(line_segments[:-1], mid)
        if 2 * mid * math.sin(largest_angle_left/2) < line_segments[-1]:
            lo = mid
        else:
            hi = mid
    return lo
basically, you add up the resulting angles from every line segment except the biggest one
then you check if the length of the chord of the remaining angle matches the biggest segment
 
8:31 AM
@ಠ_ಠ please get back into chat, we can't make ಠ_ಠ faces easily without you. Q_Q — Easterly Irk Apr 7 at 22:20
Wish granted.
 
@ಠ_ಠ I agree that you make my life easier each time I wanna type ಠ_ಠ
Hum, I just came across this question on XKCD #936 on security.se, it is pretty interesting
Might think of something along this line, some of our user are still using passe as a password
 
@ಠ_ಠ are you a sockpuppet?
 
9:22 AM
@ಠ_ಠ \o/
 
@Katenkyo How do you know?
 
@MarsUltor They pass it around when they store documents on their session instead of the common server and are in vacation... Even though I could totally give others said document without needing it -_-
You'de be surprised of how unaware people are about where a sysadmin can go on its own network
 
@Katenkyo Are you sure that's not a temporary password used solely to pass documents?
 
@MarsUltor For some of them, it might be, but in most case, they have to give their password because they forgot that somebody might need that document
Heck, even if it's a temporary password, it's a bad idea to give access to your account to someone else!
 
10:01 AM
0
Q: Autocomplete the input

BasGiven a dictionary of words, you should write an autocomplete program or function. Input Your program/function will take a single parameter of input. This parameter can either be a string or an array of characters, and will consist of lowercase characters [a-z]. Output You should print or ret...

 
10:27 AM
@orlp That only works for the circle center outside the polygon, right?
 
@feersum no, it works for everything
it's actually pretty elegant how things work out
4
A: Find the area of a polygon

orlpPython 2, 191 bytes from math import* C=sorted(input());l,h=C[-1]/2,sum(C) while h-l>1e-9:m=l+h;a=[asin(c/m)for c in C[:-1]];f=pi-sum(a);l,h=[l,m/2,h][m*sin(f)<C[-1]:][:2] print sum(l*l*sin(2*t)for t in a+[f])/2 Uses a binary search to find the radius, then calculates the area of each segment ...

 
It seemed the same as an approach I mentioned previously for that case only
 
@feersum I updated my answer
 
largest angle = sum of other angles
 
largest angle = 360 - sum of other angles
 
10:30 AM
why is it not equivalent to that?
 
I don't know what you're referring to
 
Oh, I didn't see the 2pi part
 
@feersum basically, we compare the last angle to the last chord
to check the radius
 
Well it can't be equal to both x and 2pi-x at the same time...I must be ovelooking something
 
@feersum what is 'x' here?
 
10:33 AM
sum of the non-largest angles
 
why would those be equal to the largest angle?
 
hmm, do you have a counterexample?
 
@feersum [1, 1, 1, 1]
270 != 90
 
One with the circumcenter outside the polygon.
 
it's equal to x and 2pi - x if and only if the largest chord is exactly the diameter (forming some sort of moon-shape
@feersum what I say can not possibly be false, in a cyclic polygon the sum of angles of segments must be 360
but if you really want a counterexample, let me fire up geogebra
 
10:46 AM
The sum of the angles won't be 360 if you calculate simply asin(length/2r) and the polygon does not contain the circle's center.
 
@feersum sorry packet at the door
it should be trivial to see that the first three angles do not equal the fourth
actually, let me highlight the 4th angle
 
But the arcsin thing will give you min(a, 360-a).
 
@feersum I never use asin on the last chord
If you calculate the first n-1 angles, you know that the last angle is 360 - the others
then I check whether that angle is correct
by comparing it to the length of the last chord
 
All right, I see it now, that's a sin not an asin
 
2 * mid * math.sin(angles[-1]/2) calculates how long the last chord is, if it's angle is 360 - sum(the_others)
then I compare that length to the actual length
 
10:56 AM
Yes. Nice way to avoid the asin two-valued issue.
 
but the best part is this
you still have to sum the areas of the segments
note that big angle is 225 degrees?
>>> sin(radians(225))
-0.7071067811865475
it gets subtracted automagically :)
 

« first day (1908 days earlier)      last day (2938 days later) »