Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 790 KB, 663x1300, __bowsette_and_princess_peach_mario_series_new_super_mario_bros_u_deluxe_and_super_mario_bros_drawn_by_hinghoi__14e6bad680ca2a348ea18d921fdd26a1.png [View same] [iqdb] [saucenao] [google] [report]
67885917 No.67885917 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Previous thread: >>67881207

>> No.67885929

>>67885917
First for Java

>> No.67885942

nth for nim

>> No.67885949
File: 1.76 MB, 1075x1518, 1537985908896.png [View same] [iqdb] [saucenao] [google] [report]
67885949

Why haven't you learned Haskell yet, /g/?
>>67885917
good image OP

>> No.67885953

>making a thread as soon as bump limit gets hit
>>>/v/

>> No.67885966
File: 1.31 MB, 1000x1400, K&R c.png [View same] [iqdb] [saucenao] [google] [report]
67885966

I wonder if the bowsette poster is the same person who would spam hime years back

>> No.67885968

>>67885949
what use case does hasklel excel at?

>> No.67885972

Why does strncpy always write n bytes? Wouldn't
char* copy_string(char* dst, char* src, size_t write_max)
{
size_t write_count = 0;
while( *src != 0 && ++write_count < write_max )
{
*dst++ = *src++;
}
*dst = 0;
return dst;
}

be much faster, especially as potential string length (n in strncpy) becomes large?

>> No.67885973

>>67885966
more than one himeposter

>> No.67885976

>>67885968
DSLs for parallel and distributed programming

>> No.67885977

>>67885968
Development time and program correctness.

>> No.67885981

>>67885968
it's a general purpose programming language and it excels at most things

>> No.67885989

>>67885981
Except memory usage and binary bloat.

>> No.67886023

>>67885989
yes

>> No.67886029

>>67886023
And cross-compilation.

>> No.67886047

>>67885968
shitposting

>> No.67886069

>>67885976
I don't buy that until someone posts benchmarks of such DSL vs MPI

>> No.67886076
File: 34 KB, 678x260, Screen Shot 2018-10-02 at 7.48.10 PM.png [View same] [iqdb] [saucenao] [google] [report]
67886076

uwu

>> No.67886083

>>67886076
based sepples

>> No.67886101

>>67886076
why "by"

>> No.67886113

>>67886076
>I write code that looks like shit so I can save myself a couple well-written lines doing something else

Maybe if it was efficient or something but it's not. Use C++ tools when they make the easier to read or understand, not harder

>> No.67886119

>>67885938
Like this
using System;
using System.Linq;

namespace DivisibleSumPairs
{
public class Program
{
public static void Main()
{
int k = int.Parse(Console.ReadLine().Split()[1]);
int[] list = Console.ReadLine().Split().Select(int.Parse).ToArray();

Console.WriteLine(DivisibleSumPairs(list, k));
}

static int DivisibleSumPairs(int[] list, int k)
{
int count = 0;

for (int a = 0; a < list.Length; a++)
{
for (int b = 0; b < list.Length; b++)
{
if (a < b
&& (list[a] + list[b]) % k == 0)
{
count++;
}
}
}

return count;
}
}
}

>> No.67886122
File: 127 KB, 601x508, 1506112612488.png [View same] [iqdb] [saucenao] [google] [report]
67886122

>>67886113

>> No.67886135

>>67885972
To paraphrase my post in the last thread: the C stdlib is just unbelievably shittily designed, and strncpy() is a prime example of this.

Anyway, sounds like you want strlcpy()

>> No.67886142

>>67886076
what does the "unit_type" do? also that unit is the same as just feet since a radian is unitless

>> No.67886155
File: 212 KB, 1218x1015, 1509893022495.jpg [View same] [iqdb] [saucenao] [google] [report]
67886155

>>67886142
>a radian is unitless

>> No.67886161

>>67886155
radian is length per length, making it unitless

>> No.67886164

>>67886119
god, C# is gross.

>> No.67886167

>>67886119
Thank you!

>> No.67886182

