• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:21
CEST 21:21
KST 04:21
  • 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
Code S Season 1 (2026) - RO4 & Finals Preview5[ASL21] Ro4 Preview: On Course12Code S Season 1 - RO8 Preview7[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13
Community News
Weekly Cups (May 11-17): Classic wins double0Code S Season 1 (2026) - RO8 Results2Weekly Cups (May 4-10): Clem, MaxPax, herO win1Maestros of The Game 2 announcement and schedule !18Weekly Cups (April 27-May 4): Clem takes triple0
StarCraft 2
General
herO wins GSL Code S Season 1 (2026) Weekly Cups (May 11-17): Classic wins double Code S Season 1 (2026) - RO4 & Finals Preview Team Liquid Map Contest #22 - The Finalists Code S Season 1 (2026) - RO8 Results
Tourneys
Maestros of The Game 2 announcement and schedule ! $1,400 SEL Season 3 Ladder Invitational GSL Code S Season 2 (2026) GSL Code S Season 1 (2026) $5,000 WardiTV Spring Championship 2026
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
The PondCast: SC2 News & Results Mutation # 526 Rubber and Glue Mutation # 525 Wheel of Misfortune Mutation # 524 Death and Taxes
Brood War
General
Lights Ro.8 Review (asl s21) 25 Years Since Brood War Patch 1.08 vespene.gg — BW replays in browser BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion
Tourneys
[ASL21] Semifinals B [BSL22] RO8 Bracket Stage + Another TieBreaker [ASL21] Ro8 Day 4 Escore Tournament StarCraft Season 2
Strategy
Muta micro map competition Fighting Spirit mining rates [G] Hydra ZvZ: An Introduction Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Warcraft III: The Frozen Throne ZeroSpace Megathread War of Dots, 2026 minimalst RTS Nintendo Switch Thread
Dota 2
The Story of Wings Gaming
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 TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread YouTube Thread Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
ETHEREUM RECOVERY ASSISTANCE streaming software Strange computer issues (software)
TL Community
The Automated Ban List
Blogs
Why RTS gamers make better f…
gosubay
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1889 users

The Big Programming Thread - Page 911

Forum Index > General Forum
Post a Reply
Prev 1 909 910 911 912 913 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
Poland17745 Posts
Last Edited: 2017-10-21 11:00:15
October 21 2017 10:59 GMT
#18201
On October 21 2017 01:43 travis wrote:
zigg, like your idea, that makes sense
hanh, i took a glance. I'll look at it a bit closer at some of the algorithms for that and see if I can apply them.

Show nested quote +
On October 20 2017 21:15 Manit0u wrote:
Just remove all 1's that are adjacent to 2's and then remove the 2's?

Edit:
Simpler yet:
1. Find all 2's
2. Make an adjacency list for 2's (ignoring duplicates) which is dead simple for 2d array
3. Profit!


I don't understand your first suggestion.

For the 2nd suggestion, you are saying to
1.) put each 2_location[x][y] into a list
2.) then for each element of the list create a sublist of each adjacent_1_location[x][y]
3.) and then for the next iteration I can just repeat for the elements in the sublist?
4.) repeat 2 and 3 until I am done?

Is this correct? If so, I really like this. And you'd probably mean for me to avoid adding the same adjacent_1_location[x][y] into 2 different sublists, but actually, because of the nature of what I am trying to do with this problem it is actually solving a future problem for me to just put them in there anyways. Long term I was going to need to do math based on the relationship of every square of ring 2 that touches any given square of ring 1. So this is PERFECT for that.


Here's how to do it step by step:

1. Note the location of all 2's (x, y).
2. Note the location of all elements adjacent to those 2's (we don't care if it's 0, 1, 2).
3. Set all those locations to 0.

Example:

1 1 1 1
1 1 2 1
1 2 2 1
1 1 1 1

grid_size = 4
loc_2 = [ [1, 2], [2, 1], [2, 2] ]

def find_adjacent_to(coords)
adj = []

