• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:02
CEST 13:02
KST 20:02
  • 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
Team Liquid Map Contest #22 - The Finalists9[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21
Community News
2026 GSL Season 1 Qualifiers6Maestros of the Game 2 announced22026 GSL Tour plans announced4Weekly Cups (April 6-12): herO doubles, "Villains" prevail0MaNa leaves Team Liquid18
StarCraft 2
General
Team Liquid Map Contest #22 - The Finalists 2026 GSL Tour plans announced Maestros of the Game 2 announced Weekly Cups (April 6-12): herO doubles, "Villains" prevail MaNa leaves Team Liquid
Tourneys
2026 GSL Season 1 Qualifiers Master Swan Open (Global Bronze-Master 2) SEL Doubles (SC Evo Bimonthly) Sparkling Tuna Cup - Weekly Open Tournament $5,000 WardiTV TLMC tournament - Presented by Monster Energy
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Data needed A cwal.gg Extension - Easily keep track of anyone [ASL21] Ro16 Preview Pt1: Fresh Flow
Tourneys
[ASL21] Ro16 Group B [ASL21] Ro16 Group A [ASL21] Ro24 Group F [Megathread] Daily Proleagues
Strategy
What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates Muta micro map competition
Other Games
General Games
Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Stormgate/Frost Giant Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
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 Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Reappraising The Situation T…
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1945 users

The Big Programming Thread - Page 910

Forum Index > General Forum
Post a Reply
Prev 1 908 909 910 911 912 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.
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 14 2017 15:52 GMT
#18181
On October 15 2017 00:34 Wrath wrote:
Not sure if I get it right... You made a enterprise application client and deployed to the server. Thus the client called the server from within the server? I'm still learning what is the InitialContext is so not sure what is the different between using here within the code or use it via jndi.properties. Sorry I'm still beginner


Hey I'm still all new to this too! I was surprised I got it working. So I think from the tutorial when it tried to run the client code, it was just running it as a main method. That's why it had you put all the jars etc on the classpath. I wasn't prepared for it but when I told netbeans to make a new application client and then I tried to run a main method it actually ran the main method from within the application server itself as you were asking. If you watch the output of the netbeans glassfish server it's trying to deploy the jar.

Since the jar is running within the application server itself, it doesn't need to use remote jndi properties. The initial context that it has access to is from the container (glassfish) and has the remote bean within it.

Does that make more sense? You can pm me and we can exchange chat info if you want to and I can try to talk you through it more if you wish.
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 16 2017 07:27 GMT
#18182
I just spent a small amount of time learning shell scripts, honestly one of the better things I've done. Really useful things can be done relatively quickly in there.

For instance, in a game I play the linux port doesn't play mp3 music files. So the solution is to convert all of the files to ogg, and then change the .ogg extension to a .mp3 extension. Given that there was a few hundred files a quick shell script came to save the day :D

Yes this is being made a bigger deal then it needs to be, but I'm glad I learned how to do it efficiently.
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2017-10-16 14:14:32
October 16 2017 09:14 GMT
#18183
https://api-platform.com/

Fucken amazing!

https://github.com/docker/dockercraft

This is too much...
Time is precious. Waste it wisely.
ZigguratOfUr
Profile Blog Joined April 2012
Iraq16955 Posts
October 18 2017 22:10 GMT
#18184
Are there any parallel sorting algorithms that can actually run in log(n) time when you use n processors? Most parallel sorting algorithms that people actually use such as bitonic sort or odd-even merge sort are all log²(n), but is it because there we haven't found a log(n) algorithm, or is it because in practice they are too inefficient?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-10-19 21:16:29
October 19 2017 21:13 GMT
#18185
Alright braniacs, what's the best way to conquer the following scenario.

I have a square grid(like graph paper), represented by a 2d array. Each square can be 0, 1, or 2.

In a typical grid, the "2" squares are a small portion of the grid, surrounded by "1" squares. The 1s are surrounded by 0s.

The grids have this general design but the specifics are random, I don't know what a grid will look like.

I want to isolate the positions of every "ring" of 1s, expanding outward, starting at the border between 2s and 1s. A square is in the ring if it touches the last ring (even diagonally).

For example if my grid was


11111
11211
12111
11111

then I would isolate the following rings

x111x
x1x1x
1x11x
111xx

and then

1xxx1
1xxx1
xxxx1
xxx11


Now of course, my grid is much bigger than this.

So, my approach to solving this problem is pretty much brute force.

I make an array of 2d arrays of nil (or whatever), matching the size of my original grid
I do a for loop through the original array
if I hit a 2 in the original array, I look one square in every direction for a 1
if I hit a 1, I record the 1s index into the positionally identical index of the new (empty) 2d array
when I am done checking the original grid, I go through the 2d array of nil and 1s, I find each ring position, and for every 1 I find, I change that position to a 2 in the original array

I then go to the next index of my array of 2d arrays, and repeat the process. I repeat until the process results in a new array that finds no 1s.



So, this works. But it doesn't seem very efficient. I will potentially be doing this for quite a few grids (a couple hundred?). And this is a lot of for loops over each grid.

