• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Chris R

Member
I've never taken graph theory, so I'm not sure what 'simply connected' means, but can't that algorithm get you stuck in a loop if you start with one on your left?


I really think there was more to it. Something was not correctly said or understood.

Simply connected as in there are no "floating" walls that aren't connected to anything else, because then you could get stuck in a loop with the left hand solving technique. When I was in college we made sure the mazes we were working on were simple by starting with a graph where no nodes were connected and adding edges one at a time until the entire graph was connected.
 

Slavik81

Member
No, BFS has very different behavior. My suggestion is essentially iterative deepening depth first search but without backtracking prevention. Or sanity. Recursion is just an implementation detail; equivalent pseudocode is
Code:
loop L = 1.. infinity
  generate all possible NSEW movement combinations of length L
  attempt to walk each one; bail when walking over exit
So this genius algorithm will check locations like "north-south-north-south" for the exit over and over again.
I'm still not understanding the difference. This was my reasoning, though perhaps I screwed something up:

Consider a binary tree as a simple example.
Code:
    0
   / \
  1   2
 / \ / \
3  4 5  6

If I understand correctly, this would be an iterative depth-first traversal:
Depth 0: 0
Depth 1: 0, 01, 02
Depth 2: 0, 01, 013, 014, 02, 025, 026

Listing only newly traversed nodes, iterative depth-first looks like so:
Depth 0: 0
Depth 1: 01, 02
Depth 2: 013, 014, 025, 026

That's second one is the same pattern I'd list for breadth-first. Hence my conclusion that an iterative depth-first search is equivalent to doing a breadth-first search, recreating the state of the search at each level, rather than storing it.
 

Water

Member
Hence my conclusion that an iterative depth-first search is equivalent to doing a breadth-first search, recreating the state of the search at each level, rather than storing it.
That's all correct. The iterative deepening brute force algo also visits the same fresh nodes per level as IDDFS. In your binary tree, the brute force algo would traverse

Depth 2: 0, 01, 010, 013, 014, 02, 020, 025, 026
 

fallagin

Member
Lately I've been checking out shell scripts to help automate some of my code making and it is going pretty awesome. i feel so much more productive when I dont have to lay out my pages over and over again, and I can customize it however I want.

feels_good_man
 

upandaway

Member
Can anyone help me out a bit with switch cases (java)?

I want to have a pretty long switch case to translate a number range into stuff those numbers are supposed to refer to.
If the number isn't in range, it would go to "default" and that would be fine, but I honestly want to perform the range check in an If statement before the switch case, because going through everything up to default seems inefficient. It should check for that before it starts polling for every number.

The compiler hates this and keeps treating my switch case as incomplete, so it won't let me return or handle objects that might not be instantiated (when it's failure proof that they will, if you combine the if statement and the switch case).

Am I worrying for no reason and the JVM optimizes for this, or is there a neat way to do this? Does it work fine if I put default before the first case (edit: nope, this compiler hates me)?
 

Water

Member
Can anyone help me out a bit with switch cases (java)?

I want to have a pretty long switch case to translate a number range into stuff those numbers are supposed to refer to.
Post the code snippet in a gist.

Switch cases, especially long ones, are usually a sign of bad code. One of the most common ways to get rid of them is to replace them with an array or map lookup. The appropriate way depends on how the range is split and how the results need to be produced.
 

upandaway

Member
Post the code snippet in a gist.

Switch cases, especially long ones, are usually a sign of bad code. One of the most common ways to get rid of them is to replace them with an array or map lookup. The appropriate way depends on how the range is split and how the results need to be produced.
It's really just taking a number and returning the appropriate enum that corresponds to that number (I'm reading a sequence enums from a text file but I want to keep the file simple and short, no need to be human readable).. I totally get what you're saying, and it would definitely work if I just use a collection and use the number as the index, but my line of thinking was that a simple translator would be easier to read and maintain as a switch case (say I want to remove a number without changing the others, or anything else, the more such tweaking happens with a collection the more messy the code will get).
If using a collection is the more efficient way then I guess that's what I'll do, it's not like either of these won't work.. dunno.

Here the code in any case
And the file for example would be 1;1;1;1;2;1;2;2;1

If I decide I don't want 1 anymore (and disallow files with it), I could just go to that case and change it to throw an exception. In a collection I'd have to add an extra if statement for 1 before the other code that checks the collection.
 
