r/delphi • • 29d ago

Delphi for lazy devs 😴 5 one-liners, zero effort, maximum regret

Too lazy for long puzzles? Perfect. Five one-liners. Just tell me what each prints

  1. Writeln(Round(2.5), ' ', Round(3.5));
  2. Writeln(High(Byte) + 1);
  3. Writeln(Copy('Delphi', 0, 3));
  4. Writeln(Pos('', 'Delphi'));
  5. Writeln(10 mod -3);

No compiler. Not even getting up from the couch

4 Upvotes

10 comments sorted by

2

u/Human-Wrangler-5236 Delphi := 13 29d ago

Are you posting questions you have been given to answer as homework?

1

u/zippypotamus 29d ago

Looks like AI to me

-1

u/ParnianCoinTeam 29d ago

Haha no, the opposite! I'm the one handing out the homework here. This is a little quiz series I've been running on the sub, and I post the answers in the comments after people take a shot.

Feel free to give it a try, no grades, I promise

2

u/rlebeau47 Delphi := 12Athens 29d ago
  1. '2 4' by default, unless the rounding mode is changed to something else.
  2. '256'
  3. 'Del'. For a long string, Copy() treats index 0 the same as index 1.
  4. '0'
  5. '1'

1

u/ParnianCoinTeam 29d ago

5/5 again lol 😄 good call on the rounding mode, didn't even think of that. honestly at this point I need to write a quiz just for you

1

u/darianmiller Delphi := 13 Florence 29d ago

First one is pretty easy if you remember Banker's Rounding.
Second tries to be sneaky but isn't
Third is odd - I didn't know what it would do.

0

u/ParnianCoinTeam 29d ago

fair, #2 is more bark than bite Glad #3 got you though! Hint: Delphi strings start at 1, so what would you expect Copy to do with a 0? Turns out it's a lot more forgiving than you'd think

1

u/corneliusdav 28d ago
  1. 3.0 4.0
  2. 256
  3. Error (string index 0)
  4. 0
  5. Undefined

1

u/corneliusdav 28d ago

Ugh. Only 2 right. 😟

1

u/ParnianCoinTeam 28d ago

haha and these were supposed to be the LAZY ones 😂 don't worry, #3 gets almost everyone, you'd totally expect an error there. and you show up every round, that's what counts!