adj << [ coords[0], coords[1] - 1] if coords[1] > 0 # left
adj << [ coords[0], coords[1] + 1] if coords[1] < grid_size # right
adj << [ coords[0 - 1], coords[1]] if coords[0] > 0 # top
adj << [ coords[0] + 1, coords[1]] if coords[0] < grid_size # bottom

adj
end

# all cells of interest are loc_2 + find_adjacent for each loc_2


This is pretty naive example but it gives you every single cell you need to work with by traversing the grid just once (to find the 2's).
All you're working with later is a specific set of coordinates being just a subset of the grid, which makes your work that much easier.

On October 21 2017 04:55 spinesheath wrote:
I'm reading your solution as
^$|^b*(ab)*b*(a?)$
Is that right? Not sure what those dots below the stars mean here.
Anyways, my counterexample would be:
abbbabbbab

Reason: you only allow a single occurrence of the a - many b's - a pattern. The NFA allows an arbitrary number of those by going 100010001000...

My solution:
^(b*(ab)*)*(a?)$

Also you shouldn't need to explicitly have the epsilon case when everything in your regex is optional.


This is not in line with what he stated earlier in the question. Travis marked "ababb" as acceptable and this will fail on such expression (you can't start with "a").

Here's a proper regexp for that:

^(?:(?!aa)[ab])+$
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-10-21 13:29:53
October 21 2017 13:29 GMT
#18202
I am not familiar with the "?:" "?:". Is this language specific ?
But I think spinesheath's solution actually does work

for ababb he sees

(b*(ab*))

which he uses to construct abab

but outside of (b*(ab)*) we have another * (you may have missed this)

so we run through again (b*(ab)*) again to get our final b

and then have ababb
Hanh
Profile Joined June 2016
146 Posts
October 21 2017 13:50 GMT
#18203
How about

(b|ab)*a?


Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
October 21 2017 14:43 GMT
#18204
yeah, I think that is the most concise version.
Manit0u
Profile Blog Joined August 2004
Poland17745 Posts
October 21 2017 15:25 GMT
#18205
On October 21 2017 22:29 travis wrote:
I am not familiar with the "?:" "?:". Is this language specific ?
But I think spinesheath's solution actually does work

for ababb he sees

(b*(ab*))

which he uses to construct abab

but outside of (b*(ab)*) we have another * (you may have missed this)

so we run through again (b*(ab)*) again to get our final b

and then have ababb


"?:" is a non-capturing group in the regex (when you want to know if it matches but don't care about the result). "?!" is negative look ahead (in the regex I posted it allows any combination of letters "a" and "b" as long as there are no 2+ letters "a" adjacent to each other).
Time is precious. Waste it wisely.
Hanh
Profile Joined June 2016
146 Posts
October 22 2017 02:25 GMT
#18206
No offence but
^(?:(?!aa)[ab])+$
...

1. it is not obvious why it should be equivalent to the NFA,
2. in fact it is not equivalent, the empty string is acceptable in the NFA but not in the regex,
3. it uses uncommon regex features, the ?! part
4. it does things that are not required: nothing about capturing group was mentioned in the question
5. the ?! has performance issue because of the lookahead backtrack
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2017-10-22 07:17:46
October 22 2017 07:14 GMT
#18207
On October 21 2017 19:59 Manit0u wrote:
Show nested quote +
On October 21 2017 04:55 spinesheath wrote:
I'm reading your solution as
^$|^b*(ab)*b*(a?)$
Is that right? Not sure what those dots below the stars mean here.
Anyways, my counterexample would be:
abbbabbbab

Reason: you only allow a single occurrence of the a - many b's - a pattern. The NFA allows an arbitrary number of those by going 100010001000...

My solution:
^(b*(ab)*)*(a?)$

Also you shouldn't need to explicitly have the epsilon case when everything in your regex is optional.


This is not in line with what he stated earlier in the question. Travis marked "ababb" as acceptable and this will fail on such expression (you can't start with "a").

Here's a proper regexp for that:

^(?:(?!aa)[ab])+$

I fail to see why my regex wouldn't match ababb. Especially since an online regex tester confirms it does.
I'm fairly confident that stuff like negative lookahead is not really a topic in university at that level (or any level at all). As far as I know it is not part of the formal definition of regex.

Also I need to play more regex golf. (b|ab)*a? is so clean and honestly, it should have been obvious.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17745 Posts
October 23 2017 06:06 GMT
#18208
On October 22 2017 11:25 Hanh wrote:
No offence but
^(?:(?!aa)[ab])+$
...

1. it is not obvious why it should be equivalent to the NFA,
2. in fact it is not equivalent, the empty string is acceptable in the NFA but not in the regex,
3. it uses uncommon regex features, the ?! part
4. it does things that are not required: nothing about capturing group was mentioned in the question
5. the ?! has performance issue because of the lookahead backtrack


Haha, yeah. I'm way over my head with regexes lately. Still trying to figure out the best way to validate allowed path and filenames on Windows with it without much success, there's so many conditions that I keep running into catastrophic backtrace with strings that are > 12 characters long and have failing condition at the end.

On October 22 2017 16:14 spinesheath wrote:
Show nested quote +
On October 21 2017 19:59 Manit0u wrote:
On October 21 2017 04:55 spinesheath wrote:
I'm reading your solution as
^$|^b*(ab)*b*(a?)$
Is that right? Not sure what those dots below the stars mean here.
Anyways, my counterexample would be:
abbbabbbab

Reason: you only allow a single occurrence of the a - many b's - a pattern. The NFA allows an arbitrary number of those by going 100010001000...

My solution:
^(b*(ab)*)*(a?)$

Also you shouldn't need to explicitly have the epsilon case when everything in your regex is optional.


This is not in line with what he stated earlier in the question. Travis marked "ababb" as acceptable and this will fail on such expression (you can't start with "a").

Here's a proper regexp for that:

^(?:(?!aa)[ab])+$

I fail to see why my regex wouldn't match ababb. Especially since an online regex tester confirms it does.
I'm fairly confident that stuff like negative lookahead is not really a topic in university at that level (or any level at all). As far as I know it is not part of the formal definition of regex.

Also I need to play more regex golf. (b|ab)*a? is so clean and honestly, it should have been obvious.


The problem with this regex is that it allows multiples of "a" in succession (and I thought the goal was not to allow them).
Time is precious. Waste it wisely.
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 23 2017 08:36 GMT
#18209
Is it possible with cmake to have multiple independant executables with different names? I have a folder of very small files where I like to try things out (think less then 1k loc) and I'd really like to not have to organise this disaster.
Hanh
Profile Joined June 2016
146 Posts
Last Edited: 2017-10-23 08:40:55
October 23 2017 08:40 GMT
#18210
On October 23 2017 15:06 Manit0u wrote:
The problem with this regex is that it allows multiples of "a" in succession (and I thought the goal was not to allow them).


Hmm ... no it doesn't... Besides, the goal is not to avoid multiple "a" in succession but to translate the NFA.


Acrofales
Profile Joined August 2010
Spain18292 Posts
October 23 2017 17:17 GMT
#18211
On October 23 2017 17:40 Hanh wrote:
Show nested quote +
On October 23 2017 15:06 Manit0u wrote:
The problem with this regex is that it allows multiples of "a" in succession (and I thought the goal was not to allow them).


Hmm ... no it doesn't... Besides, the goal is not to avoid multiple "a" in succession but to translate the NFA.



Well, the NFA doesn't allow multiple "a"s in succession...

Anyway, spinesheath got by far the most elegant solution (and it was really obvious). I was wondering where the hell you guys found the problem, but I just figured out that travis had an image link that I had clicked on, but didn't open properly on my phone.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 23 2017 17:38 GMT
#18212
On October 24 2017 02:17 Acrofales wrote:
Show nested quote +
On October 23 2017 17:40 Hanh wrote:
On October 23 2017 15:06 Manit0u wrote:
The problem with this regex is that it allows multiples of "a" in succession (and I thought the goal was not to allow them).


Hmm ... no it doesn't... Besides, the goal is not to avoid multiple "a" in succession but to translate the NFA.



Well, the NFA doesn't allow multiple "a"s in succession...

Anyway, spinesheath got by far the most elegant solution (and it was really obvious). I was wondering where the hell you guys found the problem, but I just figured out that travis had an image link that I had clicked on, but didn't open properly on my phone.

Whoa hold it. That's Hanh's solution.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-10-23 18:02:35
October 23 2017 18:02 GMT
#18213
On October 23 2017 17:36 bo1b wrote:
Is it possible with cmake to have multiple independant executables with different names? I have a folder of very small files where I like to try things out (think less then 1k loc) and I'd really like to not have to organise this disaster.



add_executable(exec_a a1.c a2.c)
add_executable(exec_b b1.c b2.c)


?
There is no one like you in the universe.
LG)Sabbath
Profile Blog Joined July 2005
Argentina3024 Posts
October 23 2017 23:52 GMT
#18214
On October 16 2017 18:14 Manit0u wrote:
https://api-platform.com/

Fucken amazing!

https://github.com/docker/dockercraft

This is too much...

After reading the intro, still not sure what that framework is like. The intro is basically a docker-compose + doctrine tutorial.
https://www.twitch.tv/argsabbath/
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 24 2017 07:20 GMT
#18215
On October 24 2017 03:02 Blisse wrote:
Show nested quote +
On October 23 2017 17:36 bo1b wrote:
Is it possible with cmake to have multiple independant executables with different names? I have a folder of very small files where I like to try things out (think less then 1k loc) and I'd really like to not have to organise this disaster.



add_executable(exec_a a1.c a2.c)
add_executable(exec_b b1.c b2.c)


?

I tried doing something similar and had an error come up. Tried doing it again and it works. :\ I feel a little silly now lol.
Silvanel
Profile Blog Joined March 2003
Poland4756 Posts
October 24 2017 14:50 GMT
#18216
Does anyone have experience with PyQt exit codes? I am running PyQt5 and python 3.6.2 and my app crashes with some exit codes like: "Process finished with exit code 3" not usual python traceback info. This makes it really hard to debug since i cant find any explantion for those codes.

I think this is PyQt thing and the only solution i found on net is overwriting exeption handler.
Any ideas?
Pathetic Greta hater.
Acrofales
Profile Joined August 2010
Spain18292 Posts
October 24 2017 19:16 GMT
#18217
Don't use PyQT, but seems this is relevant: https://stackoverflow.com/questions/33736819/pyqt-no-error-msg-traceback-on-exit

Have you tried just putting your entire script between try catch and printing the exception and callback? Reading this seems like PyQT treats this as a last resource if the exception isn't being handled, and exits with an information-less error code.
Manit0u
Profile Blog Joined August 2004
Poland17745 Posts
October 25 2017 04:59 GMT
#18218
On October 24 2017 08:52 LG)Sabbath wrote:
Show nested quote +
On October 16 2017 18:14 Manit0u wrote:
https://api-platform.com/

Fucken amazing!

https://github.com/docker/dockercraft

This is too much...

After reading the intro, still not sure what that framework is like. The intro is basically a docker-compose + doctrine tutorial.


It's pretty much Symfony in API-only mode
Time is precious. Waste it wisely.
Silvanel
Profile Blog Joined March 2003
Poland4756 Posts
Last Edited: 2017-10-25 07:31:49
October 25 2017 07:30 GMT
#18219
On October 25 2017 04:16 Acrofales wrote:
Don't use PyQT, but seems this is relevant: https://stackoverflow.com/questions/33736819/pyqt-no-error-msg-traceback-on-exit

Have you tried just putting your entire script between try catch and printing the exception and callback? Reading this seems like PyQT treats this as a last resource if the exception isn't being handled, and exits with an information-less error code.


Yeah i found this also. I think i will try to run line by line and if that doesnt help try override sys.execpthook. Still there is number provided in that exit process message (its 0 for example if application finish without errors), so i wondered if anyone knows what 3 stands for in my example, thats probably some group of errors. Knowning that could probably help me a lot.
Pathetic Greta hater.
Manit0u
Profile Blog Joined August 2004
Poland17745 Posts
October 25 2017 07:56 GMT
#18220
Completely unrelated:


module Api::V1::Media::JobProcessingService
def self.find_all_processes_for_job(job)
subquery = Api::V1::Media::Process.select(:id).where(
process_step_id: Api::V1::Media::ProcessStep.select(:id).where(
job_id: job.id
)
)

query = lambda { |model|
model
.joins(process: :process_step)
.select("#{model.table_name}.*, api_v1_media_process_steps.position")
.where(process_id: subquery)
.order('api_v1_media_process_steps.position ASC')
}

{
automated_processes: query.call(Api::V1::Media::AutomatedProcess),
manual_processes: query.call(Api::V1::Media::ManualProcess)
}
end
end


Resulting query (code returns objects):

SELECT api_v1_media_automated_processes.*, api_v1_media_process_steps.position
FROM "api_v1_media_automated_processes"
INNER JOIN "api_v1_media_processes" ON "api_v1_media_processes"."id" = "api_v1_media_automated_processes"."process_id"
INNER JOIN "api_v1_media_process_steps" ON "api_v1_media_process_steps"."id" = "api_v1_media_processes"."process_step_id"
WHERE "api_v1_media_automated_processes"."process_id" IN (
SELECT "api_v1_media_processes"."id"
FROM "api_v1_media_processes"
WHERE "api_v1_media_processes"."process_step_id" IN (
SELECT "api_v1_media_process_steps"."id"
FROM "api_v1_media_process_steps"
WHERE "api_v1_media_process_steps"."job_id" = $1
)
)
ORDER BY api_v1_media_process_steps.position ASC


Working with modern languages and frameworks can be really rewarding at times.
Time is precious. Waste it wisely.
Prev 1 909 910 911 912 913 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 4h 39m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 547
elazer 218
IndyStarCraft 161
BRAT_OK 113
SteadfastSC 97
UpATreeSC 91
Livibee 55
JuggernautJason54
Railgan 34
MindelVK 15
StarCraft: Brood War
Mini 392
firebathero 182
Dewaltoss 109
Rock 19
ajuk12(nOOB) 10
NaDa 4
Counter-Strike
fl0m2193
pashabiceps1897
Fnx 1828
Heroes of the Storm
Liquid`Hasu343
Other Games
Grubby5147
FrodaN1660
Dendi900
ceh9454
B2W.Neo447
KnowMe186
C9.Mang0163
Pyrionflax151
QueenE102
ArmadaUGS82
Trikslyr57
Organizations
Counter-Strike
PGL563
StarCraft 2
angryscii 13
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• Dystopia_ 6
• Reevou 4
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• 80smullet 24
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota296
Other Games
• imaqtpie1193
• WagamamaTV271
• Shiphtur192
Upcoming Events
PiGosaur Cup
4h 39m
GSL
14h 9m
Cure vs sOs
SHIN vs ByuN
Replay Cast
1d 4h
GSL
1d 14h
Classic vs Solar
GuMiho vs Zoun
WardiTV Spring Champion…
1d 15h
Replay Cast
2 days
Sparkling Tuna Cup
2 days
WardiTV Spring Champion…
2 days
Replay Cast
3 days
RSL Revival
3 days
Classic vs SHIN
Rogue vs Bunny
[ Show More ]
BSL
3 days
Replay Cast
4 days
Afreeca Starleague
4 days
Flash vs Soma
RSL Revival
4 days
BSL
4 days
Patches Events
5 days
Universe Titan Cup
5 days
Rogue vs Percival
Wardi Open
5 days
Monday Night Weeklies
5 days
Replay Cast
6 days
The PondCast
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Escore Tournament S2: W7
2026 GSL S1
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
YSL S3
SCTL 2026 Spring
RSL Revival: Season 5
Heroes Pulsing #1
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

Escore Tournament S2: W8
CSCL: Masked Kings S4
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
WardiTV Spring 2026
2026 GSL S2
Bounty Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 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.