+ 18
*DAILY-MINI-CHALLENGE* : ANY TEXT CAN BE STORED IN A (!VERY BIG!) NUMBER AND EACH NUMBER CAN REPRESENT ANY TEXT. CHECK IT OUT!!!
A string s = "hi" can be converted into a number x: 1) split string into characters "hi" = ['h','i'] 2) convert each character to its asci_numbr ['h','i'] = [104,105] 3) start at i = 0..s.length-1: multiply each ascii-value with (256^i) and build the sum of it 104*(256^0) + 105*(256^1) = 26984 = x Backwards: While x > 0 you have to do 1) y = x%256 2) msg += ascii_char(y) 3) x = x // 256 This returns the msg = "hi" WHAT DOES x = 1701013870 MEANS? https://code.sololearn.com/cNd0BKGghjAE/?ref=app
36 Answers
+ 23
Nice.
But why are you screaming?
+ 11
Guess I will give it a shot
+ 7
is it 'hello world'?
+ 6
I'll try this too, here it is: https://code.sololearn.com/WFsgk0vg00kS/
Nice! 👍
the hi's sum is: 26984
I could call it maxi-challenge for JavaScript by the big numbers, plus planning a solution.
+ 5
no ... NOT "hello world" !
+ 5
Will take a shot at this first, wants winner 😂
+ 3
for $0: what is "nice"?
14357682231834248035556943223
+ 3
Hopefully I got this right.
https://code.sololearn.com/cBn9mV2Mn9d7/?ref=app
+ 3
@Julian you got a minor mistake on your question. "hi" should be represented as 26984 in base 256. 👌
+ 2
Here's my C# implementation with customizable number base:-
https://code.sololearn.com/czfxMhjho33G/?ref=app
*UPDATE* With reverse implementation as well 😄
LINQ One-Liner 〰
Enumerable.Range(1, str.Length).Sum(n => str[n - 1] * Math.Pow(256, n - 1));
+ 2
@Sayantan
wich language? ^^
if you're using js there are several librarys for 'bigint'.
but you have to download most of them...
https://stackoverflow.com/questions/4557509/javascript-summing-large-integers
+ 2
Nice challenge mate, this would make for a pretty good encryption. Here's my attempt.
https://code.sololearn.com/cgj3SlchmQS4/?ref=app
+ 1
i didn't understand
+ 1
this is a good one
https://code.sololearn.com/chiwcRiS0gMU/?ref=app
+ 1
NEW CHALLENGE HERE:
https://www.sololearn.com/discuss/626739/?ref=app
+ 1
HEY CODERS OUT THERE...
NEW *DAILY CHALLENGE* RIGHT HERE:
https://www.sololearn.com/discuss/645450/?ref=app
+ 1
MY NEW *DAILY CHALLENGE*:
GIVE IT A TRY!!!
https://www.sololearn.com/discuss/647083/?ref=app