/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

code.google.com/codejam/contest/3264486/dashboard
gcc.gnu.org/ml/gcc/2017-03/msg00066.html
benchmarksgame.alioth.debian.org/u64q/lisp.html
benchmarksgame.alioth.debian.org/u64q/csharp.html
twitter.com/NSFWRedditVideo

Coding my own init.

>>Anyone working on the Google Code Jam qualification round problems?
>pls insert link
code.google.com/codejam/contest/3264486/dashboard

First for C

Thank you for anime picture

谢谢

Google confirmed for dumbs.
Use a convoluted explanation when a simple math definition would have been more simple to read and understand.

it's a tradition for all programming contests you doofus

nth for too late for an nth post but still making one

lisp is mostly useless outside of academia

Yes and it's totally dumb.
And by the way their problem is fucking easy.
Dumb problem for dumb audience.

>their problem
I mean, it's qualification round, and there's more than one problem buddy.

But I see the targeted audience.

Anyone here has any experience creating plugins for cordova using plugman?
The IDE part is the one annoying me, specially on iOS, since the files are no part of a project, they need to be added onto a project, and then edited and add more stuff, finally you move them into the plugin folder.

Any easier way to do this?

repost from last thread.

>My Program is a basic/retarded version of Pokemon Go.
>Program In C++ Goes through an array of Pokemon Names
>Randomly Chooses 1
>Assigns this to another String Variable
> I am Here
> Using this String Variable, Go to an API/Website and search for a string that is equal to the string variable
>Print out the "imageURL" variable next to it which contains a picture of the Pokemon
>Print this out to local Web Page
>Press Pokeball and Go back to C++ Program to determine if Caught or not

so should I be doing everything in Javascript or Python as opposed to C++ here?

It'd be easier to do everything in JS senpai. Like extremely easier.

Well, that makes things easier than what I was thinking.
It's worth noting that you don't actually have to leave your language of choice to do this, but it would probably be a lot simpler to just do the whole thing in Javascript.

You're delusional if you think the target audience is dumb people. They're looking to sift through all the problem solvers and find the best of them to hire them.
Google solve abstract problems with abstract solutions and they're using this Code Jam (and have been for 15 years) to scout for those people that can solve these problems.

Anybody done A or D? I found the other two easy but I'm stuck on these.

>implying real world problems aren't convoluted as hell
>implying reducing them to clear algo/math definitions isn't a very important skill

Just started. You just need 25 points to qualify right?
What's the bonus to getting more points?

Ho I see why the level of google coders is worse each year.

>GCC 7 WHEN

Literally delusional.

it's out already, isn't it?

honestly would be way easier for you in Java or C#.

Non-pure functional languages are shit

The satisfaction of solving a challenge.

no FP is pure

oh shit did I miss that somehow?

The satisfaction of doing nothing useful? Of making something literally thousands of other people are also making?

Hmmm, I'm a busy guy, think I'll get my 25 points and dip til later rounds.

gcc.gnu.org/ml/gcc/2017-03/msg00066.html

it's almost there

Why do people use hackerrank, topcoder, etc.? Their presence on your resume indicates only that you have zero imagination and creativity.

so they can feel better about themselves

You're right it's probably better to spend my time making posts like this instead of thinking critically and doing something that has any semblance of a reward.

You mean you are writing your own /sbin/init to pass to the kernel with the init= parameter? That's cool I played around with doing that a few years ago writing a simple init in Haskell it was a pretty fun toy project. Are you doing it as just a fun project or are you hoping to make something serious that could be used by others?

Why do people play videogames?

but GCC 6 is still hardmasked
sys-devel/gcc (6.3.0) **6.3.0

In case you had any doubts about how useful hackerrank is for making hiring decisions

>tfw my friend is from jagiellonian uni and is something like top 10 in java

>Czech Tech

>top 10 in java
Damning with very faint praise there, user. Some friend you are.

We don't talk about it, user.

>lmao java a shit!

Would you rather program a desktop program in D and have to use a wrapper like GtkD, or just program in C++ to use QT?

c++

I would rather use imgui.

Qt is basically java, so D

Yes, and?

I'd rather a language that's not dead, so neither?