Does anyone know of a better way to do this? I am using python if it matters, which it might, because python has lots of neat stuff and I don't know hardly any of it.

Thanks for any help!

spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 19 2017 22:19 GMT
#18186
I'm developing a web app for watching replays of mahjong games played on tenhou.net. To go with that I'm planning to have a background application that monitors a file where the game client stores IDs of those replays. When a player finishes a game, I send those IDs to my web app and pull the actual replay. Then I display a balloon notification that links to the replay online.

I'm currently working on that background application. C#, Single Instance Application based on Windows Forms but with no actual forms and instead an icon and context menu in the system tray. I added code for registering the application for autostart in the registry, which the user can toggle in the context menu (off by default even). That worked fine. Then I went on to tackle other features, and when testing another menu item to toggle notifications, I toggled autostart too. My antivirus (Avira) then flagged the executable as a virus.

I don't know at which point the antivirus would first flag it. The registry code has been in there for at least a bunch of test runs. I also added code to open google in the default browser (Process.Start). So that might be part of it. I use a FileSystemWatcher. And I have an instance of HttpClient though it's not actually used yet. Any of these might or might not contribute, I guess.

My internet searches on the topic have been rather disappointing. None of the places where I found out how to do these things (mostly stackoverflow) mentioned anything on antivirus concerns, either.

Does anyone have experience with this? Going though some whitelisting process is out of the question, my project is way too small for that. I could drop the autostart, though that would be significant loss of convenience. But I don't even know for sure if that's what's triggering it...
If you have a good reason to disagree with the above, please tell me. Thank you.
ZigguratOfUr
Profile Blog Joined April 2012
Iraq16955 Posts
Last Edited: 2017-10-20 03:08:18
October 19 2017 23:03 GMT
#18187
On October 20 2017 06:13 travis wrote:
Alright braniacs, what's the best way to conquer the following scenario.

I have a square grid(like graph paper), represented by a 2d array. Each square can be 0, 1, or 2.

In a typical grid, the "2" squares are a small portion of the grid, surrounded by "1" squares. The 1s are surrounded by 0s.

The grids have this general design but the specifics are random, I don't know what a grid will look like.

I want to isolate the positions of every "ring" of 1s, expanding outward, starting at the border between 2s and 1s. A square is in the ring if it touches the last ring (even diagonally).

For example if my grid was


11111
11211
12111
11111

then I would isolate the following rings

x111x
x1x1x
1x11x
111xx

and then

1xxx1
1xxx1
xxxx1
xxx11


Now of course, my grid is much bigger than this.

So, my approach to solving this problem is pretty much brute force.

I make an array of 2d arrays of nil (or whatever), matching the size of my original grid
I do a for loop through the original array
if I hit a 2 in the original array, I look one square in every direction for a 1
if I hit a 1, I record the 1s index into the positionally identical index of the new (empty) 2d array
when I am done checking the original grid, I go through the 2d array of nil and 1s, I find each ring position, and for every 1 I find, I change that position to a 2 in the original array

I then go to the next index of my array of 2d arrays, and repeat the process. I repeat until the process results in a new array that finds no 1s.



So, this works. But it doesn't seem very efficient. I will potentially be doing this for quite a few grids (a couple hundred?). And this is a lot of for loops over each grid.

Does anyone know of a better way to do this? I am using python if it matters, which it might, because python has lots of neat stuff and I don't know hardly any of it.

Thanks for any help!



This sounds like a caching and spatial locality problem... I think your approach is generally correct, but you can probably do clever things to get a considerable speed-up by trying to avoid cache-lines getting swapped out. For example if you go through the array operating on three rows at a time, you can avoid the re-traversal by updating the original array as you go. Also make sure to traverse the grid in rows rather than columns since Python is row-major ordered
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
Last Edited: 2017-10-20 03:13:00
October 20 2017 02:34 GMT
#18188
On October 20 2017 06:13 travis wrote:
For example if my grid was

11111
11211
12111
11111

then I would isolate the following rings

x111x
x1x1x
1x11x
111xx



So... is this just edge detection?

Can you separate it into two passes, one vertical, and one horizontal? Just check if each 1 is next to a 2 on the relevant axis on each pass.

EDIT: Though that doesn't give diagonals, so nvm.
Hanh
Profile Joined June 2016
146 Posts
October 20 2017 04:18 GMT
#18189
Looks like a flood fill
Manit0u
Profile Blog Joined August 2004
Poland17722 Posts
Last Edited: 2017-10-20 12:26:39
October 20 2017 12:15 GMT
#18190
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!
Time is precious. Waste it wisely.
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 20 2017 13:31 GMT
#18191
I'm playing around with rust atm, and I don't really know how I feel about it. It's in a weird position of being what will most likely be by far the best systems language to use in a few years (at least, I think it will be after it's more fleshed out), it has functional elements which I really like after going through haskell from first principles (great rec thanks )... but it's just not quite there yet.

But my god is it quick, and super easy in comparison to c++ - and it even has concepts!!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2017-10-20 15:50:03
October 20 2017 15:44 GMT
#18192
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!

