• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 09:39
CET 15:39
KST 23:39
  • 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
Rongyi Cup S3 - RO16 Preview3herO wins SC2 All-Star Invitational10SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)20Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
PhD study /w SC2 - help with a survey! Oliveira Would Have Returned If EWC Continued StarCraft 2 not at the Esports World Cup 2026 [Short Story] The Last GSL Stellar Fest "01" Jersey Charity Auction
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Fantasy's Q&A video [ASL21] Potential Map Candidates BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues Azhi's Colosseum - Season 2 Small VOD Thread 2.0 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
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 Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
How Esports Advertising Shap…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1436 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
Poland17616 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
Spain18198 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
Bulgaria836 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
Spain18198 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
Germany567 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
OSC
13:00
King of the Hill #235
SteadfastSC147
iHatsuTV 10
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 123
Rex 115
Creator 67
MindelVK 6
StarCraft: Brood War
Rain 12087
firebathero 3763
Shuttle 1147
Jaedong 989
Larva 676
Horang2 675
Mini 608
EffOrt 472
Hyuk 370
BeSt 279
[ Show more ]
Zeus 173
Last 143
Soulkey 132
hero 124
Sharp 101
sorry 84
Sea.KH 74
Hyun 71
Hm[arnc] 70
Mind 42
Yoon 37
Backho 34
zelot 28
910 27
ToSsGirL 25
yabsab 23
Noble 17
scan(afreeca) 15
Shinee 14
Shine 14
ZergMaN 13
Bale 11
Terrorterran 8
Icarus 6
eros_byul 1
Stormgate
BeoMulf52
Dota 2
qojqva2392
canceldota79
Counter-Strike
byalli452
edward146
Super Smash Bros
Mew2King43
Heroes of the Storm
Khaldor313
Other Games
B2W.Neo2260
singsing2089
Hui .280
Sick157
crisheroes147
XaKoH 132
KnowMe30
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• Adnapsc2 10
• Kozan
• Laughngamez YouTube
• AfreecaTV YouTube
• sooper7s
• Migwel
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• blackmanpl 41
• Michael_bg 5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 4455
League of Legends
• Jankos4161
• TFBlade934
• Stunt524
Upcoming Events
BSL 21
21m
QiaoGege vs Sziky
Dewalt vs Bonyth
Mihu vs TBD
Replay Cast
9h 21m
Replay Cast
18h 21m
RongYI Cup
20h 21m
Maru vs Cyan
Solar vs Krystianer
uThermal 2v2 Circuit
21h 21m
BSL 21
1d
Replay Cast
1d 9h
Wardi Open
1d 23h
Monday Night Weeklies
2 days
OSC
2 days
[ Show More ]
WardiTV Invitational
2 days
WardiTV Invitational
3 days
The PondCast
4 days
Korean StarCraft League
6 days
Liquipedia Results

Completed

Escore Tournament S1: W5
OSC Championship Season 13
NA Kuram Kup

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Rongyi Cup S3
Underdog Cup #3
Tektek Cup #1
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025

Upcoming

Acropolis #4 - TS4
Escore Tournament S1: W6
Escore Tournament S1: W7
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 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.