« first day (3111 days earlier)      last day (1823 days later) » 
00:00 - 15:0015:00 - 00:00

3:02 PM
@AndyK The universe is a strange place, I was reading that documentation last night actually, what is your question? Maybe I can help. I don't see date__lte in the context the exclude() explanation
 
@PawelFlajszer Apple products give me a severe allergic reaction, but i5 can hold its own. You would know if you're exceeding your 8 gig RAM?
 
@roganjosh RAM is soldered :(((
only upgradable thing is SSD really
 
You soldered your ram in?
SSD isn't RAM
 
soldering your ram in is as useful as soldering your ARM to something. pretty useless, so it wasn't me, just apple :<
 
Apple soldered it in
 
3:06 PM
Ram comes soldered in on some laptops where it isnt replaceable or upgrdeable
Macbooks are a good example.
 
Oh, well now we're back to Apple and I'm breaking out in hives
 
same with CPU
 
I kind of want to know why solder it in though? Why not just secure it in the chasis and make it more effort to get at that one would want to reasonably exert.
 
Deft little hands soldered them in
 
I'm just not sure if it's worth investing 250 quid in SSD when the laptop is nearly 4 years old. all works fine, battery will need replacement in.. like a couple of years,. that's another 200+ quid
 
3:08 PM
"deft little hands" - elaborate ? Like Child labor or shady construction habits.
 
@Dodge I found it, sorry. There you go docs.djangoproject.com/en/2.1/ref/models/querysets/…
 
@PawelFlajszer which kind of SSD do you want to install?
 
Depends do you need a new Laptop and is it worth it to upgrade or keep.
 
So you can't change it. They got sued for deliberately having their phone battery only take 100 charges and giving you no way to change it but send the phone away
The whole company is built on ripping people off
 
3:09 PM
@roganjosh my battery is currently 1200 cycles in and still pretty good :) they say it should perform top quality for around a 1000.
 
You can thank the law suit for that :)
 
to be fair I've never had a better machine :P
 
I think mobile phones are becoming a rip off market.
 
@RobertFarmer 2k for Galaxy Fold... 2k for a phone? yep. Obsolete in a couple of years
 
With year new flagships for many companies i feel like they're starting to put less long term useability in their models.
 
3:11 PM
Most valuable company in the world, but if you took the actual valuation of their hardware rather than their own...
 
The $5k iMac Pro is decently priced
For all I know
 
The Galaxy Fold is a Public Prototype Test
 
@RobertFarmer indeed. they delayed the release date , not sure if you've heard
 
Yeah cause of the issue with no warnings on the packaging with the Phone's Film Covering and the overall wear and tear a normal person inflicts causes that same Film to deteriorate a crap ton faster than their lab tests predicted.
 
issues raised with the protective foil on top that can't be removed, but testers thought it's something you remove once it's out the box, and boom
 
3:15 PM
Well one or two never removed theirs
and they still saw gradual failure
The fact a Protective Film/Foil must be kept on is a bad idea
 
it's not a ready product, essentially
 
No, and even if it was flawlessly smooth it is only a Gen 1 Product.
We'll see those concepts get expanded upon once they push newer models. But right now just getting the Galaxy Fold out of the gate is rough.
and for 2k... Your market size is extremely limited
 
It's "nobody asked for it" plus "they said we can't do it". And apparently they can't :D
The direction in which TVs and phones have been going is ridiculous.
 
I mean fair point but its not that they cant a few company's have teased flexible & fold-able devices in the past years. It's that once you hit open market stress tests in labs don't have adequate results.
 
Private beta?
 
3:21 PM
A robot flexing a phone 10,000 Times a day and swiping it in every angle imaginable plus drop tests and scratch tests doesn't correlate to day-to-day wear
Thats the review models essentially
 
there's a wide margin between lab and journalist
 
Yep, and they hit a road bump with that step
 
Swiping it to do what, though? What do these devices even do?
 
they...fold?
you can probably touch...both parts of the screen
 
Candy Crush on a wider screen?
@AndrasDeak what a time to be alive! Maybe not the best time, but a time
 
3:24 PM
What do you what do they do? Like the robots or the Galaxy Folds
 
you can also double-tap
 
But a good example in the case of the robot is look-up Tappy the T-Mobile Robot.
 
My mind is confined by a resistance to change... and 5 years of observing the regular phone doing very little that's productive. Im truly sorry
 
"regular phone"
 
The kind you power with a battery in the boot of your car
Once upon a time, we even spoke to humans with these devices
 
3:30 PM
the whole market race every year is good for creating handheld and mobile device technology that is innovative and interesting. The mobile camera industry is also interesting with some people using Mobile Devices to take their photos now exclusively.
The race to make the most powerful device every year does generate some fun stuff.
But I think the trend of making phones cost like $100 more every year is stupid too.
 
these days it seems a lot like innovation for the sake of innovation
 
Handheld devices will be gone in next 10 years or so
You will have a virtual screen wherever you want
 
Tablets already replaced all PCs and laptops five years ago
 
aabra-ka-daabra...and the screen goes live
 
@vaultah hehe
also phablets
 
3:40 PM
@ksalf we'll see. We're yet to have a mega hack
 
@roganjosh: I hope it's cheaper to afford.
I still have that keypad phone...no touch here
 
A mega hack? They generally come for free, at least initially. I mean, they can have bolt-ons like getting access to your own data etc
 
No, those virtual screens
 
Noise. Random walk on a grid?
 
3:46 PM
3/3 XY Problems busted. Behold: babby's first 3d fractal.
 
it produces the silhouette illusion to me
 
@Kevin ooo.... spinny :)
 