>>67886119
>for (int a = 0; a < list.Length; a++)
> {
> for (int b = 0; b < list.Length; b++)
> {
> if (a < b
*throws up*

>>67886076
*throws up*

>>67886122
post where you use it

>> No.67886185

>>67886164
What about it? I could have written it in a better but less compact way.

>> No.67886188

>>67886101
idk couldn't think of anything other than "times"
there will be wrappers for powers of course

>>67886113
believe it or not there is a use case for this
and I don't know what you mean by not efficient, syntax or performance?

>>67886142
>>67886161
radian is a dimensionless unit, there's a difference

>> No.67886194

>>67886161
The word you're looking for is dimensionless. It has a unit, the unit is 1 rad.

>> No.67886206

>>67886185
encasing everything in a class in a namespace.
the two loops, the formatting.

>> No.67886251

>>67886188
what's the use case?

>> No.67886278

>>67886251
APIs shared between well-established organizations who prefer working in their chosen units for a given application and can't be made to change, but where messing up the units could have significant financial impact.
Or just any code worked on by more than three people; the number of fucking times I've seen degrees passed to sin().

>> No.67886301

>>67886206
Wrapping everything in a class and a namespace might seem nonsensical for trivial stuff like this or Fizzbuzz but it's really not an issue and actually makes sense when you take the OO nature of the language into account. It does have its pros and cons, like everything else.

>> No.67886306

>>67886119
static int DivisibleSumPairs(int[] list, int k) {
int count = 0;
for(int b = 0; b < list.Length; b++)
for(int a = 0; a < b; a++)
count += ((list[a] + list[b]) % k != 0) ? 0 : 1;
return count;
}

>> No.67886312

M : [A] -> Type -> Type
return : B -> M [] B
join : M xs B -> M ys B -> M (xs ++ ys) B
mapM : (f : (x : A) -> M [x] B) -> (xs : [A]) -> M (map f xs) [B]

Hmm.

>> No.67886337

>>67886278
so something that can be done in a more readable manner

>> No.67886357

>>67886312
join : M xs (M ys B) -> M (xs ++ ys) B

Silly me, mixing up natural transformations and functions in the same type.

>> No.67886366

>>67886337
I'm just exercising the library, I don't expect it to be used like this

>> No.67886371

>>67886135
Huh, it says strlcpy is very similar to snprintf. Are you familiar with snprintf? I have a very hard time imagining how such a useful and relatively complex tool is not much, much slower than the more simple stuff (cpy, cat, etc), for simple stuff. It is, isn't it?

I'm sure it can be faster when cat'ing multiple strings or in other situations.

>> No.67886383

>>67886312
>>67886357
mapM : ((x : A) -> M [x] B) -> (xs : [A]) -> M xs B

Ugh.

>> No.67886391

>>67886188
just call it "multiply" fagtron

>> No.67886394

>>67885917
>>67886004
How do I into Python. Looks like a fun scripting language. What's a good resource for it?

>> No.67886398

>>67886383
You know, what I'm done. You know what I mean.

>> No.67886412

>>67886394
https://automatetheboringstuff.com/

>> No.67886437

>>67886394
if you don't know nothin' about programming
http://interactivepython.org/courselib/static/thinkcspy/index.html

If you're already a programmer, just download anaconda or miniconda with Python 3 and use Google every time you don't know how to do something.

If you're an IDE boy, use PyCharm and always use Python 3's type annotation features.

>> No.67886481

>>67886391
no

>> No.67886492

>>67885917
How does one start programming an operating system from scratch?

>> No.67886495

>>67886412
>>67886437
Thanks guys!

>> No.67886496

>>67886251
Google "strong typing"

>> No.67886501
File: 159 KB, 454x558, 1465542231484.jpg [View same] [iqdb] [saucenao] [google] [report]
67886501

>>67886492
I don't think the Scratch language is sophisticated enough for that

>> No.67886508

>>67886492
https://wiki.osdev.org/Expanded_Main_Page

>> No.67886529
File: 91 KB, 1300x957, affirmative_action_throwup.jpg [View same] [iqdb] [saucenao] [google] [report]
67886529

>>67886496
>strong typing

>> No.67886548

>>67886508
Thanky, fren.

>> No.67886561
File: 87 KB, 258x243, nani.png [View same] [iqdb] [saucenao] [google] [report]
67886561

>>67886501
Who put you up to this.

>> No.67886570

>>67886496
Strong typing is a meme. It hasn't been proven conclusively to actually improve program correctness or productivity.

>> No.67886601

>>67886570
the idea that you can place autistic restrictions on a language to prove certain facts about programs written using it is a relatively recent one
at the very least if you're not using C#'s unsafe blocks then you'll at least never run into pointer issues.

>> No.67886614

>>67886570
That's because the places where it would help can't be bothered to spend the budget to convert their legacy codebases.
I'm never going to stop shilling strong typing.

>> No.67886622

>>67886570
t. 150 buffer overflow and data races per line

>> No.67886638
File: 1.46 MB, 1080x963, image (4).png [View same] [iqdb] [saucenao] [google] [report]
67886638

>>67886561
i'm putting you up
this is a robbery

>> No.67886640
File: 156 KB, 686x582, smug_hatsune.jpg [View same] [iqdb] [saucenao] [google] [report]
67886640

>>67886601
>>67886614
>>67886622
>static typing makes me write less bugs and be productive, r-right guys?

>> No.67886653

>>67886640
>bugs are features!

>> No.67886660

>>67886653
>let's attack a strawman because I have no good arguments!

>> No.67886663

>>67886638
NO GOOD MORNING. FUCK YOU. BAD MORNING.
SHOOT ME.

>> No.67886665
File: 54 KB, 617x493, 1515782572773.jpg [View same] [iqdb] [saucenao] [google] [report]
67886665

>>67886306
You are like a baby, watch this
static int DivisibleSumPairs(int[] list, int k) =>
Enumerable.Range(0, list.Length)
.Select(x => Enumerable.Range(0, list.Length)
.Select(y => new Tuple<int, int>(x, y)))
.SelectMany(x => x)
.Where(pair => pair.Item1 < pair.Item2
&& (list[pair.Item1] + list[pair.Item2]) % k == 0)
.Count();

>> No.67886686

>>67886640
>write less bugs
yes
>be productive
lol no but it's fun as fuck

>> No.67886693
File: 58 KB, 820x534, 1537460465540.jpg [View same] [iqdb] [saucenao] [google] [report]
67886693

>>67886640
>hatsune

>> No.67886701

>>67886660
Stop lowering the thread's quality.

>> No.67886714

You should learn Scheme and ML first.

>> No.67886715

>>67886701
You can't stop me Varg, you'll never be my real dad!

>> No.67886725

>>67886714
install Shen instead.

>> No.67886755
File: 521 KB, 300x269, dance.gif [View same] [iqdb] [saucenao] [google] [report]
67886755

>>67886701
You're the one claiming that static typing improves productivity and correctness. Here are some sources to support my claims (You haven't provided any arguments, let alone sources).
https://dl.acm.org/citation.cfm?doid=1869459.1869462
https://ieeexplore.ieee.org/document/4273079/
https://ieeexplore.ieee.org/document/4404755

>> No.67886773
File: 448 KB, 930x700, 1524715780160.jpg [View same] [iqdb] [saucenao] [google] [report]
67886773

>>67886663
>teleports behind you
>it's already a good morning

>> No.67886774

>>67886529
nigger

>> No.67886783

>>67886755
>pay or sign in to read this
yeah, i'm gonna need non-trash links.

>> No.67886837
File: 330 KB, 782x1021, smug_laugh.png [View same] [iqdb] [saucenao] [google] [report]
67886837

>>67886783
I guess you lost the argument then. Stay mad.

>> No.67886863

>>67886837
you dont win arguments by posting studies behind a paywall

>> No.67886880
File: 1.52 MB, 1350x1126, smug_anime_face.png [View same] [iqdb] [saucenao] [google] [report]
67886880

>>67886863
You never provided an argument or sources. I guess I win by default then.

>> No.67886898
File: 119 KB, 777x656, pyramid of argumentation.jpg [View same] [iqdb] [saucenao] [google] [report]
67886898

>>67886863

>> No.67886907

#include <...> search starts here:
/usr/include/c++/7
/usr/include/x86_64-linux-gnu/c++/7
/usr/include/c++/7/backward
/usr/lib/gcc/x86_64-linux-gnu/7/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include



Can somebody tell me where are stored and defined the directories and search order for the default includes in gcc for the C and C++ compilers? I get the above from the g++ but I cant find the source.

>> No.67887016

>>67886907
Jehovah's Witnesses don't celebrate Halloween because they don't appreciate random people coming up to their door.

>> No.67887032

worst /dpt/ in recent memory
post eloquent C please

>> No.67887050

>>67887032
>post eloquent C please
here's the complete list

>> No.67887086

What's the easiest way to determine if a file is a music file in C? I could just compare extensions but that just sounds hacky and bad. The only other way I know would be to ensure it has an audio stream via libav/ffmpeg. Is that as slow as it sounds? Is there a faster/better way?

>> No.67887093

>>67887016
Thank God this is a christian board then

>> No.67887096

>>67887032
#include <stdlib.h>
int main(c, v)
int c;
char** v;
{ return atoi(c[1]); }

>> No.67887107

>>67887086
https://en.wikipedia.org/wiki/List_of_file_signatures

>> No.67887115

>>67887086
why is comparing extensions hacky?

>> No.67887116
File: 69 KB, 324x438, chie.webm [View same] [iqdb] [saucenao] [google] [report]
67887116

import turtle
x = 0
while x < 100:
x = x + 1
turtle.forward(x)
if x % 3 == 0 and x % 5 != 0:
turtle.right(90)
elif x % 5 == 0 and x % 3 != 0:
turtle.left(90)
elif x % 5 == 0 and x % 3 == 0:
turtle.circle(x)

>> No.67887117
File: 929 KB, 500x388, cat_computer.gif [View same] [iqdb] [saucenao] [google] [report]
67887117

>>67887032
Here is a neat C trick.
#include <stdio.h>

#define calculate(...) \
calculate_f((calculate_s) { .a=1, .b=1, .total=0, __VA_ARGS__})

typedef struct {
int a;
int b;
int total;
} calculate_s;

int calculate_f(calculate_s t)
{
return t.total + t.a * t.b;
}

int main()
{
printf("%d\n", calculate(.a=12));
printf("%d\n", calculate(.b=10, .total=10));
return 0;
}

>> No.67887128

>>67887115
because you can rename file extensions to whatever you want
file format specs should have information telling you what their signature or header should contain

>> No.67887130

>>67887086
steam it in and do some FFTs to ensure there are no sharps or flats if you meant C Major.

>> No.67887159

strong typing > weak typing

>> No.67887174

>>67887130
This nigga

>> No.67887186

>>67887159
Science Says You're Wrong

>> No.67887207

>>67887086
>if a file is a music file
All files are music files

>> No.67887232

>>67887186
Explicate.

>> No.67887234

>>67887032
#include <stdio.h>

int main() {
for (int i = 1; i < 100; i++)
printf(printf("%s%s", (i % 3 == 0) ? "Fizz" : "", (i % 5 == 0) ? "Buzz" : "")? "\n": "%d\n",i);

return 0;
}

>> No.67887259

>>67887107
This looks solid.
It's regrettable that there's no metadata or shit like that for this, having to open each file triggers my autism. I'll just do it at the same time I look at the tags then. Thanks anon

>> No.67887276

>>67887117
that's actually a pretty fucking neat way to do named args, but i feel like i would be shot if i did this in production code

>> No.67887283

Any anons here used fennel?

>> No.67887291

>>67887259
opening a file and reading first few bytes counts as metadata

>> No.67887308

>>67887232
>>67886755

>> No.67887317

>>67887308
static typing is not the same thing as strong typing

>> No.67887319

>>67887276
Also won't work in C++, FWIW. That's also quite a bit of boilerplate to enable it for each function.

Still, very cool!

>> No.67887328

>>67887186
Agreed.

>> No.67887329

>>67887317
>arguing with python pajeets

>> No.67887355

>>67887317
they literally both begin with s retard

>> No.67887357

>>67887329
It's a guilty pleasure of mine.

>> No.67887374

>>67887032
size_t build_str_from_argv(char** ar, char* str, size_t str_size)
{
size_t s = 0;

for(char* ch = *ar; *ar != 0; ch = *(++ar))
{
while( *ch != 0 && s < str_size )
*(str+(s++)) = *ch++;
if( s < str_size ) *(str+(s++)) = ' ';
}
*(str+(--s)) = 0;

return s;
}

>> No.67887391

>>67887283
I had some halal today, so yes?

>> No.67887457

>>67887291
*throws up*

>> No.67887479

How can people call themselves programmers when they can't even eat hot peppers raw??

>> No.67887485
File: 29 KB, 239x237, 1497240010098.png [View same] [iqdb] [saucenao] [google] [report]
67887485

>>67887479

>> No.67887495

>>67887485
G R E E N

>> No.67887523

>>67887374
*throws up*

>> No.67887529

>>67885972

Because why not? When are you using strncpy in a context where performance matters? Also, copying 0s to a buffer of data is extremely fast when compiled. strncpy is probably faster than your function on a lot of small buffers (you don't have an if statement on every value in the buffer). Padding zeros provides a lot of useful safety and allots you to do a lot more things with the string later on in more efficient manors, like appending.

>> No.67887536
File: 153 KB, 1150x498, demo.png [View same] [iqdb] [saucenao] [google] [report]
67887536

not an art guy, thoughts on this UI? have no one to get opinions from.

>> No.67887561

>>67887536
give up

just plagiarize ESPN or something

>> No.67887570

>>67887561
can i get some feedback instead of nonsense?

>> No.67887598

>>67887570
sure
forget UI
UX or nothing.

>> No.67887617

>>67887598
just compile a list of use cases and build the absolute minimum you need to accomplish the set of use cases in a logical fashion, taking human factors into account

bam
there's your UI
no one gives a shit about how it looks. Plaster on some material design garbage or plagiarize someone's padding and spacing.

>> No.67887636

>>67887598
>>67887617
alright thanks, helpful

>> No.67887664

>>67886119
Garbage

>> No.67887671

>>67887529
only use snprintf

>> No.67887690
File: 30 KB, 699x669, cod.png [View same] [iqdb] [saucenao] [google] [report]
67887690

for that one nigger >>67885070 who wants to parse a string with cruft and json: just use the json decoder to find out where the json ends
there's a thousand ways you can fuck up your own algorithms, there's only a few ways you can fuck up using a standard library

holy fucking shit, 4chan is rejecting my code again

>> No.67887719

>>67887690
and a copypasta link https://pastebin.com/x8hfZmsp

>> No.67887726

Most types of software ran faster 20 years ago on the considerably more limited hardware we had back then. You should all be ashamed of yourselves.

>> No.67887781

>>67887726
It's why I do all my web programming in C++
>say it with me
>zero-overhead abstractions

>> No.67887860

>>67887726
most types of software were severely limited back then
you should be ashamed of being a grampa

>> No.67887922

>>67887726
people who bring this argument up always seem to leave out how severely primitive software was back then.

>> No.67887939

>>67887922
Javascript is a cancer

>> No.67887950

>>67887939
yes, and so is C.

>> No.67888006

Where can I play some newbie wargames for getting into netsec stuff, years ago I had a list from the same site with many servers in ascending order of difficulty but I've lost it.

>> No.67888063

>>67887922
well shit I guess if we get emojis then horrendous performance is just fucking fine

>> No.67888071

>>67888063
you sound like you're 19 m8.

>> No.67888112

>>67888071
he does have a point, there's no reason everything's gotta run on electron

>> No.67888124

>>67888112
everything doesn't run on electron.
Stop conflating the few popular programs with the majority.

>> No.67888128

>>67885968
idk but pandoc is cool

>> No.67888169

Need to write a program that goes through a string and prints number of vowels used. Wrote pieces of code for certain sections but would get stuck. How do I "scan" the string for vowels?


public static void main(String[] args)
{
Scanner console = new Scanner(System.in);

// 1. Display a descriptive message for the program
String display_message = "This program ask the user for a sentence, \n"
+ "searches the sentence for all vowels, \n"
+ "and displays the number of times each vowel \n"
+ "appears in the sentence.";
JOptionPane.showMessageDialog(null, display_message,
"Lab 3 Description", JOptionPane.INFORMATION_MESSAGE);

// 2. Initialize all vowel counters to 0
// a_count = e_count = i_count = o_count = u_count = 0;
String input;
char ch;
char aCount = 'a', eCount = 'e', iCount = 'i', oCount = 'o', uCount = 'u';
int num_aCount = 0, num_eCount = 0, num_iCount = 0, num_oCount = 0, num_uCount = 0;

// 3. Prompt for input the String
input = JOptionPane.showInputDialog("Enter the sentence to search: ");
int length = input.length();
input = input.toLowerCase();


// 4. Visit positions 0 through String.length()-1

int i = 0;

// 5-6. If position i of Strings is vowels
// increase vowel's counter by 1
if (input_string.charAt(i)== 'a' || input_string.charAt(i)== 'A')
aCount++;
else if (input_string.charAt(i)== 'e' || input_string.charAt(i)== 'E')
eCount++;
else if (input_string.charAt(i)== 'i' || input_string.charAt(i)== 'I')
iCount++;
else if (input_string.charAt(i)== 'o' || input_string.charAt(i)== 'O')
oCount++;
else if (input_string.charAt(i)== 'u' || input_string.charAt(i)== 'U')
uCount++;


// 7-9 Display the String
// display the number of characters in string
// display the number of each vowel in String

>> No.67888174
File: 10 KB, 417x412, query1.png [View same] [iqdb] [saucenao] [google] [report]
67888174

>>67884578
>>67886119
>>67886206
so you don't like class, namespace and loops?
here's my c# code. run in linqpad for simplicity.

>> No.67888176

>Edwin's already working on a successor to idris written in Idris
the absolute lad

>> No.67888193

>>67886640
I might not be able to work as fast as you can, but I sure as hell can maintain my shit better than you can.

>> No.67888196

>>67888169
A string is an array of characters. Loop each char in the string and check if it's a vowel.

>> No.67888211

>>67887032
#define bitreverse(_in_val) ({\
auto out = _in_val;\
switch (sizeof(out)) {\
case 8:\
out = ((out & 0xFFFFFFFF00000000UL) >> 32) | ((out & 0x00000000FFFFFFFFUL) << 32);\
case 4:\
out = ((out & 0xFFFF0000FFFF0000UL) >> 16) | ((out & 0x0000FFFF0000FFFFUL) << 16);\
case 2:\
out = ((out & 0xFF00FF00FF00FF00UL) >> 8) | ((out & 0x00FF00FF00FF00FFUL) << 8);\
case 1:\
out = ((out & 0xF0F0F0F0F0F0F0F0UL) >> 4) | ((out & 0x0F0F0F0F0F0F0F0FUL) << 4);\
out = ((out & 0xCCCCCCCCCCCCCCCCUL) >> 2) | ((out & 0x3333333333333333UL) << 2);\
out = ((out & 0xAAAAAAAAAAAAAAAAUL) >> 1) | ((out & 0x5555555555555555UL) << 1);\
break;\
}\
out;\
})\

since sizeof is resolved at compile-time, so the compiler ends up optimizing out the case structure jumps. It can also be done purely with nested macro functions.

>> No.67888220

>>67888196
oof. dont think I read that far in the book yet

>> No.67888225

>>67888169
In section 5-6, add a loop. Put your code in the loop.

>> No.67888227

>>67888211
shit, this is my C++ version. replace auto with __auto_type

>> No.67888283

>>67888169
// 4. Visit positions 0 through String.length()-1
int i;
for (i = 0; i < input.length() - 1; i++)


Change the code in section 5-6 to use input instead of input_string. You can remove the upper case checking because you have lower-cased the input in section 3.

You can also remove this line in section 3. It's not needed.
int length = input.length();

>> No.67888329
File: 18 KB, 300x250, 1535058758843.png [View same] [iqdb] [saucenao] [google] [report]
67888329

#include <iostream>
#include <unistd.h>

using namespace std;
void sleep_type(const string& inputString, const uint& interval) {
for (size_t i = 0; i < inputString.size(); ++i) {

cout << inputString[i] << std::flush;
usleep(interval);
}
}

>> No.67888391

>>67886665
>using tuple
watch this >>67888174

>> No.67888432
File: 167 KB, 1919x1077, takao_bucho.jpg [View same] [iqdb] [saucenao] [google] [report]
67888432

>>67888211
please explain this bit magic, senpai

>> No.67888530

who else linux but vs code

>> No.67888549

>>67888227
>C++ version
>macros
What the fuck are you doing? Are you retarded?

>> No.67888587

Is there a reliable and elegant way to loop in python?, i just want my script to start the initial input again

>> No.67888617

>>67888587
>Is there a [..] elegant way to [..] in python?
No.

>> No.67888686

>>67888432
he's bit masking, fagtron.
He's just recursively swapping half of the bitstring.
Every step is him dividing the bitstring into half and then swapping the two components. Like a tree.

>> No.67888688
File: 200 KB, 1440x810, DmDDSzXUYAAX28w.jpg orig.jpg [View same] [iqdb] [saucenao] [google] [report]
67888688

>read the manual
Ok, what's the best source for language manuals.
Web search shows a hell of a lot.

>> No.67888699

>>67888587
>is there a reliable and elegant way to do this thing that I've described in an incredibly shitty manner?
No.
Not only does no one understand what the hell you're trying to do, you're probably going about it all wrong at that.

>> No.67888701

>>67888617
what about the fizzbuzz of the christ?, that's elegant

>> No.67888724

>>67888688
Use the official documentation.

>> No.67888737
File: 18 KB, 250x266, reverse-small2.png [View same] [iqdb] [saucenao] [google] [report]
67888737

>>67888432
here you go desu

>> No.67888787

C++:
>Give power and control to experts, while keeping simple things simple.
Rust:
>Assume the programmer is retarded.

>> No.67888794
File: 147 KB, 3328x740, Screenshot_2018-09-26 g - dpt - Daily Programming Thread - Technology - 4chan.png [View same] [iqdb] [saucenao] [google] [report]
67888794

>>67888787

>> No.67888814

>>67888787
>while keeping simple things simple.
std::doubt()

>> No.67888819

>>67888794
>use an IDE
>use CMake only for releases
>use references, smart pointers, and move semantics
i could go on

>> No.67888834

>>67888688
https://www.stackage.org/lts-12.11/hoogle?q=

>> No.67888837
File: 11 KB, 397x273, ddddddddddddddddddd.png [View same] [iqdb] [saucenao] [google] [report]
67888837

what's the time complexity of this algorithm? logn?

>> No.67888847

>>67888819
>he needs a non portable IDE to accommodate the lackings of his dev environment
>he avoids a (non) standard build system because the best he has is a piece of garbge
>He needs 5 different ctors in order to come up with a class
go on...

>> No.67888888

>>67888837
fixed input size, so O(1)

>> No.67888892
File: 625 KB, 1496x2933, repent.jpg [View same] [iqdb] [saucenao] [google] [report]
67888892

>>67888888
wasted get

>> No.67888893

>>67888888
smart and digitpilled

>> No.67888897

>>67888888
this nigger right here

>> No.67888922

>>67888888
I sort of understand why it's constant, what if b is really huge, since we're doing bitshifts it's going to work on log_2n time no?

>> No.67888950

>>67888922
O(INT_MAX) = O(1)

>> No.67888978

>>67888888
Damn you, Computational Complexity Hitler

>> No.67888987

>>67888787
>while keeping simple things simple
if only

>> No.67889007

>>67888787
It's true that Rust can't represent a linked list, but how often do you use heap allocation anyway? Just keep everything on the stack, what's the problem?

>> No.67889022

>>67889007
>It's true that Rust can't represent a linked list
use std::collections::LinkedList;

Illuminati confirmed xDD

>> No.67889043
File: 162 KB, 321x322, b5f.png [View same] [iqdb] [saucenao] [google] [report]
67889043

https://news.softpedia.com/news/gnome-3-30-desktop-environment-is-now-available-on-flathub-as-flatpak-runtimes-522993.shtml

>> No.67889059

>>67888888
nice digits

>> No.67889072

>>67888787
>>67889007
Why is /g/ so adamant about spreading misinfo and FUD about Rust?

>> No.67889076
File: 325 KB, 529x735, smug_ran5.png [View same] [iqdb] [saucenao] [google] [report]
67889076

>>67885968
It excels at making absolute retards ITT feel smart

>> No.67889091

>>67888950
That's not how you compute complexity of algorithms.

It's O(lg(n))

>> No.67889093

>>67889076
This isn't your blog, faggot

>> No.67889100
File: 177 KB, 850x850, 38a22d8709a57894fd118390401ebc4e.jpg [View same] [iqdb] [saucenao] [google] [report]
67889100

>>67889007
>who needs closures anyway

>>67889076
bad ranposter

>> No.67889101

>>67889093
>can't even tell facts from blogging
Case in point

>> No.67889104

>>67889091
n <= INT_MAX
lg is monotonic
ergo O(lg(INT_MAX))
O(1)

>> No.67889118

>>67889091
yeah the answer says its O(logn)

>> No.67889125

>>67889101
I don't give a shit who or what you're replying to, I'm saying this isn't your fucking blog.

>> No.67889146
File: 495 KB, 1000x1000, smug_ran2.png [View same] [iqdb] [saucenao] [google] [report]
67889146

>>67889125
I'm replying to you dumbshit. No where and never have I blogged anywhere on 4chan and your little pissyfits won't stop making me telling the truth about how fucking stupid this board is.
Cry me a river, stupid little boy.

>> No.67889150

>>67888888
took me fewer than 10000*ln(2) posts so the digit gods are favourable

>> No.67889157

>>67889146
Go to hell Hank

>> No.67889169

>>67889107
So in an algorithm that has a for loop n times inside a for loop n times,
n<=int_max
x^2 is monotonic for x>=0
ergo O(int_max^2)
O(1)

Are you retarded?

>> No.67889174

>>67888888
You're retarded. n isn't always the size of the input.

>> No.67889179

>>67889169
Whoops, in reply to >>67889104

>> No.67889192
File: 467 KB, 1000x1000, smug_ran3.png [View same] [iqdb] [saucenao] [google] [report]
67889192

>>67888888
Need I say more? THESE are the kind of """people""" giving you programming """advice""" ITT.
Fucking pathetic lmao

>> No.67889194

>>67888837
b gets 'converted' to binary form, after which it is shifted until it becomes 0, that requires O(log_2n) so its logn

>> No.67889204

>>67889104
No. O(1) refers to complexity being independent of the data, ie same demands for 5 elements or 5 million

>> No.67889213

>>67889104
this is what happens when you learn programming without studying data structures/algorithms

>> No.67889228

>>67889169
>>67889204
>>67889213
If n < 0 no, though in the int case it'll be constrained on the negative side anyway. Generally you shouldn't use O(n) with negative numbers. I'm just pointing out the other anon's autism.
For all input (which is a natural number <= INT_MAX), it operates in O(1).

>> No.67889247

>>67889174
when discussing time complexity it is, unless explicitly stated otherwise
this algorithm can do up to 31 iterations, so either you can argue that its time complexity is non-sensical or you give it an O(1) because of its fixed input size

>> No.67889266

How do you copy arrays fast instead of member-by-member copying?

>> No.67889276

>>67889266
copy the pointer

>> No.67889280

>>67889247
>>67889228
Please go back to school or India

>> No.67889296

>>67889266
SIMD and possibly even multiple threads.

>> No.67889308

>>67889266
copying one-by-one is the only way to do it, thats how memcopy works

>> No.67889321

>>67889280
It's true.

>> No.67889328

>>67889228
precondition: x and y > 0

>> No.67889336

>>67889247
>>67889228
I can't tell if you're serious.
If the time it takes to complete the algorithm is not constant, independent of the data, then the function does not have O(1) algorithm.

Take his code and run it 100,000,000 times twice, one set of trials with value 2 and the other with value INT_MAX. This alone is proof. You are wrong.

>> No.67889341

>>67889266
for a shallow copy of a contiguous array, memcpy()
the compiler will pick the fastest implementation

>>67889280
>can't handle the pedanticism
go away normie

>> No.67889343

>>67889336
>then the algorithm does not have O(1) complexity*

>> No.67889354

>>67889266
x86 cache lines are 64 bytes so utilizing something like simd you can copy large 64 byte chunks of memory around very very fast and also utilize multiple threads to have multiple cores in parallel moving a large amount of memory. SIMD also features plenty of scatter-gather instructions that allow you to handle edge cases.

But yea, simd lets you move large chunks of data but oyu should only have to do that if you have to. It's better to just shift a pointer around if you can. Try and see if you can redesign the context of your problem around to possibly save you from ever having to do a memcpy.

the standard memcpy has had years and years of attention and design work to fully utilize every possible feature your processor could support(except for multi-threading) so if your slowdown is at memcpy then i highly doubt youll be able to get better than most memcpy implementations which utilize simd and virtual page swapping and all that fancy stuff.

Again, look at your problem domain and see if you even have to do a memcpy at all.

>> No.67889359

Why would anyone talk about complexity in terms of big O instead of big Theta?

>> No.67889366
File: 54 KB, 500x500, 24231.jpg [View same] [iqdb] [saucenao] [google] [report]
67889366

>>67889336
f(x) in O(g(n)) iff there exists m > 0, x0 >= 0 s.t forall x >= x0, |f(x)| < m*g(x)
in this case x is always <= INT_MAX
g(x) = 1, x0 = 0, m = MAX({ |f(x)| | x in 0 ... INT_MAX)
forall x in 0..INT_MAX, |f(x)| <= m
this is true by the definition of m

>> No.67889385

>>67889354
I thought SIMD could only operate on 4 or 8 values at a time?

>> No.67889454

>>67889385
if you are doing ALU arithmetic, like multiplications and additions and all that. then yes most instructions are at the granularity of 2 or 4 or 8 or 16 or 32 elements (from MMX all the way to the recent AVX 512, which are 512 bit registers, 64 bytes)

if you are purely moving data around, then a 128-bit SSE register is 16 bytes of data being moved around at a time. a 256-bit AVX2 register is 32 bytes at a time, a 512-bit AVX512 register is 64 bytes at a time. Though either way. you're eventually going to be flushing 64-byte cache lines so no matter what instructions you use to get data read into a cache line to be copied somewhere else in your ram, your CPU is flushing out data to the ram in chunks of 64-bytes no matter what.

Also, depending on how your ram is configured(dual channel, quad channel), you can have multiple cores concurrently interfacing with your ram.

For example. a i7-7700 has a 37.76 GiB/s bandwidth with your ram in dual channel mode. That's 40 gigabytes per second.
https://en.wikichip.org/wiki/intel/core_i7/i7-7700

An i9-7900x in quad channel can do 79.47 GiB/s. That's 85.33 gigabytes per second.

>> No.67889458

>>67889385
Technically, some Intel CPUs support a version of AVX that can manipulate up to 512 bits (64 bytes) at a time.

>> No.67889486

>>67885917
REMINDER THE BOWSETTE MEME IS DESIGNED TO BE THE IMAGE OF MOLACH.
THE HORNS ARE THE SAME.
THIS IS A PSYOP THAT DESTROY YOUR SOUL IF YOU POST IT.

>> No.67889537

>>67889366
>f(x) in O(g(n)) iff there exists m > 0, x0 >= 0 s.t forall x >= x0, |f(x)| < m*g(x)
You mean f(x) in O(g(x)). Or f(n) in O(g(n)). And |f(x)| <= m*|g(x)|.

So I'm curious, since most functions in common programming languages are bound in their number of iterations, are all these implementations of algorithms in these programming languages O(1)? :)

Like I said, go back to school. Or India. You need a better understanding than some meme that "hehe it can't be asymptotic because its bounded lol"

>> No.67889568

>>67889537
>You mean f(x) in O(g(x)). Or f(n) in O(g(n)). And |f(x)| <= m*|g(x)|.
Two typos, wow I've really got to go back to school.
>the entire thing is still valid
As I've said, I'm just explaining anon's autism. You can give the algorithm a
constant maximum growth, thus it's O(a constant) and O(1)

>> No.67889598

If I got an algorithm that takes 1 second to process a dataset of size N, and now I get a machine that is 10x faster, what's the size of the dataset I can process in 1 second if the execution time for the dataset is proportional to logn?

>> No.67889612

>>67889598
N*10

>> No.67889618

>>67889612
N^10 you mean? can you explain?

>> No.67889619

>>67889276
Editing "copy" will cause source change.

>> No.67889636

>>67889598
Given
>log N = 1
Solve for
>log M = 10
(since running on a machine 10x as fast is the same as running on the same machine for 10x as long)
10 log N = log M
log N^10 = log M
M = N^10

>> No.67889675

All code is O(1)

>> No.67889676

>>67889636
Why isn't the answer 1024N? assuming log_2n, if I 4x the data it means I 2x the time, 16x data, 4x the time, 1024x the data, 10x the time

>> No.67889700

>>67889676
That's not logarithmic.
Log means doubling the amount of data adds a certain amount of time, e.g. N data takes 5 seconds, 2N takes 6, 4N takes 7, ... 1024N takes 15 seconds, etc.
What you're thinking of is square root.

>> No.67889717
File: 405 KB, 540x432, 1524893462127.gif [View same] [iqdb] [saucenao] [google] [report]
67889717

>>67889700
I got it, thanks m8

>> No.67889742
File: 27 KB, 372x99, 4yiP0.jpg [View same] [iqdb] [saucenao] [google] [report]
67889742

>>67889598
1024 takes 10 times as long assuming logn

>> No.67889773

>Java > Scala
>C# > F#
which combo is better for the future?

>> No.67889779

>>67889773
Java is eternal

>> No.67889814

>>67889773
both are shite

>> No.67889900

Can anyone help me figure this out? I'm trying to store a string based on what the user scans in. I'm in C.

if(start == 'B' || 'b')
city = "Baltimore";

>> No.67889903

>>67889900
When I try to run this code by calling %s later on, the compiler says city is an int?

>> No.67889947
File: 505 KB, 1280x720, 1537951356338.jpg [View same] [iqdb] [saucenao] [google] [report]
67889947

do i have to learn c++ before learning qt?

>> No.67889954

>>67889900
if (start == 'B' || start == 'b')

>> No.67889968

>>67889954
That seems to help, but for some reason I still get this error:
warning: assignment makes integer from pointer without a cast

Any ideas? This is killing meeee

>> No.67889991

>>67885949
Learning (or at least being familiar with) Haskell is on my "todo list".
What are examples of nice projects for getting my hands and brain around Haskell?
Not as trivial as a mere example, but not so difficult either so I don't give up halfway?

I'm on my own, so I intend to learn the syntax on the website learnahaskell then put these in practice.

>> No.67890005

>>67889947
yes

>> No.67890009

>>67889773
Java has the big data ecosystem and J2EE. C# has anything to do with MS, which isn't going anywhere.

The only reason anyone talks about Scala is Spark and Akka. Beyond that, the ecosystem doesn't have much to offer and the language itself isn't much more than a stripped down Java with some FP stuff thrown in the mix.

I doubt that Scala has much of a future if Spark is superceeded by a Java API based platform. This is inevitable as its common path most developers take today due to easy porting to R/Python or other languages.

>>67889814
>i hate money and i think the height of programming is embedded shit or raspberry pi
Got it. Stay in your confinement zone.

>> No.67890012

>>67889954
>no unicode support

>> No.67890019

>>67889991
haven't got any good project examples, but as far as tutorials go, learnyouahaskell is a bit out of date, the wikibook or the book (haskell programming from first principles, if you can find an online pdf) are better

>> No.67890058

>>67890009
>i hate money and i think the height of programming is embedded shit or raspberry pi
No I just think both Java and C# are shite languages. Didn't think money was the factor here

>> No.67890084

>>67890019
Thanks for the tip

>> No.67890088

>>67890058
When it comes to making a career out of programming if you are working outside of these two languages and you aren't a front-end developer or a 'data scientist', if you are employed you have a job not a career.

As just about every other programming language is either dying or a niche to a particular company.

Before you write about C++ game engines or some other high performance application like that. 99%+ of programmers would never be trusted to do this kind of work, so it's not even relevant to raise it in the current year.

>> No.67890090
File: 64 KB, 1024x576, 9eb8d0bd071342ac5ffc060713e3617fe511493a_hq.jpg [View same] [iqdb] [saucenao] [google] [report]
67890090

>>67890005
damnit

>> No.67890101

>>67890090
you can learn Haskell then use hsQt

>> No.67890171

>>67890088
Ok, but original anon was a bit vague about 'better for the future', this could have been sanity, as a hobby as well as as a career. I think they are shite languages, does that mean I think they're not highly employable? No

>> No.67890197

>>67890090
https://www.youtube.com/watch?v=r9wSGbb2uQg

>> No.67890209

>>67889779
>>67890009
>>67890088
I'll take the Java route. thanks, anons.

>> No.67890211
File: 204 KB, 440x500, 1537566634658.png [View same] [iqdb] [saucenao] [google] [report]
67890211

>>67890101
>haskell
haskell is even scarier than c++

>> No.67890219
File: 899 KB, 1600x901, 1480383386969.png [View same] [iqdb] [saucenao] [google] [report]
67890219

>>67890211

>> No.67890240

>>67890197
kek

>> No.67890279

>>67889486
>SOUL
DNE

>> No.67890292

Jesus, it was a pain setting up a Mega Drive development environment on Linux. Most of the tools are for DOS/Windows. Finally found and built an ancient version of binutils that included M68000 support. Getting the right assembler and linker options to shit out a binary that the Mega Drive would actually run also took a while with a lot of cross referencing sketchy CPU documentation. But it seems to be working properly now that it's all set up, which is good since most of the popular homebrew assemblers and linkers are ripped from old dev kits and are of questionable legality, not that I've heard of anyone policing licenses.

Now to configure vim...

>> No.67890300

>>67885972
just write your own stdlib bro

>> No.67890318
File: 607 KB, 250x249, 1538002040207.gif [View same] [iqdb] [saucenao] [google] [report]
67890318

>>67890219
please don't cry, i'm just too brainlet for c/c++/haskell.

>> No.67890360

>>67888888
Based and getpilled

>> No.67890404

>>67890292
What language does that toolchain even support?

>> No.67890414

I want a cute nopan anime girl to sit on my face.
Also C++ is the best programming language.

>> No.67890443
File: 6 KB, 250x249, f60.jpg [View same] [iqdb] [saucenao] [google] [report]
67890443

I FUCKING HATE MY ADVANCED C CLASS FUUUUUUCKKK

>> No.67890487

>>67890443
You mean C struct, right

>> No.67890508

>>67885917
My PWA: https://daniel-jianoran.com - CHIP-8 sokoban, see if you can solve it

You can control it using wasd on your keyboard, the wasd buttons on the screen, a bluetooth controller which I've mapped only wasd to. You can also download it from your phone as a PWA

>> No.67890518

>>67890404
m68k assembly. I mean, you could pretty much tack on whatever gnu compiler you want if you wanted to develop in C or C++ or whatever, but without library support for the platform I don't see much point? You'd be spending all your time implementing basic library functionality and writing drivers for the hardware components, which isn't worth it unless you plan on doing a lot of projects on the platform.

>> No.67890590
File: 32 KB, 860x152, Screen Shot 2018-10-03 at 12.56.15 AM.png [View same] [iqdb] [saucenao] [google] [report]
67890590

>>67885917
I want to create a function/operator that, similar to a "+", takes a left and a right integer as arguments and outputs a list with all numbers between the two?
How would you do something like this in Lisp?

The most I have so far is
(defun -> (left right)
(cond ((eq left right) ())
(else (cons left (-> (+ left 1) right))))
)

>> No.67890606

>>67890508
>tfw got lazy and left the icon as my github pic
dont download it yet boys pls

>> No.67890671

>>67890590
I don't know how you'd do it in Common Lisp but I can answer in Scheme.
(define (range from to)
(if (> from to)
(cons from (range (+ 1 from) to))
'()))

Super inefficient though

>> No.67890681

>>67890671
I fucked it up but I think you get the idea

>> No.67890731

>>67885917
I'm working on a lexer library.
1. Tokenization expressions translate via shunting yard to a tree.
2. Take a powerset.
3. Minimize the graph.
4. JIT a lexer to x64.
It's fast and dynamic. I think it could be sweet for a neutron-star-dense Lisp with modern sensibilities.
Can we do a competitively fast JIT Lisp in 3000 lines?

>> No.67890761

>>67890443
Advanced
C
?
Advanced C...
Advanced C?

>> No.67890862

>>67890671
I might not have been super clear about this, but I was asking if it'd be possible to write a function you'd call like this:
(5 -> 7) ;; Same as calling (range .5 7)

>> No.67890940

This is just a general best practice question but I want to make a program that basically catalogues, displays and keeps track of images. First what GUI framework isn't completely horrible, language is pretty much anything but I enjoy C the most. Where do you store data and preferences? In the same folder as the application? I wouldn't be releasing it and even if I did no one would use it but I'd like to do it as if it were going to be used on different platforms.

>> No.67890947

should dev machines with access to critical IP/code have access to the internet outside of ssh to pull/push? how do companies like google, amazon etc keep their shit safe when literally every modern OS is backdoored out the ass and even normie websites are infected with malware?

>> No.67890973

Please someone fucking help me in c language
How do I use a string using IF and else?
I want to put : Fine street
but it won't read it
I am kinda making a text based adventurer but it won't just fucking read

>> No.67890983

>>67890973
I'm not sure what the heck you mean but to compare a string you use strcmp or similar, which returns a 1 or 0 or something. Read the docs.

>> No.67891018

>>67890983
Kinda like question that needs to input a string
Ex: Where does he live?
User would input 'Fine Street
then IF ELSE stuff

>> No.67891038

>>67891018
Something like scanf or fgets. You'll need to understand points for strings though so it's better to start with that.

>> No.67891078

>>67889076
this is enough for me. I cant give motivation to myself so ill get it wherever

>> No.67891090
File: 492 KB, 1408x786, ICFP.png [View same] [iqdb] [saucenao] [google] [report]
67891090

Functional programming is kill
Send help

>> No.67891117

>>67891018
>>67891038
Something like this.

char string[10];

printf("Enter your name: ");
fgets(string, 10, stdin);

sscanf(string, "%s", string);

if (strcmp(string, "John") == 0) {
printf("Your name is %s", string);
} else {
printf("Your name is not John %d", strcmp(string, "John"));
}


The reason for sscanf is because the newline feed was getting added to the string. There's probably better ways to do it.

>> No.67891120

>>67890862
>>67890590
Yes and no.
No you cannot have a function like this.
You'll have to write a macro or even a reader macro for something like this.
http://gigamonkeys.com/book/macros-defining-your-own.html
https://lisper.in/reader-macros

The questions are though, why do you need this? Do you REALLY need this?

>> No.67891138

>>67891120
>Do you really need this?
Nah, just wanted to see if it was possible.
I found this neat way to extend racket to support infixes, but for now I'll just keep it in the backburner for when I have time to kill.
https://lexi-lambda.github.io/blog/2017/08/12/user-programmable-infix-operators-in-racket/

>> No.67891168

>>67891138
I've something that kinda does a similar thing actually, usage looks something like this:
CL-USER> (cmp 5 + 6 + 8)
19

>> No.67891171

>>67885917
Booru-backed anime image captcha with face-detection-based croping for reverse image search prevention. Think Google captcha but with "Select all images of $well_known_character" and completely open source.

>> No.67891177

>>67891168
Though it is more of a DSL.

>> No.67891183

>>67891171
Make it $less_known_character and keep the normies out.

>> No.67891189

>>67891117
I just got lazy so I just went

(strcmp(string, "Fine") == 0 || (strcmp(string, "Street") == 0 )

it worked but I am not proud of it

>> No.67891202

>>67891171
It's about time someone made something like this.

>> No.67891207

>>67891183
>$less_known_character
It's configurable. You can go as niche as you want.

>> No.67891326

Jesus christ how long does webkitgtk take to build?

>> No.67891345
File: 215 KB, 1896x632, Screenshot from 2018-10-03 19-34-18.png [View same] [iqdb] [saucenao] [google] [report]
67891345

>>67891326
lol

>> No.67891463
File: 140 KB, 937x1200, Bowsette-Mangaka-Illustrations-3.jpg [View same] [iqdb] [saucenao] [google] [report]
67891463

>>67885917
>tfw bowsette is propoganda for thicc transgenders

>> No.67891525
File: 103 KB, 768x960, 1516088870733.jpg [View same] [iqdb] [saucenao] [google] [report]
67891525

You ready for a quick code puzzle?
>Some number can be read upside down without changing it's value, write a code that find out those numbers that lies between 1-1000 in the language of your choosing.
>e.g. 1 and 8, also while 6 and 9 become another number when read upside down 69 is not, so keep that in mind.

>> No.67891534

>>67891525
do your own homework anon

>> No.67891679
File: 1.33 MB, 2232x1256, dff7cd20b53b992cbfba687431b915287e92034bae54c7de4957e84b106bcb9f.jpg [View same] [iqdb] [saucenao] [google] [report]
67891679

>>67891534
Just admit you know nothing and you lurk around here for an excuse to wear programing socks.
def upsidecheck(tocheck):
intolist=list(map(int, str(tocheck)))
x=0
while x<(len(intolist)/2):
if (intolist[x]+intolist[len(intolist)-x-1])!= 10 :
return False
break
x+=1
return True
print("which nth upsidedownnumber do you want?")
nth=int(input())
y=0
answer=0
for x in range (1,(2**31)):
counter=upsidecheck(x)
if counter == True:y+=1
if y==nth:answer=x;break
print("the answeris",answer)

>> No.67891688
File: 944 KB, 1920x1693, 1453400948152s.jpg [View same] [iqdb] [saucenao] [google] [report]
67891688

>>67891679
>== True

>> No.67891695

>>67889104
It's logN faggot, you're describing an implementation-specific upper bound on the algorithm

>> No.67891705

>>67891695
>>67888888
>>67888837

>> No.67891722

>>67891679
y+=upsidecheck(x)

>> No.67891803

union{
char ch;
signed char sc;
unsigned char uc;
int8_t s8;
uint8_t u8;
}foo[STRING_LENGHT];

How to get the pointer pointed to the foo[0] with the char datatype without the ugly &(foo[0].ch) ??

>> No.67891843

>>67891803
http://www.cplusplus.com/reference/cstddef/offsetof/

>> No.67891848

>>67891803
Since when do you need the parens?

>> No.67891940

>>67890590
In Haskell this is just
(-->) :: Int -> Int -> [Int]
(-->) a b
| a < b = [a+1..b-1]
| otherwise = [a-1,a-2..b+1]

{- 1 --> 5 == [2,3,4]
5 --> 1 == [4,3,2] -}

>> No.67892010

>>67891940
(-->) :: Int -> Int -> [Int]
(-->) a b = [a+1..b-1]

(<--) :: Int -> Int -> [Int]
(<--) a b = [a-1,a-2..b+1]

(<-->) :: Int -> Int -> [Int]
(<-->) a b
| a < b = a --> b
| otherwise = a <-- b

>> No.67892034

>>67892031
>>67892031
>>67892031
>>67892031

>> No.67892051

can someone shed some light on the runtime of this algorithm?

arr = some array of size n
k = some constant
for (i = arr.length - 1; i >= 0; i--) {
if (i >= k) {
for (j = i - 1; j >= (i - c); j--) {
// do some constant operatior
}
} else {
for (j = i - 1; j >= 0; j--) {
// do some constant operation
}
}
}


it doesn't look O(n^2). since the amount of iterations for the inner loops cannot ever be N on all iterations as they are bounded to be less than the current iterator, which is constantly decrementing.

>> No.67892248

>>67891803
&foo[0].ch
In this specific case, &foo->ch would work, but this syntax is odd to use on an array.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action