• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 07:54
CET 13:54
KST 21:54
  • 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
SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion7Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)16Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
PhD study /w SC2 - help with a survey! When will we find out if there are more tournament Weekly Cups (Jan 12-18): herO, MaxPax, Solar win I am looking for StarCraft 2 Beta Patch files Stellar Fest "01" Jersey Charity Auction
Tourneys
$70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament SC2 AI Tournament 2026 $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
BSL Season 2025 - Full Overview and Conclusion [ASL21] Potential Map Candidates Gypsy to Korea Video Footage from 2005: The Birth of G2 in Spain BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] Non-Korean Championship - Starts Jan 10 Small VOD Thread 2.0 Azhi's Colosseum - Season 2
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft Current Meta
Other Games
General Games
Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread NASA and the Private Sector Canadian Politics Mega-thread
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Navigating the Risks and Rew…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1740 users

The Big Programming Thread - Page 221

Forum Index > General Forum
Post a Reply
Prev 1 219 220 221 222 223 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.
heishe
Profile Blog Joined June 2009
Germany2284 Posts
December 18 2012 14:35 GMT
#4401
Need some help finding an article.

A while ago I read this article that did pretty in-depth comparisons between optimization performance of g++ (don't remember which versions), VS 2008/2010, maybe 2005 and Apples compilers as well.

Did anyone read this as well and knows where I can find it again?
If you value your soul, never look into the eye of a horse. Your soul will forever be lost in the void of the horse.
Recognizable
Profile Blog Joined December 2011
Netherlands1552 Posts
Last Edited: 2012-12-20 08:45:26
December 19 2012 15:11 GMT
#4402
Edit: Figured it out!
Thorakh
Profile Joined April 2011
Netherlands1788 Posts
December 19 2012 16:06 GMT
#4403
I am not familiar with Python but it looks like

return x += i


should be

return x + i
tzenes
Profile Blog Joined March 2010
Canada64 Posts
December 19 2012 17:02 GMT
#4404
On December 17 2012 04:13 Fission wrote:
Show nested quote +
On December 17 2012 04:10 Fission wrote:
I don't really get what all the fuss is about "getting a CS degree". I took a bunch of cs courses in university for easy credits due to my experience, and I found the courses to be comically trivial and mostly worthless. Tons of emphasis on completely unrealistic nonsense, no talk of coding design or practices, professors who had never worked as programmers etc. There were no courses on many widely used industry standard technologies. There were no .net courses, no database applications courses (just theory), zip. Just shitloads of C, C++, and a few java courses. The "really hard" algorithms and analysis compsci courses were laughably easy compared to honors real analysis or any high level honors math classes.



I went to one of the top canadian engineering schools


I actually spent some time teaching CS at a Canadian Engineering School and I'd like to share my experiences with you guys. For reference I got my undergraduate degree in the US (in computer science) and my graduate degree in Canada. I originally learned programming in highschool. Partially self taught while auditing a few courses in my home town.

One of the most frustrating things for me as a teacher, was the lack of programming experience the students had. I taught a series of third year courses, but spent an in-ordinate amount of time have to review what I felt were relatively basic concepts (pass by reference, linked lists, etc). This made it extremely difficult to teach more advanced concepts (such as using linear algebra to perform refraction in a ray tracer). I was also frustrated by the poor quality of the code and limited knowledge of what I felt were fairly standard coding practices (refactoring for example).

While I was there I spent some time talking to the other faculty about the problems I felt in the students we were graduating (many would graduate without understanding basic concepts). There were a number who shared my sentiments or went the extra mile to teach their students; sadly this was the minority. The majority of the faculty were concerned with one of two opinions: 1) teaching is a chore and should be pawned off on under prepared, over worked gradstudents so they could focus on what really mattered: research, or 2) they were here to teach the science of computers, the theory, not to teach students how to program (they believed that was what differed them from trade schools).

The former opinion is actually the easier one to understand. All the rewards a professor received (grants, tenure, etc) are keyed to their research with teaching playing a back seat in the academic world. My brother, who is an economist, would say: they've been incentivized to spend as little effort on teaching as necessary. I think you can influence this some at individual universities, but as this is really the pervasive feeling of the larger academic community it'll be hard to make progress here.

The latter opinion is the one that really frustrated me. Having been at a couple different universities I've found this is a constant debate in the computer science curriculum. It tends to have it's roots in whether the computer science department grew out of the university's electrical engineering curriculum or mathematics curriculum. Those that grew out of engineering departments tend to have a stronger focus on labs and producing actual code, where as those that grew out of mathematics tend to have a stronger emphasis on theory. By now these departments are mature enough at almost all universities that they're a blend of the two, but the roots tend to show a little.

