Programming challenges thread? Feel kinda bored and I want to make something

Programming challenges thread? Feel kinda bored and I want to make something.

Attached: programming_challenges.jpg (1920x1080, 366K)

If you're so bored bend over so I can fuck your little faggot ass

>bend over
kek, manlet can't take matters in his own hands, asking for cooperation

Programming challenge:

A set of integers is called sum-free when it is disjoint with its Minkowski sum. Given a finite set of integers (represent sets as whatever data structure you'd like), efficiently find a sum-free subset of size greater than one third the size of the given set.

Attached: 1401501598044.jpg (393x591, 45K)

>questions that require you to know random jew shit

>random jew shit
Like, uh... addition of integers? Sets? The notion of "one third"? I'm afraid you've lost me, friend.

Attached: ---.jpg (283x302, 11K)

i'm not going to google any of it and i'm going to continue throwing math phd resumes in the trash

Attached: 7422480.png (170x170, 48K)

I have found an autistic nigger

Here's a neat programming challenge from me:


-- Keyboard Driven Thumbnailing File Manager with a Clean Interface --


The command line is fine for most things, but it's inadequate if you want to manipulate a large number of files with non descriptive file names by looking at thumbnails. That's the only reason I have PCManFM installed, but I hate using it. It's clumsy and inefficient. It doesn't have proper keybinding capabilities and requires you to use the mouse. I'm sure I'm not the only one who feels this way. We lack a clean and efficient thumbnailing file manager. Every single thumbnailing file manager we have is a shitty explorer.exe clone. Hence my request.

Features/requirements:
* Must be completely keyboard driven, preferably with Vi-like keybinds.
* Must have a thumbnail view mode and nothing else, since that is the program's purpose.
* Can be either TUI (using w3mimgdisplay or something for thumbnails) or GUI, but if it's GUI, it mustn't use GTK3.
* There should be a Vi-like status/command line at the bottom which allows you to perform commands on selected files.
* The status line in normal mode should show the selected file number, name (and maybe size) and the scroll percent (since there's no scrollbar).
* Other than that, it shouldn't have any kind of GUI menus or elements besides the thumbnails themselves.
* Configuration can be done though config files or config.h.
Bonus points for:
* Multiple selection registers. [1]
* Clean and easily extensible code.

Basically a thumbnailing file manager in the vein of qutebrowser or zathura.

Attached: 1497955939804.png (567x748, 328K)

[1] Let's say you're going through your downloads folder and sorting out images and or videos in 5 categories. You don't want to go through the entire downloads folder 5 times to select and perform a bulk action on each category separately each time. It would be neat if you could go through the directory just once while assigning selected files to 5 separate registers (something like Vim clipboard registers). You could then use the registers on the command line to perform all 5 bulk actions at once like so: mv %r1% ~/img/wp/; rm %r2%; mv %r3% ~/webms/animu; ...
Selected groups of files that belong to different registers should be marked with different colors or something so they're easily distinguishable at a glance. You can also put the register name in the thumbnail corner or something.

roll

Attached: Screenshot_20190221_225328_com.notabasement.mangarock.android.lotus.jpg (2280x1080, 955K)

Programming challenge: write a program that lets you talk to God.

CS is what you do when you have the skillset but not the talent for math.

rolerino

Eh, why not give it a shot. I'm bored.

Roll

roll

Attached: emacs-vs-vim2.jpg (569x400, 86K)

roll

Attached: 1568398867722.png (470x495, 33K)

koding roll

Attached: karlie-kloss-express-like-a-kloss-2-tout.jpg (1080x1080, 154K)

which autist created this list
from itertools import permutations
amount_of_bells = 3
print(list(permutations(range(amount_of_bells))))

rul

Rolling, but won't actually do it
Noting personel kid

This seriously needs updating, we should be on 2.0 by now. Remember tech is an ever-changing field. Except tablets, that is just going downhill ever since its inception.

Same probs just wanna see if I could

Oh that'd be super easy

honk roll

Attached: 1556809218457.jpg (640x480, 52K)

roll but im not gonna do it just like every time I roll

Rollin

Attached: 1563911670062.jpg (1280x1807, 294K)

How do I make a self learning AI that applies for jobs for me and writes cover letters.

roll roll roll

Rolling

Roll

Rolling

Attached: 20190921_175631.jpg (1070x1161, 643K)

When the only place math degree is useful is on a fucking imageboard

I'm not sure why you dumb javaniggers think that -san's post is for math PhDs only, but let me break it down so maybe even a dumb freshman like you can understand.

>A set
A set is just a collection. Some languages, e.g. Python, have a built-in set datatype. If you start with something more basic, like a barebones scheme, then you can built sets from lists, where to sets-as-lists are equivalent if they become the same after reordering the list.
>of integers
Integers are the numbers ..., -2, -1, 0, 1 2, ....
>is called sum-free when it is disjoint with its Minkowski sum.
In other words, a set S of integers is called sum-free if you cannot write a+b=c where a, b, and c are elements of the set S.
>Given a finite set of integers
In other words, a collection of integers for which there exists some positive integer N such that all integers in the set are smaller than N and greater than -N.
>efficiently find
Don't just bruteforce.
>a sum-free subset
A sum-free set, all of whose elements are contained in the larger set which was given as an argument to the program.

>of size greater than one third the size of the given set.
The size of a set is the number of elements it contains. One third is (1/3), so it's asking for a set that has a number of elements at least (1/3) times the number of elements in the given set.

Now, let's review, and see how complicated that was. What were the main concepts introduced?
>Integer
Yeah, it's a scary word at first, but I should hope you've seen a fucking integer before.
>Set
Back in the days of New Math, we tried to teach little kids this stuff. It didn't really work out, but I should at least hope that a smart young programmer like you can grok the concept.
>Sum
Addition of integers is indeed a very deep concept. If you hang in there, one day you might be able to understand this. Maybe ask some math PhDs for help?
>One third
Not sure what to say here.

let me guess it ended in mating press ?

It ends in the nigger turning her into his cockslave. It's a 4 page comic.

owo

Nice projection. I'll explain so even a brainlet like you would understand. It's not just a programming task, but math+programming which you'll never meet in real life apart from math classes. Now please clean that shit that you wrote and return to solving useless puzzles if you have nothing better to di with your life.

roll

rollin'

Not sure if i can do most of these, but ill roll anyways

roll

lol why are most hentai so cucked

I started learning programming in c just a week ago and wanted to practice. So i wanted to make a small program wich takes 2 float values x,y and subtract y as a percentage. So if y=37 it means x-37%.

The peoblem is i only learned by now, how to use "+,×,÷,-,(),=". I solved the problem after breaking my head for 2 hours until i decided to go to sleep and it just came.

What would be your solution and did you had similar experiences?

z = x - (x * ( y / 100))

>after breaking my head for 2 hours
Wut?
float percentSub(float x, float y){
float per = (y*0.01f)*x;
return x-per;
}

>Minkowski sum
can you explain this in more detail? I looked it up, and it seems to refer to some computational geometry stuff. I don't see how it applies to a set of integers

>It's not just a programming task, but math+programming which you'll never meet in real life
No shit, this is a programming challenge thread, not a ``what webapp should I code today?'' thread.

You can ignore it, because I rewrote the definition of sum-free without using the term. However, the Wikipedia page on Minkowski addition seems to have the definition: given two sets, their Minkowski sum is the set of elements obtained by adding an element of the first set to an element of the second. I assume that -san meant to say ``its Minkowski sum with itself'' or similar.

Roollla-kun

Broll

Python was a mistake.

Here is the traduction of the problem if you are a math retard.
Input: A list of n distinct integers a_1, a_2, ... , a_n
output: A list of m distinct integers b_1, b_2, ... , b_m chosen from the input integers such that every sum of two integers from the output is not also in the output. The numbers of integers m must verify 3 * m >= n.
Now you have no excuse for not solving the problem (well if you don't understand what is the sum of two integers just kill yourself).

I had the same result, took me 2 hours lol.

I only knew the 4 basic calculsting methods, so percentsub ans return are unknown to me by now^^

Can you learn programming without writing a lot of code? As in just read the solution and understand/grasp whats going on

Can you learn the piano without playing a lot of songs? As in just read the sheet music and understand/grasp what it should sound like.

you might want to watch some algebra videos on Khan academy. You don't need much math for programming but you need basic math just to function in every day life. What would you do if you had to calculate a tip?

Its not exactly intuitive how to represent your idea in code, especially when you are still getting comfortable with syntax and stuff. Don't be hard on yourself, keep practicing and youll get better.

the best way to learn programming is by reading and modifying a lot of code. You can find many repositories on github, and even upload your changes there. Just remember to always use a GPL when possible.

I know math actually pretty good. And tips are easy, but i had to convert an variable percentage to an float number first, wich took me a while. I just started a week ago, so i have to learn a lot.

Its important to me to solve such things on my own, because just looking it up wont work well with me.

But i managed to do what i want, to calculate the tax out of my income with an variable percentage without knowing any way to calculate percentages in C.

But i will look him up, thabks for the info.

Im not hard with me, of course i have to learn a lot. But i am happy because i was able to solve an simple problem in C, wich is amazing for me. Started a week ago with literally 0 knowledge except that there is an "if" command.

Its really enjoyable when you got a solution on your own and know you not only achieved something but also you learned the lessons you went through.

Dumb ESL.

Rolllllll

ESL?

don't bother if you're good at math. For some reason I missed the part where you said you just started programming. Try writing a program to determine whether a randomly generated dot is inside a randomly generated triangle.

You can copy paste the code and make the necessary changes
you cant copy paste the piano
shit analogy

I think i have to pass until i know more commants than "printf,scanf_s and if/else"

Just started on if/else

That's not programming. At best, it's coding.

Does anyone on Jow Forums even know how to program?

Roll

Roll

To those who rolled: Post code.

rolling

Post code.

nobody ever does them
rolling

i do, but in a mediocre way that makes everything frustrating

mh, i want to make that Jow Forums thread downloader.

the api states that you should make max 1 request/second

does that request count only for the json file itself or should i time that for the image downloading too

Rolling for love calculator whatever it is

Roll.

I rolled the Benford's law one
Here you go, it takes in a file, it can have text, but each line that has text will be ignored
I know it's probably longer than it needs to be and badly written but whatever, still learning
import sys

if len(sys.argv) > 0:
f = open(sys.argv[1], "r")
res = [0, 0, 0, 0, 0, 0, 0, 0, 0]
total = 0
for line in f:
if line.rstrip().isdigit():
total += 1
first = int(line[0])
if first == 1:
res[0] += 1
elif first == 2:
res[1] += 1
elif first == 3:
res[2] += 1
elif first == 4:
res[3] += 1
elif first == 5:
res[4] += 1
elif first == 6:
res[5] += 1
elif first == 7:
res[6] += 1
elif first == 8:
res[7] += 1
elif first == 9:
res[8] += 1
else:
print("wat")
if total != 0:
print("Number of occurances:")
print("1: " + str(res[0]))
print("2: " + str(res[1]))
print("3: " + str(res[2]))
print("4: " + str(res[3]))
print("5: " + str(res[4]))
print("6: " + str(res[5]))
print("7: " + str(res[6]))
print("8: " + str(res[7]))
print("9: " + str(res[8]))
print("---")
print("Percent of total leading numbers:")
print("1: " + str(res[0]/total*100) + "%")
print("2: " + str(res[1]/total*100) + "%")
print("3: " + str(res[2]/total*100) + "%")
print("4: " + str(res[3]/total*100) + "%")
print("5: " + str(res[4]/total*100) + "%")
print("6: " + str(res[5]/total*100) + "%")
print("7: " + str(res[6]/total*100) + "%")
print("8: " + str(res[7]/total*100) + "%")
print("9: " + str(res[8]/total*100) + "%")
else:
print("No number founds")
f.close

>occurances
Stopped reading right there.

It's a misspelling Himmler, calm down. It works is the point

rollin

>tfw reading that code

Attached: 1539936170989.jpg (332x277, 27K)

Gimme something I can write in bash

write a program that given a folder, it'll hash each and every file, if there are duplicates:
-if they're on the same subdirectory, delete one of them
-if they're in different subdirectories, delete one and replace it with a symlink to the remaining one

Neat, I'll do that. I already wrote one that will return duplicate hashes, but it doesn't actually do anything with them:

#!/bin/bash

while getopts "rt:" opt; do
case ${opt} in
t) TYPE=."${OPTARG}" ;; # type
r) COMMAND="find . -name \"*${TYPE}\" -exec md5sum {} \\;" ;; # recursive
"") COMMAND="md5sum \"*.${TYPE}\"" ;;
esac
done

