New Formatting Options

We've rolled out some improvements to our formatting engine today, and wanted to let everyone know how to take advantage of them.

For a full specification of formatting on Brilliant, you can review the full formatting guide.

The two new things you'll probably want to know about:

Tables

It is now possible to use tables in problems and notes on Brilliant.

This code:

1
2
|| 1 || 2 || 3 || 4 || 
|| a || b || c || d || 

produces this:

1234
abcd

Code Snippets with Syntax Highlighting

There is also a new method for code blocks. Previously, it was necessary to use four spaces before any line of code, like this:

Type this:

1
2
3
    print "Hello World!"
    for x in range(5):
        print x

Get this:

1
2
3
print "Hello World!"
for x in range(5):
    print x

However, we have a new method, which produces the same output and is easier to work with. Now you may simple add three backticks ( ` ) on the lines before and after your code, and you'll get the same result:

Type this:

```
print "Hello World!"
    for x in range(5):
    print x
```

Get this:

1
2
3
print "Hello World!"
for x in range(5):
    print x

In addition, the new system allows syntax highlighting for C, Python, and Java code (and many others). Just add the language name in lowercase (c++ or cpp instead of C++ and javascript instead of JavaScript) after the first line of backticks.

Type this:

```python
#A comment
print "Hello World!"
    for x in range(5):
    print x
```

Get this:

1
2
3
4
#A comment
print "Hello World!"
for x in range(5):
    print x

We're excited about these improvements and hope they'll be helpful to you.

Note by Arron Kau
6 years, 8 months ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Sort by:

Top Newest

PSA: It took me a minute to figure this out, a backtick on your keyboard is the key under the escape key. It is the unshifted version of the ~.

1
print "Thanks for the update, Brilliant! " + "I'm sure it's going to be very useful!"

Trevor B. - 6 years, 8 months ago

Log in to reply

I think I've done too many code reviews, haha, this is a compulsive comment saying that:

  1. It'll end up smooshing the two sentences together ("...Brilliant!I'm sure...")
  2. String concatenation in python is inefficient (and some people's opinion ugly/un-pythonic) and the preferable way to print that would be:
1
print "Thanks for the update, Brilliant!", "I'm sure it's going to be very useful!"

Which also happens to add a space implicitly.

Sam Solomon Staff - 6 years, 8 months ago

Log in to reply

Hm, I didn't know that about the comma. I'll use that in the future. I tend to just use spaces at the end of parts of a concatenation.

Trevor B. - 6 years, 8 months ago

Log in to reply

@Trevor B. Oh, another cool thing, is that you can put any number of arguments and it converts them all to strings separately, so you don't have to do anything ugly like:

1
print "I have " + str(num_cats) + " cats and " + str(num_dogs) + " dogs."

you can instead do:

1
print "I have", num_cats, "cats and", num_dogs, "dogs."

Sam Solomon Staff - 6 years, 8 months ago

Log in to reply

@Sam Solomon Maybe I shouldn't make this question here, but could you give me a simple explanation about how this is possible? How is print defined so that it can take n arguments*? Is it written in another language (not Python)?

  • I know that obviously there is a limit for this, but it seems to be pretty big.

Bernardo Sulzbach - 6 years, 4 months ago

Log in to reply

@Bernardo Sulzbach I'm not sure what the process is for turning a function into a command (as in print "something" rather than print("something")) but for the function this is how I would implement it roughly (Note that I didn't actually look up what it takes to print to the stdout at a lower level, I'm just guessing it's something like sys.print):

1
2
def print(*args):
    sys.print(u" ".join(unicode(arg) for arg in args))

*args grabs all arguments that aren't accounted for and puts them into a list for you to use in the function.

**kwargs does the same for extra keyword arguments.

Sam Solomon Staff - 6 years, 4 months ago

Log in to reply

@Sam Solomon that's very helpful what does sys.print is it equivalent to normal print function do is it a part of python code? LOL I love how we are asking questions in here and I asked this even though this is 5 to 6 years old

Oximas omar - 5 months, 1 week ago

Log in to reply

There is one problem-

When I use this code

def doNothing():
    '''
    It does nothing.
    '''
    pass

I got this

1
2
3
4
5
def doNothing():
    '''
    It does nothing.
    '''
    pass

Notice, the third line 'It does nothing.' doesn't have four spaces before it as I wanted. It's not that a big problem but it would enhance readability if you could solve it.

Lokesh Sharma - 6 years, 7 months ago

Log in to reply

1
2
3
4
#A comment
printf("Test Code C\n");
int ngmq = 0x3fff;
return ngmq;

Manh Quan Nguyen - 6 years, 8 months ago

Log in to reply

1
2
#testing A comment 1y 9m later
chr(int("3fff",16)) #gtranslate=>googling=>ended up reading cake recipes

Mahdi Al-kawaz - 4 years, 10 months ago

Log in to reply

Cool! Let's see:

1234
abcd

Being proficient with LaTeX{\LaTeX}, let's see how that compares with a LaTeX table:

1234abcd\begin{array}{|cccc|}\hline 1&2&3&4 \\\hline \text{a} & \text{b} & \text{c} & \text{d}\\\hline \end{array}

What do you guys think?

Daniel Liu - 6 years, 8 months ago

Log in to reply

We wanted to offer an easy alternative for those who do not know latex. Typing a bunch of || is much easier than memorizing the array / align environments.

Calvin Lin Staff - 6 years, 8 months ago

Log in to reply

Also, since we render LaTeX \LaTeX on our servers rather than in the browser and display it as an image most of the time, if you have a large table, it'll end up being a lot slower to display/more annoying to work with on some people's computers/internet connections.

Sam Solomon Staff - 6 years, 8 months ago

Log in to reply

@Sam Solomon since this post is 6 years old, i assume this information is outdated.
or is Latex still displayed as an image?

num IC - 1 month ago

Log in to reply

@Num Ic I don't think it is outdated, but you can ask staff :)

Percy Jackson - 1 month ago

Log in to reply

@Percy Jackson i thought i did. or is sam solomon not staff?
i think it is outdated because i can copy posted Latex text letter by letter.
i assume if it were a pic, i would not be able to do this.

num IC - 1 month ago

Log in to reply

@Num Ic Yes, now the table doesn't appear as an image, but not as text either, as you can't copy /paste the table, only the content inside.

Percy Jackson - 1 month ago

Log in to reply

@Percy Jackson @Percy Jackson @num IC

Yeah, we updated how LaTeX \LaTeX is rendered and now render it into code that browsers can understand rather than images on our servers. This means it should be faster for everyone to load even LaTeX \LaTeX blocks that take up a lot of screen space.

Sam Solomon Staff - 4 weeks, 1 day ago

Log in to reply

@Sam Solomon ty for this clarification and for increasing the performance. this makes it much easier.

num IC - 4 weeks, 1 day ago

Log in to reply

@Sam Solomon Thank you :)

Percy Jackson - 4 weeks, 1 day ago

Log in to reply

@Percy Jackson ty. i just wanted to make sure. if Latex would still be converted to images, i could just post images instead of Latex to speed up the loading. but i dont experience loading delays - only when i load daily problems, it sometimes takes a while until all the solutions are loaded, but i assume that has other reasons.

num IC - 1 month ago

Log in to reply

1
std::cout<<"Thanks!\n";

Valerian Pratama - 5 years, 4 months ago

Log in to reply

:-)

Arron Kau Staff - 5 years, 4 months ago

Log in to reply

1
2
3
4
#m comment
print " great ! " +  " glad ! "
for x in range(5) :
      print x

Mayank Pratap - 6 years, 8 months ago

Log in to reply

Hi, I fixed your comment, you were using normal single quotation marks ' instead of "backticks" which are under the escape key on most keyboards (you may have encountered the tilde ~ more often).

Sam Solomon Staff - 6 years, 8 months ago

Log in to reply

Great update! Keep up the good work and thank you very much, Brilliant.

Can you add IDE (in example: Sphere Engine) into the Computer Science section?

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
    cout << "Thank you very much, Brilliant!";
    return 0;
}

Daniel Lim - 6 years, 8 months ago

Log in to reply

1
2
3
print "agreed"
for x = 5:
      print x

敬全 钟 - 6 years, 8 months ago

Log in to reply

That is interesting, we will consider that but it probably would not be a high priority feature, we may add a link to http://ideone.com/ for people to use (sorta like we have a link to the Daum Equation Editor from our formatting guide (for users who use the chrome browser since it's a chrome plugin) even though we don't have immediate plans to add any kind of "easy LaTeX \LaTeX editor" to Brilliant.)

Also: the syntax highlighting code for C++ is c++ (or cpp) (I've edited your comment so that your code will be properly highlighted). Basically, all of the "codes" are the name of the language in lower case.

Sam Solomon Staff - 6 years, 8 months ago

Log in to reply

thanks, but I hope the experience will be like CodeForces or any other similar website

Daniel Lim - 6 years, 8 months ago

Log in to reply

How to use the LaTex code has been addressed, too? I read many answers not appearing as examples in the formatting guide, such as this one

\sqrt{2}

Lovelli Fuad - 6 years, 7 months ago

Log in to reply

1
2
char * str = "This is awesome";
printf("%s",str);

Sandeep Thakur - 6 years, 7 months ago

Log in to reply

cool..

Abhishek Sakhaparia - 6 years, 7 months ago

Log in to reply

1
2
3
4
5
6
#include<iostream>
using namespace std;
int main(){
cout<<"testing"<<endl;
return 0;
}

Dion Solang - 2 years, 10 months ago

Log in to reply

``` C++

include<iostream>

int main(){ std::cout<<"testing2"<<endl; return 0; } ```

Dion Solang - 2 years, 10 months ago

Log in to reply

1
2
3
4
5
#include<iostream>
using namespace std;
int main(){
cout<<"testingsss"<<endl;
return 0;

Dion Solang - 2 years, 10 months ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...