/dpt/ - Daily Programming Thread

Chase Moore
Chase Moore

old thread: /g/thread/58443173#p58443173

What are you working on, Sup Forums?

All urls found in this thread:
https://www.gnu.org/software/make/manual/html_node/Shell-Function.html
https://is.Sup
https://is2.Sup
https://golang.org/dl/
http://pastebin.com/12eVX19f
Nathan Gray
Nathan Gray

First for D

Joseph Martinez
Joseph Martinez

hi anons, i have a game server on python, im currently passing it to ctypes cause slow

but

i just figured, is linux faster than python? ( i think not cause ram) i mean, say instead of loading a bunch of classes and shit i just created temporary folders with data in it and used C programs to asses shit like "can USER move there?" "can USER attack there?" "how much DAMAGE did it make" etc?

would it be faster? like, operating in linux instead of operating withing python?

Or am i just being retarded?

(pls just answer even if its to call me a retard, don't make fun of me)

Mason Watson
Mason Watson

Operating with data files on the filesystem is going to be a lot slower than operating with classes etc loaded into memory whether you do it in python or in a shell script (which is what I assume you mean by operating in linux)

Hunter Moore
Hunter Moore

thank you a lot for giving me a straight answer and not an anime face, ask me for anythnig and i shall deliver

Jeremiah Baker
Jeremiah Baker

I'm a complete noob to C++, but can someone optimize or shorten this for me? Just want to see how short you can make a program and still make it run with C++.

// typecast.cpp -- forcing type changes
#include "stdafx.h"
#include "math.h"
#include <iostream>
#include <iomanip>

int main()
{
using namespace std;
cout << "Enter the latitude in degrees, minutes and seconds";
int degrees;
int minutes;
int seconds;
cout << "First enter the degrees:";
cin >> degrees;
cout << "Next Enter the minute of the arc:";
cin >> minutes;
cout << "Finally. enter the seconds of arc:";
cin >> seconds;
const float conversionRatio = 60;
float decimalDegrees;
float decimalMinutes;
float decimalSeconds;
decimalSeconds = seconds / conversionRatio;
decimalMinutes = (decimalSeconds + minutes) / 60;
decimalDegrees = decimalMinutes + degrees;

cout << decimalDegrees;


cin.get();
cin.get();
return 0;
}

Zachary Morris
Zachary Morris

you're not gonna make it bruh

Luis Price
Luis Price

not C++ wizard, but input a string, split by "," and do the math in a single line

wont be faster but will look shorter

Luis Gutierrez
Luis Gutierrez

Is this messy code?

if ((time = (!i) ? sec % lmt[0] : sec % lmt[i] / lmt[i - 1]) || 
(!i && !iters))

Cameron Perry
Cameron Perry

Fucking shit AMD and their shitty drivers.
I was getting massive screen tearings on my app and I tried everything to fix it. After much work I found out that were AMD drivers that were causing the fucking tearing.

Eli Hall
Eli Hall

Anything with a tertiary operator is messy code, in my opinion.

Joseph Roberts
Joseph Roberts

*ternary

Ryan Turner
Ryan Turner

is this better?

#include "stdafx.h"
#include "math.h"
#include <iostream>

int main()
{
using namespace std;
cout << "Enter the latitude in degrees, minutes and seconds\n";
int degrees, minutes, seconds;
cout << "First enter the degrees:";
cin >> degrees;
cout << "Next Enter the minute of the arc:";
cin >> minutes;
cout << "Finally. enter the seconds of arc:";
cin >> seconds;
const float r = 60; // Conversion Ratio
cout << (seconds / r + minutes) / r + degrees;
cin.get();
cin.get();
return 0;
}

Blake Gomez
Blake Gomez

best programming language for programming?

Dylan Watson
Dylan Watson

Ebin overflows senpai

Matthew Thompson
Matthew Thompson

this program is not feasible in the real world, try again

Elijah Ross
Elijah Ross

1. Remove stdafx.h. It's not portable.
2. Remove unnecessary calls to cin.get(); You aren't using the value from them. It just unnecessarily stalls the program when the ideal behavior is to return as quickly as possible to the shell that called it.

Benjamin Edwards
Benjamin Edwards

Like your waifu, the one language you cherish and love.

Carter Johnson
Carter Johnson

Why isn't my makefile recognizing the pkg-config bit?

main : main.cpp
g++ main.cpp $(pkg-config --cflags --libs sdl2) -o output

As written, the g++ line works fine in the command line, but in a makefile it reads as

g++ main.cpp -o output

What exactly does the $( ... ) do? Other time I saw it, it was for noting a variable OBJS = main.cpp and $(OBJS) at the target.

Leo Hughes
Leo Hughes

And this is how the man details using it in a Makefile:

program: program.c
cc program.c $(pkg-config --cflags --libs gnomeui)

Eli Morris
Eli Morris

$() is variable expansion in Make. I think you need to use the shell function?

https://www.gnu.org/software/make/manual/html_node/Shell-Function.html

Henry Perry
Henry Perry

gimme a simple example of the benefits of pointers in C

Angel Roberts
Angel Roberts

Try

$(shell pkg-config --cflags --libs sdl2)
instead for command subtitution. Also, it may be possible pkg-config returns nothing if the package is not installed.

Sebastian Cooper
Sebastian Cooper

What does this even mean?

Jason Brown
Jason Brown

teach me senpai, i'm doing questions out of c++ primer plus 6th edition.

is this better, or does it still overflow?

#include "stdafx.h"
#include <iostream>

int main()
{
using namespace std;
cout << "Enter the latitude in degrees, minutes and seconds\n";
float degrees, minutes, seconds;
cout << "First enter the degrees:";
cin >> degrees;
cout << "Next Enter the minute of the arc:";
cin >> minutes;
cout << "Finally. enter the seconds of arc:";
cin >> seconds;
const short r = 60; // Conversion Ratio
cout << (seconds / r + minutes) / r + degrees;
cin.get();
cin.get();
return 0;
}

Because of overflows?

1. I can't compile in visual basic without it for some reason, can you offer any suggestions to why that is?

2. cin.get(); stops program from closing after it has finished it's calculations.

Matthew Adams
Matthew Adams

Adding shell did it, thanks.

Why doesn't the manual show that though?

Carson Perry
Carson Perry

The benefits of pointers in C are strictly speaking the same as the benefits of indirection in programmation in general. That is, you don't have to depend on fixed addresses to write algorithms, your algorithms work wherever its inputs are located in memory.

Gavin James
Gavin James

Fuck I hate everything about pkg-config and it's related autotools.

Ayden Long
Ayden Long

Why doesn't the manual show that though?
If by manual, you mean "man make", it is the manual of the make program, but not of the Makefile specification.

Charles Gray
Charles Gray

Most arithmetic has the risk of overflow unless you sanitize the valid range of your variables. Also cin isn't safe from overflows either, so even the input can be read wrong.

Jace King
Jace King

no, I meant man pkg-config from here
That's the example of how to put pkg-config into a makefile given by the pkg-config manual.

Alexander Wood
Alexander Wood

https://is.Sup Forums.org/g/1484199873139.jpg
https://is2.Sup Forums.org/g/1484201701201.webm

Christopher Thomas
Christopher Thomas

compile in visual basic
You mean Visual Studio? Also, I'm pretty sure there's a flag somewhere buried under mountains of graphical interface to turn on or off precompiled headers, which is what you need stdafx.h for.

cin.get(); stops program from closing after it has finished it's calculations.
No, user, you don't get it. The program is supposed to stop. And when it stops, the command line that you called it from resumes control. If you did not call it from a command line, you are running it wrong. Console applications by definition are intended to be run within the context of a console. But nonetheless, since you are using Visual Studio... "start without debugging". And then get your ass a real compiler.

Camden Young
Camden Young

nice slowdown senpai.
Why are you making a gif-viewer in 2016+1?
Can you scroll the dir with keys?

Nicholas Bell
Nicholas Bell

okay, so how would I make sure it couldn't overflow? I haven't learnt if statements yet but would I use an if statement to end the program or display a message if data not in the range of it's intended variable is entered?

Brandon Clark
Brandon Clark

oh okay, sorry senpai, what do you recommend I use instead of visual studio?

Luis Kelly
Luis Kelly

More or less, except for getting the input from the user. There are functions that handle it, you can put it in your list of things to look into when you finish your book or whatever.

Jonathan Hill
Jonathan Hill

MinGW-w64, which is a proper port of GCC to Windows. What you learn from using it will translate seamlessly to every other platform. For your editor, use whatever you like. Notepad++ is a common choice for Windows users who don't want to learn anything new

Jayden Murphy
Jayden Murphy

"start without debugging"
why? learning gdb as early on as possible is a blessing.

Angel Stewart
Angel Stewart

Can you scroll the dir with keys
yes if you right click and select the option to slideshow with arrows

Hunter Morgan
Hunter Morgan

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>

#define RATIO 60

static long str_to_long(const char *str)
{
char *end;

errno = 0;
long ret = strtol(str, &end, 10);

if (errno == ERANGE) {
fprintf(stderr ,"%sflow for '%s'\n",
ret == LONG_MAX ? "Over" : "Under", str);
exit(1);
}

if (end == str || *end != '\0') {
fprintf(stderr, "Invalid number '%s'\n", str);
exit(1);
}

return ret;
}

int main(int argc, char *argv[])
{
if (argc != 4) {
fprintf(stderr, "usage: %s <degrees> <minutes> <seconds>\n", argv[0]);
return 1;
}

long degrees = str_to_long(argv[1]);
long minutes = str_to_long(argv[2]);
long seconds = str_to_long(argv[3]);

seconds /= RATIO;
if (seconds > LONG_MAX - minutes)
goto overflow;

long tmp = seconds + minutes;

tmp /= RATIO;
if (tmp > LONG_MAX - degrees)
goto overflow;

printf("%ld\n", tmp + degrees);

return 0;

overflow:
fprintf(stderr, "Calculation overflowed\n");
return 1;
}

Xavier Clark
Xavier Clark

friendly reminder that the only way to really understand programming is to manufacture a computer from scratch

Robert Cox
Robert Cox

I've written a simple microprocessor (to run on an FPGA) in Verilog before, as part of a university assignment.
Does that count?

Landon Jones
Landon Jones

no you have to mine your own silicone ore

Benjamin Lopez
Benjamin Lopez

I will do, hopefully the book touches on it later anyway.

Thanks, would it better for me to download a Linux kernel like arch instead?

thanks, I can't understand most of that lol

Eli Murphy
Eli Murphy

maybe not the only one, but surely one of the quickest ways

Bentley King
Bentley King

It's a Visual Studio thing to keep the output window from destroying itself.

Owen Foster
Owen Foster

silicone ore

...rocks?

Jose Gomez
Jose Gomez

But the paper mentioned how all of that shit is done.
Silicon doping, transistor logic, and all that.

Jace Gutierrez
Jace Gutierrez

Programming on Linux is less of a pain in the ass as on Windows, but it isn't wholly necessary. There's not too much difference between using GCC on Windows and using GCC on Linux (though any other supporting tools on Windows will make you want to tear your hair out). If you would nonetheless like to work in Linux, I would recommend using an easier distro than Arch. Ubuntu, OpenSuSE, Fedora, Mint... these all work rather fine for beginners and have excellent package managers for getting the tools that you need. It is even possible to develop Windows applications on Linux by getting the MinGW-w64 cross compiler. Testing is as simple as running Wine on the application. Though not every Windows application works perfectly in Wine, almost every application that works in Wine works on Windows... with a few odd exceptions of some really old applications that no longer work in compatibility mode on Windows.

Anthony Gutierrez
Anthony Gutierrez

silicone
Fucking idiot. We aren't making fake tits here.

Cooper Phillips
Cooper Phillips

got hired
got to work with Plone and shit
currently being fired
got to explain the system to newbie
mfw I have no clue how that shit works
It seems I'm just a shit programmer, then.

Zachary Edwards
Zachary Edwards

With all of the traps lurking around here... we might as well.

Adrian Lewis
Adrian Lewis

all of the traps
There would be 2 on here at most. They are just very vocal.
I wish they would shut up and stop pushing their stupid forced meme, like they have been for the last several years.

Liam Sanchez
Liam Sanchez

Can they actually program though?

Jace Jackson
Jace Jackson

Probably not.

Owen Lopez
Owen Lopez

Kinda wonder why they come here of all places to attention whore... and why they don't put on a fucking trip.

Tyler Lewis
Tyler Lewis

Can you give an example piece of code?

Nathaniel Ward
Nathaniel Ward

1. Allocate buffers of arbitrary amounts of memory without the possibility of stack overflow or trashing a register to keep track of the length of a variable length array.

2. Outputting variables from a function while also returning a status code (pass variable as pointer argument, set it from the function).

3. Passing large data structures around without copying memory.

4. Any linked data structure (trees, graphs, linked lists).

5. Anything involving strings.

Bentley Hall
Bentley Hall

Any non-trivial piece of C code will use pointers extensively.
They are absolutely fundamental to the way C works.

It's kind of hard to come up with an example, because I could post practically anything.
Here is the most trivial example I can think of:

int n;
scanf("%d", &n);

scanf couldn't work unless you give it a pointer to an existing memory location.

Jose Garcia
Jose Garcia

this do?

int a[3];
for(int i=0; i<3; i++){
a[i] = 10*i+3;
}

It's an array, but pointers are more or less the same, except they can point anywhere

Nolan Gonzalez
Nolan Gonzalez

I get that, I mean &n obviously means "into the memory address of n"
What I'm confused about are variables that begin with *

Nolan Morris
Nolan Morris

Mostly pointer math. Just look up linked list double pointers.

It's also used to easily break the type system since any type of pointer can be cast to any type. That way you can easily write your own allocators.

It's what they did for the curiosity rover navigation system since it doesn't have any memory protection or virtual addresses.

They allocated a pool of memory and used placement new.

Jose Campbell
Jose Campbell

"the memory address of n" is of type int*.

Oliver Collins
Oliver Collins

Think about it from the function's perspective:

#include <stdio.h>

void set_int(int *ptr)
{
*ptr = 2;
}

int main()
{
int n = 10;
printf("%d\n", n);

set_int(&n);
printf("%d\n", n);
}


It allows you to modify local variables in other functions.

In my examples, 'ptr' refers to the pointer itself, and '*ptr' refers to the value that the pointer is pointing at.

Jordan Sanders
Jordan Sanders

this makes much sense, thanks

Jose Ramirez
Jose Ramirez

having pointers to functions and using them as callbacks is a neat thing too

Jaxon Moore
Jaxon Moore

why static/heap memory tho?

Hunter Long
Hunter Long

static
The function has no external linkage, so it should be declared as static.
For a trivial program, it's not really important though.
heap memory
My program didn't make use of the heap.

Carter Morales
Carter Morales

A while ago, I found myself regularly having a section of code where I would fprintf some error message at stdout, and then exit with a failure status. Easiest to condense it into one function. It's a little cleaner than a goto fail kinda thing.

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdnoreturn.h>

/* Exit program with error message */
noreturn void bail(const char *fmt, ...)
{
va_list args;

va_start(args, fmt);
fprintf(stderr, fmt, args);
va_end(args);
abort();
}

Jose Cooper
Jose Cooper

Could you please stop tripfagging, bro?

Caleb Collins
Caleb Collins

No thank you.

Noah Gonzalez
Noah Gonzalez

u go to uoft?

Lincoln Cox
Lincoln Cox

No.

Yes, 'die' functions are nice and all, but I couldn't be bothered with that for my example.
I can't wait until C2X and getting __VA_OPT__ (assuming it gets through, but it's likely), making these sorts of functions much nicer to use.