I don't know how to overcome tradition, and eventually I left to work in industry. As someone who's a solid developer at a major tech company and has interviewed over a hundred college graduate candidates I can safely say the following: There is no trade school that feeds into big companies like Google, Facebook, Amazon, or Microsoft. That place doesn't exist. These companies hire (aggressively) from major universities and colleges. I can assure you they care both about theory and about actual code (neither is left out).

If you actually want some advice on getting a job at such a place, I'd certainly say the CS degree can't hurt (in fact, it'll probably help get a recruiter's attention). However, far more important is your level of skill. Programming is a craft, and if you don't practice it you will not get better. I would recommend you write code every day. Work on your own projects or contribute to open source. Every time you're using a computer and you think there should be a programming way to make it easier, go learn that way. Doesn't matter if learning takes longer because you will benefit from the knowledge and experience.
StraTkSloth
Profile Blog Joined August 2012
United States181 Posts
December 19 2012 17:45 GMT
#4405
Does anyone know how to search for a value and report its position in an array in java? Thanks.
Vega Squadron Player || StarCraft II entusiast
Thorakh
Profile Joined April 2011
Netherlands1788 Posts
Last Edited: 2012-12-19 17:56:49
December 19 2012 17:55 GMT
#4406
Does anyone know how to search for a value and report its position in an array in java? Thanks.

for (int i=0; i<array.length; i++)
{
if (array[i] == value)
{
return i;
}
}
Keep in mind that if value is a String, you'll have to use array[i].equals(value) instead of array[i] == value.
odE
Profile Joined December 2010
Finland177 Posts
Last Edited: 2012-12-19 19:33:10
December 19 2012 19:32 GMT
#4407
Or a method, depending on return type.

public int getValue(int index) {

return array[index];

}


RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
December 19 2012 19:45 GMT
#4408
On December 20 2012 02:55 Thorakh wrote:
Show nested quote +
Does anyone know how to search for a value and report its position in an array in java? Thanks.

for (int i=0; i<array.length; i++)
{
if (array[i] == value)
{
return i;
}
}
Keep in mind that if value is a String, you'll have to use array[i].equals(value) instead of array[i] == value.


Or binary search, or radix search.... wait... this is java, there's an api that will do this: http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html

If its unsorted, you can use Array.toString, then a String method like indexOf.
Any sufficiently advanced technology is indistinguishable from magic
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
Last Edited: 2012-12-20 03:38:46
December 20 2012 03:35 GMT
#4409
I just got from a job interview and I was asked with this problem

+ Show Spoiler +
We are developing Calculator application
it supports only 4 operators: +, -, *, /
the input text can take a string as input containing more that one operator
when the user clicks on "=" button, the application will parse and produce the output
give me all the possible scenarios where you'll have to handle the exceptions to make this calculator non-crashable


my answers were

+ Show Spoiler +
1) if there two or more operators used in succession i.e. (1 + + 1)
2) if the string input is not parsed to int or float
3) if the input is non numerical (not accepted, same as #2)
4) the input should be considered as long int to handle more values
and also the output (not an error, duh =.=)
5) the string should parse negative numbers correctly
6) there should only be one decimal point
7) the input should end with a number i.e. (1 + is not accepted)
8) the input should have at least one operation used (not accepted, since you can input 1 then press =)
9) the calculator must abide by mathematical laws. (i.e. cannot divide by 0)
10) the calculator should have a limit of decimal places as answers to avoid infinite loops by repeating decimals
11) more about logical error handling, the calculator should follow the MDAS, multiplication, division, addition/subtraction
12) if parenthesis is used, it should also calculate in the proper order
13) decimals with no numbers must be avoided
i.e. (5 + . + 9)


are there more errors that i have missed?
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
tofucake
Profile Blog Joined October 2009
Hyrule19189 Posts
Last Edited: 2012-12-20 03:44:32
December 20 2012 03:43 GMT
#4410
The simple answer is to parse it out into a tree. If there are any unbalanced nodes it's an invalid equation. Not sure if this would be accepted as just an answer but you can say "also you can make it a tree which should cover most issues" or whatever.
Liquipediaasante sana squash banana
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
December 20 2012 03:48 GMT
#4411
haven't thought about that, but i think he wanted me to enumerate the 'issues' =/
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
tofucake
Profile Blog Joined October 2009
Hyrule19189 Posts
December 20 2012 03:52 GMT
#4412
Yeah that's what I figured after I wrote my reply. 13 is redundant though because . doesn't parse to a number and it's not an operator.
Liquipediaasante sana squash banana
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2012-12-20 04:23:36
December 20 2012 04:16 GMT
#4413
To be fair, questions like that are rarely about the answer and almost definitely about the thought process. If you're jumping around into different areas while giving errors, it looks bad on you. You should've been asking more questions about what the calculator can do, rather than focusing on solving it. It doesn't really matter if you get all the cases as long as you show you understand how to test something.


