[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Pro/g/ramming Challenge!

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 46
Thread images: 5

File: 1467756898246-1-inverted2.png (550KB, 1450x1080px) Image search: [Google]
1467756898246-1-inverted2.png
550KB, 1450x1080px
"Continuing from Yesterday" - edition

RULES:

Pick a challenge between 0-99, do it as quickly as possible and make your code as small and efficient as you can in the language of your choosing. Post code when you're done!

And don't forget, Have fun!
>>
Dijkstra's algorithm (at least 5 nodes)
Dafuq is that supposed to mean? dijkstra doesn't depend on the number of nodes.
>>
>>55516192
From what I can tell, while the algorithm doesn't depend on the number of nodes, it's telling you to implement the algorithm with a non-arbitrary number of points to make sure it works properly...
But that's just my guess
>>
What's 06 tornado?
>>
Do we roll for it?
>>
>>55516016
roll
>>
>>55516343
I got a password generator. Fucking EZ.
>>
>>55516342
You can if you want, but a while ago someone mentioned "rolling" is considered spam...

Just choose one that looks interesting
>>
rollllinnnn
>>
File: 1449093611239.gif (1009KB, 345x343px) Image search: [Google]
1449093611239.gif
1009KB, 345x343px
#!/bin/bash
echo "fizzbuzz"

Join my startup
>>
File: 1452347724883.png (1MB, 3840x2160px) Image search: [Google]
1452347724883.png
1MB, 3840x2160px
What do you anons think should be the definitive version: 2.0 or 3.0? (I think I also have v1.4)

I personally like 2.0's difficulty levels, but enjoy 3.0's massive variety and info table near the end...

Thoughts?
>>
rolling for
>>
>>55516737
what do you think /g/uys
def check_pali(word):
w = word.replace(" ", "")
l = len(w)
l = l / 2 if l % 2 == 0 else (l - 1) / 2
p = [w[i] == w[len(w) - 1 - i] for i in range(int(l))]
return all(p)

w1 = "race car"
print(check_pali(w1))
>>
>>55516717
Let's see 1.4

That being said, I vote for 2 because of the difficulty levels. 3 is overwhelming with variety. If it was sorted, it would probably be the winner
>>
File: 1452346403480.png (302KB, 1920x1080px) Image search: [Google]
1452346403480.png
302KB, 1920x1080px
>>55516896
Here's 1.4(epsilon)... Don't really have much of an opinion for this as much as versions 2 or 3
>>
>>55516342
C#. The difficult part was finding a big decimal library.

BigFloat pi = 0;
for (var i = 0; i <= 825; i++)
{
BigFloat k = i;
pi += (1 / BigFloat.Pow(16, i)) * ((4 / (8 * k + 1)) - (2 / (8 * k + 4)) - (1 / (8 * k + 5)) - (1 / (8 * k + 6)));
Console.Write("\r" + i * 100 / j + "%");
}
Console.WriteLine("\r" + pi.ToString(1000));
>>
>>55517074
It's easier to read than 3
>>
>>55517277
typedef struct { Node* next; void* data;} Node;

Rolling again
>>
>>55516016
>>55516016
>>55516016
>>
>>55517425
oh well, it wasn't so difficult
while true; do
TIME="/bin/date +%H:%M"
printf "\r$($TIME) "
sleep 1
printf "\r$($TIME)."
sleep 1
done
>>
>>55516016
roll
>>
>>55516016
rollu
>>
>>55516016
Roll
I won't post results because I'm a faggot
>>
>>55517823
#include<iostream>
#include<cstdlib>
int GetDate()
{
int months[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int month, day, result;
std::cout << "1)Jan\n2)Feb\n3)Mar\n4)Apr\n5)May";
std::cout << "\n6)Jun\n7)July\n8)Aug\n9)Sept\n10)Oct\n11)";
std::cout << "Nov\n12)Dec\nEnter Month [1-12] " << std::flush;
std::cin >> month;
std::cout << "\nEnter day [1-31] " << std::flush;
std::cin >> day;
std::cout << std::endl;
return ((month == 1) ? (day) : (months[month - 2] + day));
}
int main()
{
int first = GetDate();
int second = GetDate();
std::cout << "Difference = " << abs(first - second);
return 0;
}
>>
>>55518050
no thanks. Looks boring enough to skip. Reroll!
>>
>>55516016
roll
>>
>>55516016
rolllllllllor
>>
File: Challenges.png (305KB, 1920x1080px) Image search: [Google]
Challenges.png
305KB, 1920x1080px
Here is the one I use to use. I found it on an old USB with all my source code on it :D
>>
We should make this a general.

Also, do any of the lists contain a Red Black Tree challenge? Had to do it for class, was pretty fun
>>
>>55516016
Rowle
>>
Coco bongo.
>>
>>55518109
template<class T> 
std::vector<T> fit_in(std::vector<T> A, T a) {

if (A[A.size() - 1] < a) {
A.push_back(a);
return A;
}

for (int i = 0; i < A.size(); i++) {
if (A[i] > a) {
A.insert(A.begin() + i, a);
break;
}
if (A[i] == a) {
return A;
}
}
return A;
}

template<class T>
std::vector<T> sort(std::vector<T> A) {

if (A.size() < 2)
return A;

std::vector<T> alias;
alias.push_back(A[0]);

for (auto member : A) {
alias = fit_in(alias, member);
}

return alias;
}

template<class T>
int bin_search(std::vector<T> A, T a) {

int puffer = 0;
while (true) {
int half = (int)((A.size()-1) / 2);
if (a < A[half]) {
A = std::vector<T>(A.begin(), A.begin() + half);
}
else if (a > A[half]) {
puffer += half;
A = std::vector<T>(A.begin() + half, A.end());
}
else {
return puffer + half;
}
}
return -1;
}


reroll
>>
>>55516016
OK roll
I haven't coded in a fucking month
About damn time
>>
>>55519557
Fuck that rerolling
>>
>>55518444
Trips speak truth
>>
>>55519882
const int MAX = 1000000;
#include<iostream>
#include<fstream>
int main()
{
std::ofstream out("out.txt");
if(!out.is_open())
{
std::cout << "File open failure.";
return -1;
}
bool a[MAX];
for(int x = 0; x < MAX; x++)
{
a[x] = true;
}
a[0] = a[1] = false;
for(int n = 2; n <= MAX / 2; n++)
if(a[n] == true)
for(int m = n+n; m < MAX; m+=n)
a[m] = false;
int n = 1;
for(int i = 0; i < MAX; i++)
{
if (a[i])
{
out << i << " ";
if( (n++ % 11) == 0) out << std::endl;
}

}
return 0;
}
>>
>>55520070
#include<iostream>
int main()
{
int XYZ = 123;
std::cout << (XYZ % 10) * 100 + (((XYZ% 100) - (XYZ % 10))/10) *10 + ((XYZ % 1000) - (XYZ % 100))/100 << std::endl;
return 0;
}

>>
>>55516717
rolllorllllr
>>
>>55520335
#include<iostream>
#include<ctime>
int main()
{
std::cout << ((time(0) / 3600) % 12) << ":" << ((time(0) / 60) % 60);
return 0;
}
>>
>>55520335
>>55520411
Disgusting.
>>
>>55520411
reroll
>>
>>55520427
I agree the first one is not a generic algorithm, but what is wrong with the second one?
>>
>>55520452
<< << << << << << << << << << << << << << <<
>>
>>55516016
roll
>>
bumpin'
>>
rollan
Thread posts: 46
Thread images: 5


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.