-
-
Notifications
You must be signed in to change notification settings - Fork 37
Update the instructions and the answer of the Ballerina billionare exercise #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SasinduDilshara
wants to merge
16
commits into
exercism:main
Choose a base branch
from
SasinduDilshara:issue-update-billion-question
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e96724d
Update instructions for collatz_conjecture problem
SasinduDilshara 7d3ea6e
Enable tests in collatz_conjecture_test
SasinduDilshara fd283bb
Add a example with an error for collatz_conjecture
SasinduDilshara cb18c64
Update question Bob
SasinduDilshara d8606f6
update Sieve example
SasinduDilshara e84bc99
Update sieve exercise description
SasinduDilshara 6270319
Update acronym example
SasinduDilshara 19e9726
Update space-age exercise
SasinduDilshara 77fcec7
uypdate roman numerals example
SasinduDilshara 2a6c849
Revert instructions,tests updates in exercises
SasinduDilshara fa6ca19
Fix broken links in cake is lie exercise
SasinduDilshara 6b6c47f
Update Billionare exercise with inbuilt module
SasinduDilshara 9369b3c
Merge branch 'main' of https://github.com/exercism/ballerina into iss…
SasinduDilshara dff21f3
Add billionaire details into resource folder
SasinduDilshara fd9ea6d
Update instructions
SasinduDilshara bb95ce2
Change status of the billonare exercise
SasinduDilshara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
exercises/practice/http-billion-dollar-question/modules/billionairehub_client/client.bal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ballerina/http; | ||
|
||
type Billionaire record {| | ||
SasinduDilshara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
string name; | ||
float netWorth; | ||
|}; | ||
|
||
const string clientUrl = "http://localhost:9090"; | ||
SasinduDilshara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public client class BillionaireClient { | ||
private final http:Client httpClient; | ||
|
||
public function init() returns error? { | ||
self.httpClient = check new (clientUrl); | ||
SasinduDilshara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
remote function getBillionaires(string country) returns Billionaire[]|error { | ||
return self.httpClient->/getBillionaires(country=country); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ce/http-billion-dollar-question/modules/billionairehub_server/resources/billionaires.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"United States":[{"name":"Elon Musk", "netWorth":177}, {"name":"Jeff Bezos", "netWorth":151}, {"name":"Bill Gates", "netWorth":124}, {"name":"Mark Zuckerberg", "netWorth":97}, {"name":"Larry Ellison", "netWorth":93}, {"name":"Larry Page", "netWorth":91.5}, {"name":"Sergey Brin", "netWorth":89}, {"name":"Warren Buffett", "netWorth":88}, {"name":"Steve Ballmer", "netWorth":68}, {"name":"Mukesh Ambani", "netWorth":84}], "China":[{"name":"Zhong Shanshan", "netWorth":68}, {"name":"Zhang Yiming", "netWorth":35}, {"name":"Ma Huateng", "netWorth":65}, {"name":"Jack Ma", "netWorth":48}, {"name":"Colin Huang", "netWorth":55}, {"name":"Pony Ma", "netWorth":55}, {"name":"He Xiangjian", "netWorth":43}, {"name":"Yang Huiyan & family", "netWorth":29}, {"name":"Wang Xing", "netWorth":27}, {"name":"William Lei Ding", "netWorth":27}], "India":[{"name":"Mukesh Ambani", "netWorth":84}, {"name":"Gautam Adani & family", "netWorth":50}, {"name":"Shiv Nadar", "netWorth":23}, {"name":"Radhakishan Damani", "netWorth":16}, {"name":"Lakshmi Mittal", "netWorth":18}, {"name":"Hinduja brothers", "netWorth":17}, {"name":"Cyrus Poonawalla", "netWorth":12}, {"name":"Uday Kotak", "netWorth":15}, {"name":"Sunil Mittal & family", "netWorth":11}, {"name":"Kumar Birla", "netWorth":10}], "Japan":[{"name":"Tadashi Yanai & family", "netWorth":31}, {"name":"Takemitsu Takizaki", "netWorth":28}, {"name":"Masayoshi Son", "netWorth":29}, {"name":"Nobutada Saji & family", "netWorth":28}, {"name":"Takemitsu Takizaki", "netWorth":28}, {"name":"Hiroshi Mikitani", "netWorth":24}, {"name":"Yasumitsu Shigeta", "netWorth":24}, {"name":"Takemitsu Takizaki", "netWorth":28}, {"name":"Takemitsu Takizaki", "netWorth":28}, {"name":"Takemitsu Takizaki", "netWorth":28}], "Hong Kong":[{"name":"Li Ka-shing", "netWorth":35}, {"name":"Lee Shau Kee", "netWorth":28}, {"name":"Raymond Kwok & family", "netWorth":17}, {"name":"Thomas Kwok & family", "netWorth":17}, {"name":"Peter Woo", "netWorth":14}, {"name":"Joseph Lau", "netWorth":17}, {"name":"Cheng Yu-tung & family", "netWorth":17}, {"name":"Lui Che Woo & family", "netWorth":15}, {"name":"Henry Cheng & family", "netWorth":15}, {"name":"Michael Kadoorie & family", "netWorth":13}], "Russia":[{"name":"Vladimir Lisin", "netWorth":24}, {"name":"Vladimir Potanin", "netWorth":23}, {"name":"Alexey Mordashov & family", "netWorth":22}, {"name":"Leonid Mikhelson", "netWorth":20}, {"name":"Gennady Timchenko", "netWorth":20}, {"name":"Vagit Alekperov", "netWorth":19}, {"name":"Alisher Usmanov", "netWorth":19}, {"name":"Viktor Vekselberg", "netWorth":17}, {"name":"Roman Abramovich", "netWorth":17}, {"name":"Andrey Melnichenko", "netWorth":16}], "Italy":[{"name":"Leonardo Del Vecchio & family", "netWorth":25}, {"name":"Stefano Pessina", "netWorth":12}, {"name":"Massimiliana Landini Aleotti & family", "netWorth":13}, {"name":"Giovanni Ferrero", "netWorth":35}, {"name":"Giorgio Armani", "netWorth":8}, {"name":"Sergio Marchionne", "netWorth":5}, {"name":"Stefano Pessina", "netWorth":12}, {"name":"Massimiliana Landini Aleotti & family", "netWorth":13}, {"name":"Giovanni Ferrero", "netWorth":35}, {"name":"Giorgio Armani", "netWorth":8}], "France":[{"name":"Bernard Arnault & family", "netWorth":150}, {"name":"Francoise Bettencourt Meyers & family", "netWorth":71}, {"name":"Francois Pinault & family", "netWorth":42}, {"name":"Alain Wertheimer", "netWorth":33}, {"name":"Gerard Wertheimer", "netWorth":33}, {"name":"Serge Dassault & family", "netWorth":26}, {"name":"Patrick Drahi", "netWorth":21}, {"name":"Xavier Niel", "netWorth":13}, {"name":"Alain Merieux & family", "netWorth":7}, {"name":"Vincent Bollore", "netWorth":7}], "Germany":[{"name":"Beate Heister & Karl Albrecht Jr.", "netWorth":39}, {"name":"Dieter Schwarz", "netWorth":35}, {"name":"Susanne Klatten", "netWorth":29}, {"name":"Stefan Quandt", "netWorth":29}, {"name":"Heinz Hermann Thiele & family", "netWorth":22}, {"name":"Klaus-Michael Kuhne", "netWorth":20}, {"name":"August von Finck", "netWorth":20}, {"name":"Michael Otto & family", "netWorth":19}, {"name":"Hasso Plattner & family", "netWorth":15}, {"name":"Reinhold Wurth & family", "netWorth":12}], "Australia":[{"name":"Gina Rinehart", "netWorth":31}, {"name":"Andrew Forrest", "netWorth":23}, {"name":"Anthony Pratt & family", "netWorth":19}, {"name":"James Packer", "netWorth":3}, {"name":"Harry Triguboff", "netWorth":12}, {"name":"Frank Lowy", "netWorth":6}, {"name":"John Gandel", "netWorth":6}, {"name":"Stan Perron", "netWorth":2}, {"name":"Kerr Neilson", "netWorth":2}, {"name":"Lindsay Fox", "netWorth":2}], "Indonesia":[{"name":"Robert Budi Hartono", "netWorth":20}, {"name":"Michael Hartono", "netWorth":20}, {"name":"Sri Prakash Lohia", "netWorth":13}, {"name":"Eka Tjipta Widjaja & family", "netWorth":9}, {"name":"Anthoni Salim & family", "netWorth":7}, {"name":"Tahir", "netWorth":4}, {"name":"Sukanto Tanoto", "netWorth":4}, {"name":"Peter Sondakh", "netWorth":3}, {"name":"Low Tuck Kwong", "netWorth":3}, {"name":"Putera Sampoerna", "netWorth":3}], "Canada":[{"name":"David Thomson & family", "netWorth":39}, {"name":"Joseph Tsai", "netWorth":10}, {"name":"Galen Weston & family", "netWorth":10}, {"name":"James Irving", "netWorth":8}, {"name":"Jim Pattison", "netWorth":7}, {"name":"Emanuele (Lino) Saputo", "netWorth":5}, {"name":"Alain Bouchard", "netWorth":4}, {"name":"Charles Bronfman", "netWorth":2}, {"name":"Michael Lee-Chin", "netWorth":2}, {"name":"Daryl Katz", "netWorth":2}], "Finland":[{"name":"Antti Herlin & family", "netWorth":13}, {"name":"Heikki Kyostila", "netWorth":5}, {"name":"Ilkka Herlin", "netWorth":4}, {"name":"Mika Anttonen", "netWorth":3}, {"name":"Niklas Herlin", "netWorth":3}, {"name":"Ilona Herlin", "netWorth":3}, {"name":"Ilkka Paananen", "netWorth":2}, {"name":"Hannu Haukka", "netWorth":2}, {"name":"Matti Marjanen", "netWorth":2}, {"name":"Mika Ihamuotila", "netWorth":2}], "Mexico":[{"name":"Carlos Slim Helu & family", "netWorth":52}, {"name":"German Larrea Mota Velasco & family", "netWorth":27}, {"name":"Alberto Bailleres Gonzalez & family", "netWorth":10}, {"name":"Ricardo Salinas Pliego & family", "netWorth":9}, {"name":"Maria Asuncion Aramburuzabala & family", "netWorth":5}, {"name":"Juan Francisco Beckmann Vidal & family", "netWorth":5}, {"name":"Roberto Hernandez Ramirez & family", "netWorth":4}, {"name":"Carlos Hank Rhon", "netWorth":2}, {"name":"Antonio del Valle Ruiz & family", "netWorth":2}, {"name":"Carlos Peralta Quintero", "netWorth":2}]} |
23 changes: 23 additions & 0 deletions
23
exercises/practice/http-billion-dollar-question/modules/billionairehub_server/server.bal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import ballerina/http; | ||
import ballerina/io; | ||
|
||
type Billionaire record {| | ||
string name; | ||
float netWorth; | ||
|}; | ||
|
||
service / on new http:Listener(9090) { | ||
map<Billionaire[]> topbillionaires = {}; | ||
|
||
resource function get getBillionaires(string country) returns Billionaire[]|error { | ||
if self.topbillionaires.length() == 0 { | ||
json billionaireDetails = check io:fileReadJson("modules/billionairehub_server/resources/billionaires.json"); | ||
self.topbillionaires = check billionaireDetails.cloneWithType(); | ||
} | ||
Billionaire[]? billionaires = self.topbillionaires[country]; | ||
if billionaires is Billionaire[] { | ||
return billionaires; | ||
} | ||
return error(country + " is not found in the sample dataset."); | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
exercises/practice/http-billion-dollar-question/tests/Config.toml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.