Do you often get a value outside of the allowed range? If this rarely happens the extra if statement is probably less efficient than just using the default case. If you don't want one of the cases anymore delete it and let it go to default, no need to have 20 lines of code throwing the same error.
 

upandaway

Member
Do you often get a value outside of the allowed range? If this rarely happens the extra if statement is probably less efficient than just using the default case. If you don't want one of the cases anymore delete it and let it go to default, no need to have 20 lines of code throwing the same error.
Nah it's supposed to never happen, at least not as long as I write the text files (I'm gonna write a tool that makes them later too, so even more so). I'm just racking my brains to make the best choices because this is meant as practice more than anything. Not to mention like Water said I've never seen anything good said about switch cases (I'm still not confident that I should be using it honestly).
 

tokkun

Member
It's really just taking a number and returning the appropriate enum that corresponds to that number (I'm reading a sequence enums from a text file but I want to keep the file simple and short, no need to be human readable).. I totally get what you're saying, and it would definitely work if I just use a collection and use the number as the index, but my line of thinking was that a simple translator would be easier to read and maintain as a switch case (say I want to remove a number without changing the others, or anything else, the more such tweaking happens with a collection the more messy the code will get).
If using a collection is the more efficient way then I guess that's what I'll do, it's not like either of these won't work.. dunno.

Here the code in any case
And the file for example would be 1;1;1;1;2;1;2;2;1

If I decide I don't want 1 anymore (and disallow files with it), I could just go to that case and change it to throw an exception. In a collection I'd have to add an extra if statement for 1 before the other code that checks the collection.

I usually opt to handle integer to Enum mapping in Java via a member method in the enumerated class like this:

Code:
 public enum InstructionCycle {
    kFetchInstruction1(kFetch1Code),
    kFetchInstruction2(kFetch2Code),
    kDecodeInstruction1(kDecode1Code),
    //...
   ;

    public static final int kFetch1Code = 7;
    // ...
    
    private InstructionCycle(int code) {
      code_ = code;
    }
    
    public int as_int() {
      return code_;
    }
    
    public static InstructionCycle Lookup(int code) {
      for (InstructionCycle cycle : InstructionCycle.values()) {
        if (code == cycle.as_int()) {
          return cycle;
        }
      }
      // Throw exception here if you want.
      return null;
    }
    
    private final int code_;
  }

I think this sort of approach is more inline with the spirit of OO, by bundling the class-specific method into the class itself.
 

upandaway

Member
That looks really good, except for the fact that I'm using one range of numbers across more than one enum (some are kinda big, but I want only 1 text file), so I could keep the codes in the enums but I'd have to have an independent translator either way with no way to cycle through them.

I guess my entire setup is bad if I keep hitting annoyances like this. Maaaaaaaaaaan... I wanna just scrap everything now.

edit: actually all the big enums can be labeled as a different category, so I could keep a translator only for those and use the above for the others. Still left at the first issue though, but I give up, I'll go to default thanks to runningjoke. My head hurts and it really shouldn't! (thanks people)
 

Water

Member
If I decide I don't want 1 anymore (and disallow files with it), I could just go to that case and change it to throw an exception. In a collection I'd have to add an extra if statement for 1 before the other code that checks the collection.
Don't see why. If the collection is a map, you just do the lookup and get an error if there's no result found. You don't even need a separate range check; either a number is defined in the map or it's not. All you need to do to disallow '1' is to remove it from the map.

This kind of arrangement might also make it easier to support reading different versions of the data; you can just as easily give the translator an old map or a new one.
 

upandaway

Member
Whatever happens, even with a map, the fact I'm using different classes with no way of iterating them means I'd still have the manually written huge block of text somewhere, whether it's to make the map or the switch case.. so reading/maintaining would be exactly the same. I guess there's no real difference besides the efficiency (which would be better with a map if I got this right). With a map the translator won't be so much a translator as it will be a class to put the map in, which might be more flexible. Well ok then, I'll also use a collection for the non-iterable classes.
 
Still chugging in through school, 10 or so more classes to go, not really that many left dealing with just high level languages. Surprisingly there's no non elective required classes for java, so I may not be able to get to it based on what classes are being offered. Does anyone have recommendations for a java book for adept programmers? I'm pretty knowledgeable (not an expert) on C++ and VB, so I know control structures, storage containers, memory allocation, just need to learn syntax and unique features of java.
 