Carson Rogers
Carson Rogers

how many programs do you have to write to become a programmer

Adrian Price
Adrian Price

Technically, one.

Robert Rogers
Robert Rogers

silicone ore

Elijah Murphy
Elijah Murphy

silicone
not graphite

Xavier Nelson
Xavier Nelson

What lang + framework to use to develop mobile applications?
I know python and kivy but afraid of the performance.
I know java and javafx but it has poor performance. you can't style stuff easily in java and basically the documents say you should write css and then apply the css class for your objects which is fucking retarded IMO.
I could go with web apps but I could as well just kill myself now.

Easton Diaz
Easton Diaz

(C and NOT A) or (B and NOT A)

Can this be shortened? My brain has shut down for the night.

Jason Lopez
Jason Lopez

(c or b) and a

Cooper Hill
Cooper Hill

¬A ^ (B ∨ C)

Adrian Hall
Adrian Hall

Yes that worked thanks.

Luke Cruz
Luke Cruz

suppose i am to implement list that keep its elements sorted
what sorting algorithm is best for this? everytime an element is added to the list, i should run this sorting algorith,

Wyatt White
Wyatt White

If it's a list of n elements and it's already ordered, inserting in order should be O(n) at worst, no need to sort the list again after insertion.

Charles Miller
Charles Miller