or maybe it doesn't, I'm no longer sure
 
What is it? It looks a bit like a molecule
 
It's symmetric so not a walk after all, probably some procedurally generated fractal. Iterated function system perhaps.
 
3:48 PM
Protein folding?
 
nope
OK, I got it to rotate in the other direction again.
 
This is a procedurally generated fractal. You start with a list of two unit vectors that are at right angles to each other. You create the next generation of the fractal by iterating over the list and for each pair of vectors, you insert between them the cross product of those vectors.
 
It surprises me how ordered it looks
 
The result is a list of axis-aligned unit vectors. These vectors represent a walk through 3d space. A point starts at (0,0,0) and moves in the direction of each vector in turn.
 
As opposed to just a scribble all over the screen
 
3:56 PM
@Kevin Don't you mean 1.9d fractal?
 
I suppose. It's a line rather than a collection of faces or a collection of solid bodies, so it's not as 3d as it could possibly be.
 
Kevin I'll have you know I got my entire Program runtime now to 55-65 Seconds.
 
@AndrasDeak It should, since I'm using a rather primitive isometric projection. There's no depth.
 
Still got to congratulate you for that help
 
@RobertFarmer I'm glad something I did this week had an actual practical influence on the world :-)
 
4:00 PM
Well my only issue is my Supervisor's Macro might be doubling the Transitions. I put a don't increment if row is in my deadrows list and I got half of what he was counting. I'm wondering if I'm off now or if he wants it to be doubled.
 
This curve has some properties in common with the Dragon Curve. In particular, the first half of the walk is identical to the second half, not taking into account translation and rotation; and the first half of the walk is identical to the entire walk, not taking into account translation, rotation, and scaling.
Or so I assume based on my observation of the image. I haven't formally proven anything.
 
4:13 PM
Mr. God too created a fractal like that (The RNA), gave it some AI with necessary environment to support its reproduction, and boom that fractal gave rise to humans and this room, eventually.
 
It occurs to me that rather than doing cross-products, I could have written an L system: Start with "forward up", then apply rules such as "forward up -> forward right up" and the other 23 combinations of rules that cover each valid cardinal direction pair
pairs such as "up down" and "left left" will never occur, so we don't need to write rules for those.
 
how much faster is just an if (cond1) and (cond2)-else to
`if (cond)
    if (cond):
    else:
`
 
@AndyK Sorry I had to step away, that is a filter tag, so something like date__lte=datetieme.now()-timdelta(days=1) would be filtering instances of a given model by the model attribute 'date' where the value is a date sometime before this time yesterday. You can use __[whatever tag] attached to the model attribute in a filter() call
 
Its not marginally faster is it?
 
@AndyK I don't know if they are officially called "filter tags"
 
