Post Reply 
Think you're good at bash? Think again!
Author Message
Joom
WOOP
Worlds End

Posts: 4,206.7320
Threads: 417
Joined: 20th Mar 2009
Reputation: 5.41709
E-Pigs: 134.1772
Offline
Post: #4
RE: Think you're good at bash? Think again!

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash -i

for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  cols[$i]="`tput setaf $i`"
done

L=99
P=100000000
Q=$(( P/100 ))
X=$(( Q*320 / (`tput cols` - 1) ))
Y=$(( Q*210 / `tput lines` ))
y=$(( Q*-105 ))
v=$(( Q*-220 ))
x=$v
 
while (( y<105*Q )); do
 
  while (( x<P )); do
    (( a=b=i=c=0 ))
    while (( a*a + b*b < 4*P**2 && i++ < L )); do
      (( c=a,
         a=(a**2 - b**2)/P + x,
         b=2*b*c/P + y ))
    done
 
    if (( i >= L )); then j=0; else (( j=i%16 )); fi
 
    if (( j>7 )); then (( k=1, j-= 8 )); else k=0; fi
 
    printf "${cols[$j]}#"
 
    (( x+=X ))
  done
  tput sgr0

  (( x=v, y+=Y ))
done


[Image: ROVBdMh.png]
3DS Friend Code: 5000-6045-4964
27/05/2016 03:36 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Think you're good at bash? Think again! - Joom - 27/05/2016 03:36 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: