• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:32
CET 11:32
KST 19:32
  • 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
[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy7ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289
Community News
Weekly Cups (March 16-22): herO doubles, Cure surprises3Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool42Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12
StarCraft 2
General
Explore the Palmistry Certificate Course at Bivs Weekly Cups (March 16-22): herO doubles, Cure surprises Weekly Cups (August 25-31): Clem's Last Straw? Team Liquid Map Contest #22 - Presented by Monster Energy What mix of new & old maps do you want in the next ladder pool? (SC2)
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 518 Radiation Zone Mutation # 517 Distant Threat Mutation # 516 Specter of Death
Brood War
General
ASL21 General Discussion Soulkey's decision to leave C9 BGH Auto Balance -> http://bghmmr.eu/ JaeDong's form before ASL [ASL21] Ro24 Preview Pt1: New Chaos
Tourneys
[ASL21] Ro24 Group B [ASL21] Ro24 Group A ASL Season 21 LIVESTREAM with English Commentary [Megathread] Daily Proleagues
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
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
TL Mafia Community Thread Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2077 users

The Big Programming Thread - Page 130

Forum Index > General Forum
Post a Reply
Prev 1 128 129 130 131 132 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.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-03-27 20:00:18
March 27 2012 19:54 GMT
#2581
On March 27 2012 10:57 berated- wrote:
Show nested quote +
On March 27 2012 10:27 teamamerica wrote:
Hey guys, I'm a pretty noob cs guy (2nd year of B.S) but I was wondering what you guys thought of this list of what every cs major should know. It pretty comprehensive and something I'd like to refer to from time to time as a kind of checkoff list of things to learn.


If you know all of those things I doubt there is a company in the world that wouldn't hire you. We ask the people we are trying to hire to have about 1/4 of those requirements and still can't find them.

Pretty interesting. I read the K & R book and luckily I know and have experience with everything there except hash lookups, which I'll be writing this summer for use in projects next term. I'm also solid on the mathematics (take a ton at my college). Also taking multiple years of C++ and doing many large projects from scratch in C++. Have experience writing in Assembly as well, but not a whole lot. Would love to learn more but have to wait until 3rd year where we program an 8-bit microprocessor to run a game on a hand-held device. Going to be so fun! Hopefully I can apply what I learn on a side-project of creating a SNES game. Always been interesting in coding something for the SNES. Also have classes on operating systems and will be creating networking for game projects in C++. Many classes on graphics programming, AI, databases and data structures, there's a machine learning class though it's not on the required course sequence.

Looks like I'm in a good position

https://www.digipen.edu/academics/degree-programs/real-time-interactive-simulation/course-sequence/
https://www.digipen.edu/academics/course-catalog/course-descriptions/computer-science-cs/
SpaceFighting
Profile Joined January 2010
New Zealand690 Posts
March 27 2012 20:29 GMT
#2582
Hey guys, for my university assignment , i have to create two random rectangles and im having trouble trying to code it, is anyone familiar with this?
kuz pro
gauauu
Profile Joined May 2010
United States47 Posts
March 27 2012 20:32 GMT
#2583
Spacefighting, your description of the assignment is to vague to be of no use to help you, really. (What langauge? What libraries? What sort of result do you need?)

To create a random rectangle, you need 4 random points, or 8 random numbers (x and y) to be the 4 corners. So generate 8 random numbers, call them the corners of the rectangle, and you're done.

Unless you need to draw them? Or they have to be within a certain size/area? That would complicate things slightly.
Millitron
Profile Blog Joined August 2010
United States2611 Posts
March 27 2012 20:38 GMT
#2584
On March 28 2012 01:00 ThatGuy wrote:
Yeah the solution I currently came up with is O(n/2 * n^2), but I usually don't deal with stuff that goes beyond O(n^2), so I wasn't sure if I was being stupid. Thanks for the reply. On the plus side, once it's constructed I don't really have to deal with it again lol.

EDIT: Actually it looks a bit less than that, since it keep looping through a smaller list on every iteration...w/e.

Unless you need a really precise efficiency, O((n/2)*(n^2)) is on the order of O(n^3).

Unless you're doing this for an upper-level Master's Degree class, or an independent research project in algorithms, O(n^3) is good enough.
Who called in the fleet?
SpaceFighting
Profile Joined January 2010
New Zealand690 Posts
March 27 2012 22:14 GMT
#2585
On March 28 2012 05:32 gauauu wrote:
Spacefighting, your description of the assignment is to vague to be of no use to help you, really. (What langauge? What libraries? What sort of result do you need?)

To create a random rectangle, you need 4 random points, or 8 random numbers (x and y) to be the 4 corners. So generate 8 random numbers, call them the corners of the rectangle, and you're done.

Unless you need to draw them? Or they have to be within a certain size/area? That would complicate things slightly.


Ops sorry, the language used is java and its about rectangle class, im a first year comp sci major and i am uncertain of how to create a random rectangle with this.

The reault im looking for is to create 2 random rectangles, choose a random point within them and see whether they intersect at that given point.
kuz pro
Millitron
Profile Blog Joined August 2010
United States2611 Posts
March 27 2012 22:52 GMT
#2586
On March 28 2012 07:14 SpaceFighting wrote:
Show nested quote +
On March 28 2012 05:32 gauauu wrote:
Spacefighting, your description of the assignment is to vague to be of no use to help you, really. (What langauge? What libraries? What sort of result do you need?)

To create a random rectangle, you need 4 random points, or 8 random numbers (x and y) to be the 4 corners. So generate 8 random numbers, call them the corners of the rectangle, and you're done.

Unless you need to draw them? Or they have to be within a certain size/area? That would complicate things slightly.


Ops sorry, the language used is java and its about rectangle class, im a first year comp sci major and i am uncertain of how to create a random rectangle with this.

The reault im looking for is to create 2 random rectangles, choose a random point within them and see whether they intersect at that given point.

The Java API is your best friend: API for Rectangle().

To get random numbers in Java, check out: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html. Look for the Math.random() method.
Who called in the fleet?
SpaceFighting
Profile Joined January 2010
New Zealand690 Posts
March 28 2012 00:32 GMT
#2587
On March 28 2012 07:52 Millitron wrote:
Show nested quote +
On March 28 2012 07:14 SpaceFighting wrote:
On March 28 2012 05:32 gauauu wrote:
Spacefighting, your description of the assignment is to vague to be of no use to help you, really. (What langauge? What libraries? What sort of result do you need?)

To create a random rectangle, you need 4 random points, or 8 random numbers (x and y) to be the 4 corners. So generate 8 random numbers, call them the corners of the rectangle, and you're done.

Unless you need to draw them? Or they have to be within a certain size/area? That would complicate things slightly.


Ops sorry, the language used is java and its about rectangle class, im a first year comp sci major and i am uncertain of how to create a random rectangle with this.

The reault im looking for is to create 2 random rectangles, choose a random point within them and see whether they intersect at that given point.

The Java API is your best friend: API for Rectangle().

To get random numbers in Java, check out: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html. Look for the Math.random() method.


Oh kewl thanks, exactly what im looking for, programming seems to be difficult for me, gotta study hard!

Thanks once again
kuz pro
dogmeatstew
Profile Joined April 2010
Canada574 Posts
March 28 2012 00:39 GMT
#2588
On March 28 2012 05:29 SpaceFighting wrote:
Hey guys, for my university assignment , i have to create two random rectangles and im having trouble trying to code it, is anyone familiar with this?

Really really depends on the language for how you actually go about it but the concept is pretty simple.

1. Find the random number generator for your language
2. Get random values within the range you have (0 - screen width and 0 - screen height I'd imagine):
- start x coord
- start y coord
- height of rect
- width of rect
3. repeat for second rectagle.


From my experience most languages will ask you for an (x.y) for top left corner and then a height and width so your're looking at something like:

Rectangle rect = new Rectangle(x,y,length,width); << Very java esk
iglocska
Profile Joined May 2011
Norway589 Posts
March 28 2012 05:49 GMT
#2589
On March 28 2012 09:39 dogmeatstew wrote:
Show nested quote +
On March 28 2012 05:29 SpaceFighting wrote:
Hey guys, for my university assignment , i have to create two random rectangles and im having trouble trying to code it, is anyone familiar with this?

Really really depends on the language for how you actually go about it but the concept is pretty simple.

1. Find the random number generator for your language
2. Get random values within the range you have (0 - screen width and 0 - screen height I'd imagine):
- start x coord
- start y coord
- height of rect
- width of rect
3. repeat for second rectagle.


From my experience most languages will ask you for an (x.y) for top left corner and then a height and width so your're looking at something like:

Rectangle rect = new Rectangle(x,y,length,width); << Very java esk


Just keep in mind that this can place the rectangle (parts of it at least) outside of the screen if for example start x coord + rectangle width > screen width.

Do it like this:

- randomise height + width of rectangle (max limit < screen size)
- randomise start x coordinate (max limit < (screen width - rectangle width))
- randomise start y coordinate (max limit < (screen height - rectangle height))
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2012-03-29 13:13:32
March 29 2012 13:12 GMT
#2590
I was looking for an example how to use 2 threads, so I found this one:
http://www.cs.nccu.edu.tw/~linw/javadoc/tutorial/java/threads/simple.html
However, both threads execute the same code. How can one make each thread do something else? E.g. this thread will clean floor, while the other will wash clothes. At first I thought about variable check, but if threads are 4... is it still possible?
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
March 29 2012 13:20 GMT
#2591
For everything that you want to execute in such a thread, simply create an instance of the Runnable interface. Then you just call new Thread(runnable).start(); (where runnable is your Runnable instance) for every thread you want to start besides the main thread and it will execute the runnable's run(){..} method in a separate thread.
Gold isn't everything in life... you need wood, too!
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
April 03 2012 02:19 GMT
#2592
Can anyone explain how Wolfram Alpha does their computations so quickly? It's kinda ridiculous imho. I haven't looked into it much. Just wondered this earlier today in class.
There is no one like you in the universe.
Millitron
Profile Blog Joined August 2010
United States2611 Posts
April 03 2012 02:52 GMT
#2593
On April 03 2012 11:19 Blisse wrote:
Can anyone explain how Wolfram Alpha does their computations so quickly? It's kinda ridiculous imho. I haven't looked into it much. Just wondered this earlier today in class.

Brute-force computation is what computers were invented for. Its amazing how quickly they can plow through arithmetic expressions. You don't even need exceptionally efficient algorithms for most pure arithmetic calculations. Basically, if it can be represented by an equation and doesn't involve summations, almost any modern computer can do it pretty much instantly. What slows them down are repeated calculations. For instance, in a videogame, when your computer tries to draw something on the screen, it does so by drawing many triangles. It can draw a single triangle in a fraction of a millisecond, but if you have to draw 20,000 of them, those fractions of a millisecond add up.

I would suspect WA does have exceptionally efficient algorithms as well, but they would be just as fast without them for most users needs. Only the people running N-body orbital integrators, and other insane stuff need the high-efficiency algorithms.
Who called in the fleet?
Mittens
Profile Joined April 2009
Australia102 Posts
April 04 2012 01:58 GMT
#2594
Hey, I was doing homework that ended up like this: http://pastebin.com/VujQAxPq (~50 lines long)

While it produced a valid answer, it used an unreasonable amount of memory to do it (7.5GB of 8 RAM that was free + tons of pagefile on top of that).

Anyone know what's happened to make it so memory consuming?
chiboni
Profile Joined June 2011
15 Posts
April 04 2012 08:20 GMT
#2595
On April 04 2012 10:58 Mittens wrote:
Hey, I was doing homework that ended up like this: http://pastebin.com/VujQAxPq (~50 lines long)

While it produced a valid answer, it used an unreasonable amount of memory to do it (7.5GB of 8 RAM that was free + tons of pagefile on top of that).

Anyone know what's happened to make it so memory consuming?



Im Not sure if i understand your question correct...
You wonder why your program uses ~500mb Memory ?

If so, You have two Byte arrays with total of 15 Byte * 39506988 loop = ~ 59260482 Byte
= 565 mb

I hope i got that right :/
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2012-04-04 13:57:20
April 04 2012 13:56 GMT
#2596
I use Java nested class, but it doesn't work on Linux although I get a file similar to: mainclass$innerclass.class (the problem is the inner class isn't executed)
There is no problem on Windows though. Any suggestions?
WhuazGoodJaggah
Profile Blog Joined January 2009
Lesotho777 Posts
April 04 2012 14:52 GMT
#2597
On April 04 2012 10:58 Mittens wrote:
Hey, I was doing homework that ended up like this: http://pastebin.com/VujQAxPq (~50 lines long)

While it produced a valid answer, it used an unreasonable amount of memory to do it (7.5GB of 8 RAM that was free + tons of pagefile on top of that).

Anyone know what's happened to make it so memory consuming?


byte[] hashedBYTES = hashSha.ComputeHash(byteContainer);
this line could eat up memory, have you tried to declare hashedBYTES outside of the loop? that should be better for performance anyway.
small dicks have great firepower
Millitron
Profile Blog Joined August 2010
United States2611 Posts
April 04 2012 17:27 GMT
#2598
On April 04 2012 22:56 darkness wrote:
I use Java nested class, but it doesn't work on Linux although I get a file similar to: mainclass$innerclass.class (the problem is the inner class isn't executed)
There is no problem on Windows though. Any suggestions?

Read up on how your Linux JVM handles inner classes. I suspect its a linking issue though.

Anyways, I got a question TL. I'm working on a fairly large project in Java, and I'm using Eclipse. My problem is that each version only changes a couple of methods in each class, so I like to collapse the ones that I'm not working on. But, since each version gets its own project, Eclipse seems to forget what methods I've collapsed, and displays them all, and its getting annoying to have to manually collapse them all every time I start a new version. Is there any way to make it remember this kind of thing between projects?
Who called in the fleet?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 04 2012 20:28 GMT
#2599
On April 05 2012 02:27 Millitron wrote:
Read up on how your Linux JVM handles inner classes. I suspect its a linking issue though.


Any links? I can't find anything useful in particular.
Millitron
Profile Blog Joined August 2010
United States2611 Posts
April 04 2012 21:42 GMT
#2600
On April 05 2012 05:28 darkness wrote:
Show nested quote +
On April 05 2012 02:27 Millitron wrote:
Read up on how your Linux JVM handles inner classes. I suspect its a linking issue though.


Any links? I can't find anything useful in particular.

Actually, no. This is harder to look up than I imagined it would be. I can't find much about how any Linux JVM's work at all, let alone how they deal with this admittedly unique situation.

What I mean by a linking issue though, is that the classes aren't being linked together properly. In C++, you do this with DLL's or .lib files, but in Java, the JVM takes care of it for you normally.

Does your program outright crash, or just not execute the inner class stuff?
Who called in the fleet?
Prev 1 128 129 130 131 132 1032 Next
Please log in or register to reply.
Live Events Refresh
Afreeca Starleague
10:00
Ro24 Group B
Soulkey vs Ample
JyJ vs sSak
Afreeca ASL 7227
StarCastTV_EN181
Liquipedia
Sparkling Tuna Cup
10:00
Weekly #124
CranKy Ducklings70
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 178
ProTech146
SortOf 101
StarCraft: Brood War
Calm 11662
Flash 4766
Bisu 4167
GuemChi 1606
BeSt 671
firebathero 631
EffOrt 309
Zeus 258
Pusan 242
Leta 216
[ Show more ]
actioN 204
Light 200
ZerO 196
Stork 155
HiyA 121
ToSsGirL 83
Killer 78
Rush 71
Mind 57
Sharp 56
PianO 47
Terrorterran 41
Barracks 36
Hm[arnc] 21
Shinee 20
GoRush 19
Nal_rA 18
yabsab 15
Bale 14
Noble 10
soO 10
Purpose 8
sorry 8
Dota 2
XcaliburYe258
canceldota142
BananaSlamJamma130
League of Legends
JimRising 357
Counter-Strike
olofmeister2098
shoxiejesuss627
byalli447
x6flipin170
Super Smash Bros
Westballz13
Other Games
singsing1846
ceh9692
Sick274
crisheroes233
Happy76
Livibee68
Trikslyr22
Organizations
Other Games
gamesdonequick875
StarCraft: Brood War
UltimateBattle 197
Dota 2
PGL Dota 2 - Main Stream128
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH191
• StrangeGG 47
• LUISG 29
• CranKy Ducklings SOOP4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 5
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Replay Cast
22h 28m
Afreeca Starleague
23h 28m
hero vs YSC
Larva vs Shine
Kung Fu Cup
1d
Replay Cast
1d 13h
KCM Race Survival
1d 22h
The PondCast
1d 23h
WardiTV Team League
2 days
Replay Cast
2 days
WardiTV Team League
3 days
RSL Revival
3 days
Cure vs Zoun
herO vs Rogue
[ Show More ]
WardiTV Team League
4 days
Platinum Heroes Events
4 days
BSL
4 days
RSL Revival
4 days
ByuN vs Maru
MaxPax vs TriGGeR
WardiTV Team League
5 days
BSL
5 days
Replay Cast
5 days
Afreeca Starleague
5 days
Light vs Calm
Royal vs Mind
Wardi Open
6 days
Monday Night Weeklies
6 days
Sparkling Tuna Cup
6 days
Afreeca Starleague
6 days
Rush vs PianO
Flash vs Speed
Liquipedia Results

Completed

Proleague 2026-03-23
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
CSL Season 20: Qualifier 1
ASL Season 21
Acropolis #4 - TS6
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

2026 Changsha Offline CUP
CSL Season 20: Qualifier 2
CSL 2026 SPRING (S20)
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
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.