4:17 PM
@RobertFarmer somewhat of an apples and oranges comparison because that code will not have the same behavior as an if-elif-else block
 
Okay. Cause I noticed in some of my code I can replace having a if-else nested in an if statement with just if it fulfills both conditions increment x and append else increment y
 
#assuming we are comparing this block:
if a() and b():
    print("foo")
else:
    print("bar")

#with this block:
if a():
    if b():
        print("foo")
    else:
        print("bar")
 
This is usually not a concern of performance, but rather a concern of readability.
 
If a() returns False and b() returns True, then the first block will print "bar", but the second block will print nothing.
I suppose you could do:
if a():
    if b():
        print("foo")
    else:
        print("bar")
else:
    print("bar")
... And this would have identical behavior to the first block. But it violates DRY principles.
And it's no faster. If you're thinking "but surely this way is fast because it doesn't bother to evaluate b() when a() returns False?" you're correct. But if a() and b(): also doesn't bother to evaluate b() when a() returns False.
 
4:22 PM
Actually yeah, I was mistaken i should leave it cause I don't want it doing anything if the first condition is false.
Completely had a brain fart.
 
Hey there, I got a quick question about itertools.groupby. I'm currently grouping by a formatted datetime like this:
changes = itertools.groupby(changes, lambda x: x["date"].strftime("%Y-%m-%d"))
So it groups by unique dates
But I want the keys to be datetime objects too, for later formatting. Is there any way to get that behaviour?
I could go over the list afterwards and parse the dates into datetime objects gain but that would lose me some data.
 
You'll still have the date time objects available on the grouped objects...
 
hm
let me try something
 
If you're only ever going to want day precision, then you might want to just use x['date'].date() so your key will be a datetime object converted to just a date instead of a str...
 
What is the object you're working with?
 
4:32 PM
I take it changes is an iterable of dictionaries or similar?
 
Afternoon y'all
Hey look, a pupper
 
@OldTinfoil how ya doing matey?!
 
I'm doing alright mate - currently in Florida doing some last minute coding before a conference, you?
 
changes is a list of dicts that look like this {content, user, date}
 
lambda x: x["date"].strftime("%Y-%m-%d") is the key you're grouping by. It doesn't change the types of elements in changes
 
4:35 PM
That was just my stupid way of grouping by date, its been fixed now with .date()
perfect, thats what I was missing. Thanks
now the jinja2 template can handle date formatting
 
@OldTinfoil feeling quite jealous now :p
 
As everyone should - but I choose to think that's because of my grand ginger beard
 
I have half a mind to learn numpy so I don't have to do all this matrix multiplication manually
 
I'm just trying to figure out why my alembic history is all out of flunter. The changes it needs to make to get to the newest version haven't taken, and I'm not sure why
grumbles
 
@Kevin That would be awful. :P
 
4:41 PM
@Kevin the basics are very simple
plus with two array-likes I can give you a single call to numpy.einsum that will do whatever you want
 
If numpy has a way to generate a rotation matrix then that'll cut my line count right in half
 
Maybe not built-in but it should be easy enough. Rodrigues' formula or general Euler angles?
 
Most of numpy should be very simple for Kevin tbh. Anything else, you have Divakar for
 
Right now I only need to rotate around the x and z axes so I don't even necessarily need anything fancy enough to rotate around arbitrary vectors
 
@OldTinfoil anyway - how long you in Florida for?
 
4:46 PM
Just about a week. It'll be mostly spent in meetings and conference halls unfortunately
Was hoping to hit Daytona beach this time
But no such luck. I've gone to St Augustine and Cape Canaveral in previous trips
 
@Kevin yeah, that's easy to put together by hand. But the same goes without numpy.
 
pastebin.com/Z7zbtWFH does the trick right now but it's so very very slow
 
around z you have [[c,-s,0],[s,c,0],[0,0,1]] and around x you have [[1,0,0],[0,c,-s],[0,s,c]] where c and s are the sine and cosine of the angle, respectively
 
It's not a dealbreaker that numpy won't autogenerate the matrices for me. I'm only creating num_frames+1 rotation matrices over the course of the entire program, so it's not at all a bottleneck
 