Does it have to be a linked list? It's extremely easy to keep a binary tree sorted as you go.
everytime an element is added to the list, i should run this sorting algorith,
You don't even need a sophisticated sorting algorithm for this. You just need to do a linear search through the list, and then insert the element at the correct place.
Unfortunately for a linked list, there isn't really a more efficient way to do this, unless you're trying to do it all up front.

Brayden Jenkins
Brayden Jenkins

This is actually for a wrapper class. It can be backed by array or linked list.
Isn't insertion sort too slow for this? I'm thinking something like how binary search looks for elements. Check middle, if less than, check left, etc etc.. until the insertion point is found.

Adrian Wilson
Adrian Wilson

take a bunch of programming courses in school
proudest achievement was a working version of pong
drop out for a year
don't write any code during that time
don't remember the exact syntax involved to write hello world anymore in java
remember after a few hours of failure and despair everything is a fucking class andI've been trying to do it like I would in C this whole time
this language is stupid

Christopher Robinson
Christopher Robinson

I'm thinking something like how binary search looks for elements
You can't binary search a linked list, because you don't have random access.

Jaxson Scott
Jaxson Scott

me again, of course for linked list, i have no choice but to crawl from index 0 until the insertion point is found

Kevin Davis
Kevin Davis

Graphite
Not titanium trisulfide

Charles Fisher
Charles Fisher

I have a Java job interview in two hours.

What buzzwords should I drop? Already prepared Spring, Maven and Hibernate.

Aiden Cruz
Aiden Cruz

design patterns

model-view-controller

service-oriented-architecture

WSDL
Java 8
Lambdas

Streams

Justin Moore
Justin Moore

I'd rather become a beggar than work as a java programmer.

Cameron Nelson
Cameron Nelson

Thx

Stay a Haskell NEET then

Joseph Long
Joseph Long

I just wrote my first simple program in c++ and I feel like I'm on top of the world.

Sebastian Long
Sebastian Long

Must read programming books for beginners?
Thanks Sup Forums

Easton Hughes
Easton Hughes

reading programming books

Brayden Brooks
Brayden Brooks

The functional stuff in Java 8 is pretty good.
Mention how you can now do method chaining without getting fucked over by nulls due to monads (Optional<T> being the main hero here), which lets you write much better looking and easy to understand code.

That at least makes you sound like you have an interest in the development Java goes in.

It's like Oracle wants a language with the flexibility of Common Lisp and the type safety of Haskell. They just don't care enough to get it done.

Blake Hernandez
Blake Hernandez

