Skip to content
← Back to Community
[UPDATE] Weekly Challenge #19
Profile icon
h
has Hacker Plan
TheDrone7

Hey there replers! 2 weeks ago, we started the 5th batch of repl.it weekly challenges!

So below are the results for the last weekly challenge aka Weekly Challenge #18.


WEEKLY 18 Results

Here are the results for the weekly challenge #18.

RANK 1 : @HarperframeInc

RANK 2 : @Lord_Poseidon

RANK 3 : @fuzzyastrocat and @Coder100

In case you did not make into the top 3, you can check out your score at the weekly results website - https://weekly.thedrone7.repl.co

But before that, here's this week's weekly challenge for you all!


PRIME FIBONACCI!

Basically, fibonacci series but instead of using whole numbers, you use prime numbers. The first time will be 2, second term will be 3, and third time will be 2 + 3 = 5. But here comes the tricky part, the term should always be a prime number. So, 5 + 3 = 8 will be invalid, moving forward, 5 + 8 = 13 so 4th term will be 13 (which is prime again). Your program should be able to generate up to 5
20 such terms.

Also, for testing, only the first 10 terms will be checked but it should (at least theoretically) be possible of finding up to 20 terms.

SUBMISSION

For submitting your repls, post them on the repl talk share board and ensure that they contain #WEEKLY in their name.

NOTE : You cannot have multiple weekly challenge submissions but if you want to share multiple ways of achieving the goal, you can make regular posts that don't contain #WEEKLY in their name, even WEEKLY is fine.

And that's it for today, code away and have fun replers!

UPDATE
Since calculating up to 50 terms seems to be not possible without the hacker plan (lack of resources). The requirement has been reduced to 20 terms instead.

Voters
Profile icon
gradjoh
Profile icon
CosmicEgg
Profile icon
programmeruser
Profile icon
AmazingMech2418
Profile icon
BRAYDONHOLMES
Profile icon
Faunet
Profile icon
jjrice2233
Profile icon
seanlnge
Profile icon
IsaacSchofield
Profile icon
RobinSaunders1
Comments
hotnewtop
Profile icon
HarperframeInc

Wait a minute- How is this possible?

Such a formula would require intense computing power which we don't have- and the last site I've been on was only able to calculate the 21 first primes of Fibonacci. Edit: Wikipedia says there are only has 34 proven fibonacci primes. Not 50.

So are you looking for a working program that theoretically could do it? Or you want an actual prototype?

Profile icon
xxpertHacker

@HarperframeInc Parallelism, concurrency, efficient algorithms, umm... and some more stuff.

I've got both, an efficient Fibonacci function and an efficient prime finder, let's see how this works.

Profile icon
xxpertHacker

@HarperframeInc Update: just ran my code, seemed to run pretty fast, but then overflowed the stack after the 11th number. :)

Profile icon
DynamicSquid

@HarperframeInc have you tried quantum computing? heard those were pretty fast

Profile icon
adl212

@HarperframeInc Yeah, I have no idea how this is possible.

Profile icon
TheDrone7
Profile icon
xxpertHacker

@DynamicSquid Quantum computing is great for only certain types of code, here it would ineffective.

Profile icon
HarperframeInc
Profile icon
HarperframeInc

@xxpertHacker That's nice, but primes are one of a kind. It's like finding a needle in a hay stack except your 1 needle is in 100K hay stacks

Profile icon
fuzzyastrocat

@HarperframeInc Lol, my Haskell program "can" do it but it gets hung up on the 8th number, even with laziness and fairly efficient algorithms... I'm really stumped here

Profile icon
HarperframeInc

@fuzzyastrocat Same with my program. I haven't gotten any crashed programs so I'm suggesting that it can do it, it's just not as efficent and needs a better processor.

Profile icon
fuzzyastrocat

@HarperframeInc Yay now I can get to 11, still gets stuck there tho... I guess I've reached @xxpertHacker's program's performance now

Profile icon
xxpertHacker

@fuzzyastrocat Ha, I honestly wanna check your Repls to see if we did the same thing.

Profile icon
fuzzyastrocat
Profile icon
xxpertHacker

@HarperframeInc You say it as if you need to "find" primes, as if it's just by chance. My program makes it look like light-work: https://repl.it/@xxpertHacker/weekly-19#main.rs

Profile icon
xxpertHacker