The description is asking you to make sure the calculator doesn't crash, nothing about the logic of the operations. You should have clarified this immediately.

You should also ask how the calculator parses numbers, or are you implementing that functionality, because then you have to handle cases such as " - - 1 " or " 1 - + 0 " being valid operations since " - - 1 " could be handled as just " 1 ".

Anyways, having a structured approach would've looked good on you.

  • validate this string only has legal characters ( numbers + operators only )
  • validate this string is a mathematical operation ( building a tree )
  • validate that all the mathematic operations produce real numbers ( check for division by 0 )




* actually, I think it doesn't have to be a balanced tree entirely. It can be balanced only for * and / operations, but as long as the + and - operators remain on the left side of a node, the equation could still be valid. No parentheses though so that should be clarified.


On December 20 2012 13:19 Craton wrote:
You could've also tackled regional support, where different countries transpose the meanings of periods and commas.


This would've been awesome to note. XD
There is no one like you in the universe.
Craton
Profile Blog Joined December 2009
United States17274 Posts
December 20 2012 04:19 GMT
#4414
You could've also tackled regional support, where different countries transpose the meanings of periods and commas.
twitch.tv/cratonz
tofucake
Profile Blog Joined October 2009
Hyrule19189 Posts
December 20 2012 04:30 GMT
#4415
On December 20 2012 13:16 Blisse wrote:
To be fair, questions like that are rarely about the answer and almost definitely about the thought process. If you're jumping around into different areas while giving errors, it looks bad on you. You should've been asking more questions about what the calculator can do, rather than focusing on solving it. It doesn't really matter if you get all the cases as long as you show you understand how to test something.


The description is asking you to make sure the calculator doesn't crash, nothing about the logic of the operations. You should have clarified this immediately.

You should also ask how the calculator parses numbers, or are you implementing that functionality, because then you have to handle cases such as " - - 1 " or " 1 - + 0 " being valid operations since " - - 1 " could be handled as just " 1 ".

Anyways, having a structured approach would've looked good on you.

  • validate this string only has legal characters ( numbers + operators only )
  • validate this string is a mathematical operation ( building a tree )
  • validate that all the mathematic operations produce real numbers ( check for division by 0 )




* actually, I think it doesn't have to be a balanced tree entirely. It can be balanced only for * and / operations, but as long as the + and - operators remain on the left side of a node, the equation could still be valid. No parentheses though so that should be clarified.


Show nested quote +
On December 20 2012 13:19 Craton wrote:
You could've also tackled regional support, where different countries transpose the meanings of periods and commas.


This would've been awesome to note. XD

the tautology is like

EQUATION: EXPRESSION
EXPRESSION: EXPRESSION
EXPRESSION: (EXPRESSION)
EXPRESSION: NUMBER
EXPRESSION: EXPRESSION OPERATOR EXPRESSION
NUMBER: a number
OPERATOR: + - * /

So that would cover just about everything (except inputting ++1 or something like that). So then you get just one case to check for. The rest works itself out.
Liquipediaasante sana squash banana
AmericanUmlaut
Profile Blog Joined November 2010
Germany2589 Posts
December 20 2012 11:14 GMT
#4416
I think the discussion of icystorage's specific interview question so far has been excellent in terms of solving the specific problem. Since you're not likely to need this specific knowledge again, though, here would be my analysis of the general case of which this question is a specific example:

- Blisse's point is very important. Past a certain point, your interviewer does not care whether your conclusion is correct. Forgetting a semicolon or missing one of several obscure edge cases is not going to sink your prospects. What your interviewer wants to see is that you approach a problem correctly.

- Elegance in a solution is one of the hallmarks of a good programmer. Your approach seems like it was to figure out every specific instance in which a string would evaluate as invalid, whereas a better solution is almost always to find the smallest possible set of general rules from which those specific instances arise. Such solutions are easier to maintain due to their simplicity, and they're also much less likely to have bugs, because they're less likely to have holes. If you check specifics, you'll only recognize specifics. If you check generalities, you'll recognize all specifics that match those generalities, even the ones you didn't think of.

- That being said, being able to reel off a list of invalid states like you did is actually really good, because that's what you do after you've design an algorithm. You get all crazy paranoid and put on your tinfoil hat and think about malicious users entering "-----------------------------------------------------------------1++++++++++++++++++++-+-+-+-+-++++3=x". If you can present an elegant solution and then go through a list of a couple of normal cases and a couple of crazy edge cases and explain why your solution handles all of them correctly, then you've got an excellent response.

So I'd say your response wasn't bad per se, it was just missing the important middle step. The way you answered is the way I would want someone I was considering for a QA position to answer.
The frumious Bandersnatch
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
December 20 2012 11:30 GMT
#4417
honestly, this is my first job interview, i really got mentally blocked and was very nervous. there were theoretical questions like what's the difference between c and c++? what's in c++ OOP not in Java OOP? how do you make a class non-inheritable?
most of the questions i got stumped and started to make up using stock knowledge.

