• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 17:39
CET 23:39
KST 07: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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
RSL Season 3: RO16 results & RO8 bracket12Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge1[TLMC] Fall/Winter 2025 Ladder Map Rotation14Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA12
StarCraft 2
General
RSL Season 3: RO16 results & RO8 bracket SC: Evo Complete - Ranked Ladder OPEN ALPHA RSL Season 3 - Playoffs Preview Mech is the composition that needs teleportation t GM / Master map hacker and general hacking and cheating thread
Tourneys
RSL Revival: Season 3 $5,000+ WardiTV 2025 Championship StarCraft Evolution League (SC Evo Biweekly) Constellation Cup - Main Event - Stellar Fest 2025 RSL Offline Finals Dates + Ticket Sales!
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 500 Fright night Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened
Brood War
General
Data analysis on 70 million replays A cwal.gg Extension - Easily keep track of anyone soO on: FanTaSy's Potential Return to StarCraft [ASL20] Ask the mapmakers — Drop your questions FlaSh on: Biggest Problem With SnOw's Playstyle
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] GosuLeague T1 Ro16 - Tue & Thu 22:00 CET [BSL21] RO16 Tie Breaker - Group B - Sun 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread EVE Corporation Path of Exile [Game] Osu! Should offensive tower rushing be viable in RTS games?
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
Mafia Game Mode Feedback/Ideas
Community
General
Russo-Ukrainian War Thread The Games Industry And ATVI US Politics Mega-thread Things Aren’t Peaceful in Palestine About SC2SEA.COM
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread Korean Music Discussion
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
The Health Impact of Joining…
TrAiDoS
Dyadica Evangelium — Chapt…
Hildegard
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2080 users

The Big Programming Thread - Page 159

Forum Index > General Forum
Post a Reply
Prev 1 157 158 159 160 161 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.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
August 27 2012 11:01 GMT
#3161
On August 27 2012 19:58 KainiT wrote:
While I do admit obviously that my understanding of backtracking was stupid, I would still like to know why my algorithm doesn't work -.-
I will write the code like you suggested now but not knowing why the previous one didn't work is kind of destroying my nerves right now.


I don't have the compiler ready to test it, but from a quick look it would suggest that it's an endless recursion with:
If valid, move forward. If invalid, move backwards, repeat for infinity.

However, i haven't really looked into that code in detail.
KainiT
Profile Joined July 2011
Austria392 Posts
August 27 2012 11:05 GMT
#3162
On August 27 2012 20:01 Morfildur wrote:
Show nested quote +
On August 27 2012 19:58 KainiT wrote:
While I do admit obviously that my understanding of backtracking was stupid, I would still like to know why my algorithm doesn't work -.-
I will write the code like you suggested now but not knowing why the previous one didn't work is kind of destroying my nerves right now.


I don't have the compiler ready to test it, but from a quick look it would suggest that it's an endless recursion with:
If valid, move forward. If invalid, move backwards, repeat for infinity.

However, i haven't really looked into that code in detail.


Yeah, most likely, but they program has some strange behaviour that I don't understand at all like suddenly printing 10 to 12 numbers per row after going back. Anyways I will now use my new understanding of recursion. Seems waaaaaaaaaaaay easier to debug. thx
With great power comes great responsibility.
KainiT
Profile Joined July 2011
Austria392 Posts
August 27 2012 12:29 GMT
#3163
I am done now
Still don't know why the previous algorithm didn't work but it is great to see how easy it can be with proper recursion.
I think this is even a bit simpler than what you suggested cause I don't need dynamic storage.


