Post your code and be judged

Post your code and be judged.

Attached: scrot.png (623x300, 29K)

Other urls found in this thread:

pastebin.com/ZnnNkUCy
daylerees.github.io/
github.com/daylerees/colour-schemes
pastebin.com/XJaWdDGQ
docs.swift.org/swift-book/
twitter.com/NSFWRedditVideo

#include

int main()
{
static const char *fmts[] = {
"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"
};

for (int i = 1; i

very classy

for i in range(1, 101):
i = "fizz-buzz" if divmod(i, 4)[1] is 0 and divmod(i, 5)[1] is 0 \
else "buzz" if divmod(i, 5)[1] is 0 \
else "fizz" if divmod(i, 3)[1] is 0 else i
print(f"{i}")

you can put the print inside the for loop as a 4th argument
for (
int i = 0;
i < 100;
i++,
printf(fmts[(i % 3 == 0) | ((i % 5 == 0)

learning C pastebin.com/ZnnNkUCy

Attached: 409px-Hewlett-Packard_No_Equals_hat.jpg (409x599, 49K)

#define W 8
#define H 8

int walk(int board[H][W], int start_row, int start_col, int pos_row, int pos_col)
{
int val = board[pos_row][pos_col];
for (int r = -2; r < 3; r++) {
if (r == 0) continue;
for (int c = -2; c < 3; c++) {
if (c == 0 || r == c || r == -c) continue;
int row = pos_row + r;
int col = pos_col + c;
if (row >= H || row < 0 || col >= W || col < 0) continue;
if (row == start_row && col == start_col)
if (val == H*W-1)
return 0;
if (board[row][col] != -1) continue;
board[row][col] = 1 + val;
if (walk(board, start_row, start_col, row, col) == 0)
return 0;
board[row][col] = -1;
}
}
return -1;
}

void knight(int board[H][W], int start_row, int start_col)
{
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++)
board[row][col] = -1;
board[start_row][start_col] = 0;
walk(board, start_row, start_col, start_row, start_col);
}

>inb4 W and H should be parameters and not macros

Out of curiousity, you don’t have to make those const right? I mean they won’t change so it makes sense but would it still compile without const?

...

I'm conflicted on your xmalloc.
Is the purpose of it to crash on out-of-memory or to never return NULL? Usually is the never-null but yours allows xmalloc(0) => NULL

It crashes on error that's all

Attached: Screenshot_20190303_154007.png (769x242, 27K)

Attached: Screenshot_20190303_124453.png (674x479, 58K)

>he thinks fizzbuzz is a test of efficiency, not readability
thanks we'll call you
>places resume in drawer next to the autismo that mispronounced his own last name

Nice color scheme. What's it called?

>foreach that causes another foreach without passing anything

you can view a preview of colorschemes here:
daylerees.github.io/

github.com/daylerees/colour-schemes

Thanks, but I don't think it's in that collection. Do you know the name of it?

fn main() {
(1..101)
.for_each(|s| {
if s % 3 == 0 && s % 5 == 0 { println!("fizzbuzz") }
else if s % 3 == 0 { println!("fizz") }
else if s % 5 == 0 { println!("buzz") }
else { println!("{}", s) };
});
}

Attached: 1549047309371.gif (734x490, 258K)

I want to fuck that crab

>int flags = (i % 3 == 0) | ((i % 5 == 0) "C IS 100% SAFE IF YOU'RE NOT A BRAINLET I'M THE BEST 1337 H4XX0RZ EVER MY CODE HAS NO BUG STOP BULLYING C"

Attached: lawl.jpg (317x267, 22K)

>being this retarded

Learning Java

Attached: vscode.png (1920x1080, 194K)

def _move_player(self, action):
movement = MOVE_CHANGE[action]
current_pos = self.player_pos.copy()
new_pos = self.player_pos.copy()
temp_pos = self.player_pos + movement
bounds = self.level_state.shape

while temp_pos[0] >= 0 and temp_pos[0] < bounds[0] \
and temp_pos[1] >= 0 and temp_pos[1] < bounds[1] :
# if the next position is not a wall
if self.level_state[temp_pos[0], temp_pos[1]] != 1:
new_pos = temp_pos.copy()

# if the next position is a wall or if current position is finish
if self.level_state[temp_pos[0], temp_pos[1]] == 1 \
or self.level_state[new_pos[0], new_pos[1]] == 3:
break

temp_pos += movement

if new_pos[0] != current_pos[0] \
or new_pos[1] != current_pos[1]:
self.player_pos = new_pos
# set new position to player
self.level_state[(new_pos[0], new_pos[1])] = 2
# set old position to empty space
self.level_state[current_pos[0], current_pos[1]] = 0
return True

return False

imagine being this much of a brainlet who can't even into bit-shifting

iirc nothing guarantees that the parameter board is actually an array of size W*H, you get a pointer as argument
not sure tho

formatted like this, not commented, and separated from other code this makes no sense to me. All I can say is "have you tried to combine some if statements so that there aren't this many?"

lold
thanks user made my night

Readability is the biggest reason why Python is so popular. The tards who only know C and try to write 300 character one liners using single character variable names are literally laughed at when they try to submit to open source projects.

Imagine being such a loser you need to do bit-shifting on logic operations to feel like a hacker because that's the only way you don't feel like your life is worthless and then some civilized person promptly tells you your code is disgusting and you have shit-tier unsafe habits and you get all defensive and shit your pants and call them a brainlet for not acting like Neo on something as performance-uncritical as fizzbuzz.

Attached: lol nigga.gif (159x119, 1.19M)

shut up faggot lmfao

Attached: Screenshot 2019-03-03 at 23.48.19.png (1888x1070, 329K)

what abysmal language

obj-C?

yeah i'm an ios developer

REEEEEEEEEE POSTS SHOULD BE A CONST

interesting.
do you need xcode to make apps?

>unironically seething
cope my guy

let out;
for(let i = 1; i

I gotchu.

function countArr(arr, init, end) { if (init >= end) { return init; } return arr.concat(init, countArr(arr, (init + 1), end)); } function fizzBuzz(arr) { return arr.map((x) => { if (x % 15 === 0) { return "Fizzbuzz"; } else if (x % 5 === 0) { return "Fizz"; } else if (x % 3 === 0) { return "Buzz"; } else { return x; } }); } console.log(fizzBuzz(countArr([], 1, 100)))

yeah that was a screenshot from xcode

theoretically you can compile everything through terminal with xcode build tools but good luck doing that

there's also appcode but no storyboard support

Fuck 4channel.

pastebin.com/XJaWdDGQ

const countArr = (arr, init, end) => {
return (init >= end) ? init :
arr.concat(init, countArr(arr, (init + 1), end));
}

const fizzBuzz = (arr) => {
return arr.map((x) => {
return (x % 15 === 0) ? "Fizzbuzz" :
(x % 5 === 0) ? "Fizz" :
(x % 3 === 0) ? "Buzz" : x;

});
}
console.log(fizzBuzz(countArr([], 1, 100)))

i see.

that code seems very complex for a noob like me.

what is the app about? what the average time for an app to be made? 6 months ?

nothing complex going on but it's just a tiny out of context snippet so hard to figure out

the app is a fintech app

development time depends on a lot of shit, most of the time slowdowns are due to the client changing his fucking mind mid development or the backend API being changed constantly

rule34 that crab

>fintech
nice.

>client
are you a freelance developer? or do you have a time of people working on that app?

>using querySelectorAll instead of the infinitely more efficient getElementsByTagName

>hurr durr

Attached: Untitled.png (1359x978, 145K)

ah

three people working on this app currently
it's an older codebase, most new projects get written in swift not objc

do you recommend working as a iOS developer? do you like it?

what would you need to apply for a position like this? show your portfolio of apps?

>do you recommend working as a iOS developer
sure, if you like frontend
it's a bit less meme than doing JS web front end though since there's less hipster trends

>do you like it?
yes

>what would you need to apply for a position like this? show your portfolio of apps?
it depends on your location, are there a lot of mobile dev jobs available where you live?
if so just apply for a junior position
you can learn by just making a simple calculator app or something
you'll need a macbook to start learning though

Imagine being the basic bitch of programmers

nice
thanks for the detailed answer based user

```
asasd
```

no problem
i recommend starting with swift, not objective c if you're serious about it

objective c is still important but swift is definitely what apple's focusing 100% on right now so it's the future of the platform

you can install the language itself on linux and start learning the basic concepts
docs.swift.org/swift-book/

you won't have any of the ios UI frameworks on linux though

Roast me faggots.

Attached: Screen Shot 2019-03-03 at 6.25.43 PM.png (1342x1746, 315K)

thanks again. Yes i guess i need apple hardware

one last question: do you find it annoying that you have to pay $99/ year to have apps in the app store?

do your apps make any money on the app store?

nice

how's Miami?

Attached: Screenshot from 2019-03-04 00-31-37.png (906x1472, 206K)

Attached: Screenshot from 2019-03-04 00-33-56.png (1114x1410, 167K)

01001110 01001111

I don't have any personal apps on the app store so the pricing doesn't concern me.

>do your apps make any money on the app store?
Like I said I have no apps but the app i'm working on makes the client money. As they're offering their core product through it. Currently they make more money from their web app but the plan is to make the mobile app just as feature-full.

This higher barrier of entry into iOS development keeps the pajeet hordes at bay unlike Android. If you ever look into freelancing you'll see that iOS devs charge more per $ because they have less competition. So apple jewery can benefit you down the line.

#include
/* A program to return all values between 1 and 100 that are even numbers*/

main()
{
/* define the variables by type and default value */
int topnum=101;
int numbr=1;

/*beginning of while loop*/
while (numbr

interesting.

have a cat

Attached: h2f892csrxj21.jpg (1031x1374, 176K)

Pretty gucci, waiting for the rains

Leave a star if you like the project!

#include

int main()
{
int topnum = 101, numbr = 1;
while (++numbr

oh cool thanks I will try that

Every comment except the very first one is useless. Remove them. Don't use abbreviations for variable names; especially don't be inconsistent with them like you were with "numbr" and "num". The line where you increment numbr is outside of the while loop and your program will never terminate. You should be using a for-loop instead.

Is this Ruby? Looks comfy.

It's Elixir

>Every comment except the very first one is useless.
not to me it's not
> Don't use abbreviations for variable names;
well that's silly

>especially don't be inconsistent with them like you were with "numbr" and "num".
thats a point

>The line where you increment numbr is outside of the while loop
No it isnt
>and your program will never terminate. You should be using a for-loop instead.
The program works fine and does terminate correctly
are you drunk?

>looks comfy
dude it looks completely gay

takes one to know one

This was for Project Euler problem 54, ranking poker hands. This function checks to see if a hand is four of a kind. Returns 1 (true) or 0 (false)
/*
* Cards format:
* C = Club, S = Spade, H = Heart, D = Diamond
* 8C TS KC 9H 4S
*/
int isFourOfAKind( char ** cards, char * pairRankValues )
{
/*
* Four cards of the same value
*/
char * ranks = (char *) calloc(5, sizeof(char));
int * counts = (int *) calloc(5, sizeof(int));
/*
* ranks will be filled with unique ranks found
* counts will be their associated counts
* counts[index] is the count of rank found in ranks[index]
*/
countRanks( cards, ranks, counts );
if( 4 == counts[0] )
{
pairRankValues[0] = ranks[0];
pairRankValues[1] = 'X';
free(ranks);
free(counts);
return 1;
}
else if( 4 == counts[1] )
{
pairRankValues[0] = ranks[1];
pairRankValues[1] = 'X';
free(ranks);
free(counts);
return 1;
}
else
{
free(ranks);
free(counts);
return 0;
}
}

Use proper indentation to avoid having the unnecessary comments like the other user said. Even if a while loop will do the same job here,it is better practice to use a for loop because you know how many iterations it will go through. Proper use of a while loop is when you don't know how many iterations it will take.

Attached: ss.png (542x361, 38K)

Why is Objective-C so ugly?

you must be 18 years or older to post on Jow Forums

t. mad queer

>Returns 1 (true) or 0 (false)
lol why not return a boolean

>>>/reddit/

I wrote it in Elixir, it's a fuckin' /comfy/ language for sure.

That's one of the main goals of the language: being comfy, google it.

this

needs comments and documentation

int isFourOfAKind( char ** cards, char * pairRankValues )
{
int val = 0
char * ranks = calloc(5, sizeof(char));
int * counts = calloc(5, sizeof(int));

countRanks( cards, ranks, counts );
if (counts[0] == 4) {
pairRankValues[0] = ranks[0];
pairRankValues[1] = 'X';
val = 1
} else if (counts[1] == 4) {
pairRankValues[0] = ranks[1];
pairRankValues[1] = 'X';
val = 1
}

free(ranks);
free(counts);

return (val == 1);
}

a fizzbuzz posted the other day in a oop hate thread

Attached: fizz.png (963x666, 53K)

std::string PhysicalDeviceInfo::checkQueueProperties(VkQueueFlags requiredflags) const{
std::string missingqueueproperties;
VkQueueFlags supportedflags = 0;
auto checkflags = [&](VkQueueFlags required, const std::string & flagname){
if ((requiredflags & required) && !(supportedflags & required))
missingqueueproperties.append(std::string("Physical device does not support ")+flagname+std::string("!\n"));
};
for (const auto & queueproperties : deviceQueueFamilyProperties)
supportedflags = supportedflags | (requiredflags & queueproperties.queueFlags);
checkflags(VK_QUEUE_GRAPHICS_BIT, std::string("VK_QUEUE_GRAPHICS_BIT"));
checkflags(VK_QUEUE_COMPUTE_BIT, std::string("VK_QUEUE_COMPUTE_BIT"));
checkflags(VK_QUEUE_TRANSFER_BIT, std::string("VK_QUEUE_TRANSFER_BIT"));
checkflags(VK_QUEUE_SPARSE_BINDING_BIT, std::string("VK_QUEUE_SPARSE_BINDING_BIT"));
checkflags(VK_QUEUE_PROTECTED_BIT, std::string("VK_QUEUE_PROTECTED_BIT"));
return missingqueueproperties;
}

needs comments and documentation

that's clean OO code right there

God damn Rust is fucking UGLY.

>Rust
retard alert

its a meme you dip

>i was pretending to be retarded guise!!!11!!!1!!!

>supports different divisors / words
Now that's the kind of go-getter attitude I like to see. When can you start?

Eh, the variable and lambda names are self explanatory. Other Vulkan devs would know what's going on.

ew.

You can see why C++ is considered garbage nowadays. Ugly languages/syntax.

I wasn't even the guy who posted it

Best thing about this is that left-pad didn't even work correctly.