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.---------.[-]<<<-<->>-]>>>>>>>>>>>>>>>>[<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<<<[>[-]+<-]>[<+>>+++++++++++[>+++++++>++++++++++>+++++++++>+++>++++<<<<<-]>-.>+.+++++++.>++.<---.>>-.<<------.>.>.<<+.+.+++++.>>>++...[-]<[-]<[-]<[-]<[-]<++++++++++.[-]>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>->[-]<[>+<-][-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>>>[-]<<[<<<<<<+>>>>>>-]->>[<<<<<<<<-<+>>>>>>>>>-]<<<<<<<<<[>>>>>>>>>+<<<<<<<<<-]>[>>>>>>+<<<<<<[-]]<->>>>>>>[<<<<<<<->>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>>>>>>>[>>>>>>>+<<<<<<<<<<<<<<<<->>>>>>>>>[-]]<<<<<<<<-]<[>[-]+<-]>[<+>>++++++[>++++++++++<-]>.-------------.++++.<<<<->>-]<<]
pseudocode
loop
get a random byte
until random byte is >2 and <21
point to byte
[
output "Loves me..."
decrease byte by 1
if byte is 0
output "<3"
exit
eif
output "Loves me not..."
decrease byte by 1
]
output "</3"
Numune
Çalıştırıldığında, program girişi bekleyen etkileşimli bir oturuma girer. Giriş bir sayı olmalıdır. Bu sayı bir tohum olarak kullanılır.
Tohum: 1 (rastgele sayı 5, 218.158.042 işlem alıyor)
1
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
<3
Tohum: 3 (rastgele sayı 20, 463,253,048 işlem alır)
3
Loves me...
Loves me not...
(...)
Loves me...
Loves me not...
</3
Sonucu hesaplamanızı öneririm 6
, çünkü 2,105,900,375
sonucu hesaplamak için yinelemeler yapılır :).
Derleme / Çalıştırma
Bunun için hızlı bir tercümana ihtiyacınız var. Test ettiğim hiçbir çevrimiçi tercüman çalıştırma hızını kaldıramaz. İps (saniye başına yineleme) daha fazla olmalıdır 100,000,000
. Bu yüzden başka bir çözüm buldum.
Bu, Brainfuck'ta yazılmış, C'ye derleyici olan bir Brainfuck. Sen kullanmanızı öneririz saf C. I kodumu transpile için herhangi bir çevrimiçi tercüman kullanabilirsiniz brainfuck.tk . Kodumu stdin girişine yapıştırın, bu kodu kod girişine yapıştırın:
+++[>+++++<-]>>+<[>>++++>++>+++++>+++++>+>>+<++[++<]>---]>++++.>>>.+++++.>------.<--.+++++++++.>+.+.<<<<---.[>]<<.<<<.-------.>++++.<+++++.+.>-----.>+.<++++.>>++.>-----.<<<-----.+++++.-------.<--.<<<.>>>.<<+.>------.-..--.+++.-----<++.<--[>+<-]>>>>>--.--.<++++.>>-.<<<.>>>--.>.<<<<-----.>----.++++++++.----<+.+++++++++>>--.+.++<<<<.[>]<.>>,[>>+++[<+++++++>-]<[<[-[-<]]>>[>]<-]<[<+++++>-[<+++>-[<-->-[<+++>-[<++++[>[->>]<[>>]<<-]>[<+++>-[<--->-[<++++>-[<+++[>[-[-[-[->>]]]]<[>>]<<-]>[<+>-[<->-[<++>-[<[-]>-]]]]]]]]]]]]]<[-[-[>+<-]>]<[<<<<.>+++.+.+++.-------.>---.++.<.>-.++<<<<.[>]>>>>>>>>>]<[[<]>++.--[>]>>>>>>>>]<[<<++..-->>>>>>]<[<<..>>>>>]<[<<..-.+>>>>]<[<<++..---.+>>>]<[<<<.>>.>>>>>]<[<<<<-----.+++++>.----.+++.+>---.<<<-.[>]>]<[<<<<.-----.>++++.<++.+++>----.>---.<<<.-[>]]<[<<<<<----.>>.<<.+++++.>>>+.++>.>>]<.>]>,]<<<<<.<+.>++++.<----.>>---.<<<-.>>>+.>.>.[<]>++.[>]<.>[.---->.---,....]
Kaynağı indirin ve derleyin:
gcc.exe -c main.c -o main.o
gcc.exe main.o -o loveme.exe
Ayrıca çevrimiçi olarak C kodunun bir kopyasını da çalıştırabilirsiniz: via. CodingGround .
optimizasyonları
Hala yapılacak bazı işler var, ancak hücrenin yeniden kullanımı neredeyse en uygun seviyede.
Uyarılar
Kelimeleri veya cümleleri tohum olarak kullanabilirsiniz:
Programming Puzzles & Code Golf
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me...
<3