int solve(int r, int c)
{
if(c==9)
{
++r;
c=0;
if(r==9)
{
return 1;
}
}
if(vordefiniertefelderarray[r][c]>0)
{
return solve(r,c+1);
}
for(int i=1; i<=9; ++i)
{
if(!check(r,c,i))
{
sudfeld[r][c]=i;
if(solve(r,c+1))
{
feldausgeben(sudfeld);
return 0;
}
}
}
sudfeld[r][c]=0;
return 0;

}
With great power comes great responsibility.
Djin)ftw(
Profile Blog Joined November 2008
Germany3357 Posts
Last Edited: 2012-08-27 13:25:22
August 27 2012 13:22 GMT
#3164
Hello! I hope this is the right thread to ask this. I finally want to learn how to program. So what I want to do is program a GUI with which the user can solve Sudokus

Program starts, empty suduko field opens, user klicks on a field and types in the number. He does that until he is finished. Then there is a button which starts the solving processs.
I guess it's pretty straightforward and will hopefully cover a lot of must know techniques (like recursion).

So, I have a LITTLE BIT of experience in JAVA and C#. For example I know the difference between a for- and while-loop (in case these constructs are still used, lol). But thats pretty much it. So my questions:
a) I normally use UBUNTU and I dont want to use WINE and a windows based IDE so the IDE (emacs?) would have to be available for Linux/Ubuntu
b) I dont want the IDE to be super complex. What I hate the most when using software is when it is so complex you cant really do anything unless you spend a shitload of time to figure out what to do (hello Photoshop). I want to spend my time learning the API and how to program and not reading a book on how to use the IDE.
+ Show Spoiler +

[image loading]
Just look at this, wtf. A thousend buttons and symbols, omg

c) I want the programm to be portable (JAVA and JVM like). While it probably is fascinating to program something for an Assembler thats not what I want to do.
d) I want full control over the GUI. I dont want some windows like dialogue boxes. As a start this might be ok, but if I wont be able to fully customize the GUI I will be very disappointed.

So I hope you can help me getting started, I'd appreciate it. Thank you!
"jk CLG best mindgames using the baron to counterthrow" - boesthius
meatpudding
Profile Joined March 2011
Australia520 Posts
August 27 2012 13:44 GMT
#3165
+ Show Spoiler +
On August 27 2012 22:22 Djin)ftw( wrote:
Hello! I hope this is the right thread to ask this. I finally want to learn how to program. So what I want to do is program a GUI with which the user can solve Sudokus

Program starts, empty suduko field opens, user klicks on a field and types in the number. He does that until he is finished. Then there is a button which starts the solving processs.
I guess it's pretty straightforward and will hopefully cover a lot of must know techniques (like recursion).

So, I have a LITTLE BIT of experience in JAVA and C#. For example I know the difference between a for- and while-loop (in case these constructs are still used, lol). But thats pretty much it. So my questions:
a) I normally use UBUNTU and I dont want to use WINE and a windows based IDE so the IDE (emacs?) would have to be available for Linux/Ubuntu
b) I dont want the IDE to be super complex. What I hate the most when using software is when it is so complex you cant really do anything unless you spend a shitload of time to figure out what to do (hello Photoshop). I want to spend my time learning the API and how to program and not reading a book on how to use the IDE.
+ Show Spoiler +

[image loading]
Just look at this, wtf. A thousend buttons and symbols, omg

c) I want the programm to be portable (JAVA and JVM like). While it probably is fascinating to program something for an Assembler thats not what I want to do.
d) I want full control over the GUI. I dont want some windows like dialogue boxes. As a start this might be ok, but if I wont be able to fully customize the GUI I will be very disappointed.

So I hope you can help me getting started, I'd appreciate it. Thank you!


