#voice-chat-text-0
1 messages · Page 81 of 1
yeah
Well let's start with what you know already.
Have you written any code for this yet or are you struggling with how to use functions in general
Gotcha gotcha
thats what I have so far
!e
Okay, so. Functions are blocks of code that you can use again and again by calling it. So for example:
def ham():
print("Big fan of ham here")
ham()
@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.
Big fan of ham here
@molten pewter Thanks Jaden Smith
"How can mirrors be real if our eyes aren't"
Back to the help
hi vc0
"u can never have a new mirror"
congrats on the freedom green man
This tracks - you are the hammiest person I know
@sharp urchin Not really
yeah dont click any unless u trust
When you define a function, there's a few key components: def is require to tell Python you're about to make a function, ham in this case is the function name, () anything in the parentheses is considered a parameter. So if we instead had:
def ham(pork):
print(f"My new favorite food is {pork}.")
ham("bacon")
In this case, pork is a parameter. And in the function call ham("bacon"), "bacon" is considered an argument. Arguments are what we pass, parameters are what catch the arguments
oh ik this one the 4 the different types of functions right?
Not quite sure what you mean
I can relate to your problem
But this is just one part of what functions can do. In this case, we're just tossing a value to the function and saying "print with it". But what if we want to have it calculate something or we want to get a value back from the function? Then we'll use the return keyword.
!e
So for example:
def add_2(number):
new_number = 2 + number
return new_number
spam = 3
print(spam)
beef = add_2(spam)
print(beef)
@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 3
002 | 5
Note that I could have done a shorter version, where I do return number + 2
But it was just to show the full process
@mossy cedar Yeah I don't think it's specifically the coding that is the issue there.
Questions, comments?
does she need a 4th?
Bad
heheh
No
Just hanging out at home. Wife is sick so not really going out to do anything
Oh currently I'm at work
Same
That much coffee is probably not overly healthy either
if ur depressed make ur self more sad because 2 negatives make a positive
worked for me '
As someone with clinical depression, no
That help you out?
im starting to understand it a lot more
u are the GOAT
Hit me up if the course ever covers classes. I love explaining those
drink green tea better than coffee helps u get that energy without a crash
also drink water when u wake up and dont drink caffeine for like an hour and a half after u wake up
this helps u not crash and need a second dose
It's actually a myth that you will become more dehydrated from coffee. While yes, caffeine is a diuretic, the amount of water in it compensates for that and then some
the biter coffee taste makes my soul twitch so it keeps me from overtheinking
thinking*
understandable
whats that
what which roast do u get?
8 o'clock is my favorite brand, typically. But Maxwell House if I'm wanting cheap and a lot
I typically get darker roasts
hmm
I typically either get columbian roast folgers or tim hortons medium roast
darker roast takes a man
lol
Eh, my wife prefers it as well. Ooooo and if you can ever find espresso blends, so good
The flavor is just better
LMAO
Back in a bit.
built to stay longer!!!
$75

