• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:20
CEST 10:20
KST 17:20
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL, and the Limitations of Standard Play1Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12TL.net Map Contest #22 - Voting & Ladder Map Selection7Code S Season 2 (2026) - RO8 Preview8
Community News
[TLMC] Summer 2026 Ladder Map Rotation05.0.16 patch for SC2 goes live (8 worker start)65ZeroSpace at Steam NextFest - Last free demo31Weekly Cups (June 8-14): Clem and Solar double, PTR tested0RSL: S6 Finals played at BlizzCon 202611
StarCraft 2
General
Mizenhauer's Douyu Cup Preview Is the larve respawn broken? 5.0.16 patch for SC2 goes live (8 worker start) ByuL, and the Limitations of Standard Play Possible bug in the new patch?
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Douyu Cup 2026: $20,000 Legends Event (June 26-28) INu's Battles#17 <BO.9> Sparkling Tuna Cup - Weekly Open Tournament GSL CK #4 20-21th June
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 531 Experimental Artillery Mutation # 530 One For All Mutation # 529 Opportunities Unleashed
Brood War
General
vespene.gg — BW replays in browser Quality of life changes in BW that you will like ? ASL 22 Proposed Map Pool BW General Discussion [BSL22] Non-Korean Championship from 13 to 28 June
Tourneys
[ASL21] Grand Finals [Megathread] Daily Proleagues The Casual Games of the Week Thread [BSL22] GosuLeague Casts - Tue & Thu 22:00 CEST
Strategy
Creating a full chart of Zerg builds Relatively freeroll strategies Why doesn't anyone use restoration? Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Beyond All Reason Nintendo Switch Thread ZeroSpace at Steam NextFest - Last free demo
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread [H]Internet/Gaming Cafe Tips and Tricks
Fan Clubs
The HerO Fan Club! The herO Fan Club!
Media & Entertainment
Movie Discussion! Series you have seen recently... [Req][Books] Good Fantasy/SciFi books [TV/BOOK] *SPOILERS* Game of Thrones Discussion
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 McBoner: A hockey love story Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Facing Challenges in Mobile App Development
TL Community
The Automated Ban List
Blogs
Listen To The Coaches!
TrAiDoS
An Exploration of th…
waywardstrategy
I'm an arrogant trash talke…
FlaShFTW
Gauntlet SC2: A Retrospectiv…
Ctone23
Customize Sidebar...

Website Feedback

Closed Threads



Active: 6754 users

The Big Programming Thread - Page 995

Forum Index > General Forum
Post a Reply
Prev 1 993 994 995 996 997 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17774 Posts
Last Edited: 2019-02-09 08:00:17
February 09 2019 07:59 GMT
#19881
If you need a list of primes you can always generate them yourself...


"""Returns True if n is prime."""
def isprime(n):
if n <= 3 and n > 1:
return True

if n % 2 == 0 or n % 3 == 0:
return False

i = 5
w = 2

while i * i <= n:
if n % i == 0:
return False

i += w
w = 6 - w

return True
Time is precious. Waste it wisely.
Acrofales
Profile Joined August 2010
Spain18330 Posts
February 09 2019 08:58 GMT
#19882
Why would you do that?
mahrgell
Profile Blog Joined December 2009
Germany3943 Posts
February 09 2019 10:09 GMT
#19883
Because coders pride. Why use an existing list of primes, when you can write (a highly inefficient) algorithm to make one?

In fact, why not be cool and impress anyone who later reads this code, by using the regexp ^.?$|^(..+?)\1+$ as prime checker?
I'm sure they will all bow to your skills! (and hopefully never have to run the code)
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
February 09 2019 10:41 GMT
#19884
On February 09 2019 16:59 Manit0u wrote:
If you need a list of primes you can always generate them yourself...

+ Show Spoiler +

"""Returns True if n is prime."""
def isprime(n):
if n <= 3 and n > 1:
return True

if n % 2 == 0 or n % 3 == 0:
return False

i = 5
w = 2

while i * i <= n:
if n % i == 0:
return False

i += w
w = 6 - w

return True

thats a yikes
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 09 2019 13:28 GMT
#19885
coder's pride lol I love it
SC-Shield
Profile Joined December 2018
Bulgaria862 Posts
February 10 2019 19:08 GMT
#19886
On February 09 2019 19:09 mahrgell wrote:
Because coders pride. Why use an existing list of primes, when you can write (a highly inefficient) algorithm to make one?

In fact, why not be cool and impress anyone who later reads this code, by using the regexp ^.?$|^(..+?)\1+$ as prime checker?
I'm sure they will all bow to your skills! (and hopefully never have to run the code)


It's probably human mentality. Why pay a handyman when you can do it yourself even if it's done really bad? Easily noticeable if you rent a property and you deal with landlord directly. :D
graNite
Profile Blog Joined December 2010
Germany4434 Posts
February 10 2019 23:38 GMT
#19887
can i simplify this somehow? i feel like this should be able to be done with only one height_at call.
i want to get a set of all points that have the maximum height.
max_height = max(self.height_at(p) for p in self._points) 
return {p for p in self._points if self.height_at(p) == max_height}
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
Frolossus
Profile Joined February 2010
United States4779 Posts
February 10 2019 23:57 GMT
#19888
On February 11 2019 08:38 graNite wrote:
can i simplify this somehow? i feel like this should be able to be done with only one height_at call.
i want to get a set of all points that have the maximum height.
max_height = max(self.height_at(p) for p in self._points) 
return {p for p in self._points if self.height_at(p) == max_height}