Check out Qt. One of the best GUI programs available. Completely cross platform and open source. It includes it's own sdk with a c++ compiler, and there's also the option to write apps in markup language like xml.
Be excellent to each other.
dottycakes
Profile Joined April 2011
Canada548 Posts
August 27 2012 14:10 GMT
#3166
Just a forewarning, solving sudokus might be a bit too complex for beginner programmers.
Djin)ftw(
Profile Blog Joined November 2008
Germany3357 Posts
August 27 2012 14:32 GMT
#3167
Hm so QT is an extension to C++ with a WYSIWYG editor? Hm. I have no idea what programming language is the most popular atm, but C++ seems a bit outdated. Or is it still used?

On August 27 2012 23:10 dottycakes wrote:
Just a forewarning, solving sudokus might be a bit too complex for beginner programmers.


Yeah well.. maybe I'll work on a chess GUI then if I should fail, thats no problem.
"jk CLG best mindgames using the baron to counterthrow" - boesthius
KainiT
Profile Joined July 2011
Austria392 Posts
August 27 2012 14:52 GMT
#3168
On August 27 2012 23:32 Djin)ftw( wrote:
Hm so QT is an extension to C++ with a WYSIWYG editor? Hm. I have no idea what programming language is the most popular atm, but C++ seems a bit outdated. Or is it still used?

Show nested quote +
On August 27 2012 23:10 dottycakes wrote:
Just a forewarning, solving sudokus might be a bit too complex for beginner programmers.


Yeah well.. maybe I'll work on a chess GUI then if I should fail, thats no problem.


As far as I am concerned c++(or even C) is still the most used language for big software projects like an operating system or Starcraft(:D) and people like myself start with it cause other languages are appearantly based on the C syntax as well.

If you just want to make a sudoku solver with gui c++ is certainly not a very good choice for that as c# or java will be much better suited.
With great power comes great responsibility.
Djin)ftw(
Profile Blog Joined November 2008
Germany3357 Posts
August 27 2012 16:09 GMT
#3169
Hm after a bit of research I think I'll learn Python and probably use DrPython. xD I'm too chobo for C/JAVA and emacs/eclipse lol. Maybe I'll look into this later. Thanks anyway!
"jk CLG best mindgames using the baron to counterthrow" - boesthius
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
August 27 2012 17:17 GMT
#3170
On August 27 2012 23:10 dottycakes wrote:
Just a forewarning, solving sudokus might be a bit too complex for beginner programmers.


only if you try an intelligent algorithm.. you can always just brute force the thing in a few lines of code, that's suitable for beginners as well.
Gold isn't everything in life... you need wood, too!
supereddie
Profile Joined March 2011
Netherlands151 Posts
Last Edited: 2012-08-27 20:36:24
August 27 2012 20:35 GMT
#3171
On August 27 2012 23:32 Djin)ftw( wrote:
Yeah well.. maybe I'll work on a chess GUI then if I should fail, thats no problem.

As long as you stick with the GUI it should be fine, but if you also want to verify a valid move, or determine states like check, check-mate and pat that is a whole other ballgame. If you don't want to brute force that is...
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2012-08-28 04:35:48
August 28 2012 01:28 GMT
#3172
Hi guys,

I'm looking for a really fast way to find and remove duplicates in two lists in Python.

Right now my implementation does it via simple brute force, but it's way too slow for my uses. The two lists can possibly have over 20,000 items each.

This is what I've been working on so far. The first part finds two matching items, sets their value to some random string, repeat, then remove_all( list_obj, text ) will remove all instances of the text afterwards.

+ Show Spoiler +
left = [...]#really long list of strings
right = [...]#really long list of strings

for i in range(len(left)):
if left[i] == "SETTOBEREMOVEDexa01%44":
continue
for j in range(len(right)):
if left[i].split() == right[j].split():
left[i] = "SETTOBEREMOVEDexa01%44"
right[j] = "SETTOBEREMOVEDexa01%44"
continue

left = remove_all(left, "SETTOBEREMOVED%44" )
right = remove_all(right, "SETTOBEREMOVED%44" )

The reason I cannot use sets is that I need to see if there are duplicate values.

A common example of the list would be, given

a = [1,1,3,2,3,3,2,2]
b = [1,1,2,3,2]

I need the following by the end

a = [2,3,3]
b = []

whereas sets would return equal. No one seems to have a fast way to find it for non-unique lists.


The original lists need to be returned in the same order they're passed in, so sorting isn't an option. :s I think I didn't remove them directly because I believe there are issues with messing with the size of lists/arrays while you're iterating through.

I'm thinking of sorting and then removing from all lists simultaneously ... but I can't imagine sorting would make things faster.

As far as I know, this seems to be the only way to do it. Any help would be appreciated! Right now my application hangs for 90s before completing. I would like to reduce it to around 10s if possible. If it can't be done, then it's fine. Thanks ^^
There is no one like you in the universe.
meatpudding
Profile Joined March 2011
Australia520 Posts
August 28 2012 03:34 GMT
#3173
Not sure what you mean about removing duplicates. Do you mean the difference between a and b?
Be excellent to each other.
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
August 28 2012 03:58 GMT
#3174
Blisse:

My first thought is that the fastest implementation will still involve sorting both lists first. Since you need to return the lists in original order, then as you sort the lists, you build/maintain a map from old=>new for each array. Once you have both arrays sorted, you iterate through them consecutively, removing items that are duplicates. The remaining arrays you restore to a final return array via the initial array index maps you created.
RoTaNiMoD
Profile Blog Joined January 2004
United States558 Posts
August 28 2012 03:59 GMT
#3175
With ~20,000 items I can't imagine this taking more than a few seconds on decent hardware properly implemented.
waxypants
Profile Blog Joined September 2009
United States479 Posts
Last Edited: 2012-08-28 04:25:59
August 28 2012 04:12 GMT
#3176
On August 28 2012 10:28 Blisse wrote:
Hi guys,

I'm looking for a really fast way to find and remove duplicates in two lists in Python.

Right now my implementation does it via simple brute force, but it's way too slow for my uses. The two lists can possibly have over 20,000 items each.

This is what I've been working on so far. The first part finds two matching items, sets their value to some random string, repeat, then remove_all( list_obj, text ) will remove all instances of the text afterwards.

left = [...]#really long list of strings
right = [...]#really long list of strings

for i in range(len(left)):
if left[i] == "SETTOBEREMOVEDexa01%44":
continue
for j in range(len(right)):
if left[i].split() == right[j].split():
left[i] = "SETTOBEREMOVEDexa01%44"
right[j] = "SETTOBEREMOVEDexa01%44"
continue

left = remove_all(left, "SETTOBEREMOVED%44" )
right = remove_all(right, "SETTOBEREMOVED%44" )

The reason I cannot use sets is that I need to see if there are duplicate values.

A common example of the list would be, given

a = [1,1,3,2,3,3,2]
b = [1,1,2,3,2]

I need the following by the end

a = [2,3,3]
b = []

whereas sets would return equal. No one seems to have a fast way to find it for non-unique lists.


The original lists need to be returned in the same order they're passed in, so sorting isn't an option. :s I think I didn't remove them directly because I believe there are issues with messing with the size of lists/arrays while you're iterating through.

I'm thinking of sorting and then removing from all lists simultaneously ... but I can't imagine sorting would make things faster.

As far as I know, this seems to be the only way to do it. Any help would be appreciated! Right now my application hangs for 90s before completing. I would like to reduce it to around 10s if possible. If it can't be done, then it's fine. Thanks ^^


1) Why don't you just use "None" as your "stringtoremove"?
2) There is no point in continuing to go through the 'j' loop once you have already found a match.
3) I haven't tested it yet, but it seems that your example is wrong according to your code. I think it should be a = [3, 3], b = [].