That matmul can probably be replaced with np.dot(a,b). And if they are already arrays (they should be) then just a @ b
 
4:50 PM
multiplying all num_frames * 2**15 vertexes by those matrices is the bottleneck.
 
if you have 3-length coordinates in a list of length 2**15 that's an array-like all_points with shape (2**15, 3), for which you can do either or all_points @ rotmat.T` or np.einsum('ab,cb->ca', rotmat, all_points) I think (not tested)
 
Yeah, that's approximately the design I have in mind.
Although I think I need 4-length coordinates because you can't do proper translation matrices without the magical W dimension
 
because translations aren't linear operations :P
 
Anything goes in the Wth dimension. Cats and dogs living together, babies having babies,
My current code doesn't have a W component. Without translation I don't have direct control over the point that the model chooses to rotate around. It's a happy coincidence that it currently rotates around its centroid, approximately
When I animated the Stanford Bunny, it rotated around its nose
 
If you switch to numpy this all becomes much easier. (all_points - origin) @ rotmat.T + origin is not that much worse to write and read
 
5:00 PM
The only thing I'm not sure will be easy is towards the end when I need to concatenate M array-likes of shape (N, 3) into a single array-like of shape (M*N, 3)
With M ≈ 32 and N ≈ 2^15
 
>>> np.concatenate([np.random.rand(3,4) for _ in range(5)]).shape
(15, 4)
oh, I thought syntactically speaking
>>> 32*2**15
1048576
That's not the end of the world.
 
My concern is in two parts. Concern one is that I would be too addled to discover the concatenate function. But you've given it to me here, so that's no problem. Concern two is that it would be computationally expensive. But if numpy scoffs at a million rows, then I won't fret.
 
the only question is whether you have 25165824 bytes of RAM lying around but that's, what, 24 MB?
 
I probably have that :-)
The final stage of all fractal rendering programs is asking "now, how high can I crank 2^X before the space/time requirements become ridiculous?"
 
>>> np.random.rand(3*5*2**15).nbytes
3932160
 
5:07 PM
If N=2^15 consumes 24 MB, then naturally I will also try N=2^20.
 
5:23 PM
Hmm, I planned to replace the cross products in my procedural generation function with an L-system, but that rather hinged on being able to have more than one token on the LHS of each rule...
I can still do it if I'm willing to use twice as much memory.
Ooh, I get to use numpy.cumsum here. I've heard much about it, usually in the form of furtive snickers from immature users.
 
it's just a replacement for a handy assignment expression inside a list comp
 
I hope it has at least a little C-level magic because accumulating the coordinates of the walk my the second biggest bottleneck
 
5:39 PM
it's probably written in C, yes
 
m8_
Hola! Anyone familiar with spaCy? I'm trying to follow their tutorial but hit a snag on Chapter 2 course.spacy.io/chapter2
specifically...coffee_hash = nlp.vocab.strings['coffee'], properly returns the hash ID. but coffee_string = nlp.vocab.strings[coffee_hash] returns an error: KeyError: "[E018] Can't retrieve string for hash '3197928453018144401'."
 
That's a strange exercise. Since hashes are non-unique, it's not always possible to turn a hash back into the original object.
For all we know both "coffee" and "coconuts" hash into 3197928453018144401
 
Perhaps "hash" is a misnomer in that case.
 
m8_
I believe that's correct @AndrasDeak. According to the tutorial, a hash is associated with one or more instances of the same string
To save memory
 
Skimming through Chapter 1, I suspect spaCy maintains a bidirectional collection, and simply throws out a string if it would collide with another.
 
5:47 PM
it's probably more of an encoding than a hash
 
In which case, you can get the original object from the hash. But you have to live with the one in a quadrillion case that your "coconuts" string will be inaccessible
 
m8_
That makes sense, since hashing is not reversible, which the tutorial claims this process should be.
Semantics aside, still not sure why it's not returning the string from the "hash"
 
Strange. When I run the Chapter 2 Part 1 exercise with cat_hash = nlp.vocab.strings["cat"] and cat_string = nlp.vocab.strings[cat_hash], it works for me.
 
try coffee, duh
 
I don't know why my cat_hash would work and your coffee_hash wouldn't.
 