Water

Member
Whatever happens, even with a map, the fact I'm using different classes with no way of iterating them means I'd still have the manually written huge block of text somewhere, whether it's to make the map or the switch case.. so reading/maintaining would be exactly the same. I guess there's no real difference besides the efficiency (which would be better with a map if I got this right). With a map the translator won't be so much a translator as it will be a class to put the map in, which might be more flexible. Well ok then, I'll also use a collection for the non-iterable classes.

Well, either you retain full control over the translation and get the burden of defining what it is exactly, or you let the code do it automatically e.g. by using .ordinal(), in which case you can't count on data compatibility between different code versions.

There's no way you have to worry about efficiency details of simple conversion in a situation like this. The fact you are reading files is going to mask everything. But given that what you are doing is simple 1:1 mapping of data, I'm convinced that you'll have clearer code if that mapping is represented as such instead of embedded in a control structure.
 
So I made a random sentence generator in C++ the other day when I was bored. It's just using random numbers seeded with time to pick a number 1-20 to determine which words to use. Extremely basic but fun to work on.

My only issue is that I was closing out and reopening my program when I was testing it, which I don't want to do anymore. So I stuck it in a while loop, but the issue with this is that if I hit the button to run the program again too fast, it will either give me the same sentence or some parts of the sentence will be the same.

Is there any simple way to avoid this, so that I can rerun the program as quickly as I want? I guess I could implement a couple second wait, but I'd like to avoid that if possible. Thanks in advance for any advice.
 
So I made a random sentence generator in C++ the other day when I was bored. It's just using random numbers seeded with time to pick a number 1-20 to determine which words to use. Extremely basic but fun to work on.

My only issue is that I was closing out and reopening my program when I was testing it, which I don't want to do anymore. So I stuck it in a while loop, but the issue with this is that if I hit the button to run the program again too fast, it will either give me the same sentence or some parts of the sentence will be the same.

Is there any simple way to avoid this, so that I can rerun the program as quickly as I want? I guess I could implement a couple second wait, but I'd like to avoid that if possible. Thanks in advance for any advice.

Change the way you're seeding your random numbers?
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Yeah, I guess I'll have to if I want the results I'm looking for. I was just hoping maybe there was some trick I could use that I wasn't aware of. Oh well! Thanks.

Judging by your explanation of it only happening when you press the button too fast, my guess would be that it's using the same seed twice for two consecutive generations.
 

Water

Member
Judging by your explanation of it only happening when you press the button too fast, my guess would be that it's using the same seed twice for two consecutive generations.
And that makes me think he's re-seeding the generator before every use, which a) causes the problem, b) is unnecessary. Seeding the generator once at the beginning is enough.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
And that makes me think he's re-seeding the generator before every use, which a) causes the problem, b) is unnecessary. Seeding the generator once at the beginning is enough.

I'm guessing this is caused by him closing the program and running it over and over?

A more practical solution could be utilizing a really simple GUI with a button and display area. Each time you press the button it generates one of your sentences and displays it. Then you could have an RNG that uses a constant seed.
This could probably be done easily without a GUI as well. It was just the first thing that came to mind.
 
Okay, I think I got it. Like Water said, it looks like I may have been unintentionally seeding more than once which is most likely the issue. I have to test a little more but hopefully that's it.

I'll mess around with it and see how it goes. Thanks a lot guys!

EDIT: Absolutely the problem. Works great now. Thanks again.
 

upandaway

Member
"Oh upandaway, I see you're attempting to code some graphics. Yes, yes, it's the same exact code you've tried last week down to the letter that worked last week, yes. No it won't work this time, why did you ever think that it will? Be reasonable."
 

Slavik81

Member
"Oh upandaway, I see you're attempting to code some graphics. Yes, yes, it's the same exact code you've tried last week down to the letter that worked last week, yes. No it won't work this time, why did you ever think that it will? Be reasonable."

This is why configuration management exists.

To help prevent this problem, you can use a source control system like git or hg. If you're willing to do even more work to prevent it, you could consider building only in an isolated container, like a virtual machine, a chroot jail or even a specific OS image.

As for fixing your problem right now, check out ApiTrace. It helped me quite a bit in finding and fixing mistakes in my use of OpenGL calls. Valve released an OpenGL debugger today which might be of aid, as well. I haven't had a chance to try it yet, though.
 