@rugged root when I find myself glancing into discord and see you givimg examples.. I onno.. it makes me take a minute and then figure out a new way to...
!e
print(chr(0b01001000), chr(0b01100001), chr(0b01101101))
@pallid hazel :white_check_mark: Your 3.11 eval job has completed with return code 0.
H a m
YSL black is a great fragrance
@mossy cedar before downloading next time create a restore point
got it
alright i hadit. im fresh booting c drive
screw install or uninstall gettin it reset
@rugged root
I figured it out finally
and i was able to apply a loop and break command
looks lonely
nvm
Nice
Hey Griff
How goes it
How's it feel to have that much power
Right?!?
It's so irritating
Same
Opaaaaal
Yo
Well at least it's not an unpaid bill
Small price to pay
Of course not.
@tepid edge Sup
an interesting l33t code question
Such a thing exists?
class Solution:
def lengthOfLastWord(self, string: str) -> int:
count = 0
for i in range(-1, -len(string) - 1, -1):
if string[i] == " ":
if count:
return count
else:
continue
count += 1
return count
class Solution:
def lengthOfLastWord(self, string: str) -> int:
return len(string.strip().split(" ")[-1])
zubba zubba
How are you testing the memory usage?
Gotcha
I'd ditch the else
First one feels clearer
Sure sure
expensive = time consumption ?
!e
import dis
def lengthOfLastWord(self, string: str) -> int:
return len(string.strip().split(" ")[-1])
print(dis.dis(lengthOfLastWord))
@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 3 0 RESUME 0
002 |
003 | 4 2 LOAD_GLOBAL 1 (NULL + len)
004 | 14 LOAD_FAST 1 (string)
005 | 16 LOAD_METHOD 1 (strip)
006 | 38 PRECALL 0
007 | 42 CALL 0
008 | 52 LOAD_METHOD 2 (split)
009 | 74 LOAD_CONST 1 (' ')
010 | 76 PRECALL 1
011 | 80 CALL 1
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/ifulixibaz.txt?noredirect
Working on the second one, one sec
!e
import dis
def lengthOfLastWord(self, string: str) -> int:
count = 0
for i in range(-1, -len(string) - 1, -1):
if string[i] == " ":
if count:
return count
else:
continue
count += 1
return count
print(dis.dis(lengthOfLastWord))
@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 3 0 RESUME 0
002 |
003 | 4 2 LOAD_CONST 1 (0)
004 | 4 STORE_FAST 2 (count)
005 |
006 | 5 6 LOAD_GLOBAL 1 (NULL + range)
007 | 18 LOAD_CONST 2 (-1)
008 | 20 LOAD_GLOBAL 3 (NULL + len)
009 | 32 LOAD_FAST 1 (string)
010 | 34 PRECALL 1
011 | 38 CALL 1
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/emelaheceg.txt?noredirect
Ah yeah, fuckton more calls
Yo 
Sup brah
def cat():
pass
cat()```
For some reason imagining a cat being passed like a basketball
If they bother asking about that stuff in the interview, bleh
Welcome to my life
i tend to revisit my old code - and apply speed pieces of code , so any idea is good
It's neat
speed up code
True. I like to do that and just see how much I've improved
That's the tough thing for me
Finding usecases
Q - what is faster , more flexible , Arcade OR Pygame ?
Not sure, haven't tested. PyGame is likely more flexible
I think Arcade is built on top of PyGame, right?
pygame i assume more mature , more banged on for ... x,y,z reasons
just heard about Arcade 10 min ago -
It's older, but it was stagnant for a long while
How do you know that dough is always bettering itself?
It says "I'm proved!"
pygame is more active than it has been in the past
i want to blend , tkinter and pygame to have hi-res / animated gui control panels
Loss of precision 
I thought Arcade was built on top of Pyglet. At least that's what I was told.
Looking
HA
Oh god, a few years ago - yeah you're right, it is pyglet
When I was working in the tax file room, I HEARD a spider land next to me
I thumped down
Also yes
The spiders will shank you
Don't get on Opal's bad side
Oz landia grow BIG poisonous critters , shake out your boots first
need sticky traps - zappy traps , what else
breed a vicious cat that is immune to most toxins
If you bite something and you die, it's poisonous
If something bites you and you die, it's venomous
If it bites you and someone else dies, that's voodoo
What if you bite each other and die in an indeterminate order
Romeo and Juliet
HAH exactly what I was thinking
She's dead, whoop he's dead, oh wait she wasn't dead no wait now she's dead
oh wait she isn't dead ... nvm
Yeah actually
I was surprised how good that movie was
Agreed
I mean... he's not currently president
Sooo
Your mom
¯_(ツ)_/¯
See? Griff understands me
Doesn't work for me
@limpid umbra Oh huh, they have a comparison chart
@uncut meteor There's probably some like novelty site you could get it.
Like there's Vat19 in the US that has fucking massive gummy bears
They like sugar
Oh then... hmm
mmm looking.....
Wouldn't it curdle a little?
In the lemon one
@past oar Yo
HA
I have 2 British friends
minimum
You might
You know one of them at least
Brad
Ohhhhhh okay
I think when you were saying that, I was imagining the candy
You wouldn't need a lot for your tea
Licorice root
Of course you were
Yeah I was
For some reason thinking like licorice candy
iwas thinking of a certain kinda leaf
@bronze copper Yo
hi
this is my goal
Yes yes har dee har pot
How's it going
@uncut meteor High purity oxygen is actually pretty bad for the body, if memory - DAMN IT OPAL
Handsome bastard, I was writing it out as he said it
@acoustic saffron Sup
Later griff

cohort effect
HeHeHe
HA
Took me a second
Inert yeah
It's why I stuck with more practical stuff
Practical as in... I guess things I can touch and fix
IT
it's mah jam
@rugged root Arcade much faster at everything....
Not quite
But faster in enough places
But if it's just for a GUI, that really shouldn't matter
It's not like if you use pygame it's going to work like a slideshow
@rugged root you saw the GUI pic up top?
I did. And that kind of thing can be done with fairly simple processing and software
@tepid edge Are you still interested in the answer to that question?
@rugged root the PC and microcontroller , setup
Hm. Ball point pen.
I'm not sure what you're getting at, prop
I think it's just because one solution uses built-in string methods, and the other uses python loops. The first approach is usually going to be much faster. I don't think I can really say much more than that.
This is actually a bit faster still: ```py
def lengthOfLastWord(string):
_, _, suffix = string.rstrip().rpartition(' ')
return len(suffix)
Yeap
@rugged root i can have a , uC or a raspi in a greenhouse -- then link to it via wifi , and have a fancy GUI page to display pumps , chart logged data , ect
*_, suffix = string.rpartition(' ')
Eh...
Doesn't look that much cleaner
Plus it'd waste time making a tuple...
Hmm
Right I get that, but how quick of a refresh rate do you need on the GUI? I've seen these kinds of layouts and diagrams on old equipment from the 90's
@rugged root my idea is old , just trying to cobble it together small scale
Sure sure
Yeah I didn't realise the input might end with a space.
@rugged root i can try both , see what is simple to run on old RPI , like a RP3B+ , computationally friendly
pygame is going to be less intensive on it
Plenty of open source projects looking for people to review PRs and what have you
im using UBUNTU on my RP3B+ , 32 bit OS , for a juke box
so i need to test pygame on it also
well its just a display terminal for data from microcontroller
Right
if something is , animated , its just to show it is active , like a pump or fan
HA
It's a joke
"Deaf con"
You little scamp
Dorknet
No Such Thing as a Fish
Can't recommend this one enough
Really good podcast
Not quite
In the Oxford Dictionary of Underwater Life, it states that there is no such thing as a fish
Because a fish as it's used implies that they're all very directly related, which is often not the case
We use KnowBe4 at work
@whole bear Yo
@rugged root yo
How's it going
I'd like to hand the authors an extra-fizzy drink.
discovering discord and learning python
Well cool, happy to have you
NO NO NO
I HIGHLY recommend it
Fucking love it
I can't recommend it enough means I genuinely run out of words trying to say how good it is
@prime forge I do indeed
this is super cool
metaclasses ?
Meta classes are ways to manipulate how Python works
It's a bit funky
Free samples!
@rugged root thanks
Any time
@rugged root hmmm i will ask you about CLASSES at a later date , they kinda confuse me
✅ @prime forge can now stream until <t:1676409179:f>.
what are flask and django. I am about to finish a book on python and I see these terms everywhere but I don't know when I have to use them or go to them
So flask and django are web backends. When you go to a website, the backend is what serves you that page. Any links you click or things you enter, they get sent to that backend, are processed, and served back to the user.
That's just broad concept
It gets a bit more into the weeds
oh ok thank
Which book, if you don't mind me asking
@rugged root Head First Learn to Code
Huh, hadn't heard of that one
Oh I know
It sounds like I'm a mad man
I do actually have ADHD
So it works
From Eric Freeman, editions O'Reilly
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
If you find yourself looking for additional resources or wanting to try another book to make sure you have your basics down, we got a bunch of stuff listed
monkey brain go brr
I mean if it's cold
@somber heath Oh dude, did you ever see that old movie Merlin?
Yes
Yes it is
If someone is learning how to program, especially just starting out, CS50 just throws too much at someone
Like that's not the main focus
@rugged root You recommend me the Resources page ? You seem to know so much, give me a shortcut. My eyes are burning from studying
Hmmm..... Well, if you want to make sure you have your basics down, A Byte of Python is one I recommend
And it's free on its respective site, which is a plus
I will go check it out. I trust you 100%
@somber heath But you know the movie I'm talking about right? With the cymbal monkey that every time it strikes its cymbals someone dies?
I was a CIS major
So I'm probably just biased against it
cis?
who did the cs50 entirely ?
Think more IT and boots on the ground coding
what is the difference between that and a cs or cybersecurity degree
I consider CIS as practical vs CS which is more theoretical
Practical more hands on I mean
IT being one of the more hands on
im self taught so 🤷
In fairness, take what I say with a grain of salt. I'm a hobbyist, I don't work in the industry
(except for IT, I do indeed do that for work)
I guess my main thought is, if someone comes in and says "Hey, I want to learn how to program", I start basic
We also have a younger userbase
id make them make a peanut butter jelly sandwich on paper
Exactly
@past oar what can you do now with your self taught knowledge. Are you able to get into the marketplace and get gigs and stuff ?
Not everyone has or wants the higher maths
The guy who presents CS50 is a little too high-energy for me 😄
🐐
@stuck furnace he was sweating like in a sauna
i teach programming/stem at a private high school and i do occasional pentesting gigs
@past oar amazing. respect 
Some of our staff (lemon for example) is primarily self taught and has gotten quite far in his career
Certifications are a bit more handy in IT
Not as much in programming
For now
you guys are giving me hope. I can relate to you @rugged root for CFE (College Failure Enthusiast)
Oh sorry
hahhahaha
Due to having to move a lot, I've gone to 6 different colleges in 3 different states. I had around 100 credit hours that were essentially rendered useless as they got converted into electives
I got my associates of liberal arts as a transfer degree, but at some point I just broke
It was not a good time in my life
hey, I heard we must learn at least 2 programming languages to be called a developper. The founder of Linux said this in a talk. Which programming language do you guys think makes more sense to couple with Python ?
You don't HAVE to learn more than one language, but it's good to have more than one under your belt
And Python is more of a glue language
It helps if you stick with it, though.
Which kills me inside that you can
@tepid edge
Introduction to Computer Science from Harvard, better known as CS50, is the largest course on the Harvard campus and more than 2,000,000 learners worldwide have registered for the course on edX.
awesome, thanks guys
@tepid edge pv message
I have to adhere to my principles.
Didn't work, u have settings set to don't acc from strangers
What're the common ones in industry... Java is still very very common, C# is good, JavaScript is handy, and then like the next tier of niche would be stuff like C, C++, Rust, Go...
yeye
.NET is everywhere now
It's not restricted to just Windows
HA
Rider
^
VS Codium?
Ah gotcha
Back in a bit
CSS ?
Introduction to Computer Science from Harvard, better known as CS50, is the largest course on the Harvard campus and more than 2,000,000 learners worldwide have registered for the course on edX.
oh ok
how long it took you to finish it ?
I understand
Awesome. Great value. Do any of you have tried competitive programming with Python ?
Staines massive!
codewars if that counts
from what i've seen though most ppl use c or cpp
Yes there is @somber heath , they hold contests and rank coders by the speed and concision of their code. They in turn get contacted by headhunters like Google or other software companies
Ey Jake. How goes? 
Good to hear 😄
I feel like I have no idea what IBM actually does today.
Other than make AIs to win Jeopardy.
software engineer and software developer is the same thing ?
Mainframes
They’re also making their own cloud, believe it or not
Have you opened up a portal to hell?
Balsamic vinegar lol
Could you imagine cleaning your monitor with it
that's a blow below the belt
Oh yeah that is true.
You can avoid that by always using task groups.
Like Trio's nurseries.
Tasks being cleaned up was one of the first asyncio lessons I learnt the hard way.
Bye Opal 
Woah. Hemlock changed colour? When did that happen?!
Mhm. About a week ago: #changelog message
Also Joe and Sebastian stepped down as owners/directors.
Ah.. Thanks for linking me.
I prefer teal over red anyway!
assert.almost_equal
It is so neat in pytest!
Mhm
Basil Brush? 
.... I think this is the first time I've seen entirely staff in a public VC
... nevermind
8080 
oh dear dog no
not the GPT
Narrator: frenchy french copied the code
!e
from itertools import batched
for batch in batched(range(60), 4):
print(batch)
@uncut meteor :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ImportError: cannot import name 'batched' from 'itertools' (unknown location)
oh
its 3.12
@olive hedge ^
Learning to be a software developer is a complex and challenging process that requires dedication, hard work, and the right tools and resources. While Minecraft is not directly related to software development, it can be a fun and engaging way to get started with programming and computer science concepts. Additionally,
!steam @lucid blade
!stream @lucid blade
✅ @lucid blade can now stream until <t:1676416858:f>.