m8_
5:51 PM
let me try cat..
 
Side note: having the to and from mappings in the same dict is a bit weird. Even though I know it's safe because the domain and the range are different types.
it's a good way to prevent anyone from JSON-encoding your bidirectional mapping ;)
 
m8_
Ah, I should have skipped ahead
I didn't have the doc object defined
I needed doc = nlp("coffee")
 
I notice that if I replace the string literal "cat" with the string literal "derp", then the code crashes on cat_string = nlp.vocab.strings[cat_hash].
This makes me suspect that hashes are only reversible if the string appears in the doc object. Oops, you beat me to it.
I thought perhaps that the hash-to-string relation would get automatically added to the doc when you do nlp.vocab.strings["derp"] but I guess this is not the case
 
m8_
ha, well thanks for investigating with me @Kevin!
Right, that's what I thought.
but I guess the doc object needs to be initialized regardless
 
6:42 PM
I am currently making one million unfounded assumptions about how numpy handles arithmetic between matrices and sequences and scalars
 
@Kevin what you need is broadcasting. The gist of it is that singleton (1-length) dimensions are expanded, and there are an infinite number of implicit leading singleton dimensions on any array-like
(3,1,5) is compatible with (3,2,5) and (3,2,1) and (2,5) and (5,) and a scalar
"expanded" means "imagine the array is repeated like tiles along that dimension"
and you can inject singleton-dimensions with the short-hand arr[:,None,:] for a 2d array (injects a singleton in the middle, gives you a 3d array), or even arr[...,None,:] to inject a penultimate singleton for any ndarray
 
The output I currently have, while incorrect, is not so mangled that I can't see some glimmer of the desired result. So I think 99% of my assumptions are actually founded.
 
it's fairly sane, so odds are good ;)
 
7:11 PM
 
Awesome :)
 
woot
 
wow... looks like an RPG map level
 
bit dizzying speed
 
Success. It's not pixel-for-pixel identical to the previous version, probably because I had a slightly different starting configuration the first time and I'm doing something different with the centroid
 
7:14 PM
or perhaps the speed is the same but the angle is different, so that the top is flailing wildly rather than turning in a cute pirouette
 
The X-axis is flipped compared to v1.0, I think. So instead the bottom is doing the pirouette.
Maybe I was better off rotating around the end point rather than the center of gravity... Let's see.
Yeah, I think that's a little better.
Here is the code. 91 lines, which is a fair improvement from v1.0's 167.
 
using ndarray.min/max might give some minor speed improvement
 
@Kevin Is that a 3d dragon fractal?
and by "3D" I mean embedded in R^3 for representational purposes, not its fractal dimensions
 
Kind of. The L system doesn't particularly resemble the Dragon Curve's, but I do feel that the output has some striking similarities to it.
 
visually it reminds me of the dragon
 
7:27 PM
I said as much when I posted v1.0 this morning. chat.stackoverflow.com/transcript/6?m=46013598#46013598
 
I've pretty much had my head buried in work most of this morning, so not paying a lot of attention to chat
 
@AndrasDeak If I could get the min of the x and y columns at the same time, that would be pretty rad.
It wouldn't change the comutational complexity any of course, but I hate spending four whole lines finding the bounding box.
 
so you are doing all the math with numpy, right?
 
@Kevin arr.min(axis=0) (or 1, depending on orientation)
 
@Kevin sometimes reducing those smaller terms and constant factors can make a significant difference
 
7:31 PM
Everything in my code from coords = np.cumsum(walk_steps, 0) onwards uses np types, AFAIK. So yeah, it's doing all the math.
 
yup
 
7:50 PM
At the beginning of this project I was hoping to make a fractal with actual polygons, not just line segments in R^3. I toyed around with the idea of iteratively replacing each of the triangles in a scene with ~3 interlocking triangles in a pyramid shape. But if I want each Nth generation triangle to be similar to its N+1th generation descendants, then I think all triangles have to be equilateral and the only way to make them interlock is to join them up in a tetrahedron.
I haven't written any code to confirm, but I suspect this wouldn't produce any interesting emergent geometry, just an increasingly large pyramid.
 
At least that probably doesn't depend on the shape of the triangles.
 