upandaway

Member
ApiTrace looks a bit complicated for me right now, but it looks really cool, I'll keep it in mind. I'm still trying to do something really simple so I'll try and figure it out "normally".
 

g23

European pre-madonna
Hello GAF. New to programming.

Anyways, I'm currently trying to learn both Python and C#. I was wondering what you guys think about these languages and if they are good languages to start off with as a beginner?

Also I would like to know the best (free) resources to learn programming with these respective languages.

For Python I have been using Code Academy and am planning to take an intro course at Coursera. Both have worked out great for me and I'm progressing conveniently with them.

However, I would like to know some tools for C# because I eventually want to break into game development. Any good links to easy tutorials for learning the basics of C#? Thank you.
 

Water

Member
Hello GAF. New to programming.

Anyways, I'm currently trying to learn both Python and C#. I was wondering what you guys think about these languages and if they are good languages to start off with as a beginner?
Think of a programming language and associated tools, frameworks, etc. as an alphabet, and programming itself as writing. You have to learn an alphabet before you can start actually learning to write, but you don't become a writer - much less a good writer - by knowing many different alphabets. It's the same with programming; the actual challenge of programming is in building complex systems. Dabbling with several languages immediately doesn't help you to do that, it just wastes time. Once you are a good programmer, it's much easier to absorb more languages and tools when that is necessary.

So dump one of those languages, and do a lot of work in the other. I don't recommend touching a second language at least for a year. When you get deeper into things, you'll soon understand just how little you know.

Python is better for beginners, both for its own characteristics and because there's more and better beginner material out for it. You can get into making games very easily with Pygame. The only reason to start with C# would be to use Unity, but I don't think that is so good for general programming skill development.
 

g23

European pre-madonna
Think of a programming language and associated tools, frameworks, etc. as an alphabet, and programming itself as writing. You have to learn an alphabet before you can start actually learning to write, but you don't become a writer - much less a good writer - by knowing many different alphabets. It's the same with programming; the actual challenge of programming is in building complex systems. Dabbling with several languages immediately doesn't help you to do that, it just wastes time. Once you are a good programmer, it's much easier to absorb more languages and tools when that is necessary.

So dump one of those languages, and do a lot of work in the other. I don't recommend touching a second language at least for a year. When you get deeper into things, you'll soon understand just how little you know.

Python is better for beginners, both for its own characteristics and because there's more and better beginner material out for it. You can get into making games very easily with Pygame. The only reason to start with C# would be to use Unity, but I don't think that is so good for general programming skill development.

Ohic got it. So for game development is there any other reason to learn C# besides using Unity and XNA/MonoGame?

Alas, the ultimate goal here is to start coding games and eventually break into the industry, and i guess my question is if learning Python first and then moving on to C# (or whatever) the best road to take?

-Thanks

Also, why don't you think Unity is good for skill development? What other engine(?) would you recommend for beginners?
 

Water

Member
Ohic got it. So for game development is there any other reason to learn C# besides using Unity and XNA/MonoGame?

Alas, the ultimate goal here is to start coding games and eventually break into the industry, and i guess my question is if learning Python first and then moving on to C# (or whatever) the best road to take?
It's a good road. If someone says they know what the best road is, they are bullshitting. :)

AFAIK, C# is pretty frequently used in in-house tools for game development in addition to being the Unity and Monogame language. And it's a very "mainstream style" language, so languages like Java are going to be trivial after learning C#.
Also, why don't you think Unity is good for skill development? What other engine(?) would you recommend for beginners?
I recommend starting from a raw framework like Pygame instead of any engine, because you are trying to become a full-fledged programmer. Unity is a black box. It does a lot of things for you that you should initially think through and build by yourself. It makes it hard to organize your code and data in certain ways that would normally make the most sense, and promotes some habits that are bad for programming outside Unity.
 
This is probably a really dumb question but in Python how do I modify a multiple of a pixel?
Like let's say I want to modify the color value of every second pixel in a picture, how would I tackle that? Any help is appreciated.
Example: 5x5 picture, so for the first row I'd want to modify pixels 0, 2, and 4.


(sorry if this is the wrong place to ask this)
 

Chris R