not just watching YouTube programming tutorials

James Stewart
James Stewart

But they are almost always utter shit, done by clueless 14-year olds and/or indians.

Brayden Lee
Brayden Lee

sounds like your mom

Michael Bailey
Michael Bailey

tfw trying to solve a problem
in desperation try the jewtube
open a seemingly relevant video
hear an indian accent
ctrl+f4
the search continues
everytime

Nathan Edwards
Nathan Edwards

I know this feel
Fuck Indians

Blake Cruz
Blake Cruz

Ive seen vids by indians that were helpful

stop being so buttblasted, not everything's about race

Isaac Nelson
Isaac Nelson

can't attend real analysis classes because aids
Indian guy on yt teaches me real analysis

epic nice, thanks pajeet

Oliver Morris
Oliver Morris

I saw a video by a 10 year old indian kid on connecting ESCs to a raspberry pi (including soldering connectors for the battery) which was immensely useful to me.

Wyatt Jackson
Wyatt Jackson

There's a strong possibility that you might be mentally retarded then.

Aaron Brown
Aaron Brown

And why exactly? I don't remember the exact problem I had but I remember that no other video had the information I was looking for. Don't act as though you never look up info on the internet...

Colton Peterson
Colton Peterson

You just confirmed it, you're definitely mentally retarded.

Nolan Myers
Nolan Myers

It's more about their accents being annoying as fuck.

Henry Barnes
Henry Barnes

no arguments, just insults
ok pajeet

Isaiah Rodriguez
Isaiah Rodriguez

It isn't about race. Its about the fact that I'm not a native English speaker, and Indians have very hard to understand accents.

Bentley Russell
Bentley Russell

Where do I get compilers for Android phone?

Jayden Bailey
Jayden Bailey

what would one use to write simple CLI applications with one purpose to work on both windows, mac an linux? not including python

Liam Sanders
Liam Sanders

C

Leo Gomez
Leo Gomez

Rust

Brandon Hernandez
Brandon Hernandez

needs to write simple CLI application
this retard suggests language that would require me to learn everything about transpeople and feminism before I'm even allowed to use the compiler

Aaron Harris
Aaron Harris

QT

Brody Clark
Brody Clark

Perl

Cameron Gray
Cameron Gray

Depends on language.

Brayden Edwards
Brayden Edwards

Go

Sebastian Ortiz
Sebastian Ortiz

Node.js

Lincoln Robinson
Lincoln Robinson

Java

Nathaniel Green
Nathaniel Green

bash*, C(++) w/ stdlib

Samuel Carter
Samuel Carter

assembly

Carter Evans
Carter Evans

Haskell

Brody Watson
Brody Watson

low hanging fruit 'it's SJW GUISE' pseudo-criticism
thinks his opinion is valid

Chase Butler
Chase Butler

C(++)
C and C++ are completely different languages. Grouping them together makes no sense.

Daniel Sullivan
Daniel Sullivan

For C which utility library should be used?
glib, apr, qlibc, tbox, libu?

Noah Williams
Noah Williams