Will think about it more later.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2012-08-28 04:35:59
August 28 2012 04:22 GMT
#3177
On August 28 2012 13:12 waxypants wrote:

1) Why don't you just use "None" as your "stringtoremove"?
2) There is no point in continuing to go through the 'j' loop once you have already found a match.
3) I haven't tested it yet, but it seems that your example is wrong according to your code. I think it should be a = [3, 3], b = [].

Will think about it more now.


Good catch! I didn't notice it. I'll look at some of your other suggestions. Thanks!


+ Show Spoiler +
a = [1,1,3,2,3,4,2]
b = [1,1,2,3,4]


into

a = [3,2]
b = []




On August 28 2012 12:34 meatpudding wrote:
Not sure what you mean about removing duplicates. Do you mean the difference between a and b?


Basically I want to remove anything that appears in both, but if it appears twice in a and once in b, there has to be a copy remaining in a.
There is no one like you in the universe.
waxypants
Profile Blog Joined September 2009
United States479 Posts
August 28 2012 04:29 GMT
#3178
I think your new example is wrong also since you said the order must be maintained. I think it should be a = [3, 2] and b =[]
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2012-08-28 05:17:15
August 28 2012 04:31 GMT
#3179
On August 28 2012 13:29 waxypants wrote:
I think your new example is wrong also since you said the order must be maintained. I think it should be a = [3, 2] and b =[]