i was kinda disappointed with the given problem. i guess the interviewer wanted me to enumerate the errors since when i showed him my answers he said i only got 9 right and asked me if I could get a tenth answer but I didn't. after that, i immediately went to TL and ask you guys what I missed and where I went wrong.

thank you so much for your replies. this really helps me in the future. i always approached my error handling in terms of looking for when i get errors, not the 'middle step' as you stated. the tree answer really enlightened me. thanks!
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
AmericanUmlaut
Profile Blog Joined November 2010
Germany2589 Posts
December 20 2012 12:10 GMT
#4418
Interviewing is itself a really important skill. It's fine to have an interview that doesn't go well as long as you learn something from it.
The frumious Bandersnatch
Fyodor
Profile Blog Joined September 2010
Canada971 Posts
December 20 2012 12:45 GMT
#4419
On December 20 2012 20:30 icystorage wrote:
honestly, this is my first job interview, i really got mentally blocked and was very nervous. there were theoretical questions like what's the difference between c and c++? what's in c++ OOP not in Java OOP? how do you make a class non-inheritable?
most of the questions i got stumped and started to make up using stock knowledge.

i was kinda disappointed with the given problem. i guess the interviewer wanted me to enumerate the errors since when i showed him my answers he said i only got 9 right and asked me if I could get a tenth answer but I didn't. after that, i immediately went to TL and ask you guys what I missed and where I went wrong.

thank you so much for your replies. this really helps me in the future. i always approached my error handling in terms of looking for when i get errors, not the 'middle step' as you stated. the tree answer really enlightened me. thanks!

wow wtf, I would have aced that interview ;_;

-difference between C and C++: mainly OOP. (Also lambdas, generics, much bigger standard library, etc)
-C++ OOP not in Java: multiple inheritance, "rule of three" member functions, operator overloading.
-how do you make a class non-inheritable? make it "final".

those are practical questions to me lol. Theoretical questions would be: name three O(log(n)) sorting algorithms... Difference between linked list and doubly linked list...
llllllllllllllllllllllllllllllllllllllllllll
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
December 20 2012 12:50 GMT
#4420
i actually answered some incompletely.

i was like
'the main difference about c and c++ is mainly about c++ being OOP'
'how?'
boom. stumped.
yeah i got the 'final' one correct tho i first answered to make it abstract and he said it was wrong (i was about to bang my head on the desk) then i said convert it to final.

yeah he also asked me the difference between array and ArrayList
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Prev 1 219 220 221 222 223 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
11:00
Season 13 World Championship
Nicoract vs PercivalLIVE!
Solar vs TBD
Krystianer vs Shameless
WardiTV670
TKL 166
IndyStarCraft 145
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 170
TKL 166
IndyStarCraft 145
StarCraft: Brood War
Sea 8708
Rain 2745
Calm 2430
Horang2 1640
Soma 662
Larva 545
EffOrt 523
Stork 508
Zeus 434
BeSt 405
[ Show more ]
firebathero 327
ggaemo 307
Mini 276
Snow 229
ZerO 216
Sharp 195
Mong 126
Hyun 116
hero 116
Rush 100
Hm[arnc] 93
Killer 92
Pusan 87
Mind 63
soO 57
Noble 45
ToSsGirL 44
Shuttle 36
Light 32
Barracks 31
Movie 25
ajuk12(nOOB) 20
zelot 16
Terrorterran 14
scan(afreeca) 14
HiyA 13
GoRush 12
ivOry 8
Dota 2
Gorgc3744
singsing2457
qojqva376
XcaliburYe86
NeuroSwarm75
Counter-Strike
olofmeister1974
shoxiejesuss860
x6flipin617
byalli523
Other Games
B2W.Neo1032
Pyrionflax304
Sick182
QueenE68
KnowMe44
ZerO(Twitch)4
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• StrangeGG 45
• naamasc225
• IndyKCrew
• Migwel
• AfreecaTV YouTube
• sooper7s
• intothetv
• Kozan
• LaughNgamezSOOP
• Laughngamez YouTube
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Nemesis3906
• Lourlo898
• TFBlade472
• Stunt456
Upcoming Events
PiGosaur Monday
12h 6m
The PondCast
21h 6m
OSC
22h 6m
Big Brain Bouts
3 days
Serral vs TBD
BSL 21
4 days
BSL 21
5 days
Wardi Open
6 days
Monday Night Weeklies
6 days
Liquipedia Results

Completed

Proleague 2026-01-19
SC2 All-Star Inv. 2025
NA Kuram Kup

Ongoing

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

Upcoming

Escore Tournament S1: W5
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 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.