The Official Programming Thread

Fate

-
Aug 21, 2015
61
0
0
Karachi
I'm also starting Uni so I thought I'd do some learning myself. I already know HTML and CSS a bit, but like Eternal Blizzard said they're a little different from actual programming languages. So I picked up C# a week ago and am currently practicing on C# on Visual Studio.

What books do you guys read for programming? Where can I find some good ones in Karachi?
 

EternalBlizzard

Lazy guy :s
Moderator
Oct 29, 2011
2,732
1,195
129
Attractor Field Beta
Nice share mate.

Currently learning c++ myself with the help of a good book and doing practice programs.

Where are you learning it from ?

Sent from my SM-G935F using Tapatalk
OOP in C++ by Robert Lafore for programming concepts such as inheritance/polymorphism etc. Other than that i just think of a program and start making it in the language i am currently learning. Open up the C++ reference to find the list of functions i can use and just start making my program.

@Fate
for C# check Rob Miles Yellow Book and Microsoft Visual C# Step by Step by John Sharp for some in depth details such as boxing/unboxing and garbage collector.
 

staticPointer

PG LEGENDARY
Dec 7, 2012
3,266
0
41
افغانستان
www.pakgamers.com
OOP in C++ by Robert Lafore for programming concepts such as inheritance/polymorphism etc. Other than that i just think of a program and start making it in the language i am currently learning. Open up the C++ reference to find the list of functions i can use and just start making my program.

@Fate
for C# check Rob Miles Yellow Book and Microsoft Visual C# Step by Step by John Sharp for some in depth details such as boxing/unboxing and garbage collector.

hey man.. i have an image fb but its url is expired.. any way to restore it??? its image btw

check :
Code:
https://scontent-cdg2-1.xx.fbcdn.net/v/t1.0-9/63402_10151509531634754_1048725560_n.jpg?oh=05539b0bde4e400ffafbb7bff409f2cf&oe=57B1E8AC
 

Newton

Well-known member
May 17, 2009
2,223
0
41
Lahore, Faisalabad
i thought we could use only 1 loop. to keep O ( n )

you are nesting loops here. can i nest loops?
 
Last edited by a moderator:

EternalBlizzard