You can make pyramids using a base of any shape, but you'll have a hard time making all three sides similar to the base.
Yesterday I was sure it would only be possible with equilateral triangles but now I'm wondering whether there might be some wacky triangle with side lengths 1, sqrt(2), and phi and it just happens to decompose into a self-similar pyramid
Something like the Golden Rectangle except in three dimensions and with triangles
 
Sorry, I was being ambiguous. "that" whch doesn't depend on the shape of the triangles is the "interesting emergent geometry"
 
Certainly interesting emergent properties don't necessarily require shapes that are in some way pure or clean or neat. Penrose Tiles can be constructed with 36-36-108 triangles, so maybe Kevin Pyramids can have wacky angles too.
 
8:06 PM
Maybe, perhaps I have a needlessly limited view of Romansco broccoliesque surface fractals
 
user6718998
Hi. Anyone got any idea why I get indexers out of bounds ? pastebin.com/w7CEGwjQ I just want to make a matrix
 
you need to print some shapes for us to be able to help
What is "sample data" and where do you get an out of bounds error?
data = df[['period']] will give you a dataframe with a single column, then you try 2d indexing into that dataframe with two different integer column indices. Is this really what you want? What do you want to achieve?
unless I'm mistaken that .iloc call would say "give me the first 100 rows from the first and third columns", but there's only one column
>>> df = pd.DataFrame({'a': [1,2,3], 'b':[4,5,6], 'c': [7,8,9]})
>>> df
   a  b  c
0  1  4  7
1  2  5  8
2  3  6  9
>>> df.iloc[:2, [0, 2]]
   a  c
0  1  7
1  2  8
>>> df[['a']].iloc[:2, [0, 2]]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
so you don't need to print shapes after all...
 
user6718998
Ah you are right. THen I dont udnerstand this. I was trying to build up a perceptron algorigthm. But the input is a matrix. If I have an array of ones and zeroes, how do I get that matrix ?
 
I can't answer because I don't understand your situation. Try a bit more concrete example of what you have and what you need.
 
user6718998
8:22 PM
But you know what perceptron is ?
 
only that it's a kind of neural network, or a cell (neuron? layer?) in a neural network
 
Howdy all.
 
8:51 PM
someone can help me ?
https://stackoverflow.com/questions/55758802/reaction-embed-and-edit-message-on-discord
 