Oops, I got too caught up trying to fix the other one I didn't notice. :s

I can't use "None" because that can be a possible item in the list.

+ Show Spoiler +


def panels_sec_remove_all_duplicates(self, evt):
left = [..]
right = [..]

for i in range(len(left)):
if left[i] == "xae2134eei:nOne":
continue
for j in range(len(right)):
if right[i] == "xae2134eei:nOne":
continue
if left[i].split() == right[j].split():
left[i] = "xae2134eei:nOne"
right[j] = "xae2134eei:nOne"
break




edit:

Well, it's an array of strings. Strings being sentences, lines, newlines.

However, there's no guarantee that the sentences or lines are spaced properly, so the comparison should disregard spacing for the most part.

Using the None type throws an exception on None.split() . I guess I should just catch that and continue. :s
There is no one like you in the universe.
waxypants
Profile Blog Joined September 2009
United States479 Posts
August 28 2012 04:49 GMT
#3180
I meant the None type. You said it was an array of strings. So maybe you should clarify the possible types in the list. If you really meant that it was an array of values that could either be strings or None, then you could use use [] or any number (like 0). Basically, something that is guaranteed to fail the "==" test. I know I'm being really picky but you need to be very precise about your contraints when you are asking people to help optimize some arbitrary algorithm.
Prev 1 157 158 159 160 161 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 8h 51m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
White-Ra 274
UpATreeSC 173
JuggernautJason96
Nina 79
StarCraft: Brood War
Calm 3386
Leta 33
Dota 2
NeuroSwarm53
Counter-Strike
fl0m1391
Heroes of the Storm
Liquid`Hasu497
Trikslyr50
Other Games
Grubby5710
FrodaN1690
DeMusliM304
mouzStarbuck298
shahzam283
RotterdaM174
C9.Mang0102
KnowMe91
ViBE56
ZombieGrub36
PPMD15
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• Hupsaiya 55
• sitaska47
• davetesta19
• intothetv
• sooper7s
• Migwel
• LaughNgamezSOOP
• AfreecaTV YouTube
• IndyKCrew
• Kozan
StarCraft: Brood War
• 80smullet 22
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 5288
• masondota21687
• WagamamaTV689
League of Legends
• TFBlade1353
• Doublelift782
Other Games
• imaqtpie934
• Scarra846
• Shiphtur297
Upcoming Events
RSL Revival
8h 51m
Classic vs MaxPax
SHIN vs Reynor
herO vs Maru
WardiTV Korean Royale
13h 21m
SC Evo League
13h 51m
IPSL
18h 21m
Julia vs Artosis
JDConan vs DragOn
OSC
18h 21m
BSL 21
21h 21m
TerrOr vs Aeternum
HBO vs Kyrie
RSL Revival
1d 8h
Wardi Open
1d 15h
IPSL
1d 21h
StRyKeR vs OldBoy
Sziky vs Tarson
BSL 21
1d 21h
StRyKeR vs Artosis
OyAji vs KameZerg
[ Show More ]
OSC
2 days
OSC
2 days
Monday Night Weeklies
2 days
OSC
3 days
Wardi Open
3 days
Replay Cast
4 days
Wardi Open
4 days
Tenacious Turtle Tussle
5 days
The PondCast
5 days
Replay Cast
6 days
LAN Event
6 days
Liquipedia Results

Completed

Proleague 2025-11-16
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
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 © 2025 TLnet. All Rights Reserved.