C(#)

Parker Martin
Parker Martin

triggered

Hunter Roberts
Hunter Roberts

constexpr float ratio = 60;

int get(const string &prompt) {
int ret = 0;
cin >> ret;
return ret;
}

int main(int, const char **)
{
int deg = get("first enter the degrees:");
int min = get("next enter the minute of the arc:");
int sec = get("finally enter the seconds of the arc:");

cout << (seconds / ratio + minutes) / ratio + degrees;

cin.get();
cin.get();

return 0;
}

Levi Fisher
Levi Fisher

WinApi

Michael Myers
Michael Myers

It totally fucking is.
The reason I don't like using JS isn't the language itself, it's the community.

Look at PHP. It too has a shitty community. Had the community been less 34 year old retards who happened to figure out how to write webpages during the dotcom boom and never bothered to learn what an array was, PHP would have been a tolerable language by now.

If you use a language youre joining a community, even if you're joining a community of one because all the others are intolerable.

Xavier Reed
Xavier Reed

muh group identity/community
sjw language there

Caleb Morris
Caleb Morris

you're not printing prompt
use atoi or one of its cousins

Camden Price
Camden Price

t. communist

identity and groups don't matter! blend everything together!

Xavier Gray
Xavier Gray

I use 10 languages (obv not carmack tier in any (yet :3)) and I havent joined no community

Levi Collins
Levi Collins

building an identity out of the tools you use

absolutely haram

Luis Martin
Luis Martin

Who gives a fuck about community? They already wrote libs for you, answered questions for you. All perfectly googleable, so why get yourself involved any further?

Eli Thomas
Eli Thomas

collectivist

Andrew Adams
Andrew Adams

Any

Adrian Hill
Adrian Hill

If you don't believe in your race, in your culture and in your people then what good are you?

Levi Roberts
Levi Roberts

https://golang.org/dl/

Carson Baker
Carson Baker

Java, not even kidding

Leo Martinez
Leo Martinez

instantly jumps to race
alt-sjw

Daniel Jones
Daniel Jones

giving a shit about a group of people connected by some arbitrary characteristic just because you also exhibit that characteristic
believing (strongly) that you owe them your life

Eli Torres
Eli Torres

Ther is no .apk

Jonathan Gray
Jonathan Gray

/g/thread/58443173#p58445049
/g/thread/58443173#p58445064
/g/thread/58443173#p58445106 (Me)
/g/thread/58443173#p58445146

No, it's completely okay, fagtron.

Carter Sanders
Carter Sanders

C#

Ian Edwards
Ian Edwards

Your culture and your race made you who you are, they define a huge part of you

Owen Moore
Owen Moore

Y-You want to compile on Android itself? Nobody does that, because it's terribly slow. Read up on cross-compiling.

William Powell
William Powell

In no way does it make me obliged to do anything for other people of the same race and/or culture just because they happened to be born into it (or vice versa).

Jack Clark
Jack Clark

You didn't HAPPEN to be born into it.
You couldn't have been born in a different culture or race.

Camden Robinson
Camden Robinson

my race
not really

Chase Lopez
Chase Lopez

The community and their intelligence or lack thereof influence how good the docs are, what features are coming, how the language is evolving, and so on.

Languages change and the people that use them change them.

When slave/master becomes leader/follower, it's just a prank bro. But what the fuck makes you think it will stop there?

I'm not saying that Rust is going to become C+=, but it'm not saying it won't either.

Alexander Harris
Alexander Harris

I want some programming environment to have some fun.
I've been thinking about setting up C64 emulator, though.
Let's say, I want to set up Python on Android.
How is that possible?

Joseph Nelson
Joseph Nelson

Use your Android device as a terminal and RDP into a proper machine with IDE/compiler/etc.

Colton Lee
Colton Lee

Yes, I did happen to be born into it, I didn't choose it.
And I still wouldn't owe anything to them or any other culture or race.

Cameron Sanders
Cameron Sanders

too dependent from network connection
I don't want any serious things.

Aiden Williams
Aiden Williams

libruls cant be smart
What's an alt-right langauge I can use. For the maximum amount of intelligence.

Leo Anderson
Leo Anderson

It's not.

Mason Flores
Mason Flores

I didn't choose it
It chose who you would be.
Any other culture could not have made you.

Josiah Harris
Josiah Harris

It's kind of useless to speculate on that. If I were born into a different culture I'd be a different person, but I weren't, so I'm not.

Gavin Wilson
Gavin Wilson

If I were born into a different culture I'd be a different person
Exactly.

Kevin Sanders
Kevin Sanders

I've slightly tweaked my code, but it still won't work. Any idea what's wrong?
It should return all the pairs of words with guess being a BASE-n rotation of the word.

>>> text = open('words.txt')
def rotatable(text):
by_length = {}
for line in text:
word = line.strip()
for line1 in text:
guess = line1.strip()
if len(word) == len(guess):
built = ''
n = ord(guess[0]) - ord(word[0])
i = 0
for letter in word:
m = ord(guess[i]) - ord(letter)
if m!= n:
break
built += guess[i]
i += 1
pair = word + ' ' + built
if built == guess:
by_length.setdefault(n, []).append(pair)
return by_length #returns empty dictionary

Chase Harris
Chase Harris

what good are you?

In regards to what? Being good for the sake of a culture or race is completely arbitrary. The truth is, whether that culture or race exists doesn't actually matter except to make someone feel like they belong and that they're valid. Supporting your race or culture doesn't make you any better in any way, shape, or form.

Brayden Collins
Brayden Collins

Split your function. This is unreadable.

Henry Hernandez
Henry Hernandez

Lisp

Elijah James
Elijah James

If you don't believe in your race or culture then you don't believe in yourself or don't wish to pay merit to the ones who came before you

Parker Lewis
Parker Lewis

$ info make

Nicholas Robinson
Nicholas Robinson

C

Hunter Collins
Hunter Collins

Rust

Robert James
Robert James

all those foreaches and ifs

Use lambdas, you twat.

Joshua King
Joshua King

I believe

Joseph Thomas
Joseph Thomas

No
Lambda is basically an incapsulated function, see above.
My code is pretty fancy, yet still highly readable.

Aiden Brooks
Aiden Brooks

not (((Scheme)))
Based Ashkenazi 1 SD higher IQ than white barbarians

Eli Cooper
Eli Cooper

Good

Elijah Scott
Elijah Scott

As you said, it doesn't even work, and this is partially because it's difficult to read and reason about in that format.

Levi Cooper
Levi Cooper

Python:

for each i in asdf
for each j in ivfoaj
for each k in i
...

Haskell

i <- asdf
j <- ivfoaj
k <- i
...

the second is flatter

Nathaniel Morgan
Nathaniel Morgan

I think the two most insufferable posters are Haskellfags and Pythonfags.

Seeing them argue is like watching old men wrestle in the mud.

Easton Flores
Easton Flores

Is it useful to learn Perl?

Wyatt Price
Wyatt Price

You can try messing with 'yield' to create do syntax in Python

In Idris I believe you could do

let { i = !asdf; j = !ivfoaj; k = !i } in

Sebastian Torres
Sebastian Torres

I CAN NEVER THINK OF THINGS TO CODE

Levi Rogers
Levi Rogers

I need to be part of a tribe to validate my pointless existence.
Nigger level thinking friendo

Landon Richardson
Landon Richardson

Roman numerals converter

Brody Nguyen
Brody Nguyen

nigger/jew name generator

Xavier Edwards
Xavier Edwards

Get a job.

Working with live data gives you all sorts of ideas of actual useful things to make.

Charles Gomez
Charles Gomez

Java + Android API studio shit

Jaxson Perry
Jaxson Perry

Already been done, why would you do it again?

Gavin Martin
Gavin Martin

Python:

for (i, j, k, ) in list(product(*[a, b, c])):
print(i, j, k)

Josiah Thompson
Josiah Thompson

this is my dictionary

my_dict {
'a' : [1,2,3,4,5],
'b' : [7,8,9,4,2],
'c' : [4,4,2,3,6],
'd' : [1,1,1,2,1]
}

i have to print the sum of every element with brute force, like:
sum(a) + sum(b)
sum(a) + sum(c)
sum(a) + sum(d)

sum(b) + sum(a)
sum(b) + sum(c)
sum(b) + sum(d)
...

how to iterate through this dict? i can't just range like in lists..

Brandon Kelly
Brandon Kelly

Hi, Sup Forums. Gotta C exam now. I may need some help. Watcha say?

Asher Lee
Asher Lee

I want to make something cool/useful

This could be cool/useful

I'm a full time student

Hunter Ramirez
Hunter Ramirez

Already been done
Post it then

David Gutierrez
David Gutierrez

The third part of my example iterates on something already iterated on

Caleb King
Caleb King

Install-Package RomanNumeral

Nathaniel Brown
Nathaniel Brown

Have you tried coding a program?

Hudson Diaz
Hudson Diaz

for i in my_dict:
for j in my_dict:
print(sum(i)+sum(j))

or something like that but less shitty

Tyler Green
Tyler Green

Have you?

Kayden Powell
Kayden Powell

No, only programming a code

Austin Rivera
Austin Rivera

am retard pls ignore.

Joseph Cooper
Joseph Cooper

I don't write code, I'm a webdev ;^)

Ryan Collins
Ryan Collins

  File "<stdin>", line 1
Install-Package RomanNumeral
^
SyntaxError: invalid syntax

Owen Ross
Owen Ross

Got a list of Jewish last names or first half / last half syllables?

I'll do this quick.

Nolan Perry
Nolan Perry

Let us see some code

Tyler Cox
Tyler Cox

tfw have paperback copy of 1988 ansi c book coming in the mail soon
by soon I mean like a week from now, but still, excited. Recommended tutorials or other resources to hold me over and get me into c before it comes?

Camden Richardson
Camden Richardson

l
o
l

Carter Nelson
Carter Nelson

In regards to this, since many people here are still students, like me, I was wondering if anyone has some tips to getting internships where you actually code. Like, where do I go to apply, is it a good idea?

Wyatt Nelson
Wyatt Nelson

lad, if I took the advice from every user on Sup Forums about books, I would never read anything at all. I swear, every book in the wiki will have at least ten people that scan every thread just to tell people that it is a meme/bs/etc. or that you should read this 2000 page textbook instead, and then somebody says that that textbook is a meme/bs/etc. and the cycle goes on forever. If I took /g/'s advice the only possible non-meme way I could learn programming would be from a random divine revelation.

Ian Sanders
Ian Sanders

internships are a waste of time. don't do work if you're not getting paid

Robert Jenkins
Robert Jenkins

But I thought it would be useful to get the real world experience for my own personal code? Plus I have nothing else to do and already worked and saved up enough money to support myself for a while.

Nathaniel Brooks
Nathaniel Brooks

Divine revelation is a meme, read SICP.

Grayson Gray
Grayson Gray

It's like Oracle wants a language with the flexibility of Common Lisp and the type safety of Haskell.
Doesn't everyone? Oracle just don't have the option of a clean slate.

Leo Roberts
Leo Roberts

type safety of Haskell

bad :: a
bad = bad

Juan Hill
Juan Hill

I have done the needful.

I've generated sample names for Jewish Father / Black Mother children.

Pic related.

Jayden Walker
Jayden Walker

I can make bottom type safe in other languages

Nathaniel Hill
Nathaniel Hill

bad : ∀ {A} → A
bad = bad

Rejected.

Xavier Perry
Xavier Perry

CS50.

Also if you've never programmed before then I wouldn't dive right into K&R. It's a godly introduction to C, but not so much an introduction to programming.

I strongly recommend watching CS50 or using other resources to learn the basics of programming before diving into K&R or you'll get lost.

Michael Perez
Michael Perez

Work on open-source projects on GitHub if you really despise money, much more rewarding than an internship IMO.

Henry Martinez
Henry Martinez

I have programmed before, and I actually started cs50 back in a comp sci ind. study in HS, but quit because I felt like I had learned all of the concepts in class anyways. I am sure I have forgotten a shit ton though. I learned the standard AP comp sci shit, meaning Java. So I do have experience with programming, just not all too recent experience, although I made a little project in ruby recently with not too much difficulty. Any other recs? I don't mind doing cs50 again but it may feel bretty tedious.

Dylan Scott
Dylan Scott

Bumping question

Bentley Bailey
Bentley Bailey

Then just wait for the book. It's a complete reference to C in on itself and anything else will pale in comparison. Though you might enjoy reading C tutorials online in the meantime so when the book finally arrives you can appreciate just how elegant and ideal is the code in K&R compared to the shit you see everywhere else unfortunately.

Adam Howard
Adam Howard

Alright this should be for /wdg/ but this also applies to some of you faggots who recommend languages for web dev.

Why did I believe the faggots shilling C#?
be into php7 with few small projects on github
see c# shilled fucking everywhere on wdg and dpt
invest in very large C#/.NET book
fill my head with this microshit (end up enjoying it desu :^))
upload small c# projects to github
apply to fuckton c# jobs while learning
apply to like 3 php jobs
get a fucking interview to use php

This is what the C# shills won't tell you.
it's majoritively large companies who're looking for c# devs right now
smaller businesses are more attracted to the likes of php
to get a c# job in a large company you're gonna need a degree

I'm just thankful I realised this shit only 3 weeks into my learning. But I fucking invested so much time and effort omg.
250+ pages of this lengthy af book
at least 3 hours a day dedicated to learning or coding in c#

tl;dr DO NOT DIVE HEAD FIRST INTO LANGUAGES BEING SHILLED ON THIS FUCKING MEME BOARD.

Gavin Johnson
Gavin Johnson

That's *a* bottom. Are you advocating total languages?

Because that's fine if you are :)

Robert Young
Robert Young

use itertools.combinations on the dict.values if you are only interested in the outcome and not in whethere it combined a and b or a and c
and yes you can iterate over a dict

for key in dict:
print key

prints a, b, c,d
(equivalent to for key in dict.keys())
for value in dict.values():
print values
or even

for key, value in dict.items():

Josiah Diaz
Josiah Diaz

learned C# for a web-dev-specific position

Sounds like you didn't do your research, mate.

C# is the GOAT full-stack language, and many of the jobs are back-end roles.

Also, I'm a C# dev at a small company, but you're certainly right that it's still more at-home in the enterprise.

Many people I know that use C# at SMB or for freelance use it because it's easy to rapid dev all sorts of things, particularly with Azure integrations. For example, my current projects are automated deployment of Azure Data Factory components and a Xamarin-based iOS/Android app for a service desk company.

Kevin Sanchez
Kevin Sanchez

No Tyron Schlomo

Adam Bennett
Adam Bennett

and yes you can iterate over a dict
yeah, but if i do

for key in my_dict:
for key2 in my_dict:
print sum( my_dict[key] ) + sum( my_dict[key2] )

it will print repeated values, and i dont want that

Nathaniel White
Nathaniel White

C# is the GOAT full-stack language, and many of the jobs are back-end roles.
Many people I know that use C# at SMB or for freelance use it because it's easy to rapid dev all sorts of things

THIS IS EXACTLY THE SORT OF SHILLING I'M WARNING AGAINST

I CANT HOLD IT ANY MORE

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Carter Murphy
Carter Murphy

The fuck are you on about? Plenty of people use it for exactly these things.

What were your specific issues with the language other than anecdotal evidence on failing to get an interview at various companies that decided you weren't good enough for them?

Fucking webdevs, go back to your containment thread.

Anthony Rivera
Anthony Rivera

THIS IS EXACTLY THE SORT OF SHILLING I'M WARNING AGAINST

I CANT HOLD IT ANY MORE

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Robert Bell
Robert Bell

Nazi frog posting must be bannable on the blue boards.

Jaxson Carter
Jaxson Carter

/g/catalog#s=wdg

Luke Watson
Luke Watson

Try to make a few simple things in C.
For example, make a program that calls a function from a different .c source file than the one containing your main() function. You will have to use headers.
Or a program that replace

int main()
with MAIN(), using macros.
I never read K&R to learn C tbf, just used pdfs of Understanding and Using C Pointers, 21st Century C and online tutorials. I already had some basic experience with Java and Python though.

Josiah Taylor
Josiah Taylor

const string &prompt

C++ developers will defend this

Cameron White
Cameron White

Good job user. The feeling after completing a program is the best.
What was it btw?

Jack Roberts
Jack Roberts

a simple 3D bin-packing algorithm using meta-programming.

fun stuff!

Aiden Jones
Aiden Jones

