/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/jobs/130607/ruby-on-rails-ninjaneer-agilityfeat
git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/false.c;h=bc9c703a56da58393674a02d1a54616fc5e609ef;hb=HEAD
twitter.com/NSFWRedditGif

first for Rust (C/C++ replacement language)

Second for making it shorter in Haskell.

SHORT

>not being a Ruby on Rails Ninjaneer

stackoverflow.com/jobs/130607/ruby-on-rails-ninjaneer-agilityfeat

third for lisp ain't that amazing

Rust (SJW mind-control algorithm language)

>ninjaneer

You're like fifth, bra.

I'd rather be a quim ninja.

>tfw GC pause makes u miss 3rd GET

For a better career, yeah. It's the future anyway. What sort of company do you work for?

I have to do work but i keep trying to learn F#.

Help.

I'm so sick of this aoc day 9 puzzle, my answer is still off by the entire length of the input + 13 characters that I can't even track down.

size_t decompress_v2(char *arr, size_t len)
{
size_t length = 0;
char save = arr[len];
arr[len] = '\0'; /* prevent runaways */
unsigned i, j;
for (i = 0; i < len;)
{
/* find length up to first marker */
char *next = strstr(&arr[i], "(");
i = (!next) ? len : (size_t) (next - arr);
if (!arr[i])
{
length += i;
break;
}

/* estimate size of next expansion */
unsigned dist, iters;
sscanf(&arr[i], "(%ux%u)", &dist, &iters);
for (j = 0; arr[i + j] != ')'; j++); j += 1;
length += decompress_v2(&arr[i + j], dist) * iters;
i += j + dist;
}
arr[len] = save;
return length;
}

learn f# until it is certain that you need to get the work done otherwise, you can't finished

Fuck off back to Sup Forums

(some list)

DAILY PROGRAMMING CHALLENGE

Implement Conway's game in your choice of language.
Bonus points for using something I haven't heard of, but only if it's actually correct.

People need to start posting the problems and input data. Most of us are too lazy to actually sign up for AoC.

F# is the worst functional language out there. Even worse than SML.

>hmm that sounds interesting
>google it
>To play, please identify yourself via one of these services:
>[GitHub] [Google] [Twitter] [Reddit]
Well so much for that.

are there non-free OR not open-source programming laguanges?

>most of us
speak for yourself, you autist

you don't at least have a github, why do you even come here?

> MUH SJW boogeyman
Go cry to mommy, stormtard. We don't need your whining in here. We have allotted you a containment board for that, simply out of kindness, but you still don't comply and keep infesting because you're just that despicable.

you first

I don't think I'm alone, for example:

>everyone who disagrees with me is Sup Forums, just because I said so

fuck off, rust admin

>implying there isn't SJW subterfuge underway on all boards

Nice try you commie fuckstain. The anticommunists and antiantifa fighters will once again retake Europe and the Americas.

A few questions.
Is it possible to get drunk by inhaling vaporized alcohol?
Would there be a good way to keep the dosage consistent or is the human body a system that doesn't stream alcohol out of the blood at a consistent rate?

Any experiments that have been done on this topic?

better ask /dpt/

Yes, you can get completely fucked up doing that. Be careful.

>rustcuck supremely butthurt
kek

there should be a special symbol that when typed in with a number next to it lisp souce codes, denotes "hey, complete n open parenthesis"

May be done with reader macros.

Haven't really investigated but your shit is pretty fucked. I tried it on a few test inputs and it's giving all sorts of bizarre answers. My favorite is "a(2x1)bc", which gives 2.

Alcohol literally shrinks your brain regardless of the amount you ingest. You'd be a potato in a month

Sup Forums people are this weird hybrid of Nazis and SJWs, 90% of the people here whine about Trump and "muh soggy knees", and exclusively support SJW orgs like Rust and Node.JS, and yet they're the same people who five seconds later will turn around and scream "GENOCIDE ALL THE INDIANS AND WOMEN REEEEEEE"

I'd be hard pressed to find people more autistic, more schizoid, more completely fucking brain-fried and fucked in the head than the faggots on Sup Forums

WHY did it have to be like this
WHY

The length is simply: Length of input characters (excluding parenthesized expressions) + (a x b-1) for every parenthesized expression.

that was clearly you

There are multiple people on this board.

pull the IP logs and prove it