I don't know any of the libraries you're using, but the one comment on the question suggests that there may be some missing information (functions that don't have a visible implementation). Is it possible to boil down your code further so that it's sort of self-contained? That being said, your question has only 40 views in 4 days which is probably the real problem, and I don't know if we can do anything about that. The tags are fine, for example.
I'm a bit surprised that something called add_reaction should be able to remove a reaction, but I know absolutely no discord so this might be fine
 
import discord
import requests
import json
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
from discord.utils import get
just it
 
What are get_espace and user_add_espace? — Patrick Haugh Apr 19 at 14:17
 
the custom emoji works right, add_reaction works right, my only problem is to edit the embed. I need to return to the original embed and the reactions when I click on the custom reaction
 
yeah, sorry, that needs domain knowledge (and probably not even a non-trivial amount), and I have none :(
 
9:03 PM
How do the AoC problems compare to the Hard problems on leetcode?
 
we'll see if anyone else has two cents to add, but I don't usually see discord.py being mentioned here
 
def user_add_space(user_id: int, xp: int):
    if os.path.isfile("bot/space.json"):
        try:
            with open('bot/space.json', 'r') as fp:
                users = json.load(fp)
            users[user_id]['space'] += xp
            with open('bot/space.json', 'w') as fp:
                json.dump(users, fp, sort_keys=True, indent=4)
        except KeyError:
            with open('bot/space.json', 'r') as fp:
                users = json.load(fp)
            users[user_id] = {}
            users[user_id]['space'] = xp
 
please see the pinned link for a guide on multiline formatting in chat
(bottom line: highlighting and ctrl+k usually does it)
 
this is my add_space and get_space
works fine
 
@LucasTesch OK, so perhaps you can boil that part down to two simple functions that get and set values in a dict? Because that would make your code runnable (with the aforementioned imports), so who does know discord.py can try it for themselves. My experience is that I'm 90% more likely to help solve a problem if I can drop it into my interpreter and play with it.
(actually, that 90% is off, I meant to say I'm 10 times more likely)
 
user7437554
9:10 PM
Hello guys, I've got a short question for any of you
 
user7437554
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
more_than_five=[]

[more_than_five.append(element) for element in a if element<5]
print(more_than_five)
 
@santimirandarp no no no
.append mutates the list and returns None
Don't use a list-comp for something with side-effects. Use a proper loop.
 
user7437554
wow but I'm following a tutorial :(
 
you probably meant to say more_than_five = [element for element in a if element<5]
@santimirandarp which one? And what does it say exactly? Do you have a link?
 
user7437554
 
9:13 PM
basically
 
@santimirandarp OK, that link doesn't say anything about list comprehensions. It wants you to use a loop I think.
 
@santimirandarp Notice how x.append(3) is a single line of code. This isn't embedded in a list comprehension.
 
user7437554
wait, lets go slowly
 
@LucasTesch OK, but that's a lot of code and a large part of it is the json input/output thing that's irrelevant to your problem
you should get rid of it to help those who want to help you
 
user7437554
the code I wrote returns the correct answer, but you say it is a wrong syntax?
 
9:14 PM
@santimirandarp yes, it creates a list of Nones and as a side-effect it creates the list you need
 
user7437554
but the task say create a list with the values <5
 
It's like buying a jar of syrup by ordering ten plates of pancakes, scrubbing off the syrup into a jar and throwing away the pancakes.
 
user7437554
the code you paste does not return a list, or does it?
 
try and see
If you haven't learned about list comprehensions yet, you should wait until they teach it to you :)
 
user7437554
oh I see the error. Thanks @AndrasDeak
 
9:16 PM
is the commands that I use to run and check json, this is well summarized everything that is being requested in my help, basically I am not having problems with json, but in editing my embed and returning it
 
@LucasTesch I understand that. But if you were to put all that code into your question to make it runnable, it would be way too much code and that would also distract (maybe even scare away) potential answerers. You're not obliged to do anything, it's just my suggestion to make it more likely that someone who sees it will also answer it. I can't give technical advice so you'll have to make do with this. You can take it or leave it :)
@santimirandarp no problem
 
user7437554
I've learned about that but in a very puzzled way
 
user7437554
That's why I'm trying to solve simple exercises
 
yup, go step by step
And remember: if something simple is difficult, there's probably a better way. Don't hesitate to ask.
 
user7437554
:)
 
9:26 PM
if I remove json's subjects, could anyone help me? because is it practically custom emoji and embed the question
 
So apparently there is a whole category of tetrahedrons with congruent sides, and they need not be equilateral. They're called disphenoids. But I suspect it's impossible to construct a tetrahedron with similar but noncongruent sides. My marvellous proof does not fit in this margin.
 
@LucasTesch that looks much better. Is it runnable if you add the imports? Because if it is, you should definitely update your question with that. The edit will also bump the question to the front page, so new people will probably see it.
 
alright
 
(is it runnable, and does it still reproduce the problem? ;) )
@Kevin ah, I see
 
9:35 PM
cbg
So, someone with a lot of rep answered this simple question (stackoverflow.com/questions/55819707/…) and made the answer a community wiki---I don't really understand why? I don't really understand how community wikis work. Any of you care to enlighten me on the philosophy?
 
Community wikis are a means to signal that you disown your post, usually to make sure you don't get rep from up- or downvotes.
I think Travis thought that the question is too basic to take credit for it, but there's no good reason to close it.
 
Okay, that's what I figured
Cool, ty for the explanation
 
Ok, you twisted my arm so I'll try to write the proof. Start with a scalene triangle with side lengths A B and C, where A > B > C. WLOG assume that this triangle will be the smallest of the four triangles composing the tetrahedron. A second triangle will adjoin the first on side C.
 
no problem
 
It can't be that the second triangle's side C adjoins the first triangle's side C, because then the triangles would be congruent. It also can't be that the second triangle's side B adjoins the first triangle's side C, because B>C so the second triangle would have to be shrunk for the edges to match. We already know the first triangle is the smallest, so that's out. And A can't adjoin C for the same reason.
 