do 1 loop and bind self.height(p) to a temp variable?
graNite
Profile Blog Joined December 2010
Germany4434 Posts
Last Edited: 2019-02-11 00:25:25
February 11 2019 00:22 GMT
#19889
do you mean like this?
current_max = 0
result = set()
for p in self._points:
height = self.height_at(p)
if height < current_max:
continue
elif height == current_max:
result.append(p)
else:
current_max = height
result = {p}
return result


i dont know if this is faster...i would like to use a set comprehension
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
Acrofales
Profile Joined August 2010
Spain18330 Posts
Last Edited: 2019-02-11 00:31:38
February 11 2019 00:26 GMT
#19890
On February 11 2019 08:57 Frolossus wrote:
Show nested quote +
On February 11 2019 08:38 graNite wrote:
can i simplify this somehow? i feel like this should be able to be done with only one height_at call.
i want to get a set of all points that have the maximum height.
max_height = max(self.height_at(p) for p in self._points) 
return {p for p in self._points if self.height_at(p) == max_height}

do 1 loop and bind self.height(p) to a temp variable?

E: nvm, misunderstood the question. You could do it in a single loop if you wanted, but it would be more complex, not simpler. You could make a map from heights to lists of points. That way you only loop once, but I doubt it's much faster (you have to construct the dict).
Artesimo
Profile Joined February 2015
Germany573 Posts
February 11 2019 00:46 GMT
#19891
I am trying to help a friend with a project regarding audio files and volume, regarding .wav files to be precise. He wants to make a soundmod for a game but the problem is that the original and the added files have different base volumes. Generally speaking I know how to normalize / amplify sounds using audacity, however this has some problems.

The amount of files make it hard to do this by hand. I know that there are ways to batchprocess files with audacity but here comes another problem:
We aren’t sure if all the original and additional .wavs are similar in terms of volume which got me thinking. The base volume has to be encoded in some way right? Therefore there should be a way to read out this base volume? I am looking for a way to just check how "loud" the basevolume of all the files is and deduct from that how much the added sounds need to be amplified with maybe some individual adjustment rather than adjusting every sound by hand. Does anyone has experience with this or can share some insight how the encoding of the volume actually works?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-02-11 01:24:57
February 11 2019 01:19 GMT
#19892
On February 11 2019 08:38 graNite wrote:
can i simplify this somehow? i feel like this should be able to be done with only one height_at call.
i want to get a set of all points that have the maximum height.
max_height = max(self.height_at(p) for p in self._points) 
return {p for p in self._points if self.height_at(p) == max_height}


its impossible to do it in a comprehension because a comprehension only does one loop through but you can't know what the max is until you've gone through all elements, and there is no way to go back and change what you have already added to the comprehension

well, I mean you can, but then you end up asking what the max height is for every single element, and you obviously don't want to do that


On February 11 2019 09:22 graNite wrote:
do you mean like this?
current_max = 0
result = set()
for p in self._points:
height = self.height_at(p)
if height < current_max:
continue
elif height == current_max:
result.append(p)
else:
current_max = height
result = {p}
return result


i dont know if this is faster...i would like to use a set comprehension



this is probably faster
what would be even better is to have a Max variable for whatever this object is
graNite
Profile Blog Joined December 2010
Germany4434 Posts
February 11 2019 01:45 GMT
#19893
What do you mean by Max variable? Do you mean an upper bound?

The object is the height map the sc2 api provides. This is for the Python-sc2 library.
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-02-11 02:02:18
February 11 2019 01:57 GMT
#19894
i meant if the object that has these points maintained the value of the "highest point" as a max, so that you don't have to look through all the points to find it

I've used python-sc2 a little, but not much
can I ask what are you trying to do?


you are editing the api?
graNite
Profile Blog Joined December 2010
Germany4434 Posts
February 11 2019 02:08 GMT
#19895
Yes, i thought i can improve here https://github.com/Dentosal/python-sc2/blob/1ccc1eae2e181e939aa8b6060d2014b40916f0c4/sc2/game_info.py#L39
And the 'lower' property which is the same but with minimum.
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
February 11 2019 02:14 GMT
#19896
yeah you won't be able to make it faster in one line of code I think, a comprehension will call a function on every iteration
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
February 11 2019 09:03 GMT
#19897
On February 11 2019 09:46 Artesimo wrote:
I am trying to help a friend with a project regarding audio files and volume, regarding .wav files to be precise. He wants to make a soundmod for a game but the problem is that the original and the added files have different base volumes. Generally speaking I know how to normalize / amplify sounds using audacity, however this has some problems.

