• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:32
CEST 03:32
KST 10: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
Code S Season 1 (2026) - RO4 & Finals Preview4[ASL21] Ro4 Preview: On Course12Code S Season 1 - RO8 Preview7[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13
Community News
Code S Season 1 (2026) - RO8 Results2Weekly Cups (May 4-10): Clem, MaxPax, herO win1Maestros of The Game 2 announcement and schedule !11Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12
StarCraft 2
General
Team Liquid Map Contest #22 - The Finalists Code S Season 1 (2026) - RO4 & Finals Preview Code S Season 1 (2026) - RO8 Results Code S Season 1 (2026) - RO12 Results MaNa leaves Team Liquid
Tourneys
GSL Code S Season 1 (2026) Sparkling Tuna Cup - Weekly Open Tournament KSL Week 89 2026 GSL Season 2 Qualifiers Maestros of The Game 2 announcement and schedule !
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
The PondCast: SC2 News & Results Mutation # 526 Rubber and Glue Mutation # 525 Wheel of Misfortune Mutation # 524 Death and Taxes
Brood War
General
vespene.gg — BW replays in browser Data needed BGH Auto Balance -> http://bghmmr.eu/ Pros React to: TvT Masterclass in FlaSh vs Light BW General Discussion
Tourneys
[ASL21] Semifinals B [BSL22] RO8 Bracket Stage + Another TieBreaker [ASL21] Ro8 Day 4 Escore Tournament StarCraft Season 2
Strategy
Muta micro map competition Fighting Spirit mining rates [G] Hydra ZvZ: An Introduction Simple Questions, Simple Answers
Other Games
General Games
Warcraft III: The Frozen Throne Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread YouTube Thread Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
Travel Agencies vs Online Booking Platforms The Automated Ban List
Blogs
Why RTS gamers make better f…
gosubay
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1406 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
Hyrule19213 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
Hyrule19213 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 States17282 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
Hyrule19213 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
Germany2594 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
Germany2594 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
00:00
OSC Elite Rising Star #19
CranKy Ducklings63
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft346
RuFF_SC2 136
CosmosSc2 107
JuggernautJason64
Ketroc 64
StarCraft: Brood War
GuemChi 6901
Artosis 733
Dota 2
monkeys_forever581
NeuroSwarm134
League of Legends
JimRising 657
Counter-Strike
taco 466
Other Games
summit1g16858
tarik_tv8952
FrodaN1694
Maynarde124
Organizations
Other Games
gamesdonequick1073
BasetradeTV108
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 75
• davetesta51
• CranKy Ducklings SOOP16
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra1370
Upcoming Events
Replay Cast
7h 28m
Wardi Open
10h 28m
Monday Night Weeklies
14h 28m
Replay Cast
22h 28m
The PondCast
1d 8h
Kung Fu Cup
1d 9h
GSL
2 days
Replay Cast
2 days
GSL
3 days
WardiTV Spring Champion…
3 days
[ Show More ]
Replay Cast
3 days
Sparkling Tuna Cup
4 days
WardiTV Spring Champion…
4 days
Replay Cast
4 days
RSL Revival
5 days
Classic vs SHIN
Rogue vs Bunny
BSL
5 days
Replay Cast
5 days
Afreeca Starleague
6 days
Flash vs Soma
RSL Revival
6 days
BSL
6 days
Patches Events
6 days
Liquipedia Results

Completed

Escore Tournament S2: W7
2026 GSL S1
Nations Cup 2026

Ongoing

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

Upcoming

Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
WardiTV Spring 2026
2026 GSL S2
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.