$COMMAND | sort | awk '{ print $2, $1 }' | uniq -dDf 1 | awk '{ print $1 }'

import Data.Set (Set)
import qualified Data.Set as Set

sumSet :: Set (Int) -> Set (Int)
sumSet x = Set.foldr (\(a,b) -> Set.insert $ a + b) Set.empty (Set.cartesianProduct x x)

sumFree :: Set (Int) -> Bool
sumFree x = Set.disjoint x $ sumSet x

sumFreeSubSet :: Set (Int) -> Set (Set (Int))
sumFreeSubSet x = Set.filter (\y -> sumFree y && (Set.size x < (Set.size y) * 3)) $ Set.powerSet x

-- e.g. sumFreeSubSet $ Set.fromList [1..10]

I'm new to haskell. Please don't bully me.

>Please don't bully me.
Please, this is Jow Forums. Kindest website on the internet. We would never bulling you. Well, that's not true. But for a high quality post as yours, it is.

It looks like your code is a bit brute force-y. A brute force is optimal given what posted, but with a bit of basic math, you can get a lot faster. What I'm thinking of can be had within a short search, but if you avoid search engines, let me know, and I can elaborate explicitly, probably, sometime within this week.

Attached: [Kuusou] New Game! - 08 [C7F60167].mkv_snapshot_08.56_[2016.08.27_11.48.31].jpg (319x352, 31K)

its not just hentai, cuckolding is the most popular fetish atm

use pinvoke to delete system32

How leet would I be if I managed to do all of these?

None leet. Zero.

Shame. Why can’t I just be good and employable?

is this true
if i dont have talent for math then why should i not get into cs

what has durga sir taught me

define program

Fuck you.