Do toilets trouble you?

Desktop app in which lightweight and high performance is needed. What other compiled languages have a good GUI library that is widely supported?

But QT is one of the most supported.

doesn't matter, java. java is shit. go kill yourself. real men use x86 assembly and LISP. go back to india pajeet.

CL
Java

>LISP
Confirmed unemployed 17 year old.

C#/VB.

Passing by to say I'm really enjoying JavaScript. It has some great features and writing good code is pretty easy.

C#
trying to identify each char in myString including each space. is there such a thing as ' ' ?

I may be unemployed and 17, and have never had any real experience, but I know that Common Lisp is the best language. Way better than Java or any other shit OOP languages. OOP = POO

Nice integers but it has to be both light weight and high performance so I don't think Java will be good.

Are you serious?
And it has to work on Linux.

I have to make a file system and functions to operate it in C in my Operating Systems class, I was just wondering if anyone had a ballpark of how long it will take.

The last project I had which was a linux shell with piping and redirection didn't take nearly as long as I thought, but this one seems like it might be a pain in the ass.

Is it against convention to have an empty for loop?

/* loops over a vector until it finds a nonzero number
* vector is 0 0 0 0 0 1 2 5 2 0 0 2 4 0 0 */
unsigned int i = 0;
for(; vector[i] == 0; i++) {}
//i is now 5

>Are you doing it as just a fun project or are you hoping to make something serious that could be used by others?
I am doing it seriously, but I designed it to please me.

I was being a cheeky cunt on the c#/VB.

Jokes aside, java will work like dogshit most of the time.

And also what should it do and define how fast you want it, because if you want it to go absurdly fast the answer is go as low level as you humanly can, now if it goes slow is because you're dumb.

>Desktop app in which lightweight and high performance is needed.
user it's worth considering if you should write a daemon which handles the high performance stuff and have a GUI that presents the information to the user.
In that case you can choose whatever you find most convenient for the GUI without impacting the rest of the application. Because I wouldn't want to have to deal with a GUI thread in my high performance situation if I could avoid it.

remove you programmer badge right this fucking instant
nobody will violate our convention

Make it print nigger.

benchmarksgame.alioth.debian.org/u64q/lisp.html
Java is significantly faster than CL

benchmarksgame.alioth.debian.org/u64q/csharp.html
Java is roughly the same performance wise as C# (java is a little faster)

There tends to be better ways to do this. This is fairly cooky but to be fair it's just a linear search. Most linear search function are just this except they're inside a function. Now I would question why you're not doing that. It's certainly more clear to call a dedicated linear search function and get an index back then it is to just have odd looking for loops spread throughout the code. Even if they're quite obvious.

How am I supposed to solve that google code jam problem A?

Is there an algorithm for figuring out the minimum number of flips or is it just plain bruteforce?
I was just planning on finding the lowest number after 1 million attempts at random flipping.

A is piss easy, just don't think hard about it

Seriously? It's too hard for you?

This method may give you a solution, but it doesn't guarantee the lowest number of flips and may not even find a solution.

What is your plan for the impossible cases? Just say it's impossible if you don't find a flipping order that works?

>benchmarksgame
We've been over this. Doesn't tell you anything significant about real world use because figuratively none of the solutions outside the C solutions are written as you would normally write code in the language.
And even in the case of C they're a very odd style.

What they're really testing is how effectively you can write low level code in these high level languages. And with that in mind you must realize that for a larger codebase where you can't realistically convert all the code to low level code the story is very different.

I don't understand why anyone would need something like this outside of pure fantasy.

>I was just planning on finding the lowest number after 1 million attempts at random flipping.

>I was just planning on finding the lowest number after 1 million attempts at random flipping.

>I don't understand why anyone would need something like this outside of pure fantasy.
I haven't looked at this specifically but a lot of programming challenges are actually just for computer scientists. It's not for actual software engineering. It's rare to be given a problem with a very narrow set of inputs and outputs if it's not already an established algorithm.

But my language does well on it and yours doesn't!

My idea for D is a rule based dfs for the maximum.
>tfw on vacation and only have a phone

type side =
| Blank
| Happy
;;

