• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:44
CEST 16:44
KST 23:44
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings How does the number of casters affect your enjoyment of esports? Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL BGH Auto Balance -> http://bghmmr.eu/ Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 769 users

The Big Programming Thread - Page 663

Forum Index > General Forum
Post a Reply
Prev 1 661 662 663 664 665 1031 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.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
September 13 2015 22:00 GMT
#13241
On September 11 2015 11:50 Housemd wrote:
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<<end1;
}
else
{
cout << "I suck at programming"<<end1;
}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.


Your compiler must be pretty nice to compile this code for you.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
September 14 2015 05:06 GMT
#13242
Does anyone know of some fun number logic questions, ideally the kind that get asked in interviews?
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
phar
Profile Joined August 2011
United States1080 Posts
September 14 2015 06:21 GMT
#13243
You should not be getting asked number logic questions in interviews. Or at least, what sort of position are you talking about?
Who after all is today speaking about the destruction of the Armenians?
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2015-09-14 07:22:22
September 14 2015 07:18 GMT
#13244
On September 14 2015 15:21 phar wrote:
You should not be getting asked number logic questions in interviews. Or at least, what sort of position are you talking about?

A friend of mine had an interview for a firmware programming position (graduate position) and had a series of number logic questions. For example, in 3 steps take boxes X Y and Z with any numbers in X and Y and 0 in Z and only using + and - operators (and one operation per step) to swap X and Y.

EDIT perhaps that's not a "good interview" but if it does happen then I want to prepare for it, optimal interview style or not. And the puzzles are quite fun to work out anyway.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2015-09-14 09:16:20
September 14 2015 08:45 GMT
#13245
On September 14 2015 16:18 Birdie wrote:
Show nested quote +
On September 14 2015 15:21 phar wrote:
You should not be getting asked number logic questions in interviews. Or at least, what sort of position are you talking about?

A friend of mine had an interview for a firmware programming position (graduate position) and had a series of number logic questions. For example, in 3 steps take boxes X Y and Z with any numbers in X and Y and 0 in Z and only using + and - operators (and one operation per step) to swap X and Y.

EDIT perhaps that's not a "good interview" but if it does happen then I want to prepare for it, optimal interview style or not. And the puzzles are quite fun to work out anyway.


That's actually fun. Do you mean something like that?

+ Show Spoiler +


X = 10;
Y = 5;
Z = 0;

Z = X + Y;
Y = Z - Y;
X = Z - X;

Time is precious. Waste it wisely.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2015-09-15 02:12:14
September 14 2015 09:05 GMT
#13246
On September 14 2015 17:45 Manit0u wrote:
Show nested quote +
On September 14 2015 16:18 Birdie wrote:
On September 14 2015 15:21 phar wrote:
You should not be getting asked number logic questions in interviews. Or at least, what sort of position are you talking about?

A friend of mine had an interview for a firmware programming position (graduate position) and had a series of number logic questions. For example, in 3 steps take boxes X Y and Z with any numbers in X and Y and 0 in Z and only using + and - operators (and one operation per step) to swap X and Y.

EDIT perhaps that's not a "good interview" but if it does happen then I want to prepare for it, optimal interview style or not. And the puzzles are quite fun to work out anyway.


That's actually fun. Do you mean something like that?


X = 10;
Y = 5;
Z = 0;

Z = X + Y;
Y = Z - Y;
X = Z - X;

Yes, but there were some additional rules which I didn't bother mentioning. Here's what I can recall of the problem:

Here are the additional problems that I can recall. I suggest you spoiler your answers so other people can try, if there is any interest in this thread

Note: You can add boxes to themselves (X = X + X), and for + and * place the result in any box (X = Y + Z).

+ Show Spoiler [Problem 0] +

Rule 1: Only + and - operators may be used.
Rule 2: Only one operation per step.
Rule 3: The - operator must return the result into the operand to the left of the operator (e.g. Z - X must be put into Z, not into X)
Rule 4: All operations are integer operations (5 / 3 = 1, not rounded but truncated to 1).

X and Y can be any integer number (and must work for any number) at step 0. Z = 0 at step 0.

In four (I think it was four now, originally said three) steps, swap the values in X and Y.


+ Show Spoiler [Problem 1] +

Rule 1: Only the + operator may be used.
Rule 2: Only one operation per step.

Initial values: X = 10, Y = 15, Z = 20.
After 3 steps, make Y = 55 and Z = 60 (X can be anything).


+ Show Spoiler [Problem 2] +

Rule 1: Only + - / and * operators may be used.
Rule 2: Only one operation per step.
Rule 3: All operations are integer operations (5 / 3 = 1, not rounded but truncated to 1).
Rule 4: The / and - operators must return the result into the operand to the left of the operator (e.g. Z - X must be put into Z, not into X).

