[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Pro/g/ramming Challenge!
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 46
Thread images: 5
File: 1467756898246-1-inverted2.png (550 KB, 1450x1080) Image search: [Google]
1467756898246-1-inverted2.png
550 KB, 1450x1080
"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 (1009 KB, 345x343) Image search: [Google]
1449093611239.gif
1009 KB, 345x343
#!/bin/bash
echo "fizzbuzz"

Join my startup
>>
File: 1452347724883.png (1 MB, 3840x2160) Image search: [Google]
1452347724883.png
1 MB, 3840x2160
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 (302 KB, 1920x1080) Image search: [Google]
1452346403480.png
302 KB, 1920x1080
>>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 (305 KB, 1920x1080) Image search: [Google]
Challenges.png
305 KB, 1920x1080
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 replies: 46
Thread images: 5

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.