| Bytes | Lang | Time | Link |
|---|---|---|---|
| 056 | Raku Perl 6 rakudo | 170501T225641Z | bb94 |
| 039 | Vyxal 3 | 240215T165618Z | pacman25 |
| 065 | K ngn/k | 221013T143129Z | oeuf |
| nan | 221013T133156Z | bigyihsu | |
| 073 | Vyxal | 221013T125739Z | DialFros |
| nan | 200509T204239Z | m4n0 | |
| 089 | Batch | 170428T131453Z | Somethin |
| 091 | Wren | 200106T131808Z | user8505 |
| 058 | SmileBASIC | 180303T162908Z | 12Me21 |
| 022 | Husk | 170927T024211Z | Leo |
| 046 | /// | 170926T232411Z | Leo |
| 041 | J | 170926T035629Z | FrownyFr |
| 052 | Jq 1.5 | 170926T020521Z | jq170727 |
| 087 | Tcl | 170926T001601Z | sergiol |
| 091 | Haskell | 170914T173326Z | maple_sh |
| 053 | Recursiva | 170912T122230Z | 0xffcour |
| 085 | Javascript | 170912T134820Z | Brian H. |
| 049 | /// | 170912T134227Z | DELETE_M |
| 054 | 05AB1E | 170428T170950Z | Magic Oc |
| 052 | PowerShell | 170428T130225Z | colsw |
| 097 | cat | 170502T174829Z | yo' |
| 082 | Groovy | 170505T205527Z | staticme |
| 067 | Perl | 170429T024018Z | Sinan |
| 7069 | ClojureScript | 170502T220448Z | madstap |
| 083 | R | 170428T072600Z | Masclins |
| 047 | APL Dyalog | 170502T130402Z | Adá |
| 076 | SmileBASIC 3 | 170502T123904Z | snail_ |
| nan | C# 103 99 Bytes | 170502T122353Z | raznagul |
| 109 | C# | 170428T093002Z | Mayube |
| 095 | Haskell 95 Bytes | 170502T094654Z | Pharap |
| 158 | C++ 158 Bytes | 170502T100813Z | Pharap |
| 066 | ksh / bash / sh | 170430T160915Z | ULick |
| 068 | Hack | 170428T095356Z | Mayube |
| 096 | C | 170502T034559Z | Imran Kh |
| 071 | Wolfram Mathematica | 170501T114418Z | Sauron |
| 100 | MySQL | 170428T204552Z | jlmt |
| 074 | Python 2 | 170428T145614Z | totallyh |
| nan | 170428T023258Z | hucancod | |
| 061 | PHP | 170428T071317Z | Jör |
| 109 | Emacs Lisp | 170429T120234Z | Lord Yuu |
| 072 | Perl | 170427T214427Z | steve |
| 075 | Batch | 170428T230606Z | Neil |
| 277 | Brainfuck Substitutor | 170428T163157Z | Okx |
| 074 | Perl | 170428T071038Z | ephemien |
| 090 | Bash | 170428T155807Z | Katharin |
| 061 | Ruby | 170427T205017Z | Value In |
| 094 | Fourier | 170428T165611Z | Beta Dec |
| 105 | Matlab | 170428T112214Z | user1326 |
| 022 | Jelly | 170427T200111Z | Dennis |
| 092 | AHK | 170427T210758Z | Engineer |
| 103 | Java 7 | 170428T073759Z | Kevin Cr |
| 041 | Pyth | 170427T205601Z | Maria |
| 085 | C | 170427T231917Z | 2501 |
| 039 | Retina | 170427T220251Z | Leo |
| 059 | Octave | 170427T195852Z | Stewie G |
| 060 | Retina | 170427T213729Z | Digital |
| 072 | Sed | 170427T212852Z | Digital |
| 038 | 05AB1E | 170427T205700Z | Emigna |
| 060 | Python 2 | 170427T201336Z | xnor |
| 036 | V | 170427T201848Z | DJMcMayh |
| 070 | JavaScript | 170427T200138Z | powelles |
Raku (Perl 6) (rakudo), 61 60 56 bytes
$!="Hare ";"$!$_ $!$_
$_ $_ $!$!".say for <Krishna Rama>
K (ngn/k), 65 bytes
{`0:,/("Hare ";"Krishna ";"Rama ";"\n")@"ababdbbaadacacdccaa"-97}
This has to be the longest K program I have ever written. Takes "aba..."-97 from the Octave answer.
Go, 167 bytes
func f(){w,i,k:=[]string{"Hare","Krishna","Rama"},[]int{0,1,0,1,1,1,0,0,2,0,2,0,2,2,0,0},0
for _,e:=range i{if k>3{print(`
`)
k=0}
if k>0{print(" ")}
print(w[e])
k++}}
Prints to STDERR.
Vyxal, 73 bytes
`Hλ½ K≥τ⇧¨ Hλ½ K≥τ⇧¨
K≥τ⇧¨ K≥τ⇧¨ Hλ½ Hλ½
Hλ½ R□• Hλ½ R□•
R□• R□• Hλ½ Hλ½`
CSS: 132 Bytes
No use of HTML. Not the best, not the worst but the Brainfuck (No. of bytes) and Matlab solutions (Direct output) made me post this. Can some CSS wizards help save some bytes?
body:after{content:"Hare Krishna Hare Krishna\AKrishna Krishna Hare Hare\AHare Rama Hare Rama\ARama Rama Hare Hare";white-space:pre}
CSS with superpowers could not beat it until someone can prove me wrong.
SASS: 163 Bytes
$a:Hare;$b:Krishna;$c:Rama;body:after{content:"#{$a} #{$b} #{$a} #{$b}\A#{$b} #{$b} #{$a} #{$a}\A#{$a} #{$c} #{$a} #{$c}\A#{$c} #{$c} #{$a} #{$a}";white-space:pre}
Run it on:
Batch, 117 111 103 89 bytes
@set a=Hare
@for %%A in ("Krishna " "Rama ") do @echo %a%%%~A%a%%%~A^
%%~A%%~A%a%%a%
Down to 103 now that trailing newlines are allowed. Down to 89 after adapting the Powershell answer.
^\n\n is used to insert a newline at the end of the first line and there's a space after Hare.
Wren, 91 bytes
Fn.new{
var n="Hare"
return["Krishna","Rama"].map{|i|[n,i,n,i,"
"+i,i,n,n].join(" ")+"
"}
}
Explanation
Fn.new{ // New anonymous function
var n="Hare" // Define a template constant
return["Krishna","Rama"].map{|i|[n,i,n,i, /* Map using the rule*/"
"+i,i,n,n].join(" ")+ /* [n,i,n,i,"\n",i,i,n,n]*/"
"}
}
SmileBASIC, 58 bytes
We can use the fact that the second half is the same as the first, with "Krishna" replaced by "Rama"
P"Krishna
P"Rama
DEF P K?("Hare "+K)*2?K*2;"Hare "*2
END
(Note trailing spaces)
Storing "Hare " in a variable is the same length.
Husk, 22 bytes
ṁSeÖ>m´+Πmw¶¨Hȧeȷ#,R□m
I've worked for quite some time on this answer since I wanted to beat the "compressed number" algorithm of the current top answer by exploiting more of the regularities in the text.
In the end I "only" managed to tie its score. I actually have in mind a couple of builtins for Husk that could easily save more bytes, but implementing them before posting this answer would have felt too much like cheating.
Explanation
Husk automatically prints a matrix of strings by joining them with spaces and newlines. In this case we are actually trying to build the matrix
[["Hare","Krishna","Hare","Krishna"],
["Krishna","Krishna","Hare","Hare"],
["Hare","Rama","Hare","Rama"],
["Rama","Rama","Hare","Hare"]]
which will implicitly get printed to StdOut as the required text. For simplicity, I will show each step of computation as if it was printed by a full program, joining strings with spaces and newlines.
We need to work with "Hare" and ("Krishna" and "Rama"): mw¶¨Hȧeȷ#,R□m
¨Hȧeȷ#,R□m is a compressed string; Husk has a dictionary containing common n-grams (sequences of characters) which are encoded with symbols possibly reminding of the original n-gram. For example, the H here is a plain "H", while ȧe is "are\n".
The plaintext string this decodes to is "Hare\nKrishna Rama" (where \n is an actual newline).
¶ splits this string on the newline, and mw splits each line into words. The output we get up to here is:
Hare
Krishna Rama
"Hare" should pair with both of the other words: Π
Cartesian product of all the lines. This means that we pair each element of the first line with each element of the second line. Our result is:
Hare Krishna
Hare Rama
The first and third lines are just those words repeated twice: m´+
Concatenate each of the lines with itself. (´ makes + use a single argument twice, and m maps this function to each line). We get:
Hare Krishna Hare Krishna
Hare Rama Hare Rama
The other lines are the previous lines sorted in reverse alphabetical order: ṁSeÖ>
This is not as weird as it looks. Ö> sorts a list in descending order. With SeÖ> we create a two-element list with the original argument before and after having been sorted. ṁ maps this function to each line, and concatenates the resulting lists. This is finally:
Hare Krishna Hare Krishna
Krishna Krishna Hare Hare
Hare Rama Hare Rama
Rama Rama Hare Hare
///, 46 bytes
/4/Hare //k/Krishna //X/4k4k
kk44/X
/k/Rama /X
There was already one answer in ///, but this one adds a bit of complexity to remove some bytes.
In pseudocode this could translate to:
4="Hare "
k="Krishna "
X=4+k+4+k+'\n'+k+k+4+4
print(X+'\n')
replace k with "Rama "
print(X)
(I wanted to use h as the letter to substitute with "Hare ", but "Krishna" also contains an h, so that messed up the substitutions and I had to switch it with 4)
J, 49 41 bytes
;"1{&(<;.2'Hare Krishna Rama ')(,-)#:5 12
How it works
#:5 12 to binary [(0 1 0 1), (1 1 0 0)]
( -) negate [(0-1 0-1),(-1-1 0 0)]
(, ) append [(0 1 0 1),(1 1 0 0),(0-1 0-1),(-1-1 0 0)]
(<;. 'Hare Krishna Rama ') split by
2 the last character, keep it in
{& negative argument selects from the end
;"1 get rid of the ASCII boxes
Tcl, 87 bytes
puts "[set h Hare] [set k Krishna] $h $k
$k $k $h $h
$h [set r Rama] $h $r
$r $r $h $h"
Haskell, 92 91 bytes
g=mapM_ putStr$(!!)["Hare ","Krishna ","Rama ","\n"]<$>(read.(:[]))<$>"0101311003020232200"
Edit: removed concat, used mapM_ for putStr instead
Javascript 85 bytes
I know there's a better answer already, but i wanted to give it a try anyway, the method is pretty different as you'll see:
a=["Krishna ","Rama "];q="Hare ";b=(z)=>q+a[z]+q+a[z]+`
`+a[z]+a[z]+q+q+`
`;b(0)+b(1)
a=["Krishna ","Rama "];q="Hare ";b=(z)=>q+a[z]+q+a[z]+`
`+a[z]+a[z]+q+q+`
`;console.log(b(0)+b(1));
Please note that i had to put the console.log() in a weird spot, if you just paste the code block into the console it'll print the mantra.
dumbded down better golfed version 76 bytes:
a="Krishna ";b="Rama ";c="Hare ";d=`
`;c+a+c+a+d+a+a+c+c+d+c+b+c+b+d+b+b+c+c
a="Krishna ";b="Rama ";c="Hare ";d=`
`;console.log(c+a+c+a+d+a+a+c+c+d+c+b+c+b+d+b+b+c+c)
///, 49 bytes
/#/Hare //k/Krishna //j/Rama /#k#k
kk##
#j#j
jj##
Although /// is an esoteric language, this one is shorter than most of the other (non-golfing, and a bad implementation of this problem in Retina) languages here. Mostly because /// has too few functionalities, that they can be represented in few bytes.
05AB1E, 54 bytes
•4Ñ••}ò´••9Ä•)©\•2}¾S•3BRv®yè8ÝJ"ahrekisnm"‡})4ôvyðý™,
•4Ñ• # Hare
•}ò´• # Krishnu
•9Ä•)©\ # Rama
•2}¾S•3BR # Sequencing data.
v®yè8ÝJ"ahrekisnm"‡} # For each sequence part, push the right word.
)4ôvyðý™, # Format it correctly.
05AB1E changed its base-214 encryption to base-255; this is the reason this submission no longer works; however, it was valid at the time.
PowerShell, 73 53 52 Bytes
absolutely demolished by Jeff Freeman - using an actual newline instead of \n saves another byte, and also saved one more on the array format. (from (1,2) to ,1,2)
-1 thanks to TesselatingHeckler, no comma in the array notation.
$a="Hare ";"Krishna ","Rama "|%{"$a$_$a$_
$_$_$a$a"}
My old answer - Tried a few other replace methods but all ended up being slightly longer somehow.
$a,$b,$c="Hare ","Krishna ","Rama ";"$a$b$a$b
$b$b$a$a
$a$c$a$c
$c$c$a$a"
there are newlines in the string.
pretty straightforward, uses the fact that powershell will expand variables within doublequotes, and a shorter method of assigning variables to save some bytes.
cat 97 bytes
Hare Krishna Hare Krishna<CR>
Krishna Krishna Hare Hare<CR>
Hare Rama Hare Rama<CR>
Rama Rama Hare Hare<^D>
I consider <^D> as two characters, whence 97
Groovy, 82 bytes
a=["Hare ","Krishna ","Rama ","\n"]
"0101311003020232200".each{print a[it as int]}
An improvement of my previous answer (1 byte longer)
h="Hare "
k="Krishna "
r="Rama "
n="\n"
print h+k+h+k+n+k+k+h+h+n+h+r+h+r+n+r+r+h+h
Perl, 67 bytes
Inspired by this JavaScript entry.
$_='0101
1100
0202
2200
';s/./qw'Hare Krishna Rama'[$&].$"/ge;print
Perl, 67 bytes
@_=<Hare Krishna Rama>;print"@_[split//]\n"for<0101 1100 0202 2200>
Clojure(Script), 70 bytes (69 bytes?)
(def a"Hare")(run! #(println a % a %(str"\n"%)% a a)["Krishna""Rama"])
This version with 69 bytes will only work at the repl, because map is lazy and I don't use the return value for anything. Dunno how the rules work in this case...
(def a"Hare")(map #(println a % a %(str"\n"%)% a a)["Krishna""Rama"])
R, 75 85 83 bytes
cat(x<-c("Hare ","Krishna ","\n")[c(1,2,1:3,2,2,1,1,3)],sub(x[2],"Rama ",x),sep="")
It creates a vector with Hare , Krishna , and the newline, takes the ones needed, and then repeats it replacing Krishna by Rama .
Needed to include the space on every word and sep="" because otherwise cat() would put a space at the beginning of each line.
APL (Dyalog), 47 bytes
Requires ⎕IO←0 which is default on many systems.
↑∊¨↓'Krishna ' 'Hare ' 'Rama '[(4⍴3)⊤8×4 1 5 2]
8×4 1 5 2 multiply; [32,8,40,16]
(4⍴3)⊤ convert to 4-digit base 3; matrix [[1,0,1,0],[0,0,1,1],[1,2,1,2],[2,2,1,1]]
…[…] index
↓ split into list of lists
∊¨ enlist (flatten each)
↑ mix into matrix (padding with spaces)
SmileBASIC 3, 76 bytes
Straightforward answer with string multiplication. ? is print.
?"Hare Krishna "*2?"Krishna "*2+"Hare "*2?"Hare Rama "*2?"Rama "*2+"Hare "*2
C# 103 99 Bytes
()=>{string a="Hare ",b="Krishna ",c="Rama ",d="\n";return a+b+a+b+d+b+b+a+a+d+a+c+a+c+d+c+c+a+a;};
Ungolfed full program:
class A
{
static void Main()
{
System.Func<string> f =
() =>
{
string a = "Hare ",
b = "Krishna ",
c = "Rama ",
d = "\n";
return a + b + a + b + d + b + b + a + a + d + a + c + a + c + d + c + c + a + a;
};
System.Console.Write(f());
}
}
C#, 109 bytes
void a(){Console.Write("{0}{1}{0}{1}\n{1}{1}{0}{0}\n{0}{2}{0}{2}\n{2}{2}{0}{0}","Hare ","Krishna ","Rama ");}
Fairly straightforward, Console.Write implicitly formats the string, and using Write instead of WriteLine not only saves 4 bytes, but avoids a trailing newline. Uses Unix-style newlines so might not work so well on windows, extra 6 bytes for windows by changing \n to \r\n
This method will output directly to the console, if you prefer a method that returns a string:
C#, 118 bytes
string a(){return string.Format("{0}{1}{0}{1}\n{1}{1}{0}{0}\n{0}{2}{0}{2}\n{2}{2}{0}{0}","Hare ","Krishna ","Rama ");}
Alternatively if you need a fully stand-alone and compilable program:
C#, 135 bytes
class A{static void main(){System.Console.Write("{0}{1}{0}{1}\n{1}{1}{0}{0}\n{0}{2}{0}{2}\n{2}{2}{0}{0}","Hare ","Krishna ","Rama ");}}
This should work as a compiled program provided you set A as the entry class.
Haskell 103 95 Bytes
main=putStr$concat$concat$[[h,x,h,x,n,x,x,h,h,n]|x<-["Krishna ","Rama "]]where h="Hare ";n="\n"
Old 103 Bytes:
main=putStr$concat[h,k,h,k,n,k,k,h,h,n,h,r,h,r,n,r,r,h,h] where h="Hare ";k="Krishna ";r="Rama ";n="\n"
C++ 158 Bytes
#include <iostream>
#define H "Hare "
#define K "Krishna "
#define R "Rama "
#define N "\n"
void m(){std::cout<<(H K H K N K K H H N H R H R N R R H H);}
ksh / bash / sh, 66 bytes
h=Hare;for j in Krishna Rama;do echo $h $j $h $j"
"$j $j $h $h;done
Hack 68 bytes
<?hh echo strtr("0101
1100
0202
2200",["Hare ","Krishna ","Rama "]);
Straight port of the PHP Answer, just wanted to finally get an excuse to use hack in PPCG :D
C 96 bytes
*v[]={"Hare ","Krishna ","Rama ","\n"};
main(){for(long a=0x30ae2305d10;a/=4;printf(v[a&3]));}
You only need two bits of information to figure out which word from the prayer is needed next, so instead of using a bunch of memory and encoding it as a string, you can just encode it as a 40 bit integer (i.e. inside a long int).
Wolfram Mathematica, 71 75 bytes
{"Krishna ","Hare ","Rama ","\n"}[[IntegerDigits[73825885093,4]+1]]<>""
Every part of result was encoded as an index in a list, and every index was encoded as digit of 4-ary integer.
MySQL, 115 100 bytes
(Thanks @manatwork!)
SELECT CONCAT(a,b,a,b,d,b,b,a,a,d,a,c,a,c,d,c,c,a,a)FROM(SELECT'Hare 'a,'Krishna 'b,'Rama 'c,'\n'd)t
Python 2, 92 88 74 bytes
for i in'0101311003020232200':print['Hare','Krishna','Rama','\n'][int(i)],
No, it's not clever, no, it's not the shortest but hey, I'm new to this and it works.
Another solution (84 80 bytes):
h='Hare'
k='Krishna'
r='Rama'
n='\n'
print h,k,h,k,n+k,k,h,h,n+h,r,h,r,n+r,r,h,h
C
154 bytes, 124 bytes, 96 bytes
i;main(){char*c="agagvggaavapapvppaaHare \0Krishna \0Rama \0\n";while(i<19)printf(c+c[i++]-78);}
28 bytes saved, thanks to Dennis
PHP, 61 Bytes
<?=strtr("0101
1100
0202
2200",["Hare ","Krishna ","Rama "]);
simply replacement from the digits as key in the array with the values strtr
Emacs Lisp, 109 bytes
(lambda()(apply'concat(mapcar(lambda(x)(nth(- x ?a)'("Hare ""Krishna ""Rama ""\n")))"ababdbbaadacacdccaad")))
Can theoretically be reduced to 103 bytes by using ^@,^A,^B and ^C instead of a, b, c and d and x instead of (nth(- x ?a)), but then it could not be pasted due to NULL characters.
Perl, 98 72 bytes
@a=("Hare ","Krishna ","Rama ","\n");foreach(split//,'ababdbbaadacacdccaad'){print $a[ord($_)-97]}
98 now reduced to 72, following @hobbs reworking, nice.
print+("Hare ","Krishna ","Rama ",$/)[$_]for'01013110030202322003'=~/./g
Batch, 75 bytes
@for %%h in (Krishna Rama)do @echo Hare %%h Hare %%h&echo %%h %%h Hare Hare
Brainfuck Substitutor, 277 bytes
{--y{-z[<]w++v->u>+<t-[x[-]Hxtuyy-]>-.ax+[ty<]>>-]<-.rx>+[-vwz>-]>.ext>w<y{]>-. x>tt-<]>u]>-.Kxtuyy-]>w.ix+[v-z>{]>.sx+[vv-z>{]>.hx+[v-z>{]>-.nxt>{<yy-]>.!xwwwww.Rxtuy]>y.mx+[v-z>+>{]>.
Hare Krishna Hare Krishna!Krishna Krishna Hare Hare!Hare Rama Hare Rama!Rama Rama Hare Hare
Brainfuck Substitutor (or BFS for short) can redefine characters to be replaced with other characters.
This program redefines the characters of the Hare Krishna mantra with brainfuck 'mini' programs that prints the appropiate characters.
As this is run in succinct mode (which doesn't need any command line arguments and is on my default), we can't redefine newlines (at least, in the current version) so I use the character ! instead - but it still outputs a newline.
This first bit of the program: {--y{-z[<]w++v->u>+<t-[x[-] is short replacements for patterns that come up often in the future.
The interpreter breaks them down like this:
{ equals --
y equals {- equals ---
z equals [<]
w equals ++
v equals ->
u equals >+<
t equals -[
x equals [-]
Similar thing goes for every other character. I used the shortest brainfuck constants on the esolangs wiki page to get my algorithms, and replaced common patterns. There may be other patterns I can replace (my original attempt was 320 bytes), but this is what I have for now.
Perl, 76 74 bytes
$_=121202211;$_.=0 .y/2/3/r;print$_?(0,Hare,Krishna,Rama)[$_].$":$/for/./g
Bash, 93 90 bytes
h="Hare " k="Krishna " r="Rama " s="$h$k$h$k\n$k$k$h$h\n$h$r$h$r\n$r$r$h$h"
echo -e "${s}"
Ruby, 62 61 bytes
As I worked on this it eventually became almost identical to @xnor's Python answer, except Ruby doesn't have spaces between arguments in its print function, forcing me to use joins instead and resulting in a longer answer...
-1 bytes from @manatwork
%w"Krishna Rama".map{|i|puts [h=:Hare,i]*2*' ',[i,i,h,h]*' '}
Fourier, 94 bytes
|72a97a114a101a32a|H|75a114a-9a115a104a+6a97a32a|K|82a97a109a97a32a|RHKHK10aKKHH10aHRHR10aRRHH
Makes good use of functions: H for Hare, K for Krishna and R for Rama.
Now I can't get the song My Sweet Lord out of my head :P
Matlab 139 136 105 bytes (thanks to @2501)
fprintf('Hare Krishna Hare Krishna\nKrishna Krishna Hare Hare\nHare Rama Hare Rama\nRama Rama Hare Hare')
Jelly, 22 bytes
“t,ȧṫÞċḅ»Ḳ“¡¥Ɓc’ṃs4K€Y
How it works
“t,ȧṫÞċḅ»Ḳ“¡¥Ɓc’ṃs4K€Y Main link. No arguments.
“t,ȧṫÞċḅ» Use Jelly's dictionary to yield the string
"Hare Rama Krishna". Fortunately, the words Rama, Krishna,
and hare (lowercase H) are in the dictionary.
Ḳ Split at spaces, yielding ["Hare", "Rama", "Krishna"].
“¡¥Ɓc’ Base-250 literal; yielding 15973600.
ṃ Convert 15973600 to base ["Hare", "Rama", "Krishna"]
(ternary), where "Krishna" = 0, "Hare" = 1, and "Rama" = 2.
s4 Split the resulting string array into chunks of length 4.
K€ Join each of the four chunks by spaces.
Y Join the resulting strings by linefeeds.
AHK, 107 92 bytes
This feels ridiculous but I can't find a shorter means in AHK to do this:
h=Hare
k=Krishna
Send %h% %k% %h% %k%`n%k% %k% %h% %h%`n%h% Rama %h% Rama`nRama Rama %h% %h%
Here's what I tried first that was 107 bytes and tried to be fancy. As Digital Trauma pointed out, though, it would have been shorter to just send the raw text.
n=1212422114131343311
a=Hare |Krishna |Rama |`n
StringSplit,s,a,|
Loop,Parse,n
r:=r s%A_LoopField%
Send %r%
StringSplit creates a pseudo-array with 1 as the first index. So the first term is referenced with s1, the second with s2, etc. Otherwise, there's nothing fancy here.
Java 7, 104 103 bytes
String c(){return"xyxy\nyyxx\nxRama xRama\nRama Rama xx".replace("x","Hare ").replace("y","Krishna ");}
Explanation:
String c(){ // Method without parameters and String return-type
return"xyxy\nyyxx\nxRama xRama\nRama Rama xx" // Return this String
.replace("x","Hare ") // after we've replaced all "x" with "Hare "
.replace("y","Krishna "); // and all "y" with "Krishna "
} // End of method
C, 85 bytes
i;f(){for(i=0;printf("$0$0900$$9$*$*9**$$)"[i++]-36+"Hare \0Rama \0Krishna \0\n"););}
I would prefer a secular mantra, but I hope this is one of those peaceful religions.
See it work here.
This compacts a naive implementation by 23 bytes.
Retina, 39 bytes
hkhk¶kkhh
h
Hare
*`k
Krishna
k
Rama
Mostly plain substitutions, the only "trick" is the modifier * which prints the result of the substitution and then reverts the string back to what it was before.
Octave, 74 59 bytes
[{'Hare ','Krishna ','Rama ',10}{'ababdbbaadacacdccaa'-96}]
Explanation:
{'Hare ','Krishna ','Rama ',10} creates a cell array with three strings, where the fourth is 10 (ASCII-value for newline).
{'ababdbbaadacacdccaa'-96} is a vector that indexes the cell array above. The vector is [1 2 1 2 4 ...] since we subtract 96 from the string ababd....
The surrounding square brackets are used to concatenate the results, instead of getting ans = Hare; and = Krishna; ans = ...
Retina, 60
Direct port of my sed answer:
Hari Krishna .+ $0 $0 :`(\S+)(.*)\b(.+) $0¶$3$2$1 K\S+ Rama
Sed, 72
Score includes +1 for the -r flag.
s/^/Hari Krishna/
s/.*/& &/
s/(\S+)(.*)\b(.+)/&\n\3\2\1/p
s/K\S+/Rama/g
05AB1E, 38 bytes
Can be shortened by 2 bytes if trailing newlines are okay.
“«Î‡Ä¦í¥Â“#€¦`«'kì)™ð«•2ÍZì•3BSè#4ô¨»?
Explanation
“«Î‡Ä¦í¥Â“ # push the string "drama share irish dna"
# # split on spaces
€¦ # remove the first character of each word
` # split to stack as separate words
«'kì # concatenate the last 2 and prepend "k"
)™ # wrap in list and title-case
ð« # append a space to each
•2ÍZì• # push 27073120
3B # convert to base-3: 1212221110100011
Sè # index into the list with each
# # split on spaces
4ô # split into pieces of 4
¨ # remove the last
» # join on spaces and newlines
? # print without newline
Python 2, 60 bytes
a="Hare"
for x in"Krishna","Rama":print a,x,a,x+'\n',x,x,a,a
This seems to beat template-replacement approaches like this attempt.
V, 40, 36 bytes
iHare Krishna
Rama ç^/ä$Ùdww.$2p
Hexdump:
00000000: 6948 6172 6520 4b72 6973 686e 6120 0a0e iHare Krishna ..
00000010: 2052 616d 6120 1be7 5e2f e424 d964 7777 Rama ..^/.$.dww
00000020: 2e24 3270 .$2p
Explanation:
iHare Krishna " Enter 'Hare Krishna' on line 1
<C-n> Rama " Enter 'Hare Rama' on line 2. This works because <C-n>
" autocompletes alphabetically, and 'Hare' comes before 'Krishna'
<esc> " Return to normal mode
ç^/ " On every line:
ä$ " Duplicate the text on the line horizontally
Ù " Make a new copy of the line
dw " Delete a word
w " Move forward a word
. " Delete a word again
$ " Move to the end of the line
2p " And paste what we've deleted twice
The <C-n> command is extremely useful for challenges like this. :)
JavaScript, 75 70 bytes
`0101
1100
0202
2200`.replace(/./g,n=>['Hare ','Krishna ','Rama '][n])
Try it online!
console.log(`0101
1100
0202
2200`.replace(/./g,n=>['Hare ','Krishna ','Rama '][n]))