@fuzzyastrocat Ahh, I see. I was thinking about ditching my current setup, then creating 2 arrays of values, then finding their intersections, it would be efficient, but mutative and impure. Watch me ditch my Rust and use a simple JavaScript array lol.

Profile icon
fuzzyastrocat

@xxpertHacker Yeah I tried doing lazy intersection with the cartesian product, but it yielded bad performance. I changed it to filter isPrime fibs and it greatly increased performance, so trying to rework my matrix fib solution to be more efficient rn.

Profile icon
HarperframeInc

@xxpertHacker Fibbonacci Primes are much bigger than that my friend- your program is puny at finding it

Profile icon
xxpertHacker

@fuzzyastrocat This challenge is kinda funny, the other ones took me a bit of thinking about just how to achieve the result, now I've already got a few ideas, and need to see how to make it happen computationally.

Profile icon
fuzzyastrocat

@xxpertHacker Heh yeah, this one's easy in theory but hard in practice

Profile icon
xxpertHacker

@HarperframeInc Oh yeah, I messed up my algorithm badly. Debugging it rn.

Profile icon
FlaminHotValdez

@HarperframeInc Exactly. The largest known prime fibonacci, the 34th has 21925 digits, which has to be stored in a string. And I'm 99.9% sure there's no way of determining whether a number is prime when it is in string form.

Profile icon
TheDrone7

@HarperframeInc theoretical lol. It's obvious I don't want beginners to do something like that. But aim for the highest number of terms you can calculate. I've decided to reduce the number of required terms since I realised even with most optimisations it would require the hacker plan to actually be able to do it.

Profile icon
fuzzyastrocat

@HarperframeInc @xxpertHacker Wait, I just realized... there are 34 (i think) known prime fibonacci numbers. This challenge only needs up to 20. So... copy-and-paste into an array? :D

Profile icon
xxpertHacker

@fuzzyastrocat I thought about just that the first day, but Drone will give a low score for that.

Profile icon
TheDrone7

@xxpertHacker @fuzzyastrocat low score? I'd give a 0.

Profile icon
fuzzyastrocat