9:38 PM
sorry, Kevin, this margin is 1 message wide
 
This proves that a tetrahedron must have at least two sides that are congruent. And with my magic handwave I assert that the other two sides will be congruent also.
 
proof by magic handwave
 
Just change out "largest" for "smallest" and ">" for "<" etc
 
favorite kind of proof
 
I'll have to admit I don't know what "congruent" and "similar" mean exactly in geometry. I'll have to look it up later.
 
9:40 PM
my favorite handwavy proofs were always from abstract algebra, where instead of concretely proving something using transitivity, the professor would always say "by the sandwich theorem"
 
Two triangles are congruent if they have the same side lengths and angles. Two triangles are similar if they have the same angles.
 
@AlexanderReynolds That doesn't sound like a mathematician. That sounds a lot like a physicist.
@Kevin ah, I see, thanks.
 
Oh no, definitely a mathematician. Number theorist, even.
Just more like "its trivial and you can figure it out"
 
the good old "left as an exercise to the reader"
 
9:41 PM
Sandwich theorem: get ten steps into your proof, say "I'm hungry" and go make a sandwich. When you return, you have already forgotten about the problem.
 
I mean to be fair, they were truly trivial things.
 
I have proven many many things this way.
 
No, that's the free lunch theorem
people think it means that the lunch is free, but really, it means that lunch frees you from your problem.
that's why physicists never leave their office, because they instead have the no free lunch theorem.
this thing opinion-based
Also very not happy with the answer that was just given...
 
The "no free lunch" theorem is just an emergent law similar to the cosmic censorship hypothesis that prevents the mass of physicists to reach critical values near sources of free food
 
@AndrasDeak LOL
 
9:49 PM
@AlexanderReynolds yeah, singling out one of 20 tongue-in-cheek proverbs is a good sign that the question should be closed
 
exactly lol
 
(give or take some fallacies in the previous statement, but you can get my meaning)
 
was trying to find a meta to comment on that answer
 
@Kevin Your conscious mind has already forgotten about the problem, but candidate solutions have appeared in the meantime.
 
It's the dark mirror of The Feynman Algorithm, and like its twin it only works if you're Richard Feynman
 
10:24 PM
dear community I have the following practice code solution: Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters.
For example, given s = "abcba" and k = 2, the longest substring with k distinct characters is "bcb".
def longest_substring_with_k_distinct_characters(s, k):
if k == 0:
return 0

# Keep a running window
bounds = (0, 0)
h = {}
max_length = 0
for i, char in enumerate(s):
h[char] = i
if len(h) <= k:
new_lower_bound = bounds[0] # lower bound remains the same
else:
# otherwise, pop last occurring char
key_to_pop = min(h, key=h.get)
new_lower_bound = h.pop(key_to_pop) + 1

bounds = (new_lower_bound, bounds[1] + 1)
max_length = max(max_length, bounds[1] - bounds[0])

return max_length
I dont understand the line:
min(h, key=h.get)
 
hello
 
yes
 
@Mookayama that says "for each element e in h, try to find their minimum in a way that we pretend that the value of item e is h.get(e)"
is this part OK?
 
so we are looking for an item in the dictionary, the key is the minium, of the value points to by the key is minimum ?
 
I'm not really sure I correctly understand what you're asking, so here's a rubber-duck example: imagine that h = {'apple': 2, 'potato': -1}. Then min(h, key=h.get) tries to take the minimum of ['apple', 'potato'], but based on the values given in the dict: apple is worth 2, potato is worth -1, the minimum of these values is -1, so potato wins, and min(h, key=h.get) returns 'potato'.
it should be the same as min(h.items(), key=operator.itemgetter(1))[0] if that helps
(which is functionally the same as min(h.items(), key=lambda item: item[1])[0])
oof, return inside a lambda, it's getting late
 
10:41 PM
ok i get it now
 
 
1 hour later…
11:51 PM
cbg
@JonClements Oh, i thought that you should get gold-badge of python 3.x but you got one wiki one, so one more to go.
 
00:00 - 15:0015:00 - 00:00

« first day (3111 days earlier)      last day (1823 days later) »