• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 18:47
CET 00:47
KST 08:47
  • 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
Greatest Players of All Time: Addendum - Dark10Team Liquid Map Contest #2312[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5
Community News
[BSL23] ProLeague RO82Serral wins 2026 RSL Season Finals12Weekly Cups (Nov 16-22): MaxPax doubles, Dark heats up0BSL 2v2 ProLeague Season 44Weekly Cups (Nov 9-15): Clem and herO take over6
StarCraft 2
General
About rush maps Best SC2 Parody Song about 2v2? Greatest Players of All Time: Addendum - Dark Serral wins 2026 RSL Season Finals How do you feel about the mass reverts in the 5.0.17 PTR?
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Kung Fu Cup - 2026 Grand Finals (Nov 24-29) RSL goes to London! 2026 Offline Finals Nov 21-22 soO & FanTaSy return! SC2 Kevin Scrim 4v4 (Nov 16) ISSL:Premier#2 Announcement
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps Starcraft 2 Advance [D] the control group Simple Questions/Answers
External Content
Mutation # 553 Undermined The PondCast: SC2 News & Results Mutation # 552 Secret Storm Mutation # 551 Robotic Revival
Brood War
General
BW General Discussion List of top players active on ShieldBattery New ASL23 Maps SOOP Announces New Women's Monthly Tournament screpdb: new Starcraft reporting tool
Tourneys
2v2v2v2 Tournament Stage 2: Players BSL 2v2 ProLeague Season 4 Ultimate Battle Event [BSL23] ProLeague RO8
Strategy
Request - 3-factory/fast timings as Terran Pluto's TvP 5Marine 2Medic Push Simple Questions, Simple Answers Infested Terran strategies in 2026
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread The PlayStation 5 Warcraft III: The Frozen Throne Free Space RTS Game, optimised f. Phone/Tablet etc
Dota 2
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Artificial Intelligence Thread The Chess Thread The Games Industry And ATVI Russo-Ukrainian War Thread
Fan Clubs
INnoVation Fan Club Fan Club Resource Thread
Media & Entertainment
Anime Discussion Thread Movie Discussion!
Sports
Football (Soccer) Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
[Kickstarter] The Roman E…
LUCKY_NOOB
On Parallel Lives in Fascis…
p4NDemik
The time I organised my…
AssyrianKing
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7750 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
Hyrule19276 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
Hyrule19276 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 States17305 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
Hyrule19276 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
Germany2601 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
Germany2601 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
Next event in 11h 13m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech112
EmSc Tv 21
JuggernautJason2
StarCraft: Brood War
iFU.spx 1
Dota 2
syndereN637
PGG 158
League of Legends
JimRising 129
Other Games
summit1g9207
tarik_tv4756
Doublelift3458
Grubby1954
Coldzera 793
Mew2King53
Organizations
Other Games
gamesdonequick1102
StarCraft 2
EmSc Tv 21
[ Show 12 non-featured ]
StarCraft 2
• musti20045 31
• Hupsaiya 16
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• imaqtpie1583
• Shiphtur311
Upcoming Events
Kung Fu Cup
11h 13m
Solar vs Rogue
herO vs TBD
BSL
20h 13m
Kyrie vs JDConan
Dewalt vs eOnzErG
Replay Cast
23h 13m
WardiTV Weekly
1d 12h
Ultimate Battle
1d 12h
Sparkling Tuna Cup
2 days
PiGosaur Cup
3 days
The PondCast
4 days
KCM Race Survival
4 days
Replay Cast
4 days
[ Show More ]
CranKy Ducklings
6 days
Liquipedia Results

Completed

Sijosae Cup
RSL Offline Finals
Underdog Cup 2026 Div 2-3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
CSL Season 23: Qualifier 1
Sector 591
CSL Season 23: Qualifier 2
Kung Fu Cup 2026 Grand Finals
Calamity Cup Div. A Season 8
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026

Upcoming

YSL S4
SC4ALL II: Brood War
CSL 2026 Winter (S23) - 3v3
CSL 2026 Winter (S23)
NBSL 2026 Xiamen LAN
BSL 23: Non-Korean Championship
BSL 2v2 Season 4
HSC XXX
Stellar Fest 2: Lunar Cup
StarCraft2 Weekly Open Tournament 2026 Grand Finals
SC4ALL II: StarCraft II
IEM Kraków 2027
PGL Bucharest 2027
BLAST Bounty Winter 2027
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.