let iter_range f start length =
let rec loop start = function
| 0 -> ()
| length ->
f start;
loop (succ start) (pred length) in
loop start length
;;

let flip = function
| Blank -> Happy
| Happy -> Blank
;;

let row_of_string s =
let l = String.length s in
Array.init
l
(fun i ->
match s.[i] with
| '-' -> Blank
| '+' -> Happy
| c -> failwith (Printf.sprintf "unexped side %C" c))
;;

let solve s k =
let row = row_of_string s in
let lim = Array.length row in
let rec loop count i =
let count =
match row.(i) with
| Blank ->
iter_range (fun i -> row.(i) count in
if i = lim - k then
count
else
loop count (succ i) in
let count = loop 0 0 in
let rec is_happy i =
if i < lim then
match row.(i) with
| Blank -> false
| Happy -> is_happy (succ i)
else
true in
if is_happy (lim - k) then
Some count
else
None
;;

let get_line ic =
let line = input_line ic in
Scanf.Scanning.from_string line
;;

let treat oc ic =
let ib = get_line ic in
Scanf.bscanf
ib "%d"
(fun count ->
let rec loop i =
if i = count then
()
else
let ib = get_line ic in
let result = Scanf.bscanf ib "%s %d" (fun s k -> solve s k) in
let result =
match result with
| None -> "IMPOSSIBLE"
| Some count -> string_of_int count in
let i = succ i in
Printf.fprintf oc "Case #%d: %s\n" i result;
loop i in
loop 0)
;;

let main () = treat stdout stdin;;

let () = main ();;

>ending functions with ;;
Only in OCancer

You can remove them. It will work.

>You can remove them. It will work.

hardmasked?

Also, what exactly are they even adding in the more recent versions? Have they fixed the logic bugs in their optimizer yet? Last I've seen GCC still generates garbage code under circumstances I haven't quite found a pattern to yet.

Code monkey post.

what's better?

A
// if node is null
if (!node)
return NULL;


or

B
//if node is null
if (!node)
return node;

Depends on the context.

what you mean? isn't it the same?
node *foo(node *a, node *b)
{
node *temp = a;

if (!a) {
return a;
}

while (temp->next) {
temp = temp->next;
}

temp->next = b;
return a;
}

I wouldn't call that significant, except for k-nucleotide maybe.

Data Type Ranges
char: -128 to 127
schar: -128 to 127
uchar: 0 to 255
short: -32768 to 32767
ushort: 0 to 65535
int: -2147483648 to 2147483647
uint: 0 to 4294967295
long: -9223372036854775808 to 9223372036854775807
float: 0.000000 to 340282346638528859811704183484516925440.000000
double: 2.22507e-308 to 1.79769e+308


how the hell do floats and doubles get that enormous???? they get way bigger than integers can get. 1.79769e+308 is 1.7.. * 10^308 right? i got these from limits.h and float.h

they're imprecise
they can't store every integer between those two numbers, e.g.

100000000100 and 100000000000 would be indistinguishable

>foo
What's a foo?

Openstack which requires a lot of Python, Puppet, Chef and Ansible. As well, working on DPDK. Processing line rate 40G in a VM is not easy.

The nemesis of a bar.

ok, i thought that something was fishy when i saw that. thanks

>one line
always
if (!node) return NULL;

doesn't matter. it's irrelevant here. i changed the names

foo is from the 1970s programming meme fubar meaning fucked up beyond all recognition

I'm a Java scrub, yeah hate on me but I need some review on my code.

I was just writing a fibonacci sequence in Java and I was able to implement a positive sequence using negative iteration inside the for loop parameter.

Where for (l = 31) is just replace '31' with any number for how long you want the sequence. So say you wanted a sequence of 30 numbers in fibonacci put 31, obvs haha but here's the code:

class Fibonacci {

static int a = 0;
static int b = 1;

static int l;
static int f;


static void fibCalc() {

for (l = 31; l > 0; l--) {

f = a + b;
b = a;
a = f;

System.out.println(a);

}

}

public static void main(String[] args) {

fibCalc();

}
}

I'm fucking confused by my own code, how is this working? I had an idea but never expected it to work. Any peer reviews?

That term was believed to be coined in WW2.