purple doggie
Follow the behind the scenes: https://instagram.com/FailFastV0/
Printer Mods and Components
-
My Printer -
Voronv V0.1 Kit: https://s.click.aliexpress.com/e/_9vvluR -
Hotend-
Hotend: https://s.click.aliexpress.com/e/_9zmjbV
Volcano Block: https://s.click.aliexpress.com/e/_A4DgdN
CH...
Griff
is the seller chinese ?
lol
sry i have a work deadline x_x
so does fisher
hi
hi
@wet pine u tryna help me with something small
Hey I just realised I don't have voice yet, give me a moment
It's alright, I think it's because I only joined the server recently, so it's not letting me lol
So I guess I'll type here
no worries
For coding you'll want to use CoPilot
Copilot is free
I think I might have it because I already pay for github, and I'm a student
Copilot is absolutely incredible
@lucid blade It's basically clever google in my books
I work in AI lol
Don't worry
So the thing about ChatGPT is that it's trained on the internet, which is what makes it basically equivalent to Google
@lucid blade Not always OpenCV. OpenCV is a software framework you can use, but it's no longer the sate of the art. The state of the art if I recall correctly is YOLOv3
OpenCV probably includes the YOLO algorithm these days lol
Which year was this then?
That would be 2017 then?
That was around when YOLOv2 was published as a paper I think
Defence Conference?
defcon conference
@lucid blade https://en.wikipedia.org/wiki/DEFCON
The defense readiness condition (DEFCON) is an alert state used by the United States Armed Forces.The DEFCON system was developed by the Joint Chiefs of Staff (JCS) and unified and specified combatant commands. It prescribes five graduated levels of readiness (or states of alert) for the U.S. military. It increases in severity from DEFCON 5 (lea...
DEFCON 1 isn't nuclear annihilation, it means the nukes are ready to go
No, it just means someone can push the button at a moments notice andh ave them launched I thinkl
You can probably work it out from this
This is from wikipedia
"Weather" balloons
@lucid blade I think it's 3 or 4 actually
The issue with going to 2 is you need the logistics in place
Read the definition for 2 very carefully
Launching a missile to test if it works isn't "ready to mobilise in 6 hours"
@lucid blade NK is at a permanent state of war economy. Also I am Chinese lol. I ain't gonna get pissed
I don't worry I hate Chinese people too
@stray bay knows what's up lmao

I can't make out what you're saying lol
Also, it might be cantonese. I only speak mandarin
No idea, in simplified Chinese fuck your mum is 去你娘的
Shove that into google translate lol
@stray bay What it literally means is "go to your mother". What it really means is fuck your mother
Right, I've got to hop off for a bit. It's been good, cheers folks. See you around 🙂
@bronze flare 👋
That was you that just joined and left, yes?
I only saw you(?) for a brief moment.
@latent anchor 👋
Why can I not speak?
Voice verification
Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
Well I am not a troll. How do I unmute lol
makes sense
👍
Okay well that will take awhile
Guys I am new to python and trying to code a simple blackjack script as my first project. Im not sure if I am allowed to ask but if someone can help answer an issue I am having with I would greatly appreciate it.
If not no big deal
the program is sort of large but I can not share can I post snippets in here?
temp in celcius rn?
or images of my code?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
so this link will open my code?
Thank you so much.
Im having three problems but if you could just fix this I would be estatic. My while loop displaying the hands is only running exactly 12 times and then exiting
not exiting but it just prints this line print("Cards already played:")
for cards in selected_cards:
print(cards, end=" ")
print("\nRemaining Shoe:")
for cards in shoe:
print(cards, end=" ")
and then terminates
awesome.
Is it too long? its my first project so I do not know how to do things efficiently
Makes sense.
hard to follow
Would love that
I forgot thats my name
Im sorry whats it called?
type hints
"or if you get it right but not right enough"
depends on IDE/Language Server, tbf
Pyright (Pylance) will argue
PyCharm will probably ignore
Right I was not expecting this blackjack code to take so long but I definitely need to add more notes especially if I think I am going to be sharing it 😆
there's some convention to put >>> in docstrings
does anyone know what is wrong in this
for usage
Okay I have been reading about type hinting since you mentioned it.
Looks like hping3 is taking "flood" and the ip address as 2 arguments. It's expecting 1 argument
still trying to wrap my head around exactly what it is.
@ivory schooner
there are libraries that use annotations to determine what to do with the functions
FastAPI, discord.py (discord.ext.commands)
It also might be taking -1 as an argument?
Yes, I've built applications using FastAPI
basically it takes ip of server and send bulk req
I try to type hint as much as can be done correctly
so, like, even in Jupyter where it does essentially nothing by default
that makes a lot of sense.
there needs to be a mod in the VC for giving temporary streaming permissions
for showing code there's:
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Hm. Try telling chatgpt "I get this error {error_here}". See what the response is
and what did it say?
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
-- was missing before flood that's why I was getting error 😅
there's a link
copy what I or the bot sent
with "py" after the first triple (same line)
Ahh I should've known lol
with highlighting:
from fastapi import FastAPI, Request, Response, Body
from pydantic import BaseModel
from typing import Optional
from OC_Menu import process
from Foodtec import FTcommon
from DD_Images import DDimages
from GH_Images import GHimages
app = FastAPI()
class Restaurant(BaseModel):
DD_Store_Id: int
DD_Menu_Id : int
Cookie : str
Images : Optional[bool]
class GHRestaurant(BaseModel):
storeId : int
bearerToken : str
@app.get("/api/doordash/")
async def getMenu(restaurant : Restaurant, request: Request):
header = request.headers.get('Authorization')
if header == "f741d6a9e8ae4605bb621fd70683e92e":
menuResponse = process(restaurant.DD_Store_Id, restaurant.DD_Menu_Id, restaurant.Cookie, restaurant.Images)
return menuResponse
else:
return Response(status_code=401, content = "Unauthorized")
Your a champ
So I just need to use it once correct?
async def getMenu(restaurant: Restaurant, request: Request) -> Response:
why the hell is "Optional" a keyword in this highlighting
bool | None
same as
Optional[bool]
None can be used in place of NoneType
in typing
it's probably not going to check the type validity on the fields
@cosmic cliff 👋
hello!
@vocal basin in addition to the highlighting of the code block, can you include line numbers?
discord's markdown on its own doesn't provide line numbers, afaik
it does recognise the initial >>>/... as REPL elements
>>> print( \
... [...] \
... )
[Ellipsis]
if you want to f with memory, use Rust instead
!e py s = "()(}[]" for i in range(len(s)-1): for j in range(i+1,len(s)): if s[i].startswith("(") and s[j].endswith(")"): print("true") if s[i].startswith("{") and s[j].endswith("}"): print("true") if s[i].startswith("[") and s[j].endswith("]"): print("true")
@sharp urchin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | true
002 | true
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.```
recursion uses the stack in some form anyway
but it's in The Stack not in the heap
this can print true more than once (as demonstrated by your example)
you're finding all the matching pairs instead of validating the input
!e
s = "((()))"
for i in range(len(s)-1):
for j in range(i+1,len(s)):
if s[i].startswith("(") and s[j].endswith(")"):
print("true")
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | true
002 | true
003 | true
004 | true
005 | true
006 | true
007 | true
008 | true
009 | true
!e py s = "(){}[}" for i in range(len(s)-1): for j in range(i+1,len(s)): if s[i].startswith("(") and s[j].endswith(")"): print("true") if s[i].startswith("{") and s[j].endswith("}"): print("true") if s[i].startswith("[") and s[j].endswith("]"): print("true")
start by solving for () only (without {} and [])
then solve for () and {}
Input: s = "()"
Output: true
Example 2:
Input: s = "()[]{}"
Output: true
Example 3:
Input: s = "(]"
Output: false```
first step:
getting from nothing to ()
second step:
getting from () to (){}
third step (the easiest):
getting from () to (){}[]
() you can solve with constant memory
(){} you can't
!e py s = "()" for i in range(len(s)-1): for j in range(i+1,len(s)): if s[i].startswith("(") and s[j].endswith(")"): print("true") if s[i].startswith("{") and s[j].endswith("}"): print("true") if s[i].startswith("[") and s[j].endswith("]"): print("true")
@sharp urchin :white_check_mark: Your 3.11 eval job has completed with return code 0.
true
In computer science, a stack is an abstract data type that serves as a collection of elements, with two main operations:
Push, which adds an element to the collection, and
Pop, which removes the most recently added element that was not yet removed.Additionally, a peek operation can, without modifying the stack, return the value of the last elem...
In computer science, recursion is a method of solving a computational problem where the solution depends on solutions to smaller instances of the same problem. Recursion solves such recursive problems by using functions that call themselves from within their own code. The approach can be applied to many types of problems, and recursion is one of...
@ivory schooner sorry for the ping
def isValid(self, s: str) -> bool:
for i in range(len(s)-1):
for j in range(i+1,len(s)):
if s[i].startswith("(") and s[j].endswith(")"):
print("true")
if s[i].startswith("{") and s[j].endswith("}"):
print("true")
if s[i].startswith("[") and s[j].endswith("]"):
print("true") ```
( == )
@sharp urchin
is (()(()) a valid sequence?
try to describe how you get the answer to that
without doing that in code, at first
"(" == ")"
s[i].startswith("(") does the same as s[i] == "("
if s[i] == s[i+1]
.
if it does print(bool(Solution().isValid(...))), it will print False always
return
don't print
class Solution:
def isValid(self, s: str) -> bool:
for i in range(len(s)-1):
for j in range(i+1,len(s)):
if s[i].startswith("(") and s[j].endswith(")"):
return True
if s[i].startswith("{") and s[j].endswith("}"):
return True
if s[i].startswith("[") and s[j].endswith("]"):
return True
return False
20-30 minutes so far
yes i understood ...ty
later
the common intuitive solution may come from the following assumptions:
valid + valid gives valid
empty is valid
( + valid + ) is valid
{ + valid + } is valid
[ + valid + ] is valid
or derived from the original description:
every bracket needs a closing one
so each time you see an open one, you put it away until you find a matching closing
fails on (()
@ivory schooner
correctness is more important than optimisation for now
the solution isn't correct
def isValid(self, s: str) -> bool:
stack = []
pMap = {
'}':'{',
']':'[',
')':'('
}
for paren in s:
if paren not in pMap:
stack.append(paren)
continue
else:
if stack and stack[-1] == pMap[paren]:
stack.pop()
else:
return False
return not stack
```
```py
```
. denoting where the algorithm is at:
.(()(())
(.()(())
((.)(())
( . (())
(.(())
((.())
(((.))
(( . )
((.)
( . <nothing>
(.<nothing>
<error>
like, a more visual way to describe how it goes through the string
unnecessary continue
🚀 https://neetcode.io/ - A better way to prepare for Coding Interviews
🐦 Twitter: https://twitter.com/neetcode1
🥷 Discord: https://discord.gg/ddjKRXPqtk
🐮 Support the channel: https://www.patreon.com/NEETcode
Coding Solutions: https://www.youtube.com/playlist?list=PLot-Xpze53leF0FeHz2X0aG3zd0mr1AW_
Dynamic Programming Playlist: https://www.yo...
no, the stack is never ((
)
((
(())
:{}
(everything to the left of the . is the stack)
.()()
(.)()
.()
(.)
.
and to the right is the rest of the string
and for (())
.(())
(.())
((.))
(.)
.
roman number conversions have very weird solutions
I'm looking through my codewars (weird leetcode alternative) solutions
integer to roman, the cursed way
class Solution:
def romanToInt(self, s: str) -> int:
roman_to_integer = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000,
}
s = s.replace("IV", "IIII").replace("IX", "VIIII").replace("XL", "XXXX").replace("XC", "LXXXX").replace("CD", "CCCC").replace("CM", "DCCCC")
return sum(map(lambda x: roman_to_integer[x], s))```
class Solution(object):
def romanToInt(self, s):
dict_of_num = {
'I':1,
'V':5,
'X':10,
'L':50,
'C':100,
'D':500,
'M':1000,
}
n = 0
tmp = dict_of_num[s[0]]
for i in s:
if dict_of_num[i] > tmp:
n += dict_of_num[i] - (2*tmp)
else:
n += dict_of_num[i]
tmp = dict_of_num[i]
return n```
copied from memory, originally saw in a talk by Kevlin Henney
at some point I just started solving beta (preview) problems which give something around no rating at all
gg
seven(times(five())) # must return 35
four(plus(nine())) # must return 13
eight(minus(three())) # must return 5
six(dividedBy(two())) # must return 3
this is actually polymorphism
ad hoc polymorphism
or, like, it seems to be it on the outside
(the proper solution doesn't vary behaviour between zero(something) and zero() much)
:{
would love to look at the solution
cuz i have zero idea on how to solve these
or where to even start with
the thing to realise is that this is Function Programming problem
and things like plus(nine()) are probably going to be functions
the solving route:
should plus(nine()) be enough to determine the result of four(plus(nine())) only based on the number 4?
yes
therefore four can just be responsible to passing that value to its argument, plus(nine())
so the general structure for number(f) is return f(n)
what's left to solve is how to write plus and handle the no argument case
Anybody in chat know about react Dynamic routing and data fetching?
or in call?* 😮
what's the question?
(I didn't work with React specifically but did work with other frameworks and JS/TS in general)
I can join and showcase it. I believe for the behavior to be a little weird.
Essentially I have a tree similar to this
pages
├── types
│ └── [type]
│ ├── index.tsx
│ └── shops
│ └── [id].tsx
Where my [type] can be anything, but for now it is 'FoodTruck', 'Clothes', 'Art'
through utilizing the index.tsx page I am trying to fetch some data using getStaticProps and getStaticPaths
I am not getting any data at this level ;-;
next.js?
I get some from getStaticPaths, but not getStaticProps
yes 🙂
I am using next.js
Would you be willing to take a look? I believe I can stream
oh darn
are you using fetch inside getStaticProps?
is the problem on the development server or on the production server?
you're making a request to some other server responsible for handling API calls, right?
like, a back-end
React's development server should have something for proxying to it
That is correct - I am using Next.js's back-end. (Express?)
direct requests may get blocked by CORS or something
(if you reach to the server by something other than a relative URL with proxy)
getStaticProps gets called but errors, right?
oh, nvm, CORS shouldn't matter
it's server-side
Hey @vital galleon!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
type ExploreMenuProps = {
shops:any
}
export const getStaticPaths = async () => {
const {data} = await get_shops_with_location();
// console.log(data)
const paths = data?.map(item => {
return {
params: {type: item.shopID.toString()}
}
})
// console.log(paths)
return {
paths,
fallback: false
}
}
export const getStaticProps: GetStaticProps = async ( {params: {type}}) => {
console.log(type)
//const id = params.type
const {data} = await get_shops_by_id(id)
return {props: {shopData: data}};
//const { data } = await get_shops_with_location();
// console.log(data)
// return { props: { shops: data } };
};
function Types_Dyn_Menu(props: ExploreMenuProps) {
const [curr_page, setCurrPage] = useState(1)
console.log(props)
const router = useRouter()
const routerType = router.query.type
//Hawkr-blue is #1498
return (
<main className="flex">
<section className="flex-grow h-screen pt-6 px-6 bg-slate-200 overflow-y-auto [&::-webkit-scrollbar]:hidden">
<h1 className=' pb-2 pl-2 font-bold text-gray-600 text-2xl'> {routerType} Hawkrs near me</h1>
<div className="flex flex-col">
{props.shops?.map((item: any) => (
<Link href={`/shops/${item.shopID}`}>
<InfoCard
key={item.shopID}
img={hawkr_icon}
description={item.shopDescription}
title={item.shopName}
/>
</Link>
))}
</div>
<div className="flex flex-col items-center justify-center">
{/* TODO: Set up the links to the set-up hawkr page*/}
<Link href='#' className="text-xl font-medium text-black">Want to run your business?</Link>
<Link href='#'className="text-2xl font-bold text-sky-500">Setup a Hawkr</Link>
</div>
{/* <Pagination curr_page_idx={curr_page} total_items={props.shops.length} */}
{/* items_on_each_page={10} on_page_swith_to={(num)=>setCurrPage(num)}/> */}
</section>
</main>
)
}
function Types_Dyn({ shops }: InferGetStaticPropsType<typeof getStaticProps>) {
let [showOpen, setShowOpen] = useState(true)
return (
<>
{/* <h1> THIS IS A LANDING PAGE</h1> */}
<div className="flex justify-between bg-slate-200">
<Transition className="w-2/5" show={showOpen}
enter='transition-all' enterFrom='opacity-0 w-0' enterTo='opacity-100 w-2/5'
leave='transition-all' leaveFrom='opacity-100 w-2/5' leaveTo='opacity-0 w-0'>
<Types_Dyn_Menu shops={shops} />
</Transition>
<div className='relative grow'>
<button className='absolute z-10 rounded border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm
hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 m-8'
onClick={() => setShowOpen(!showOpen)}>
{showOpen ? <Image width={23} height={23} alt="LeftArrow" src={LeftArrow.src} /> : <div className="flex text-blue-500 text-base"><Image width={20} height={20} alt="RightArrow" src={RightArrow.src} />Show List</div>}
</button>
<Map shops={shops} />
</div>
</div>
</>
)
}
export default Types_Dyn;```
is there a reason to use getStaticProps({params: {type}}) instead of getStaticProps() with no arguments (which is how it's shown in docs)?
I probably wouldn't use type as an identifier in typescript (as to not conflict with the keyword)
paths, as returned from getStaticPaths(), is not null and is not empty, right?
localhost:3000/types/[hawkrType]
at /types:
- I have 3 cards of the 3 types: 'foodTruck', 'clothes', 'art' (This is given through a 'getStaticProps' call to the database to retrieve shops and get their types)
Click on one.
route to /types/[hawkrType]
Need to pull data with shops with that one type.
^ getStaticPaths Pulls shop data. ( able to print)
- getStaticProps does not receive anything or is called at all
export const getStaticPaths = async () => {
return {
paths: [{params: {name: 'test'}}],
fallback: false
};
}
export const getStaticProps: GetStaticProps = async (context) => {
console.log("in getStaticProps", context);
throw Error();
};
I still think the {params: {type}} part looks suspicious
I missed paths:
export const getStaticPaths = async () => {
return {
paths: [{params: {hawkrType: 'FoodTruck'}}],
fallback: false
};
}
export const getStaticProps: GetStaticProps = async (context) => {
console.log("THIS IS THE STATIC PROPS")
console.log(context)
const { data } = await get_shops_with_location();
console.log(data)
return { props: { shops: data } };
};```
Traceback (most recent call last):
File "C:\Users\RYZEN\Desktop\Test-SERVERS\SwenlyTest бот — копия\main.py", line 4, in <module>
from discord_components import DiscordComponents, Button, ButtonStyle, component, interaction
ModuleNotFoundError: No module named 'discord_components'
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
later cruiser! nice hanging with ya
ERROR: Could not find a version that satisfies the requirement discord_components (from versions: none)
ERROR: No matching distribution found for discord_components
help
bitte
why do you have DDOS and DoS in the file path?
Yes, that's just what I called it.
ERROR: Could not find a version that satisfies the requirement discord_components (from versions: none)
ERROR: No matching distribution found for discord_components
Yu, I realized what my main issue was. I feel so dumb lol
The python interpreter you are currently pointing to that is running the code can't find the module
getStaticPaths resides with all the possible paths that the [type] could be in the filepath
That's the issue @whole bear
I was sending it an id and thus the paths I wanted to go into were non-existant
a
Thanks for being patient with me
I am from Ukraine I speak Ukrainian but I communicate with you with the help of an interpreter
what's the purpose of the bot then?
okay, someone's going to get modmail'ed right now
what does this mean?
Good hanging with y'all. I shall now go and focus on some Algorithms study
wish you all the best
if you can prove your project doesn't violate rule 5, I may be able to help with the issue
(otherwise no)
@steady token👋
hello
ilusion *
nice to meet you
do u know how to use the mic here?
Voice verification
Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
kinda hard question
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
sir opal
can you give me a small idea tomorrow? if possible
on making those pictures
using python
the way you gave AF
if possible
no
i wasnt there
only if your free
thanks:}
umm are we going now?
yeh cuz i was actually learning something new as well
:}
im just starting on python and trying to understand LinkedList, do you know it works?
its a bit confusing to me
but why use nods instead of a simple array?
hello @rapid chasm
how did your regular check up go ?
:{}
nicee i am glad to hear tht
:}
oh thanks i think that i understand better now
You can still use linked list structures in Python for the right use cases.
acctualy i was trying to solve a problem in letscode
leetcode*
vodka? really?
reversing the linked list?
one?
merge two sorted list
ohhk
are you creating a bot or using one tha already exists? @rapid chasm
maybe you can ask to chatgpt do that bot too
i know, its good to help but not to do everything
do you already work with python?
or just studying
hello @jolly radish
playing Fortnite
great game
It is difficult to tell if the Pythonians want to hear my life story
I tend to comment on the game or talk about my life
I don't want to make you non-comfy
gr8 idea
TLRD; some stuff happened and I have to take meds again and be nice
i have no ideia @rapid chasm
do I want to be nice? debatable
brb
@muted geyser 👋
🙂
hello im back
🥵
sup all
@cerulean ridge hello
hello sir hemlock
midnighty
for me is Morning
Australia is the only country that Energy
in Brazil its 11 am
my paren'ts doesn't allow me to ride the bus
@rapid chasm also we have a timegap of 4hrs arnd only
so not a prblm with me
:}
BEER, can we have a word for the project? in another vc for a min or so ...if yes then ping me:}
bye bye
hello @somber heath
Yo
Whose got two thumbs is Mr. Hemlock?
Sounds right
I relate to that- I mean what?
"Oh no"
"Well, shit"
@cerulean ridge Suuuuppppppppp
@chrome pewter How's it going
Dude, come on.... So there's this thing that we have to do: https://support.8x8.com/cloud-phone-service/voice/work-sms/SMS_Campaign_Registration_and_Impact?mkt_tok=NTc2LUdZQy01MDAAAAGJ6rTkbNQzUuj_qoVS_tjpwcNENYOonei-poC3wCB0HgXeoOv2Kv4lafv7J7rew2ykHmlZysAbFXk0Wr6AM_VpZ2yyyCOpIeEnOiGFxa5SSDg9-gk
@lavish rover Ahhh?
Ahhh okay
Wasn't so much a scream as much as a like... Someone trying to imitate a crow
"CAW"
And neither I nor the office manager have the proper permissions to do this. Because stupid
So I have to contact our MSP
Which is irritating
It should just be me clicking a button
But noooooooooooo
The permissions aren't set up right
it is going well
sorry for late reply
I was busy doing something else
No worries
I legit just stood here for 2 mins because I forgot which way it is to work
I'm so sleepy.depribed
Your body rejected the idea
I've slept 4 hours
Why?
Just couldn't sleep
Fair
brain kept running at a million miles an hour
Call me obtuse, but I don't get it.
I mean, it's like, symbol, symbol, Roman numerals, lemons, x, actual joke but it's in demonese.
I'm alright I think
Looks like he's got dog ears
Global not local?
Mkay
Yeah yeah
I do use that analogy a lot
@half flare Sup
OH
Did you see the one with Ron Jeremy with that?
It's so funny
If you're unsure, don't trust me it
any possible way we can figure out?
still?
i trust no one
then what shall i do?
um idk
if a frnd randomly sends me
There's also link checkers that follow the path checking for viruses
a link
it works?