The amount of files make it hard to do this by hand. I know that there are ways to batchprocess files with audacity but here comes another problem:
We aren’t sure if all the original and additional .wavs are similar in terms of volume which got me thinking. The base volume has to be encoded in some way right? Therefore there should be a way to read out this base volume? I am looking for a way to just check how "loud" the basevolume of all the files is and deduct from that how much the added sounds need to be amplified with maybe some individual adjustment rather than adjusting every sound by hand. Does anyone has experience with this or can share some insight how the encoding of the volume actually works?


I don't know anything about audio, but I would start by reading up on this: https://stackoverflow.com/questions/984729/how-can-i-determine-how-loud-a-wav-file-will-sound

Any calculations can be easily done with a for loop in Python once you have the procedure down.
TRUEESPORTS || your days as a respected member of team liquid are over
graNite
Profile Blog Joined December 2010
Germany4434 Posts
Last Edited: 2019-02-11 09:09:10
February 11 2019 09:08 GMT
#19898
On February 11 2019 11:14 travis wrote:
yeah you won't be able to make it faster in one line of code I think, a comprehension will call a function on every iteration


you are right
i use the one loop solution above now, it is almost twice as fast.
"Oink oink, bitches" - Tasteless on Pigbaby winning a map against Flash
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2019-02-11 17:30:20
February 11 2019 17:10 GMT
#19899
On February 09 2019 03:39 travis wrote:
edit:

nevermind found what I wanted. which was a list of primes. I found the first 50 million, geeze. probably morethan I need

You can generate all prime numbers up to 10^9 in less than 30 seconds on an average work station using sieve of eratosthenes: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes. It's about 50.8 million primes.

public class PrimeSieve {
private bool[] _notPrimes;
private List<ulong> _primes = new List<ulong>();

public PrimeSieve(ulong max) {
SievePrimes(max);
}

private void SievePrimes(ulong max) {
_notPrimes = new bool[max / 2 + 1];
_primes.Add(2);
for (ulong num = 3; num <= max; num += 2) {
if (!_notPrimes[num / 2 - 1]) {
_primes.Add(num);
for (ulong composite = 3; composite * num <= max; composite += 2) {
_notPrimes[composite * num / 2 - 1] = true;
}
}
}
}

public bool IsPrime(ulong num) {
if (num <= 1) {
return false;
} else if (num == 2) {
return true;
} else if (num % 2 == 0) {
return false;
} else {
return !_notPrimes[num / 2 - 1];
}
}

public int Count {
get { return _primes.Count; }
}

public IEnumerable<ulong> Enumerate {
get { return _primes; }
}
}
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 13 2019 19:29 GMT
#19900
Anyone here a regular on Project Euler? Would like to add as friend so I can occasionally ask for advice.
Prev 1 993 994 995 996 997 1032 Next
Please log in or register to reply.
Live Events Refresh
Douyu Cup 2020
05:00
2026 - Day 2
Neeb vs Impact
MacSed vs Cyan
Scarlett vs Kelazhur
INnoVation vs Dear
WardiTV585
CranKy Ducklings150
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Ryung 869
ProTech133
StateSC2 87
StarCraft: Brood War
ToSsGirL 59
Dewaltoss 54
Sharp 53
Soma 37
ZergMaN 32
Hm[arnc] 30
yabsab 14
NotJumperer 8
Dota 2
BananaSlamJamma80
League of Legends
JimRising 604
Other Games
ceh9532
Mew2King114
RuFF_SC249
Organizations
Dota 2
PGL Dota 2 - Main Stream2712
Other Games
gamesdonequick804
StarCraft: Brood War
UltimateBattle 93
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• 3DClanTV 114
• Berry_CruncH101
• CranKy Ducklings SOOP23
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1410
• Stunt464
Upcoming Events
Big Brain Bouts
7h 40m
Jumy vs eGGz
Harstem vs sebesdes
TriGGeR vs HeRoMaRinE
Douyu Cup 2020
20h 40m
Maestros of the Game
1d 4h
herO vs Classic
Maru vs Serral
BSL22 NKC (BSL vs China)
1d 5h
Douyu Cup 2020
1d 20h
BSL22 NKC (BSL vs China)
2 days
Online Event
2 days
RSL Revival
2 days
WardiTV Weekly
3 days
RSL Revival
4 days
[ Show More ]
RSL Revival
4 days
Bombastic Starleague
4 days
Kung Fu Cup
5 days
OSC
5 days
CrankTV Team League
6 days
Bombastic Starleague
6 days
Replay Cast
6 days
Liquipedia Results

Completed

CSCL: Masked Kings S4
WardiTV Spring 2026
Heroes Pulsing #2

Ongoing

IPSL Spring 2026
Acropolis #4
YSL S3
BSL 22 Non-Korean Championship
CSL Season 21: Qualifier 1
CSL Season 21: Qualifier 2
SCTL 2026 Spring
Douyu Cup 2026
Maestros of the Game 2
Murky Cup 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026

Upcoming

CSL 2026 Summer (S21)
CSLAN 4
Blizzard Classic Cup 2026
Kung Fu Cup 2026 Grand Finals
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
HSC XXIX
BCC 2026
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E1
Heroes Pulsing #3
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.