Member
This is probably a really dumb question but in Python how do I modify a multiple of a pixel?
Like let's say I want to modify the color value of every second pixel in a picture, how would I tackle that? Any help is appreciated.
Example: 5x5 picture, so for the first row I'd want to modify pixels 0, 2, and 4.


(sorry if this is the wrong place to ask this)

I'd use some form of modulus, with some kind of formula like (5x+y)%2 == 0, however you would do that in Python.
 

Hylian7

Member
Dumb Java question. I'm making something that involves a timer that counts down (and displays) and I'm curious which of these methods is the best way to do it.

A. Using System.nanoTime() However I have tried and tried this and I feel like I'm banging my head against the wall with it and it's not working for me. I get weird results like it counting down into negatives. I'm making sure to divide by 1000000000 for seconds. I did a bit of research and read that this is apparently accurate, however it's not precise, if that makes sense.

B. Same thing as method A, but using System.currentTimeMillis(). Also ran into similar problems.

C. Using Timer and TimerTask.
 

hateradio

The Most Dangerous Yes Man
Dumb Java question. I'm making something that involves a timer that counts down (and displays) and I'm curious which of these methods is the best way to do it.
Not sure, but you could try using Thread.sleep() for a second or however much you need before the next call to the next number.
 

Magni

Member
This is probably a really dumb question but in Python how do I modify a multiple of a pixel?
Like let's say I want to modify the color value of every second pixel in a picture, how would I tackle that? Any help is appreciated.
Example: 5x5 picture, so for the first row I'd want to modify pixels 0, 2, and 4.


(sorry if this is the wrong place to ask this)

How are your pixels stored? Array of arrays?
Something like:

Code:
for i in range(0, pixels.length/2):
  modify_color(pixels[i*2])
 
Dumb Java question. I'm making something that involves a timer that counts down (and displays) and I'm curious which of these methods is the best way to do it.

A. Using System.nanoTime() However I have tried and tried this and I feel like I'm banging my head against the wall with it and it's not working for me. I get weird results like it counting down into negatives. I'm making sure to divide by 1000000000 for seconds. I did a bit of research and read that this is apparently accurate, however it's not precise, if that makes sense.

B. Same thing as method A, but using System.currentTimeMillis(). Also ran into similar problems.

C. Using Timer and TimerTask.
A should work, I just made a small Timer class and from about 10 minutes of trying out stuff, it should work okay (with System.nanoTime). Maybe you're having rounding problems when converting to seconds? Try dividing by 1e9 to get a double value of the seconds, then casting to int (or better, using Math.round). Seeing actual source code would be helpful too.
 

Slavik81

Member
I don't know what the Java standard library contains, but typically you cannot be certain how much time will pass while your program is sleeping. Most timers promise very little in terms of accuracy and precision. This makes it very difficult to specify your perfect update interval.

What you can do precisely and accurately is measure how much time has elapsed between timeout events or sleep start/end. So, whenever your update rolls around, you now know how long it took.

If you decouple update frequency (which is hard to control) from the update value (which can be calculated precisely), you'll end up with a much better countdown display.
 

poweld

Member
Dumb Java question. I'm making something that involves a timer that counts down (and displays) and I'm curious which of these methods is the best way to do it.

A. Using System.nanoTime() However I have tried and tried this and I feel like I'm banging my head against the wall with it and it's not working for me. I get weird results like it counting down into negatives. I'm making sure to divide by 1000000000 for seconds. I did a bit of research and read that this is apparently accurate, however it's not precise, if that makes sense.

B. Same thing as method A, but using System.currentTimeMillis(). Also ran into similar problems.

C. Using Timer and TimerTask.
this isn't too complicated and i think you're close. you probably just have a bug in your code. please post it here so we can help.
 

Magni

Member
Dumb Java question. I'm making something that involves a timer that counts down (and displays) and I'm curious which of these methods is the best way to do it.

A. Using System.nanoTime() However I have tried and tried this and I feel like I'm banging my head against the wall with it and it's not working for me. I get weird results like it counting down into negatives. I'm making sure to divide by 1000000000 for seconds. I did a bit of research and read that this is apparently accurate, however it's not precise, if that makes sense.

B. Same thing as method A, but using System.currentTimeMillis(). Also ran into similar problems.

C. Using Timer and TimerTask.

If it's counting down into negatives, test for an inequality, not an equality. time < 0, not time == 0.
 