zero cost exceptions are implemented using a lookup table from instruction pointers to unwinding procedures

Jayden Powell
Jayden Powell

programmed in assembler last night
can't wrap up the head back to high-level abstractions
fuck me

Jonathan Wood
Jonathan Wood

what is that picture suppose to represent?

Ryan Cooper
Ryan Cooper

What about it?

Lucas Roberts
Lucas Roberts

Why does my lecturer have a problem with this?

void pause (unsigned interval)
{
time_t unpauseTime = time(0) + interval;
while (time(0) != unpauseTime);
}

Owen Nguyen
Owen Nguyen

so use

import itertools
for key1,key2 in itertools.combinations(mydict, 2):
sum(mydict[key1]) + sum(mydict[key2])

its in the stdlib

Jordan Kelly
Jordan Kelly

because it's a busy waiting loop

Asher Turner
Asher Turner

thanks dude!

James Jenkins
James Jenkins

!=

Thomas Powell
Thomas Powell

if your computer lags and misses the moment where unpausetime is exactly time(0) it will sit there literally forever/until something wraps around

Cooper Perez
Cooper Perez

You've just thrown a s4s::repeating_digits<Quads> exception. But no one caught it, so it aborted your thread without any reply. Except this one, you might say, but this message is actually a meta-reply, so it doesn't count.

Logan Thompson
Logan Thompson

kys

Jaxon Morgan
Jaxon Morgan

It must suppose anything?

Michael Wright
Michael Wright

how do i structure a chess bot in c

Blake Peterson
Blake Peterson

Like all other c projects just use one 10 000 line file

Camden Rogers
Camden Rogers

What is your favourite language feature that your favourite programming language doesn't have?

Default parameters for me.

Brayden Edwards
Brayden Edwards

Higher kind/rank polymorphism

Owen Edwards
Owen Edwards

How do you make a non-busy waiting loop? Surely the program can't unpause without knowing the time, which means it has to keep checking the time.

Jacob Lopez
Jacob Lopez

Scheme would actually be a smart language, that's the joke. C is the language you use when you think you're smarter and superior in intelligence to other developers

Dominic Phillips
Dominic Phillips

Generics.

Gabriel Johnson
Gabriel Johnson

So what are the specific advantages of purely functional languages? Most support I hear seems more ideological than concrete.

Dylan Williams
Dylan Williams

Dependent types.

Jayden Wilson
Jayden Wilson

interfaces and enums

Josiah Morgan
Josiah Morgan

Specifying effects means easier reasoning and better optimization.

Levi Long
Levi Long

not using racket scheme which has a macro for nested for's as well as explicit version

(for ([x (in-list A)])
(for ([y (in-list B)])
(for ([z (in-range N)])
...)))
; same as:
(for* ([x (in-list A)]
[y (in-list B)]
[z (in-range N)])
...)

Asher Jackson
Asher Jackson

working on a corruption of champions clone, engine is almost finished but cant arse myself to do the gui

tfw when vps host gave me an extra 60GB disk space for free

Gavin Gonzalez
Gavin Gonzalez

void pause (unsigned interval) {
time_t u = time(0);
time_t t = u + interval;
while ( u < t )
volatile asm ("nop");
}

Chase Watson
Chase Watson

A good type system (theyre working on it)

Nolan Gonzalez
Nolan Gonzalez

What langugae?

Zachary Harris
Zachary Harris

What programming language has a BASIC-like syntax and way of working?
all this java stuff with all these parenthesis is really confusing

Dominic Green
Dominic Green

How do you make a non-busy waiting loop?
You call the operating system waiting function, which will simply not give your program any processor time until the time has elapsed.

William Long
William Long

python

Samuel Peterson
Samuel Peterson

Much of Haskell's semantics force it to be purely functional, for instance lazy evaluation and some aspects of the type system.
Most people hate on lazy eval for being inefficient, which it usually is, but it also allows you to design program flow however you want, and doesn't restrict you into as specific of semantics as most other languages.
Like many novel language features, it's hard to take advantage of unless you are experienced with the language.

Jacob White
Jacob White

Message Passing
Pattern Matching
N:M Threads

Cameron Scott
Cameron Scott

Racket.
I should have been more specific: a good *static* type system. Typed racket exists but I always just use dynamically typed Racket because I don't have to fuck with the sub-par static type checker.

Jonathan Robinson
Jonathan Robinson

However Racket DOES have:
- default parameters
- generics
- message passing OO
- pattern matching
- software & hardware threads

Ayden Morgan
Ayden Morgan

I figured this would be a good place to ask; does anyone know any GOOD websites that just run you through touch typing and give you good practice? Preferably with a little picture of where to place your fingers on each keystroke to help me learn?

I can type like 50 - 60 wpm using my retarded method at the moment, but my finger(s) get fucked after awhile. I use like three fingers on my left hand to deal with most of the left side of the keyboard, but then the right side is almost entirely occupied using solely my right index finger

Need to break the decade long habit I've developed so I can type more comfortably

Caleb Taylor
Caleb Taylor

