Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Chuck Norris a un clavier avec seulement deux touches. Le 0 et la barre d'espacement lui suffisent pour envoyer un message.
Chuck Norris has a keyboard with only two keys. The 0 and the space bar are enough for him to send a message.
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
38
39
40
41
# Cette version est codée par moi :
@myStr = "Entrez votre phrase à coder en unaire ici "
@myStr = @myStr.reverse
myStrLength = @myStr.length
@myStrB = ""
@anser = nil.to_s
@compter = 0
@myStrB = @myStrB += @myStr.unpack('b7'* myStrLength).to_s.reverse
@myStrB.gsub!('"','')
@myStrB.gsub!(' ','')
@myStrB.gsub!('[','')
@myStrB.gsub!(']','')
@myStrB.gsub!(',','')
@myStrB.downcase
@compter = 0
while @myStrB.length != 0
@current = @myStrB[0]
@current == "1" ? @anser << "0 " : @anser << "00 "
for i in 0..@myStrB.length
@current == @myStrB[i] ? @compter += 1 : break
end
for i in 1..@compter
@anser << "0"
@myStrB = @myStrB.reverse.chop.reverse
end
@anser << " "
@compter = 0
end
puts @anser.chop
Enter to Rename, Shift+Enter to Preview
et voici la version codée par Chuck Norris :
1
2
puts "Entrez votre phrase à coder en unaire ici ".chomp.bytes.map{|b|'%07b'%b}.join.chars.chunk{|e|e}.flat_map{|k,v|[['00','0'][k.to_i],'0'*v.size]}*' '
Enter to Rename, Shift+Enter to Preview
Merci codingame.com
MMMMMMMMMMM
MMMMMMMMMMMMMMMMM
NMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
DMMMMMMMMMMM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MMMMMMMMMMMMMMMMMMMMMMMMMM
MMM....... M. ... . ... ..............M...$MMMMMMMMMMMMMMMMMMMM
........... ........~. ..............M..=....+MMMMMMMMMMMMMM
......+.NMI~........ . ..............M.,.I...MMMMMMMMMMMMMMN
......$... ...... O..................,.....$MMMMMMMMMMMMN
.....M.......... M M.. .............. 8 .OMMMMMMMMMMMN
..=7I,,.,,IMI...M.................. ..MMMMMMMMMMM
....DMMMMMMMMMMMMMMMO..............D...MMMMMMMMM
.MMMMMMMMMMMMMMDDMM:,N..............DMMMMMMMMMMM
NMMMMMNMM8 . .... ...,~............ MMMMMMMMM
MMMMM,:......::~..M8M8MM...............MMMMMM
MMMM ... . .........,MM..............MMMMMO$
MMMMM... =.=. .. . . MM ....... . ...MMMMMMM
NMMMMMMMMMM? ..O.?NM7 ....... ......MMMMMM
NMMMMMMMMMMMMMMMMM........ $ . ...MMMNMMM
MMMMMMMMMMMMMMM.........,, ......MMMMMMMM
OMMMMMMMM8 , .. .. .,N.... ...:MMMMMMMMMMN
MMMMMMMM?N. ...~MD.:MNI8MMMMMMMMMMMMMMMMMN
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
NMMMMMMMMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content