@TheDrone7 @xxpertHacker Yeah, I figured a low score would be given (which is why I'm not actually doing that)... though it doesn't say you have to calculate, just generate, but yeah it's a very hacky method of doing it.

The real calculating method is more fun anyways :D

Profile icon
HahaYes

test

Profile icon
[deleted]

IS THERE A WEEKLY #20? I DONT SEE IT IF THERE IS ONE

Profile icon
adl212

@poetaetoes Yeah, I saw that my weekly 19 was scored but he hasn't released the scores either.

Profile icon
AmazingMech2418

Fortran is awesome! I can get the first 12 in like 20 seconds. LOL!

Profile icon
CodeLongAndPros

@AmazingMech2418 Using ratfor?

Profile icon
AmazingMech2418

@CodeLongAndPros What? I just used 16-byte integers. Fortran generally produces faster binaries than C/C++ and I think even Rust.

Profile icon
CodeLongAndPros

@AmazingMech2418 Ratfor allows if-then and while loops

Profile icon
AmazingMech2418

@CodeLongAndPros I just used Fortran 90...

Profile icon
fuzzyastrocat

@AmazingMech2418 OOF why didn't I think of this, lol FORTRAN is like the data science programming language

Profile icon
adl212

Any idea when this will be scored?

Profile icon
TheDrone7

@adl212 I have an exam coming up on 30th so I'll score these after that.

Profile icon
SwaroopBappanad

Jeez, is this a google interview?

Profile icon
Coder100

no constraints?

Profile icon
xxpertHacker

Since calculating up to 50 terms seems to be not possible without the hacker plan...

Actually, I have the hacker plan, but I still can't figure out how to get my code to pull it off. It's all about code design.

Ohh, I think I see where I went wrong. I'll probably submit later today.

Profile icon
RohilPatel

i just lost hacker plan lolol

Profile icon
seanlnge

The 14th Fibonacci prime, 19134702400093278081449423917, is the last one before it overflows past a 128 bit integer. The only way to continue going forth is to add an external library, or to add strings together.

Even the Sieve of Atkin written in Rust, one of the fastest known prime tests, takes almost a minute to tell if 19134702400093278081449423917 is prime. Not even going to think about the other 6.

What's being asking for here is a mathematical miracle, or for us to write code with a runtime of days.

ill keep working on it though, it seems like a fun challenge

Profile icon
TheDrone7

@SpicedSpices as said above, the actual program needs to be capable of up to 10th term practically. The rest should be possible "theoretically".

Profile icon
seanlnge

@TheDrone7 hmm so "theoretically" means that we don't have to worry about integer limits?

Profile icon
TheDrone7

@SpicedSpices well yes. I only need a working algorithm that could calculate them if there were no limits.

Profile icon
seanlnge

@TheDrone7 oh ok thank you for clarifying

Profile icon
JackFly26

My repl from last week didn't seem to get scored.

Profile icon
nicholasptheepi

Are we just meant to write a program which can generate up to 50 of these terms, or to actually find them. It took my program 68 seconds just to find the 11th... (also yes i know 2 isnt in the list)

msedge_dy3uNPK9Kl

Profile icon
TheDrone7

@nicholasptheepi practically it should be capable of finding up to the 20th terms although since it can be difficult for people without repl.it hacker plan, testing will only be performed till the 10th term. You can make it capable of finding up to the 50th term theoretically however.

Profile icon
FlaminHotValdez

This is impossible. There are only 34 Fibonacci numbers that are proven to be prime. It's not even certain that there ARE 50 primes. Even if there are, the 34th Fibonacci prime has 21925 digits and is the 104911th Fibonacci number. The theoretical 50th Fibonacci prime has 678033 digits and is the 3244369th Fibonacci number. Even if you use strings to store the numbers, you'd need a heck of a lot of either memory or time to compute whether it is prime, depending on the method you use.

Profile icon
adl212

So, basically, the challenge is to return n amount of terms of the "prime" fibonacci sequence right? Also, we can use loops and recursions this time right?

Profile icon
xxpertHacker

If I might ask, could a slightly better description of the expected input and output be given? I think I already see how it's supposed to be, but just for insurance.

Also, isn't "1" a prime number, thus the first term would be "1," not 2?

Update: my logic was implemented incorrectly, 1 isn't prime, I forgot. And I searched it up to get more details already.

Profile icon
TheDrone7

@xxpertHacker 1 is neither prime nor composite. So the first term is 2.

Profile icon
TheDrone7

@xxpertHacker and as for sample input and outputs, there's 4 of them given in the challenge with explanation on how to achieve them.

Profile icon
xxpertHacker

@TheDrone7 Yeah, I should've deleted this comment, since I'd already found that there happens to be a whole Wikipedia page on this. Surprisingly, the idea is pretty simple, but the implementation is incredibly difficult. My code is mostly just trying to prevent stack overflows or something of the sort to make this computationally possible.

Profile icon
EpicGamer007

I give up at weekly challenges. :(

Profile icon
Coder100

pog

Profile icon
dabs364

50 or infinite or ask

Profile icon
firefish

Would it be OK to have a list of prime numbers (calculated on the spot) and checking if a fib number is in it?

Profile icon
HarperframeInc

@firefish You'll probably get deducted pts for that

Profile icon
firefish

@HarperframeInc Thought of another plan then

Profile icon
TheDrone7

@firefish that should be fine. If calculated on the spot.

Profile icon
firefish

@TheDrone7 Ok, that'll make it a tad slow, but so be it...

Profile icon
HarperframeInc

This file cannot be displayed: https://weeklywidget.harperframeinc.repl.co
@TheDrone7
I made a dynamic image displaying the leaderboard ^^^

Profile icon
wh0

hey can you add my entry for last week's too? https://repl.it/talk/share/WEEKLY-18/53886

Profile icon
TheDrone7

@wh0 wait, does the website not show your score? Lemme fix that.

Profile icon
TheDrone7

@wh0 should be fine now.

Profile icon
wh0

confirmed, thanks

Profile icon
CoolJames1610

Btw typo in post

WEEKLY 18 Results

Here are the results for the weekly challenge #17.

Should be weekly challenge #18 xD

Profile icon
TheDrone7

@CoolJames1610 ah yes, thanks

Profile icon
CoolJames1610

Wow 8 points thanks!!!

Profile icon
k9chelsea2

._.

Profile icon
fuzzyastrocat

Ayyy, I got 3rd rank! Yay!

Nice job to everyone else, this was a fun one. Next one looks fun too!

Profile icon
dabs364

darn it i was about to finish