You have a deck of cards of a strange game called Binary. Every card has a letter. The deck was formed by writing out a certain number in binary, spelling it out in English, and then making a card out of each character of the English word. For example, for the number 42, the binary representation is 101010, the English word is: one zero one zero one zero, and the deck consists of the following cards: 6 "o"s, three "n"s, six "e"s, three "z"s, and three "r"s. Given a shuffled version of the deck, recreate the largest number it could have correspnded to, and give your output in binary. Input The first line contains a single integer nn (1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

Write a C code.

You have a deck of cards of a strange game called Binary. Every card has a letter. The deck
was formed by writing out a certain number in binary, spelling it out in English, and then
making a card out of each character of the English word. For example, for the number 42,
the binary representation is 101010, the English word is: one zero one zero one zero, and
the deck consists of the following cards: 6 "o"s, three "n"s, six "e"s, three "z"s, and three
"r"s.
Given a shuffled version of the deck, recreate the largest number it could have correspnded
to, and give your output in binary.
Input
The first line contains a single integer nn (1<n<10)- the length of the string.
The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'.
It is guaranteed that it is possible to rearrange the letters in such a way that they form a
sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which
corresponds to the digit 1.
Output
Print the maximum possible number in binary notation. Print binary digits separated by a
space. The leading zeroes are allowed.
Examples
Transcribed Image Text:You have a deck of cards of a strange game called Binary. Every card has a letter. The deck was formed by writing out a certain number in binary, spelling it out in English, and then making a card out of each character of the English word. For example, for the number 42, the binary representation is 101010, the English word is: one zero one zero one zero, and the deck consists of the following cards: 6 "o"s, three "n"s, six "e"s, three "z"s, and three "r"s. Given a shuffled version of the deck, recreate the largest number it could have correspnded to, and give your output in binary. Input The first line contains a single integer nn (1<n<10)- the length of the string. The second line contains a string consisting of English lowercase letters: 'z', 'e', 'r', 'o' and 'n'. It is guaranteed that it is possible to rearrange the letters in such a way that they form a sequence of words, each being either "zero" which corresponds to the digit 0 or "one" which corresponds to the digit 1. Output Print the maximum possible number in binary notation. Print binary digits separated by a space. The leading zeroes are allowed. Examples
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning