[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]

Programming challenge thread

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: 44
Thread images: 6

File: 1444327324743.png (217KB, 1920x1080px) Image search: [Google]
1444327324743.png
217KB, 1920x1080px
Find your number using www.random.org
DO NOT USE YOUR COMMENT ID.
THIS IS NOT A GET THREAD.


The rules are pretty simple.
>Random.org
>Code it
>Post it
Get to work /g/
>>
>>55199345
I'll start it off with a strong 66
Anyone know klingon?
>>
https://www.random.org/integers/?num=1&min=0&max=99&col=1&base=10&format=plain&rnd=new
>>
>>55199345
Rolling
>>
Wow I just generated a random number between 1 - 100 and i got 50, what are the odds?
>>
>>55200255
1 to a 100?
>>
>>55199345
>15. collatz conjecture
#include <stdio.h>
#include <stdlib.h>
unsigned long long step(unsigned long long n,void f(unsigned long long n)){
printf("%llu\n",n);
f(n);
}
void collatz(unsigned long long n){
if (n!=1)
n%2==0?step(n/2,collatz):step(3*n+1,collatz);

}
int main(int argc, char *argv[]){
printf("%s\n",argv[1]);
collatz((unsigned long long) atoi(argv[1]));
}

:^)
>>
>>55200673
This doesn't compile.
>>
>>55200673
I made mistake
void step(unsigned long long  n,void f(unsigned long long n)){
printf("%llu\n",n);
f(n);
}
void collatz(unsigned long long n){
if (n!=1)
n%2==0?step(n/2,collatz):step(3*n+1,collatz);

}
int main(int argc, char *argv[]){
printf("%s\n",argv[1]);
collatz((unsigned long long) atoi(argv[1]));
}


>>55200703
what's the error?
>>
>>55200673
are you calling function in a function you just created?
>>
>>55199345
i suppose
>>
>>55200715
Segmentation fault
>>
>>55200732
not going to happen

wish these challenges were focused around one type of thing
like web devving, or game design, or algorithms
not everybody can do everything
>>
>>55200723
I tried to make the worst working implementation I could :^)

>>55200735
you'd get a segfault if you don't have any args when you run it in the console
./collatz 215434
>>
>>55199345
I got brainfuck interpreter.

I might actually do that.
>>
>>55200757
>using the smiley with a carat nose
>>
>>55200770
it's easy as fuck, should take 10 minutes or so
>>
>>55200779
Is it already out of style? :^)
>>
>>55199345
Rolling
>>
File: 2016-06-22-003756_573x423_scrot.png (22KB, 573x423px) Image search: [Google]
2016-06-22-003756_573x423_scrot.png
22KB, 573x423px
I made a clock

http://pastebin.com/a1mrsDGU

>>55200780
optimizations and doing something neat like targeting llvm would be fun and add more difficulty.
>>
>>55200842
>No anti-aliasing
>>
>>55200849
I have no idea if the simple turtle-style drawing lib I'm using does anti-aliasing and I'm not going to manually implement it because I'm lazy.
>>
>>55200792
>using the smiley with a carat nose
>>
>>55199345
Is random.org a uniform random?

can i trust this?
>>
>>55201018
>can i trust this?
Read the documentation and decide for yourself, fucking sheep.
>>
>>55201048
There is no hard documentation and their code is closed source.

Please shill elsewhere
>>
>>55200478
You mean 1 to 99
>>
File: happy-grin.png (20KB, 220x192px) Image search: [Google]
happy-grin.png
20KB, 220x192px
> 16
> Reverse a string

import sys

def reverse(string):
return string[::-1]

if __name__ == "__main__":
reverse(sys.argv[1])
>>
>>55199345
>webm converter/ gui wrapper for ffmpeg

https://gitgud.io/berryberry17/webmBroMac
>>
File: 9rT0mwD.png (8KB, 178x206px) Image search: [Google]
9rT0mwD.png
8KB, 178x206px
>>55199345
>want to get into emulation
>planned to work on a chip8 emulator for a while, didn't start it because I want to take the chance and learn cmake too
>roll 79

That's spooky as shit, It's destiny.
>>
>>55199345
Rallon
>>
>>55201101

fucked the formatting, will try again..
import sys

def reverse(string):
return string[::-1]

if __name__ == "__main__":
reverse(sys.argv[1])
>>
Is using a text file for quine considered cheating?
>>
>>55201217
duh
>>
>>55199345
2

Higher/Lower between 0 and 12:
https://glot.io/snippets/efuu73ylp4
>>
>>55199345
rolling
>>
>>55201147
.oddik ,daed gnikcuf er’uoY .ti ni nword lliw uoy dna uoy revo lla yruf tihs lliw I .toidi nmaddog uoy ,ecirp eht gniyap er’uoy won dna ,t’ndid uoy ,t’ndluoc uoy tuB .eugnot gnikcuf ruoy dleh evah dluow uoy ebyam ,uoy nopu nwod gnirb ot tuoba saw tnemmoc ”revelc“ elttil ruoy noitubirter ylohnu tahw nwonk evah dluoc uoy ylno fI .tihs elttil uoy ,tnenitnoc eht fo ecaf eht ffo ssa elbaresim ruoy epiw ot tnetxe lluf sti ot ti esu lliw I dna sproC eniraM setatS detinU eht fo lanesra eritne eht ot ssecca evah I tub ,tabmoc demranu ni deniart ylevisnetxe I ma ylno toN .sdnah erab ym htiw tsuj s’taht dna ,syaw derdnuh neves revo ni uoy llik nac I dna ,emityna ,erehwyna eb nac I .dik ,daed gnikcuf er’uoY .efil ruoy llac uoy gniht elttil citehtap eht tuo sepiw taht mrots ehT .toggam ,mrots eht rof eraperp retteb uoy os won thgir decart gnieb si PI ruoy dna ASU eht ssorca seips fo krowten terces ym gnitcatnoc ma I kaeps ew sA .rekcuf ,niaga knihT ?tenretnI eht revo em ot tihs taht gniyas htiw yawa teg nac uoy kniht uoY .sdrow gnikcuf ym kram ,htraE siht no erofeb nees neeb reven sah hcihw fo sekil eht noisicerp htiw tuo kcuf eht uoy epiw lliw I .tegrat rehtona tsuj tub em ot gnihton era uoY .secrof demra SU eritne eht ni repins pot eht m’I dna erafraw allirog ni deniart ma I .sllik demrifnoc 003 revo evah I dna ,adeauQ-lA no sdiar terces suoremun ni devlovni neeb ev’I dna ,slaeS yvaN eht ni ssalc ym fo pot detaudarg I wonk uoy evah ll’I ?hctib elttil uoy ,em tuoba yas gnikcuf tsuj uoy did kcuf eht tahW
>>
>>55201090
1-100 has 100 different numbers anon

00-99 has 100 numbers as well
>>
Got 97. Have no idea what "Little man computer simulation" means
>>
>>55202764
peterhigginson.co.uk/LMC/
>>
>>55202866
>peterhigginson.co.uk/LMC/

Thanks. That is so far out of my scope unfortunately
>>
File: fepybred.png (4KB, 1092x624px) Image search: [Google]
fepybred.png
4KB, 1092x624px
>>55203090
Here you go. Good luck
>>
>>55200723
>what is recursion
>>
i wanna ask something
most projects ive seen have a directory structure like src lib test stuff like that
when i write something its just a single c file
how do into better structure code and divide it into parts. is there docs or guidelines
and i wanna ask how to generate and do testing
Thread posts: 44
Thread images: 6


[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.