CrabNebula · @crabnebula
36 followers · 121 posts · Server fosstodon.org

πŸš€

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!

#RustChallenge

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1065 followers · 1395 posts · Server infosec.exchange

✨ 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
youtu.be/8afbTaA-gOQ

(Continued πŸ‘‡)

#rustlang #RustChallenge #programmers #rust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1060 followers · 1380 posts · Server infosec.exchange

πŸ¦€ an Interesting 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

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1060 followers · 1380 posts · Server infosec.exchange

@chrisg
That's possibly the side effects of my series πŸ˜‚. i set traps in that.

But in , I don't do. It will be simple πŸ˜‰

#RustChallenge #rustquiz

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1055 followers · 1350 posts · Server infosec.exchange

πŸ¦€

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

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1045 followers · 1332 posts · Server infosec.exchange

:

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

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1023 followers · 1286 posts · Server infosec.exchange

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

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1020 followers · 1274 posts · Server infosec.exchange

πŸ¦€

What is the output of this?

A. Error
B. RustJsPython
C. (Rust, Js, Python)
D. Rust

(Not hard/tricky or unique as , just simple quizzes)

#rustquiz #RustChallenge #rustlang #rust #rusttips #learnrust

Last updated 2 years ago

Astra Kernel :verified: · @AstraKernel
1007 followers · 1243 posts · Server infosec.exchange

πŸ¦€

Will it print "Yes"?

A. Yes
B. No
C. It will give error

#RustChallenge #rustlang #rust

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
999 followers · 1227 posts · Server infosec.exchange

πŸ¦€

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


Vote here πŸ‘‡

#RustChallenge #rust #rustlang #rustquiz

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
999 followers · 1227 posts · Server infosec.exchange

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

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
997 followers · 1213 posts · Server infosec.exchange

πŸ¦€ Fix the following code

πŸͺ² Error: "cannot borrow `x` as mutable because it is also borrowed as immutable"

Playground link:
play.rust-lang.org/?version=st

πŸ‘‰ You can answer either with fixed playground link or just explanation (No poll)

#RustChallenge #rustlang #rust #learnrust

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
994 followers · 1208 posts · Server infosec.exchange

πŸ¦€

What is the result?

A.
-10
100

B.
10
100

C.
-10
+100

D.
+10
+100

Vote here πŸ‘‡

#RustChallenge #rustlang #rust

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
990 followers · 1203 posts · Server infosec.exchange

πŸ¦€

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

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
990 followers · 1203 posts · Server infosec.exchange

πŸ¦€

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

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
990 followers · 1203 posts · Server infosec.exchange

πŸ¦€

What is the result?

A. Error
C. Prints 2 4 6 8
D. Prints 2
4. Prints 2 6 8

#RustChallenge #rustlang #rust

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
987 followers · 1196 posts · Server infosec.exchange

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

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
987 followers · 1196 posts · Server infosec.exchange

πŸ¦€

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

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
983 followers · 1184 posts · Server infosec.exchange

(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

vote here πŸ‘‡

#RustChallenge #rustlang

Last updated 3 years ago

Astra Kernel :verified: · @AstraKernel
983 followers · 1182 posts · Server infosec.exchange

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

vote πŸ‘‡

#RustChallenge #rustlang

Last updated 3 years ago