• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:39
CEST 11:39
KST 18:39
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou16Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (March 17-23): Clem Bounces Back DreamHack Open 2013 revealed The New Patch Killed Mech!
Tourneys
$1,200 WardiTV October (Oct 21st-31st) SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
Is there anyway to get a private coach? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BSL Season 21 OGN to release AI-upscaled StarLeague from Feb 24
Tourneys
300$ 3D!Community Brood War Super Cup #4 [ASL20] Semifinal B Azhi's Colosseum - Anonymous Tournament [Megathread] Daily Proleagues
Strategy
Current Meta Roaring Currents ASL final [I] Funny Protoss Builds/Strategies BW - ajfirecracker Strategy & Training
Other Games
General Games
Path of Exile Nintendo Switch Thread Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine The Chess Thread Russo-Ukrainian War Thread Men's Fashion Thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1091 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
Hyrule19144 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
Hyrule19144 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 States17256 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
Hyrule19144 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
Germany2579 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
Germany2579 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 21m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 205
SortOf 168
mcanning 63
StarCraft: Brood War
hero 1802
Flash 732
firebathero 417
GuemChi 359
Killer 339
Leta 259
Mini 188
Hyun 182
PianO 142
Soma 126
[ Show more ]
ZerO 107
ToSsGirL 76
Aegong 29
Free 25
Sacsri 15
Sharp 15
Rush 7
Bale 5
Mong 1
Dota 2
XaKoH 401
XcaliburYe169
canceldota73
League of Legends
JimRising 578
Counter-Strike
olofmeister1468
shoxiejesuss770
Stewie2K299
Other Games
summit1g7647
singsing798
ceh9571
B2W.Neo380
Hui .150
Mew2King56
Trikslyr13
ZerO(Twitch)6
Organizations
Other Games
gamesdonequick612
Counter-Strike
PGL270
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• LUISG 30
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• iopq 0
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV507
League of Legends
• Jankos1812
• Lourlo755
Upcoming Events
Replay Cast
21m
OSC
6h 21m
Tenacious Turtle Tussle
13h 21m
The PondCast
1d
OSC
1d 2h
WardiTV Invitational
2 days
Online Event
2 days
RSL Revival
2 days
RSL Revival
3 days
WardiTV Invitational
3 days
[ Show More ]
Afreeca Starleague
3 days
Snow vs Soma
Sparkling Tuna Cup
4 days
WardiTV Invitational
4 days
CrankTV Team League
4 days
RSL Revival
4 days
Wardi Open
5 days
CrankTV Team League
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
TLPD

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

Advertising | Privacy Policy | Terms Of Use | Contact Us

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