Yea I agree this feels like it could be done easier by constructing a graph and then traversing. Depending on the language a couple of queues and a cache/map might make it cleaner.



To the above question about sorting on multiple machines in logn, it's not quite as straightforward. Probably you want to do some searching around in academic literature for parallelized sorting. Sample sort or the like.
Who after all is today speaking about the destruction of the Armenians?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-10-20 16:28:22
October 20 2017 16:27 GMT
#18193
Haven't looked at you guy's responses about the graph thing, will in a bit. Just got home.

Wanted to post asking about this, first

https://imgur.com/a/FJYNy


I received 0 points for part b. Grader said it was incorrect. Couldn't make heads or tails of his explanation, but he didn't actually provide any examples, which should be easy to do.

I don't see how this is incorrect. I went over my regex several times, it seems to be exactly right.

Since our start state is a final state we can accept epsilon. = epsilon
or = |
we can accept any combination of "b" or "ab" = b*(ab)*b*
finally we can end with an a, or not. = (a?)

what am I missing?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
October 20 2017 16:43 GMT
#18194
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.

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.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 20 2017 19:55 GMT
#18195
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.
If you have a good reason to disagree with the above, please tell me. Thank you.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-10-20 20:11:48
October 20 2017 20:11 GMT
#18196
I think he wrote the dots beneath the stars

and true about the epsilon. But I kinda just started writing with that in front, and technically it doesn't make it wrong so I wasn't concerned.


and yeah, you're right. damnit... fucked that up, lol. thank you.

spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 20 2017 20:17 GMT
#18197
I personally don't think one should bank on being able to write regex without a validator anyways... Way too error prone. Just like coding on paper this is a dumb question.
If you have a good reason to disagree with the above, please tell me. Thank you.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-10-20 20:19:57
October 20 2017 20:19 GMT
#18198
It doesn't help that there is a third (longer question) on back and we have 15 minutes to do it all. You don't really get any time to error check.

But that excuse won't really work for me since when I got the grade back I went over it like 5 times and still didn't catch it lol
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 21 2017 05:46 GMT
#18199
I'm trying out clion, and I'm having this weird issue with it where entering my github details causes my version control settings to freeze.

Before I send through a help request to a more relevant party I thought I'd ask here to see if anyone had experienced this before.
bo1b
Profile Blog Joined August 2012
Australia12814 Posts
October 21 2017 10:27 GMT
#18200
Well github works fine on the eap version of it, so I'm beyond confused why the stable one has such a hang up.
Prev 1 908 909 910 911 912 1032 Next
Please log in or register to reply.
Live Events Refresh
Kung Fu Cup
11:00
#5
RotterdaM22
Rex14
TKL 0
Liquipedia
Replay Cast
09:00
KungFu Cup 2026 Week 4
CranKy Ducklings172
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 22
Rex 14
TKL 0
StarCraft: Brood War
Horang2 1484
Bisu 1106
Jaedong 905
firebathero 552
Zeus 351
Killer 239
actioN 239
Pusan 195
Stork 184
Larva 170
[ Show more ]
Soma 158
PianO 141
Mini 134
Light 117
ZerO 115
Britney 112
Last 106
Snow 100
sorry 93
hero 85
Rush 80
Soulkey 75
soO 43
[sc1f]eonzerg 40
Hm[arnc] 38
Shinee 38
Sharp 35
Bale 25
Free 21
NaDa 18
Sacsri 14
Movie 10
Barracks 9
Terrorterran 7
Hyun 6
HiyA 4
Dota 2
XaKoH 684
canceldota117
Counter-Strike
shoxiejesuss1215
x6flipin375
allub179
Other Games
singsing1452
B2W.Neo516
Pyrionflax255
DeMusliM89
Mew2King65
ZerO(Twitch)10
Organizations
Other Games
BasetradeTV1390
Counter-Strike
PGL173
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• LUISG 37
• CranKy Ducklings SOOP4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1021
• TFBlade962
Upcoming Events
Replay Cast
12h 58m
The PondCast
22h 58m
WardiTV Map Contest Tou…
23h 58m
CranKy Ducklings
1d 12h
Escore
1d 22h
WardiTV Map Contest Tou…
1d 23h
OSC
2 days
Korean StarCraft League
2 days
CranKy Ducklings
2 days
WardiTV Map Contest Tou…
2 days
[ Show More ]
IPSL
3 days
WolFix vs nOmaD
dxtr13 vs Razz
BSL
3 days
Sparkling Tuna Cup
3 days
WardiTV Map Contest Tou…
3 days
Ladder Legends
4 days
BSL
4 days
IPSL
4 days
JDConan vs TBD
Aegong vs rasowy
Replay Cast
4 days
Replay Cast
4 days
Wardi Open
4 days
Afreeca Starleague
4 days
Bisu vs Ample
Jaedong vs Flash
Monday Night Weeklies
5 days
RSL Revival
5 days
Afreeca Starleague
5 days
Barracks vs Leta
Royal vs Light
WardiTV Map Contest Tou…
5 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2026-04-13
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
Nations Cup 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
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
2026 GSL S1
WardiTV TLMC #16
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
CCT Season 3 Global Finals
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.