Which code formatting do you like better?

Which format better suits short code snippets that are present in the editorial? I’m talking about those short codes that are placed in the editorial, to help the reader grasp how to go about implementing a particular algo/ds.

while(l <= r){
    if(l % sqt == 0 and l + sqt < r){
        for(int x = 0; x < 26; x++){
            Temp[x] += Sqt[l / sqt][x];
        }
        l += sqt;
    }else{
        Temp[S[l] - 'a']++;
        l++;
    }
}

  • I like the text format
  • I feel the image format would be better

0 voters

Example 1

…We could make a function APSum() to calculate the sum efficiently.

ll APSum(int n, int a1, int an){
    return ((ll)n * (a1 + an)) / (ll)2;
    //AP Sum formula!
}

Example 2

…We could make a function APSum() to calculate the sum efficiently.

second one is screenshot of sublime theme right?

Nope. VSCode + Monokai Pro + SFMono Font

Oh okay, it’s kinda similar
try the Night Owl theme on VSCode as well, it’s amazing

even if the code in ss looks better we cant copy the code thats the prob.
we can generate code snippets from here https://carbon.now.sh/ .

1 Like

It would be best if there is any way to make background black and text white. ( because We cannot copy text from image)
Or you can keep both of them in editorial.
Just keep “click to view” option so that it won’t look bad.

4 Likes

https://codepen.io/mxexo/pen/dxLac
Would something like this work fine?

1 Like