π #RustChallenge
Put your Rust skills to the test with a modified FizzBuzz:
1οΈβ£ Divisible by 3: Print "Fizz"
2οΈβ£ Divisible by 5: Print "Buzz"
3οΈβ£ Divisible by both: Print "FizzBuzz"
4οΈβ£ Else: Print the number
Use `match`, `if let`, and loops to solve. Let's see your solutions!
β¨ Rust challenge explained
Ans: C. It never reaches the prints statement. It goes in an infinite loop π²
But, how? Let's break down
π End value is 0xfffffff which is 268435455.0. it is not very important here. So let's remove it and simplify the code with a constant 20,000,000.0 end value
π `f` value stops increasing(round upped) after value 16777216.0 when you add just 1.0 π€―
π To know why,you have to understand how the f32 is stored. Float is not stored as simple as integer
π f32 uses IEEE 754 format to store the value
π Larger f32 number loses accuracy
In a 32 bit float (any language not just rust):
π 1st bit is used for sign identification (positive or negative)
π Following 8 bits used for exponent
π Next 23 bits used for storing mantissa π
You can see more here, how it is calculated
https://youtu.be/8afbTaA-gOQ
(Continued π)
#rustlang #RustChallenge #programmers #rust
π¦ an Interesting #RustChallenge given by @sombrastudios
What will happen?
A) prints "Hello World" instantly
B) prints "Hello World" after 3 seconds
C) never reaches the print statement
D) Compilation error
#RustChallenge #rustlang #rust
@chrisg
That's possibly the side effects of my #RustChallenge series π. i set traps in that.
But in #RustQuiz, I don't do. It will be simple π
π¦ #RustChallenge
What will be the result?
A. Runtime error
B. Compile time error
C. It won't give an error and does nothing
Credits : @musicmatze
#RustChallenge #rustlang #rust
What is the output?
A. It will print Kernel
B. It will give a compilation error (explain why)
C. It will give a runtime error (explain why)
#RustChallenge #rustlang #rust
What is the output?
A.
[1, 3]
[3,0]
B.
[1,3]
[3,1]
C.
[3,0]
[3,0]
D.
[3,0]
[3,1]
Vote here π
#RustChallenge #rustlang #rust
π¦ #RustQuiz
What is the output of this?
A. Error
B. RustJsPython
C. (Rust, Js, Python)
D. Rust
(Not hard/tricky or unique as #RustChallenge, just simple quizzes)
#rustquiz #RustChallenge #rustlang #rust #rusttips #learnrust
π¦ #RustChallenge
What will be the outcome?
1. Both runs and gives the output
2. B gives output and A gives overflow error
3. A gives output and B gives error
4. Both gives error
#RustChallenge #rust #rustlang #rustquiz
What is the result?
A. Prints 1 (explain how)
B. Prints 2 (explain how)
C. Error (explain why)
Credits to @wcrichton(twitter)
#RustChallenge #rustlang #rustquiz #rust
π¦ Fix the following code
πͺ² Error: "cannot borrow `x` as mutable because it is also borrowed as immutable"
Playground link:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b13fc771b4c2ea39d490375c54fd5a4d
π You can answer either with fixed playground link or just explanation (No poll)
#RustChallenge #rustlang #rust #learnrust
#RustChallenge #rustlang #rust
π¦ #RustChallenge
What is the result?
A. Error
C. Prints 2 4 6 8
D. Prints 2
4. Prints 2 6 8
Vote here π
#RustChallenge #rustlang #rust
π¦ #RustChallenge
What is the result?
A. Error
C. Prints 2 4 6 8
D. Prints 2
4. Prints 2 6 8
Vote here π
#RustChallenge #rustlang #rust
#RustChallenge #rustlang #rust
Simple rust challenge for you
What is the result?
A. Prints AstraKernel
B. Panics with error AstraKernel
C. Compilation error
D. Prints nothing
Vote here π
#RustChallenge #rustlang #rust
π¦ #RustChallenge
What is the result?
A.
false
false
false
false
B.
false
false
true
false
C.
true
true
true
true
D.
true
false
true
true
#RustChallenge #rustlang #rust
(Sorry had to delete and recreate because didn't include the condition)
π What will be output if you compile and run in "release" mode?
A.Β Β Error
B. It prints
[a value] true
[a value] true
C. It prints
[a value] false
[a value] false
D. It prints
[a value]Β Β false
[a value]Β Β true
#rustlang vote here π
I will share the source after few hours. If you saw the source, please don't give spoiler
A. Error
B. It prints
[a value] true
[a value] true
C. It prints
[a value] false
[a value] false
C. It prints
[a value] false
[a value] true
#rustlang vote π