Questions tagged [alternate]

194 questions
-1
votes
2 answers

What is a cleaner way to alternate colors in a foreach loop in PHP and when would processing speed really be a factor?

Although this works, speed and cleanliness matter. if (file_exists($fileToCheck)) { $contents = file_get_contents($fileToCheck); $lines = array_reverse(explode("\n", trim($contents))); $line =""; $c = 0; foreach($lines as $row)…
Sabyre
  • 97
  • 10
-1
votes
2 answers

Writing to file alternating between contents of two other separate files

I have two files cats.txt and dogs.txt and I want to alternate between the two creating a third file that contains the content of cats and dogs in an alternating sequence. I solved the problem like this: def combiningFiles(): cats = [] dogs…
-1
votes
1 answer

Is JavaScript able to substitute php?

I have a friend who started learning website development and he's into php now. I, on the other side started studying Javascript. He asked me if it's possible to use JS instead of php code entirely? Well, I started learning JS because someone told…
Zoltán Schmidt
  • 1,286
  • 2
  • 28
  • 48
-1
votes
1 answer

MYSQL Sorting by alternative sets of results by a column

Suppose we have the result set something like this by a column_id: 1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4 I have already tried Usual "order by asc" and it returned me: 1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4 But required result set is:…
-1
votes
2 answers

Finding odd number of occurences and alternating constructions using grep

I have to search in a file with 300 000 lines of brainfuck code with grep for several constructions. First Question I need to find codes like the first code below, i am looking for an alternating + - construction, the other characters are seen as…
fangio
  • 1,746
  • 5
  • 28
  • 52
-1
votes
2 answers

Alternating Words in Strings- Python

I have to create a program that asks the user for two strings and then generates a new string alternating one word from the first string and one word from the second string, where “word” is defined as above as anything between spaces or…
-1
votes
2 answers

Google Maps API Alternative Route Description

I am working with Google Maps API V3 to calculate all the possible routes from a given Source to the specified Destination. For this I takes the Destination and Source as inputs from the user and pass these values in the request with option…
user2004685
  • 9,548
  • 5
  • 37
  • 54
-2
votes
1 answer

SQL using a different approach then CASE statements

SELECT CASE WHEN symbol - 'D' THEN 'Domain' WHEN symbol LIKE 'A%' THEN 'Alpha' WHEN symbol = 'C' THEN 'Charlie' END FROM table I would like to avoid case statements, since its severely impacting query runtime.…
-2
votes
1 answer

How to call three threads in Java alternatively

Given the number 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10, 11, 12 I have Three threads, say Thread-1(print 1), Thread-2(print 2) and Thread-3(print 3) and then again hread-1(print 4), Thread-2(print 5) and Thread-3(print 6) and so on.. How I can call them in…
guru84
  • 87
  • 1
  • 3
-2
votes
2 answers

Two threads kept running without completed in Python

I'm trying to get the result below running 2 threads alternately. *Thread A prints Step 1 and Step 3 and thread B prints Step 2 and Step 4 (I use Python 3.8.5): Step 1 Step 2 Step 3 Step 4 So, with global variables, locks and while statements, I…
-2
votes
1 answer

alternate depending on whether their id is odd or even React

I am using React for a web page. In a component, I have a div on the left and an image on the right. I would like them to alternate depending on whether their id is odd or even. function Item({ title, text, link, img,id }) { return (
-2
votes
1 answer

C++ Fill a 2D vector with alternate values

I have a 2D vector vector of characters grid[j][i] filled with various letters, I would like to create another 2D vector of characters twice the size of grid[j][i] filled alternately with points '.'(or spaces ' ') and grid[j][i] values. For example…
Reblochon Masqué
  • 55
  • 1
  • 1
  • 10
-3
votes
2 answers

Compare hash values stored in text file in Java

I have a text file that stores hash values of files generated in a Java program and I would like to write Java codes to compare the hash values stored in the file to see if they match or not. For example, the text file (md5.txt) contains the…
user3847620
  • 59
  • 4
  • 9
-3
votes
2 answers

marquee behavior:alternate

I search and try a lot to do marquee with property behavior : alternate with jQuery but I don't find any result which compatible with all browser.. please Help me... old marquee MY TEXT what I try…
1 2 3
12
13