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
IMPORTANT: Please Change Your Passwords to avoid being botted. | Click for Discord
  • No one is chatting at the moment.
  • M murtaza12:
    XPremiuM said:
    Why? Was the site hacked or something?
    Yes
    Link
  • XPremiuM XPremiuM:
    GloriousChicken said:
    Everyone, please change your passwords.
    Why? Was the site hacked or something?
    Link
  • GloriousChicken GloriousChicken:
    Everyone, please change your passwords.
    Link
  • Necrokiller Necrokiller:
    The only valid thing from his pov he said in the video is AC dead since Black Flag. According to woke police that game was woke too. Welsh man in West Indies. So atleast he's consistent I guess lol
    Link
  • Link
  • XPremiuM XPremiuM:
    Necrokiller said:
    It's based on an actual real life person so I don't think the woke police have a valid case here.
    Nope. They have a very valid case. The above video explains it all.
    Link
  • Necrokiller Necrokiller:
    It's based on an actual real life person so I don't think the woke police have a valid case here.
    • Like
    Reactions: SolitarySoldier
    Link
  • XPremiuM XPremiuM:
    Meanwhile Ghost of Tsushima PC version is out now. Looks 100 times better than ASS Creed already.
    Link
  • XPremiuM XPremiuM:
    Did y'all see the new Assassin's Creed trailer? They finally made a AC set in Japan & then they put a negro as the male protagonist. Ubisoft is taking cues from Disney, and it isn't gonna end well for them, just like Disney. Go woke, go broke!
    Link
  • Necrokiller Necrokiller:
    First Fallout 4 update and now this 🤡
    Link
  • Necrokiller Necrokiller:
    MS and Bethesda continuing their streak of massive Ls 😬
    Link
  • Link
  • funky funky:
    Hello
    Link
  • NaNoW NaNoW:
    by closing down good studios
    Link
  • NaNoW NaNoW:
    well he is breaking barriers
    • Like
    Reactions: KetchupBiryani
    Link
  • 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
    M murtaza12: Why? Was the site hacked or something?Yes