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,193
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,193
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,193
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.
  • faraany3k faraany3k:
    Which Franchise has 5 releases but only two games. Last of Us
    Link
  • faraany3k faraany3k:
    Shadowdragoo said:
    no idea how that is a steal by wasting 3500 rupees per month and for games that are removed before you can finish them off.xbox gamepass is garbage with no local prices
    why you are paying american rates in Pakistan. Search cheaper region like Turkey. 13k for 13 months. Ms does not care
    Link
  • Link
  • S Shadowdragoo:
    no idea how that is a steal by wasting 3500 rupees per month and for games that are removed before you can finish them off.xbox gamepass is garbage with no local prices
    Link
  • faraany3k faraany3k:
    Just finished Diablo 4 season in hurry to play Fallout 4 but gamepass released another banger in the form of Star Wars on April 25th. Gamepass is a steal man.
    Link
  • Necrokiller Necrokiller:
    EternalBlizzard said:
    Is it just me or people lately seem to defend every bad game design decision made by the devs and try to give bullshit reasons for that? Or perhaps it's because I'm on reddit and discord :ROFLMAO:
    There are no such thing as "bad design" bro, its all "artistic vision" now :ROFLMAO:
    • Haha
    Reactions: EternalBlizzard
    Link
  • EternalBlizzard EternalBlizzard:
    Is it just me or people lately seem to defend every bad game design decision made by the devs and try to give bullshit reasons for that? Or perhaps it's because I'm on reddit and discord :ROFLMAO:
    • Haha
    Reactions: Necrokiller
    Link
  • B Baghi:
    vos
    Link
  • Link
  • G gorillageneral:
    It's me cattoboee
    Link
  • G gorillageneral:
    It's me tattooed
    Link
  • Link
  • C cattoboee:
    testing
    Link
  • NaNoW NaNoW:
    true
    Link
  • faraany3k faraany3k:
    Add 20 years into your age. Congrats you are in Playstation 8 era. Probably a VR streaming headset in a form of glasses.
    Link
  • S Shehryar89:
    Hi any repair shop for Nintendo Switch in Isb/ Rwp? The console is not charging. Anybody? Who can help in this regard.
    Link
  • iampasha iampasha:
    Ewww brother ewww, what's that brother? Whats that?
    Link
  • Necrokiller Necrokiller:
    Senua Saga 30fps both on Series S and X. Gotta feel bad for the Series X owners.
    Link
  • Necrokiller Necrokiller:
    Imagine buying a Pro console and still getting 30fps in GTA 6 😬
    Link
  • faraany3k faraany3k:
    So this console gen was like putting a SSD in an old laptop
    Link
  • LordIT LordIT:
    does anyone know a reliable vendor in lahore for laptop batteries?
    Link
  • XPremiuM XPremiuM:
    I remember when PG used to be such an active site. Now it's barely alive.
    Link
  • XPremiuM XPremiuM:
    Any mods online?
    Link
  • NaNoW NaNoW:
    .....
    Link
  • Link
    faraany3k faraany3k: Which Franchise has 5 releases but only two games. Last of Us