X at step 0 is 8 when Y at step 0 is 9, and vice versa. The algorithm must work for both (X=8, Y= 9) and (X=9, Y=8). Z is empty. After two steps, Z must equal 9 (for both initial sets of values).


+ Show Spoiler [Problem 3] +

Rule 1: Only + and - operators may be used.
Rule 2: Only one operation per step.
Rule 3: All operations are integer operations (5 / 3 = 1, not rounded but truncated to 1).
Rule 4: The - operator must return the result into the operand to the left of the operator (e.g. Z - X must be put into Z, not into X).

For any initial values of X, Y, and Z, after four steps Z must equal X + 2Y - 3Z (the final value of Z must equal the initial value of X + 2x the initial value of Y - 3x the initial value of Z).

Example inputs and output: X=1, Y=2, Z=3. Output: Z=-4
(1 + 2(2) - 3(3))


Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2015-09-14 09:15:38
September 14 2015 09:11 GMT
#13247
On September 14 2015 18:05 Birdie wrote:
Rule 3: The - operator must return the result into the operand to the left of the operator (e.g. Z - X must be put into Z, not into X)

Note: You can add boxes to themselves (X = X + X), and for + and - place the result in any box (X = Y + Z).

Aren't you contradicting yourself here?

In any case there seems to be an awful lot of rules which won't really help show whether you're intelligent/quick-witted or whatever they wanted to see from your solutions. Unless they wanted to test your perseverance.
If you have a good reason to disagree with the above, please tell me. Thank you.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
September 14 2015 09:13 GMT
#13248
On September 14 2015 18:11 spinesheath wrote:
Show nested quote +
On September 14 2015 18:05 Birdie wrote:
Rule 3: The - operator must return the result into the operand to the left of the operator (e.g. Z - X must be put into Z, not into X)

Note: You can add boxes to themselves (X = X + X), and for + and - place the result in any box (X = Y + Z).

Aren't you contradicting yourself here?

Sorry, meant for + and * place the result in any box. Fixing now!
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
September 14 2015 09:18 GMT
#13249
Can you do X = -X - -Z?
Time is precious. Waste it wisely.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
September 14 2015 09:19 GMT
#13250
On September 14 2015 18:18 Manit0u wrote:
Can you do X = -X - -Z?

No. I think that would count as more than one operation in a step more or less.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 14 2015 12:35 GMT
#13251
--- Nuked ---
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
September 14 2015 12:45 GMT
#13252
On September 14 2015 21:35 Nesserev wrote:
I don't know if I completely understood the questions, might have missed something.

+ Show Spoiler [question 1] +


X = 10, Y = 15, Z = 20

X = Z + Z // X = 20 + 20 = 40
Y = Y + X // Y = 15 + 40 = 55
Z = Z + X // Z = 20 + 40 = 60

X = 40, Y = 55, Z = 60




+ Show Spoiler [question 2] +


X = 8, Y = 9, Z = (/) or X = 9, Y = 8, Z = (/)

X = X / Y // X = 0 or X = 1
Z = Y + X // Z = 9 + 0 = 9 or Z = 8 + 1 = 9 (finished now)
Z = Z + X
Z = Z - X

Z = 9



Haven't started the third one yet.

Correct so far. I think I mis-remembered the number of steps problem 2 required but your technique is correct. I will edit my post.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
BisuDagger
Profile Blog Joined October 2009
Bisutopia19229 Posts
September 14 2015 13:15 GMT
#13253
+ Show Spoiler [Problem 1 solution] +

x = 10
y = 15
z = 20

x = z + z; // x = 40
y += x; // y = 55
z += x; // x = 60



+ Show Spoiler [Problem 2 solution] +

(X=8, Y= 9) and (X=9, Y=8)
x = 8
y = 9
z = null

x /= y
z = x + y
z *= z
z /= z


Problem 3 is not written clearly. If they gave me the question that way, I'd hand it back to them and move on. I hope you just didn't write it clearly.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
BisuDagger
Profile Blog Joined October 2009
Bisutopia19229 Posts
Last Edited: 2015-09-14 13:17:12
September 14 2015 13:17 GMT
#13254
On September 14 2015 21:35 Nesserev wrote:
I don't know if I completely understood the questions, might have missed something.

+ Show Spoiler [question 1] +


X = 10, Y = 15, Z = 20

X = Z + Z // X = 20 + 20 = 40
Y = Y + X // Y = 15 + 40 = 55
Z = Z + X // Z = 20 + 40 = 60

X = 40, Y = 55, Z = 60




+ Show Spoiler [question 2] +


X = 8, Y = 9, Z = (/) or X = 9, Y = 8, Z = (/)

X = X / Y // X = 0 or X = 1
Z = Y + X // Z = 9 + 0 = 9 or Z = 8 + 1 = 9 (finished now)
Z = Z + X
Z = Z - X

Z = 9



Haven't started the third one yet.