>literally shrinks your brain
Source?
Why would XKCD encourage such reckless behavior?

No, that was me

The SJWs come from plebbit tho
fucking cancer

If macros are so great then why is Lisp so unpopular?

because drinking alcohol is literally the oldest meme in existence

Because he's a jew trying to get your job.

(a x (b-1)), if not clear from spacing

See image.

...

yes, and my point is that by far the vast majority of them are hyper-schizoidal, aspergoidal, completely fucking brain-scrambled freaks who exhibit the worst traits of both Nazis and SJWs simultaneously

1. Designing and implementing a compression algorithm that does NOT make i.i.d. stochastic assumptions (gzip, for example, works off of this assumption) (I'm basically trying to build an encoder that functions outside of the scope of the Shannon source coding theorem). The goal is to be able to potentially compress random strings by a reasonable amount.

2. Modifying the OpenSSL library to create an open interface for steganographic channels.

because most people are plens

Yes I understand the problem. But try running shit through your function and you will see it produces all kinds of garbage. Even the first nontrivial test case is wrong, it says A(1x5)BC decompresses to length 13 (it's actually 7).

>tfw i work for them

I wrote it the straightforward way by decompressing it iteratively, but following part 2's rules, it would take 10GB to compute the length.

the output is correct, at least.

A(1x5)BC

Length of non-parenthesized input characters = 3
(a x (b-1)) = (1 x 4) = 4
3 + 4 = 7

Yes, again, I understand the problem. As you show, the correct answer is 7. The AOC page says the same thing. But your function returns 13.

Having looked briefly at the code, I see two problems. First, (..) markers inside a repeated section should be ignored. But it looks like you are making a recursive call to process them. Second, it looks like you are adding the length of the marker (`j`) into the output somehow, when it should also be ignored.

Why are the closing parentheses necessary at the end of lisp input?

Oh right. I didn't write that function, I'm telling the guy who wrote the function how to solve the problem.

I didn't even read his function, I just assumed it was rubbish.

>why are the closing brackets in C or C++ necessary?

Because #include copies and pastes raw files

They *don't exist* goy.

Oh sorry, wasn't paying attention

>following part 2's rules, it would take 10GB to compute the length
What do you mean by "part 2's rules"? Is there more to the problem that's only visible if you log in, or something?

It's because whitespace is insignificant.

s-s-somebody express interest in my work, please :(

But if you think about it, if you know that nobody is going to #include your file, then you should be able to omit the last braces, i.e.

int main(int,char**) {
doStuff();
if (!cond)
return 0;
else {
differentStuff();
return doMoreStuff();

*glomps you*

you get part 2 once you solve the first part.
part 2 for day 9 simply says don't skip over decompressed sections, if a marker was duplicated n times, you have to expand every single one

I thank you for the glomp.

>Vast majority of them are hyper-schizoidal, aspergoidal, completely fucking brain-scrambled freaks who exhibit the worst traits of both Nazis and SJWs simultaneously

Funny enough your line perfectly describes Linux users and most people idolized in this board like Stallman or Terry Davis

Call me what you want, but you literally can't prove me wrong on this

What's the fastest way to implement the dijkstra's algorithm? Is it using a priority queue?

You're retarded. Whitespace isn't significant.
int main(void) {
if (!cond)
thing();
else {
thing1();
thing2() // ??????????????????????????

I didn't say whitespace was significant

You never #include function bodies, especially main(), moron.

Fastest as in time to implement from scratch? The original way: just use an array and iterate through it every time you need to find the minimal element.

Fastest with respect to performance: use a Fibonacci heap.

Think I fixed it. Your handling of non-repeated characters was pretty messed up.

in C++ you do

but regardless there's structs

Then thing2() is inside the else block, when it isn't intended.

no one actually idolizes terry you fuckin reprobate how new are you

git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/false.c;h=bc9c703a56da58393674a02d1a54616fc5e609ef;hb=HEAD

... no, it is intended.
the implication is that if you don't terminate a brace, the compiler puts it at the end of the file.

you do not include a file with main in it in C++ lmfao

what do you mean?

So you're saying if you ever open an else block, you can't close it? Or that the closing is optional if it's at the end of the file? Because that's pretty retarded.

>GNU

can somebody post a shorter solution?
preferably in haskell
codeFight n = map f [1..n]
where f n = case (mod n 5, mod n 7) of
(0,0) -> "CodeFight"
(0,_) -> "Code"
(_,0) -> "Fight"
_ -> show n

I didn't say main

I did it like that. Works for my input.
#include
#include

uint64_t getCompressedSectionSize(uint64_t characterLimit)
{
char c;
char buffer[16];
uint64_t size = 0;
while(characterLimit)
{
scanf("%c", &c);
if(c == '(')
{
uint64_t count, limit, headerLength;
scanf("%lu%c%lu", &limit, &c, &count);
headerLength = sprintf((char *)&buffer, "(%lu%c%lu)", limit, c, count);
scanf("%c", &c);
uint64_t sectionSize = getCompressedSectionSize(limit);
size += sectionSize * count;
characterLimit -= headerLength + limit;
}
else
{
++size;
--characterLimit;
}
}
return size;
}

int main()
{
char c;
uint64_t sum = 0;
while(scanf("%c", &c) != EOF && c != '\n')
{
if(c == '(')
{
uint64_t numOfCharactersToRepeat, repeatCount;
scanf("%lu%c%lu", &numOfCharactersToRepeat, &c, &repeatCount);
scanf("%c", &c);
sum += repeatCount * getCompressedSectionSize(numOfCharactersToRepeat);
}
else
{
sum += 1;
}
}
printf("decompressed length: %lu\n", sum);
return 0;
}

The intention is pretty obvious there. They've made two nearly identical programs and modified one's behavior in a ""clever"" way. This isn't typical.

>closing is optional if it's at the end of the file
Yes, this is exactly what was stated in the reply chain.
The point was I was saying terminating braces at the end of a file could arguably be permissible (obviously not by the standard) in some cases in C/C++, and how because of #include it might not be the same, but the original conversation was about Lisp.

In Lisp, why is terminating parentheses at the end necessary?
Apparently because of whitespace


That's pretty much the shortest you'll get

You could shave off a line by flipping map and using a lambda for the case statement. Otherwise, that's pretty optimal (assuming an 80char limit).

Loops are always better and faster than recursion. Anyone that uses recursion is a brainlet cuck.

I love programming microcontrollers. So much so that I'd do a lot of it in my free time if I had the money to blow on sensors, actuators, and casing required to do anything with them. I was taught BASIC and Mitsubishi PLC but logic is logic from what I figure. Learning a new language should be easy enough.

I guess what I'm asking for is a programming language which I can work with entirely on the computer. Something for game design or something along those lines. Definitely object oriented as I'm used to hardware triggering hardware. I played around with ActionScript before and was OK with it, but a lot of times it seemed needlessly complicated. Like the syntax was made irritating for the sake of being irritating.

Any recommendations?

aren't a lot of old axioms like recursion actually worse these days?
Like some sorts that were deemed "bad" are not actually bad anymore since we have such big caches? And our most limiting speed bump is cache misses

Can you prove that it's optimal? Questions relating to Kolmogorov complexity are undecidable.

What's the key to embedded engineering?

No, but I can prove that it's 'pretty optimal'.

Are singletons allowed for logging?

if your algorithm relies on the compiler quietly turning your recursive shit into an iterative loop to prevent a stack overflow, it's shit

what do you think tail call optimization is?

Use the writer monad

>go to one of the top CS programs in the countries for undergraduate and graduate programs
>experts in the field explaining ground-breaking (recursive) approaches to open problems that they solved
>user on Sup Forums: "recursion is for brainlet cucks"

Sure.

no memelangs pls

#include

int main(int argc, char **argv) {
int count = 0;
FILE *in = fopen(argv[1], "r");
FILE *out = fopen(argv[2], "w");
char ch;

ch = fgetc(in);
while (!feof(in)) {
fputc(ch, out);
if (ch == '{') count++;
else if (ch == '}') count--;
ch = fgetc(in);
}

fclose(in);

for (ch = 0; ch < count; ch++) {
fputc('}', out);
}
fclose(out);
return 0;
}


$ gcc addbraces.c -o ab
$ cat hello.no
#include

int main(void) {
if (2 > 3)
return 1;
else {
puts("hello");
return 0;
$ ./ab hello.no hello.c && gcc hello.c -o hello && ./hello
hello

I encourage you to use this utility when you work on projects with others