ad hoc polymorhpism (they're working on it)

Levi Lopez
Levi Lopez

Language-feature discriminated unions

They're implemented in an easy to use 3rd party library, though.

Also, more pattern matching features. They're working on this.

Adam White
Adam White

I've had to do some web dev recently to get this small project deployed and let me tell you,

web dev fucking sucks

Zachary Cox
Zachary Cox

this isn't that crazy. invoking functions in C binaries is trivial in C#, so it's not uncommon to isolate platform-specific and/or performance-critical code into a C DLL and invoke it from C# code. saying you use C(#) could be a lazy way of saying you use both C and C# in your development stack

Elijah Mitchell
Elijah Mitchell

I'm doing things!

Angel Bell
Angel Bell

too stupid to get a degree
only wants to learn about programming to get some webdev codemonkey position

poo.init()

James Perry
James Perry

Neat. C#?

Looks like a fun shader toy project..

Jaxson Cruz
Jaxson Cruz

It's actually all just simple image manipulation. That one is this normal map applied to an image.

Ethan Baker
Ethan Baker

Q U I C K
post a sorting algorithm thats the most like you

who else /bubblesort/ here?

Jayden Miller
Jayden Miller

image related shti is fun. I'm planning a big project relating to it atm.

Might never get to start it though. It's a big some-day project...

William Allen
William Allen

what does it do

Robert Garcia
Robert Garcia

So I know Java developers are at the very bottom of the foodchain here.

What about C# & .NET developers?

Julian Sanders
Julian Sanders

randsort

Nolan Parker
Nolan Parker

webdev in any language is bottom of the food chain here

if you're doing real programming in java you're somewhere in the middle

Evan Hall
Evan Hall

Download Termux. It's a command line tool for Android with a built in package manager. From there, you can use apt to get clang, python, ruby, and some other tools. There's a lot missing from the repositories, sadly, but you may be able to compile other compilers with clang, make, cmake, and other build tools.

Henry Diaz
Henry Diaz

.NET isn't web development, you dud

Noah Fisher
Noah Fisher

bogosort

Michael Green
Michael Green

I didn't say it was, numbnuts.

Asher Watson
Asher Watson

What about real programming in .NET? It has plenty of uses other than ASP.NET...

Isaiah Ward
Isaiah Ward

The upper crust of the garbage heap.

Oliver Wilson
Oliver Wilson

Why did you even mention web development, if he said C# and .NET?

Kevin Cox
Kevin Cox

Shouldn't you use the pause instruction or the POSIX sched_yield instead?

Bentley Cox
Bentley Cox

See:

I was establishing the true bottom of the food chain, with the hope that people would make the obvious inference that if you weren't do that, you weren't at the bottom.

Benjamin Nelson
Benjamin Nelson

How can I make these align so that the health boxes start in the same place and if the enemy's name is too long, it gets carried over to the next line (about 30~ characters per line)

inb4 learn a real language
I will eventually.

Liam Allen
Liam Allen

count characters, determine how many \t you need by that
eg
if tab = 4 characters and line text = 3 ch
you want 2 tabs
if next line is 5 ch you want 1 tab
so on

Ian Smith
Ian Smith

I wonder what that would look like when animated?

The normal map looks like Voronoi cells with some shading applied. It could be animated, but not easily; you have to move the points around very smoothly and it is going to be very slow, because you have to check every point from every pixel and because the points move, you can't use any precomputed lookup structures. (Or you can, but they're per-frame, so they don't accelerate anything.)

Brandon Gomez
Brandon Gomez

learn enterprise language
don't look for a job in enterprise sector
complain

????

Christian Edwards
Christian Edwards

For the former you can just use the length formatting.

print('{0: <20} {1} {2}/{3}'.format(self.name, self.healthbar, self.health, self.maxhealth))

(Where 20 is the number of characters to fill spaces with up to).

Ryder Sanchez
Ryder Sanchez

if self.tattled == true

Matthew Hernandez
Matthew Hernandez

NEW THREAD!

/g/thread/58453794#p58453794

Ryder Walker
Ryder Walker

software for creating animations. Pretty much like flash + photoshop.

Jack Jones
Jack Jones

The normal map looks like Voronoi cells with some shading applied.

That's how I was going to accomplish the effect originally.

Jackson Morgan
Jackson Morgan

too early you stupid cunt

Carson Thompson
Carson Thompson

What food chain? Who the fuck would be at the top?

Grayson Lee
Grayson Lee

alright, thank you!

Alexander Rogers
Alexander Rogers

go laugh about your mother, faggot

Bentley Murphy
Bentley Murphy

Are you guys actually able to solve those exercises of string manipulation we find at the beginning of every goddamn programming course, like "hey here's this random string : 'fkdjhsjfhaqzdjjezsdh', can you find the longest substring in alphabetical order ?" ?

Every time I want to get into programming I face these exercises. I've been interested in computer since I was fucking 12, and now that I'm 20 I still have no clue how to solve those, so I still can't program cause I've never made it through the introductory chapters of any course.

Colton Cruz
Colton Cruz

Must suck being retarded

Landon Williams
Landon Williams

What's the difficulty?

Justin Thomas
Justin Thomas

Bogobogosort

Elijah Collins
Elijah Collins

If I knew why it's hard, I could have improved

Caleb Perez
Caleb Perez

so I still can't program cause I've never made it through the introductory chapters of any course.

This is a non-sequitur. Find a good book on Python and get cracking.

If you don't want to do an exercise, skip it.

Jordan Murphy
Jordan Murphy

Learn to divide problems in your head.

How do I get each sub-string of a string?
How do I check if a string is in an alphabetical order?

If you can do those two things you can solve your problem.

You can get fancier and brute force'y with experience.

Logan Davis
Logan Davis

*fancier and LESS brute force'y

Carson Peterson
Carson Peterson

no

Carson Cox
Carson Cox

I've done that, sort of ...
Came up with this : http://pastebin.com/12eVX19f
which works for a few strings, but not for the vast majority, I don't even understand how that's possible

Benjamin Sullivan
Benjamin Sullivan

if alphabet.index(s[i+1]) >= alphabet.index(s[i])
i've never used python
is this really how you compare characters?

Alexander Hernandez
Alexander Hernandez

This is probably not how most people do it, but this is how I did it since I had no clue how to do it otherwise

Lucas Collins
Lucas Collins

You're not good with logic. One way I used to practice this was solving math contest problems. (AMC, USAMO, etc.)

Start with the problems for 5th grade and so, and as you become more acquainted to them work your way up. You can stop once just before you reach USAMO level (autistic-level hard).

It may take a year or so before you're good enough, but what can you do? Programming is all logic these days, you have to figure out good ways to solve complex problems and teach the computer how to do it. Most of the braindead stuff is already automated so you'll be useless if you can't get past the introductory logic exercises of every programming course.

Henry Green
Henry Green

look up what an ascii table is

also the solution for the alphabetically ordered string is to go from the start and check if every letter is in order(just compare the character at your index and the next one)
if you get a character that isnt in order, start it all over again from that character while remembering the longest string so far

Gavin Rodriguez
Gavin Rodriguez

f = find isSorted . reverse . sortOn length . join . map inits . tails
where isSorted = ap (==) sort

What's wrong with brute force?
reverse . sortOn length

Kayden Murphy
Kayden Murphy

It's unlikely to yield optimal solutions.

Lucas Garcia
Lucas Garcia

:(

What about optimal by character count?

Sebastian Thompson
Sebastian Thompson

you can do this in O(n), why make it more complicated

Elijah Fisher
Elijah Fisher

Longest substring in alphabetical order? That's a trivial problem that can be solved with just one for loop, since we don't need to iterate over any substrings multiple times. If you find an alphabetical substring of say, 9 characters, it stands to reason that you won't find any substring beginning in that other substring that is longer and in alphabetical order, because the character ending that order is the same.

Logan Rodriguez
Logan Rodriguez

That sounds like less fun than breaking out the S combinator.

Lincoln Green
Lincoln Green

I'm not getting the foodchain analogy.

Disable AdBlock to view this page

Disable AdBlock to view this page