I'm tired and can't sleep


by Dembadon
Tags: sleep, tired
Dembadon
Dembadon is offline
#1
Nov5-10, 02:50 AM
PF Gold
Dembadon's Avatar
P: 638
...so forgive the stupid game:

What would be the most efficient way to reproduce the following without using keyboard shortcuts for formatting, or any variant of a quote + copy-paste method?

Do you know how long this took?
Phys.Org News Partner Science news on Phys.org
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
dav2008
dav2008 is offline
#2
Nov29-10, 04:03 PM
PF Gold
dav2008's Avatar
P: 623
My submission:

Do you know how long this took?



I'm sure you could write a script in any language to go through any string and append the tags to every other letter.
Carnivroar
Carnivroar is offline
#3
Nov6-12, 01:22 AM
P: 117
[/QUOTE]
raphael@raphael:~$ cat bored.java
public class bored {
    public static void main(String[] args) {
        String r = "";
        int j = 0;
        for(int i = 0; i < args[0].length(); i++) {
            if (args[0].charAt(i) != ' ' && j++ % 2 == 0) 
                r += String.format("%s", args[0].charAt(i));
            else
                r += args[0].charAt(i);
        }
        System.out.println(r);
    }
}
raphael@raphael:~$ javac bored.java
raphael@raphael:~$ java bored "Do you know how long this took?"
Do you know how long this took?

Borek
Borek is offline
#4
Nov6-12, 04:39 AM
Admin
Borek's Avatar
P: 22,708

I'm tired and can't sleep


borek@invincible ~/python $ cat bored.py
text='Do you know how long this took?'
outtext = ''
switch = 1

for c in text:
   if c == ' ':
      outtext += ' '
   else:
      if switch:
         outtext += '[b][u][i]'+c+'[/i][/u][/b]'
      else:
         outtext += c
      switch = 1 - switch

print outtext
borek@invincible ~/python $ python bored.py
[b][u][i]D[/i][/u][/b]o [b][u][i]y[/i][/u][/b]o[b][u][i]u[/i][/u][/b] k[b][u][i]n[/i][/u][/b]o[b][u][i]w[/i][/u][/b] h[b][u][i]o[/i][/u][/b]w [b][u][i]l[/i][/u][/b]o[b][u][i]n[/i][/u][/b]g [b][u][i]t[/i][/u][/b]h[b][u][i]i[/i][/u][/b]s [b][u][i]t[/i][/u][/b]o[b][u][i]o[/i][/u][/b]k[b][u][i]?[/i][/u][/b]
Do you know how long this took?

If you are really bored you should try to code it in brain****

Sigh, one even can't post a proper name of that language.


Register to reply

Related Discussions
If sleep were not required, but just optional, would you ever sleep? General Discussion 43
Sleep / REM Sleep and homeostasis Medical Sciences 14
Tired of the Course! Academic Guidance 4
tired, but can't get no sleep General Discussion 3
I was tired while studying, but now I can't sleep! General Discussion 2