Ohic got it. So for game development is there any other reason to learn C# besides using Unity and XNA/MonoGame?

Alas, the ultimate goal here is to start coding games and eventually break into the industry, and i guess my question is if learning Python first and then moving on to C# (or whatever) the best road to take?

-Thanks

Also, why don't you think Unity is good for skill development? What other engine(?) would you recommend for beginners?

C# can be useful for tools if you learn MFC or WPF. Learn to love XML and JSON at some point as well.

The version of C# that Unity uses is a bit different than what you would use for regular application development.

Honestly though learning a compiled language like C# and an interpreted language like Python is a good start no matter what you want to do.

At some point you might want to learn a bit about lower level languages like C and C++, even if you never end up using them I think that learning about pointers and object interaction is useful for more managed languages like Java/C#/Obj-C.

My personal feeling is that if you want to be a good Software Engineer/Developer then you should always be open to learning new languages.
 

Slavik81

Member
Ohic got it. So for game development is there any other reason to learn C# besides using Unity and XNA/MonoGame?
C# is widely used for developing specialized tools in Windows-dominated environments. Internal corporate software, game development tools and a lot of other things are often built in C#.

It's also sometimes used for web development. One of the most notable examples is StackOverflow, which is built on ASP.Net.
 

Kansoku

Member
So I got this school work, and I have no clue how to do this.

"Some guy dropped a bunch of hard drive discs that had the same info on them, and they all got split in half, but at different places." I have to write a program that will piece this data back together.
Example:

IN:
011
0111
101
11
1101

OUT:
1110111

So, I was thinking of using substrings, but there's cases that it won't work. Like the "11" refers to the first 2 ones 1110111, but it can be placed as the last two, for example. Or in case I end up with two pieces like 1010 and 1011. It can be 101011, 10101011 or 10111010. And thus I have no clue how to go about this. If some one can point me in the right direction, it would be great.
 

tokkun

Member
how do I make a post-fix operator increase a given variable by more than one?(ie 2?)

Needs more details. What language? Primitives or objects? Why do you want to it?

So I got this school work, and I have no clue how to do this.



So, I was thinking of using substrings, but there's cases that it won't work. Like the "11" refers to the first 2 ones 1110111, but it can be placed as the last two, for example. Or in case I end up with two pieces like 1010 and 1011. It can be 101011, 10101011 or 10111010. And thus I have no clue how to go about this. If some one can point me in the right direction, it would be great.

Based on the details you have given, the problem is not adequately defined in a way that leads to only one possible solution. It is clearly poorly worded, since "split in half at different places" is contradictory. Maybe they mean "split into two pieces at different places", however even this is not consistent with the example input data.
 

Kansoku

Member
Based on the details you have given, the problem is not adequately defined in a way that leads to only one possible solution. It is clearly poorly worded, since "split in half at different places" is contradictory. Maybe they mean "split into two pieces at different places", however even this is not consistent with the example input data.

Yes, I had to translate from Portuguese, so I didn't get it totally right. But basically, I have a bunch of pieces and have to piece them together.
 

Water

Member
Yes, I had to translate from Portuguese, so I didn't get it totally right. But basically, I have a bunch of pieces and have to piece them together.
What do you know about the pieces? Based on the example data you show here, some pieces are missing. For instance, the same disk that had the "0111" piece should have had a "111" piece as well, but there's no "111" piece or smaller pieces that would together form "111". Do we have only one piece from each disk?
Do you know how many disks there were?
Do you know what the length of the result is?
 

Magni

Member
So I got this school work, and I have no clue how to do this.



So, I was thinking of using substrings, but there's cases that it won't work. Like the "11" refers to the first 2 ones 1110111, but it can be placed as the last two, for example. Or in case I end up with two pieces like 1010 and 1011. It can be 101011, 10101011 or 10111010. And thus I have no clue how to go about this. If some one can point me in the right direction, it would be great.

Each string was split in exactly two substrings? Your example doesn't make sense in that case (the '11' string specifically).

If each string is split in two substrings:

-length of the string = shortest_substring.length + longest_substring.length
 

Onemic

Member
Needs more details. What language? Primitives or objects? Why do you want to it?

nvm, I got it. Just wanted to make a for loop where the i value increments by 2 instead of by one so that I can access every second character in a given string to perform validation. forgot you could just do i +=2
 
Top Bottom