Lazy guy :s
Moderator
Oct 29, 2011
2,732
1,195
129
Attractor Field Beta
I'm trying to use Eternal Blizzards approach over here. Just can't figure out how to code it up.
you could make 1 for loop that iterates over all the coordinates. Make a variable that holds the starting coordinate and a variable that hold this index. Iterate over the array finding slopes between the selected starting coordinate and others. Then make a check at the end if iteration has reached the last element. If it has do a ++ in your starting coordinate index so that it is now the 2nd element. Reset the iteration variable to the starting coordinate index + 1 ( we don't need to find slope between 2nd and 1st as it has already been found the first time). That's what i can think of without nested loops.
 

Newton

Well-known member
May 17, 2009
2,223
0
41
Lahore, Faisalabad
you could make 1 for loop that iterates over all the coordinates. Make a variable that holds the starting coordinate and a variable that hold this index. Iterate over the array finding slopes between the selected starting coordinate and others. Then make a check at the end if iteration has reached the last element. If it has do a ++ in your starting coordinate index so that it is now the 2nd element. Reset the iteration variable to the starting coordinate index + 1 ( we don't need to find slope between 2nd and 1st as it has already been found the first time). That's what i can think of without nested loops.
wouldnt that make it a O ( n*n ) algorithm?
 

Ali Man

Devilz Mafia
Oct 1, 2008
4,955
1
43
Islamabad
you could make 1 for loop that iterates over all the coordinates. Make a variable that holds the starting coordinate and a variable that hold this index. Iterate over the array finding slopes between the selected starting coordinate and others. Then make a check at the end if iteration has reached the last element. If it has do a ++ in your starting coordinate index so that it is now the 2nd element. Reset the iteration variable to the starting coordinate index + 1 ( we don't need to find slope between 2nd and 1st as it has already been found the first time). That's what i can think of without nested loops.
You're saying that the array would be inside the for loop?
I'm still trying to understand how you would calculate the sloop e.g. using y = mx + c
 

EternalBlizzard

Lazy guy :s
Moderator
Oct 29, 2011
2,732
1,195
129
Attractor Field Beta
wouldnt that make it a O ( n*n ) algorithm?
Yar i still don't know how this complexity thing works. If you just have to avoid nested for loops you can reset ur iteration variables at the end of the for loop to make it serve as a nested loop. Does this reduce the complexity? Other wise i would've put that for loop i mentioned inside a while loop. It would do the same work, and save me from the work of resetting iteration variables

@Ali Man
Yes the array will be inside a single for loop. In order to advance our current selected coordinate and iterate over the whole array again and again, you need to reset the iteration variables and update the selected coordinate when the iteration variable reaches the end.
calculate slope using y2-y1/x2-x1 where y is column and x is row. take its arc tangent to get theta


EDIT:-
Wait i get it.. so O( n )means you can only iterate it n times. doesn't mean if you use nested loops or not. Well if that's the case i can't think of any other solution. I don't think you can determine in 1 go whether all the queens intersect any other queen or not.
 
Last edited:

Newton

Well-known member
May 17, 2009
2,223
0
41
Lahore, Faisalabad
Another way is as follows
the board has N rows, N columns and N+N-1 diagonals

Code:
int rowAttack[N];
int colAttack[N];
int diaAttack[N+N-1]


for (all queens)
{
   rowAttack[queen.X] = 1; //keeps a record which row has a queen when another queen comes break the loop
   colAttack[queen.Y] = 1; //keeps a record which column has a queen when another queen comes break the loop
   diaAttack[diagonal number] = 1; //keeps a record which diagonal has a queen when another queen comes break the loop
}
you will need to figure out how to check the diagonal number. the coordinates will help you in doing that.

when i say rows i mean all boxes in a horitonal line like this _
when i say columns i mean all boxes in a verticle line like this |
when i say diagonals i mean all boxes in an inclined diagonal like this /
 
General chit-chat
Help Users
We have disabled traderscore and are working on a fix. There was a bug with the plugin | Click for Discord
  • No one is chatting at the moment.
  • iampasha iampasha:
    SolitarySoldier said:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    guys the biggest yapper in the Industry right now. All he do is yap
    Link
  • Necrokiller Necrokiller:
    Phil should be held responsible for this shitfest too, just like Sarah, but it's highly likely that these decisions are coming from Satya. And this isn't even the end of it. More closures are coming.
    Link
  • SolitarySoldier SolitarySoldier:
    if we are moving towards more and more popular trash across platforms that make billions for companies, I'm happy with all the barriers and exclusivity because at least that brings some pressure to create good stuff.
    Link
  • SolitarySoldier SolitarySoldier:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    Link
  • SolitarySoldier SolitarySoldier:
    "These changes are not a reflection of the creativity and skill of the talented individuals at these teams or the risks they took to try new things" ... seems to me that's exactly what it is
    Link
  • SolitarySoldier SolitarySoldier:
    why make good games when u can just buy everyone and shut them down lol
    Link
  • XPremiuM XPremiuM:
    I'm gonna say one last time, F*** Microsoft to infinity!
    Link
  • XPremiuM XPremiuM:
    Microsoft deserves all the hate they can get. Seriously i can't explain how much i want to curse them out.
    Link
  • XPremiuM XPremiuM:
    They could've sold the studios instead of closing them, but the nazi bastards just didn't want competition down the road.
    Link
  • Link
  • XPremiuM XPremiuM:
    F*** Microsoft, and F*** their fanboys.
    Link
  • XPremiuM XPremiuM:
    What's the f*** is wrong with them? I mean really? Have they completely lost it? F***ing retards.
    Link
  • XPremiuM XPremiuM:
    So i just found out that f***ing s***bag Microsoft shut down Arkane Studio (makers of the brilliant Dishonored series) and Tango Gameworks (makers of the iconic The Evil Within series), among some other studios. I just want to say a giant F*** Y**! to Microsoft. THEY'VE F***ED UP BIG TIME this time.
    Link
  • Necrokiller Necrokiller:
    MS: Hold my trillion dollars
    Link
  • Necrokiller Necrokiller:
    Sony: We can f**k up a totally good situation.
    Link
  • Link
  • XPremiuM XPremiuM:
    Started Dead Island 2, and i find it pretty lame. The story is shit. The characters are either cringe or bland (all 6 of them), The gameplay isn't fun. Even the goddamn zombies don't behave like proper zombies. They're all fast & intelligent unlike how zombies are supposed to be like. Any fan of "zombie" genre cannot possibly like this shitfest of a game. Dying Light 2 was million times better than this shit.
    Link
  • NaNoW NaNoW:
    so Baldurs Gate 3 is pretty great!"
    Link
  • faraany3k faraany3k:
    So who here is waiting for Senua Hellblade 2. Prequel was a true mind fuck experience.
    Link
  • GloriousChicken GloriousChicken:
    Sad indeed
    Link
  • NaNoW NaNoW:
    what a sad day
    Link
  • faraany3k faraany3k:
    Necrokiller said:
    MS one upping Sony in catching the biggest L in gaming
    tbh gaming industry as a whole is failing much like tech industry. They have buckled down too much to Corporate suites then relying on passionate and innovative people. A corporate only believes in financial growth and shareholders.
    Link
  • Necrokiller Necrokiller:
    MS one upping Sony in catching the biggest L in gaming
    Link
  • Link
  • NaNoW NaNoW:
    oh
    Link
    iampasha iampasha: Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada...