c++ – Reason behind declaring iteration variables on a method level

First of all, I am not a C++ developer, so, I apologise if I ask something obvious.

Lately, I’m having to deal with some C++ snippets, and I have a very strange observation on the tiny detail:

Most of the times, in the code I see, people declare iteration variable(s) outside of the for/while definitions, and then initialise them within for/while definitions, like:

int i, j, k;

for(i=0;..;..){} //omits declaration

I wonder what is the reason behind this? why would one want to scope a loop-level temporary variable and its identifier on a method-level?

Is this conventional? does it help compilation’s lexical translation? an optimisation for static code analysis? what is the purpose?

It (important) certainly looks ugly, especially when there are numerous variables in the method; it (important) reserves variable identifiers (on a method-level); and (less important) it definitely occupies more space in the memory.

Any points?


Kioptrix level 1 SMB problem connecting

I’m new to the OSCP certification, and in lab 1, I need to solve Kioptrix level 1. In the OSCP webinar, I follow the same step as my instructor; everything seam to works just fine except the last step, which is connecting to Kioptrix throw SMB. but I am unable to connect, this is what I got:

└─# smbclient -L //                                                                              
protocol negotiation failed: NT_STATUS_IO_TIMEOUT

On Reddit, someone had the same issue, and someone else sed to go to /etc/samba/smb.conf and under (globals) I should add client min protocol = CORE and client max protocol = SMB3 but after saving smb.conf I got:

└─# smbclient -L //
WARNING: Ignoring invalid value 'CORE' for parameter 'client min protocol'
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it
protocol negotiation failed: NT_STATUS_IO_TIMEOUT

How could I solve the problem connecting to SMB?

dnd 5e – When do Druids gain the ability to cast each spell level?

In order to cast a spell of level x you need a spell slot of at least x in order to cast it.

Your max spell slot level as a full caster can be calculated by adding 1 to your character level then dividing by two.

Hence level 3 spellcasters can cast 2nd level spells, for example.

Another way to figure this out is to open up your Player’s Handbook and look at the Druid class. On the table that shows when you get class features, it also shows you your spell slot progression.

Note: this works a little differently when you are multiclassing

When multiclassing, your maximum spell slots are determined by your effective spellcaster level. This is calculated by adding the number of class levels of full casters (bard, druid, sorcerer, wizard, cleric), number of levels/2 of Half-caster levels (paladin, ranger), and the number of levels/3 of 1/3 casters (trickster, Eldritch knight).

So a character who has cleric 3/druid 5, could prepare up to 2nd level cleric spells and up to 3rd level druid spells. They can cast any of these spells using up to 4th level spell slot. This can be figured out using the Multiclass Spellcaster table in the PHB or by using the formula above: (3 + 5 + 1)/2 = 4.

dnd 5e – Which class gives most new magical powers for 1 level dip

Variety: Let’s do some Math.

We’re looking for variety of 1st level spell choices gained from a single level dip in another class. This means that we can immediately rule out the half-caster classes, Ranger and Paladin, as they do not get their spellcasting features until 2nd level.

Let $B$ be the set of 1st level spells a Bard can choose from. Let $C$ be the set of 1st level spells available to some other full caster class. Our objective is to find which class offers the greatest number of spells not already available to the Bard. Time to Math.

We begin with the well know identity:

$$|Bcup C|=|B|+|C|-|Bcap C|$$

Where $|Bcup C|$ is the number of 1st level spells that are either bard or {class} spells, $|B|$ is the number of bard spells, $|C|$ is the number of {class} spells, and $|Bcap C|$ is the number of spells appearing on both lists. So we are looking for the number of $C$ spells that are not also bard spells, which is $|C|-|Bcap C|$. Doing some simple algebra on the above identity, we have:

$$|C|-|Bcap C|=|Bcup C|-|B|$$

I’ve done the math for us, counting $|C|$ and $|Bcup C|$ on DNDBeyond. Here are the results, as well as the calculation of the number of spells gained from a single level dip into the class:

Class Spells Class or Bard Spells Net Gain from 1 level Dip
Bard 24 24 0
Artificer 18 35 11
Cleric 16+2 36+2 12+2
Druid 21 35 11
Sorcerer 27+2 41+2 17+2
Warlock 13+2 32+2 8+2
Wizard 42 50 26

The Cleric, Warlock, and Sorcerer, depending on choice of domain, patron, or origin, could have up to 2 additional spells. This has been notated in the table by the “+2” in those rows.

Volume: Preparation is King

We’ve discussed the variety of choices afforded the different caster classes, but what we’re really looking for here is the volume of magical expressions at our disposal. For this purpose, classes which prepare spells outclass the rest by significant margin.

In particular, the Cleric, Druid, and Artificer select spells each day from their entire respective lists (but Artificer is not an option as it is a 13 INT prereq). Here is the Cleric’s feature:

You prepare the list of cleric spells that are available for you to cast, choosing from the cleric spell list. When you do so, choose a number of cleric spells equal to your Wisdom modifier + your cleric level (minimum of one spell). The spells must be of a level for which you have spell slots.

As a druid or cleric, you can prepare each day a number of spells equal to your 1 plus your Wisdom modifier, and they are chosen from the entire spell list of that class. This means that choosing druid for a 1 level dip gets you access to 11 additional spells you did not have access to before, and cleric can get you up to 14 additional spells you did not have access to before.

The Cleric’s and Druid’s flexibility and number of available spells is unmatched by any other class. Despite the Sorcerer’s greater variety, the Sorcerer can only learn two 1st level spells with a single level dip. Here’s the table:

Class Cantrips Known New Daily Accessible 1st Level Spells
Cleric 3 12+2
Druid 2 11
Sorcerer 4 2
Warlock 2 2

How does an ASIC Bitcoin miner work on a fundamental level?

I’d like to understand how ASIC miners are more efficient at mining bitcoin. Having a background in CS, how does the ASIC miner work on a binary level on the CPU and why is it so much faster?

dnd 5e – Can a high level warlock with Book of Ancient Secrets learn ritual spells higher than 5th level?

Yes, but it’s not a big deal

There are only two spells that are above 5th level and have the ritual tag; Forbiddance and Drawmij’s Instant Summons

Let’s look at the wording of the Invocation:

You can now inscribe magical rituals in your Book of Shadows. Choose two 1st-level spells that have the ritual tag from any class’s spell list (the two needn’t be from the same list). The spells appear in the book and don’t count against the number of spells you know. With your Book of Shadows in hand, you can cast the chosen spells as rituals. You can’t cast the spells except as rituals, unless you’ve learned them by some other means. You can also cast a warlock spell you know as a ritual if it has the ritual tag.

On your adventures, you can add other ritual spells to your Book of Shadows. When you find such a spell, you can add it to the book if the spell’s level is equal to or less than half your warlock level (rounded up) and if you can spare the time to transcribe the spell. For each level of the spell, the transcription process takes 2 hours and costs 50 gp for the rare inks needed to inscribe it.

So you start with two spells from any class list, so long as they are rituals. As you adventure, you can also transcribe other ritual spells, so long as their level is half of your warlock level, rounded down. Not the level of spell you can cast. So at 12th level, you can cast 6th level ritual spells, so long as you have acquired and transcribed them into your Book of Shadows.

Additional, you can “cast a warlock spell you know as a ritual if it has the ritual tag.” But once again, this list is very limited; seven total if we include all Warlock sub-classes:

  • Comprehend Languages
  • Illusory Script
  • Unseen Servant
  • Silence
  • Feign Death
  • Meld into Stone
  • Contact other Plane

And it works for Arcanum, too

If some future rule change adds either Forbiddance or Instant Summons as an Arcanum, or they make a new sub-class with a new 6th-level ritual spell, those work too.

The wording of Arcanum states:

At 11th level, your patron bestows upon you a magical secret called an arcanum. Choose one 6th-level spell from the warlock spell list as this arcanum.

You can cast your arcanum spell once without expending a spell slot. You must finish a long rest before you can do so again.

At higher levels, you gain more warlock spells of your choice that can be cast in this way.

So Arcanum are warlock spells, and the Invocation states that the character can cast ritual warlock spells as rituals.

dnd 5e – What would be the ramifications of allowing a Wild Magic Sorcerer’s Bend Luck ability to scale with level?

I was wondering why a Wild Magic Sorcerer’s Bend Luck ability is always 2 sorcery points and a reaction to increase or reduce another creature’s attack roll, ability check or saving throw by 1d4.

I think it’s pretty wild (pun intended) that is does not scale with levels considering there’s another spellcaster class, Bards, that have a very similar ability with Bardic Inspiration.

Bardic Inspiration affects the same types of rolls (attack rolls, ability checks and saving throws), does not use a reaction (uses a bonus action instead) and players can hold onto their bardic inspiration for a moment of their choosing. Furthermore, Bardic Inspirations are their own unique resource (equal to Charisma modifier, minimum of 1) and best of all they scale with levels (starting as d6’s and ending as d12’s at level 15). After reaching 5th level, Font of Inspiration allows Bards to regain all their Bardic Inspirations after a short rest.

In comparison, Bend Luck is pretty pitiful.

  1. It costs 2 sorcery points (equivalent of a level 1 spell slot and also the resource required for using metamagic, basically the best part of being a Sorcerer).
  2. It is always a flat 1d4. The chance of a 1d4 being impactful diminishes as you level up & enemies get stronger.
  3. It uses your reaction, which can be super valuable for casting Shield, Counterspell, Featherfall etc.

The only real benefit I can see is that it can be used offensively, whereas Bardic Inspiration cannot.

My questions:

  1. Am I missing something? Have I accurately portrayed the usefulness of Bend Luck?
  2. If I’m not missing anything, is it reasonable to have Bend Luck scale with levels? (At 6th level, it becomes a 1d6, 11th level 1d8, 16th level 1d10, for example?)

Tertiary level mathematics questiib [closed]

The population of a colony of rabbits at time(t) years is given by P(t) =4+ae^-bt where t>=0 and a,b are positive integers.If it is given 8000 rabbits as initial population and 1 year later the population reduced by 1600. Find a, b

dnd 5e – If you succeed on the saving throw for the Sickening Radiance spell, do you still take the level of exhaustion and emit the light?

The Sickening Radiance spell says:

When a creature moves into the spell’s area for the first time on a turn or starts its turn there, that creature must succeed on a Constitution saving throw or take 4d10 radiant damage, and it suffers one level of exhaustion and emits a dim, greenish light in a 5-foot radius.

The grammar and punctuation here makes me wonder: do the level of exhaustion and greenish light happen regardless of the result of the saving throw, just like how some spells still deal half damage when you succeed on the save?

I suspect they do. Otherwise it should have been written “…must succeed on a Constitution saving throw or take 4d10 radiant damage, suffer one level of exhaustion, and emit a dim, greenish light…”

higher category theory – How do $infty$-categories allow us to do descent on the derived level?

I have heard that one application of $infty$-categories is that they allow us to formulate a meaningful theory of descent for derived categories (say of sheaves on a scheme). While I’m sure the details are somewhere in Lurie’s exposition of stable $infty$-categories, I was hoping that someone familiar with the process could explain in broad strokes why we can’t do this in the classical setting, and what $infty$-categories add to the picture that changes the situation.