I'm tired and can't sleep

  • Thread starter Dembadon
  • Start date
  • #1
Dembadon
Gold Member
624
89
...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?
 

Answers and Replies

  • #3
128
1
[/QUOTE]
Code:
[email protected]:~$ 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("[b][u][i]%s[/b][/u][/i]", args[0].charAt(i));
            else
                r += args[0].charAt(i);
        }
        System.out.println(r);
    }
}
[email protected]:~$ javac bored.java
[email protected]:~$ java bored "Do you know how long this took?"
[b][u][i]D[/b][/u][/i]o [b][u][i]y[/b][/u][/i]o[b][u][i]u[/b][/u][/i] k[b][u][i]n[/b][/u][/i]o[b][u][i]w[/b][/u][/i] h[b][u][i]o[/b][/u][/i]w [b][u][i]l[/b][/u][/i]o[b][u][i]n[/b][/u][/i]g [b][u][i]t[/b][/u][/i]h[b][u][i]i[/b][/u][/i]s [b][u][i]t[/b][/u][/i]o[b][u][i]o[/b][/u][/i]k[b][u][i]?[/b][/u][/i]
 
  • #4
Borek
Mentor
28,596
3,073
Code:
[noparse][email protected] ~/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
[email protected] ~/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][/noparse]
Do you know how long this took?

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

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

Related Threads on I'm tired and can't sleep

  • Last Post
Replies
3
Views
4K
Replies
2
Views
6K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
15
Views
3K
Replies
17
Views
3K
  • Last Post
Replies
15
Views
4K
  • Last Post
2
Replies
35
Views
3K
Replies
7
Views
1K
Replies
39
Views
4K
Replies
23
Views
6K
Top