High five bro! We got the solutions the same way. Although I feel like question #2 has more then one correct answer.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
September 14 2015 15:43 GMT
#13255
On September 14 2015 07:00 darkness wrote:
Show nested quote +
On September 11 2015 11:50 Housemd wrote:
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<<end1;
}
else
{
cout << "I suck at programming"<<end1;
}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.


Your compiler must be pretty nice to compile this code for you.


You mean the compiler is naughty for not throwing an error.
https://twitter.com/SufficientStats
BisuDagger
Profile Blog Joined October 2009
Bisutopia19229 Posts
September 14 2015 16:18 GMT
#13256
On September 15 2015 00:43 Sufficiency wrote:
Show nested quote +
On September 14 2015 07:00 darkness wrote:
On September 11 2015 11:50 Housemd wrote:
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<}
else
{
cout << "I suck at programming"<}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.


Your compiler must be pretty nice to compile this code for you.


You mean the compiler is naughty for not throwing an error.

My brain had to throw a few exceptions to process that code.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2015-09-15 02:15:08
September 14 2015 21:50 GMT
#13257
On September 14 2015 22:15 BisuDagger wrote:
+ Show Spoiler [Problem 1 solution] +

x = 10
y = 15
z = 20

x = z + z; // x = 40
y += x; // y = 55
z += x; // x = 60



+ Show Spoiler [Problem 2 solution] +

(X=8, Y= 9) and (X=9, Y=8)
x = 8
y = 9
z = null

x /= y
z = x + y
z *= z
z /= z


Problem 3 is not written clearly. If they gave me the question that way, I'd hand it back to them and move on. I hope you just didn't write it clearly.

What is unclear about it?

EDIT
I've added example inputs and outputs to problem 3, and put up problem 0 into a spoiler as no one was answering that one.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-09-16 01:06:34
September 15 2015 14:02 GMT
#13258
+ Show Spoiler [Problem 0] +


X = X Y = Y Z = 0

X = X - Y
Y = Y + X //Y = Y + (X - Y) = X
Z = Z - X //Z = 0 - (X - Y) = -X + Y
X = Z + Y //X = (-X + Y) + X = Y

(fixed)





+ Show Spoiler [Problem 3] +


X = X - Z //X = X - Z
Y = Y - Z //Y = Y - Z
Y = Y + Y //Y = (Y - Z) + (Y - Z) = 2Y - 2Z
Z = X + Y //Z = (X - Z) + (2Y - 2Z) = X + 2Y - 3Z


Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
September 15 2015 21:34 GMT
#13259
Y = Z is invalid as you didn't use an operation (other than assignment). Solution to 3 looks correct, although there's another way to do it which is slightly different (but same thought process).
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
September 15 2015 23:43 GMT
#13260
On September 15 2015 00:43 Sufficiency wrote:
Show nested quote +
On September 14 2015 07:00 darkness wrote:
On September 11 2015 11:50 Housemd wrote:
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<<end1;
}
else
{
cout << "I suck at programming"<<end1;
}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.


Your compiler must be pretty nice to compile this code for you.


You mean the compiler is naughty for not throwing an error.


It was irony. Of course, compiler should display an error.
Prev 1 661 662 663 664 665 1031 Next
Please log in or register to reply.
Live Events Refresh
OSC
13:00
King of the Hill #216
davetesta87
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko584
Hui .252
Vindicta 28
StarCraft: Brood War
Britney 57495
Calm 6793
Rain 3544
Shuttle 1426
Horang2 1401
EffOrt 1305
Hyuk 847
Larva 600
Light 294
BeSt 266
[ Show more ]
hero 201
Mini 166
Leta 164
ToSsGirL 113
Mind 87
Mong 75
Pusan 73
Snow 71
Hyun 62
Rush 49
Shinee 47
Barracks 45
JYJ39
Movie 26
soO 24
PianO 18
HiyA 13
Nal_rA 12
Backho 11
Shine 9
yabsab 8
IntoTheRainbow 8
SilentControl 7
zelot 3
Dota 2
Gorgc10538
qojqva2694
League of Legends
singsing2653
Other Games
Grubby2727
B2W.Neo1534
hiko948
DeMusliM571
Fuzer 292
XaKoH 261
ArmadaUGS126
QueenE25
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• Michael_bg 9
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2657
• WagamamaTV410
League of Legends
• Nemesis6783
• Jankos1184
• TFBlade818
Upcoming Events
WardiTV European League
1h 16m
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1h 16m
Big Brain Bouts
1h 16m
Korean StarCraft League
12h 16m
CranKy Ducklings
19h 16m
RSL Revival
19h 16m
FEL
1d 1h
RSL Revival
1d 19h
FEL
1d 21h
BSL: ProLeague
2 days
Dewalt vs Bonyth
[ Show More ]
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
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
IEM Cologne 2025
FISSURE Playground #1
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.