-
Notifications
You must be signed in to change notification settings - Fork 21
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
Vishal Singh-Module5 #87
Open
vishalsingh456
wants to merge
9
commits into
hotwax:main
Choose a base branch
from
vishalsingh456:vishalSingh-Module5
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 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
59f199d
Linked list, Queue, Stack, Tree
vishalsingh456 95f322d
Hashing Techniques completed along with all test cases and screenshot
vishalsingh456 0fba21e
All updation have been addressed. Updated deletion and insertion of c…
vishalsingh456 2817b33
Module 5 all questions
vishalsingh456 ec1b383
removed unwanted files
vishalsingh456 8995848
Updated output of question 12 and added approach.md file as well.
vishalsingh456 58853bf
approach.md file is added for all the Jolt Spec
vishalsingh456 735afd4
Question 8 has been solved using department name
vishalsingh456 4b0ea80
Question number 15 new approach added. Added name without index
vishalsingh456 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 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,183 @@ | ||
Input Json: { | ||
"orders": [ | ||
{ | ||
"orderId": 1, | ||
"orderDate": "2022-02-20T12:34:56Z", | ||
"customer": { | ||
"customerId": 1, | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "123 Main St", | ||
"city": "Anytown", | ||
"state": "CA", | ||
"zip": "12345" | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"itemId": 1, | ||
"name": "Product A", | ||
"quantity": 2, | ||
"price": 10 | ||
}, | ||
{ | ||
"itemId": 2, | ||
"name": "Product B", | ||
"quantity": 1, | ||
"price": 20 | ||
} | ||
] | ||
}, | ||
{ | ||
"orderId": 2, | ||
"orderDate": "2022-02-21T09:12:34Z", | ||
"customer": { | ||
"customerId": 2, | ||
"firstName": "Jane", | ||
"lastName": "Smith", | ||
"email": "[email protected]", | ||
"address": { | ||
"street": "456 Oak St", | ||
"city": "Somewhere", | ||
"state": "NY", | ||
"zip": "67890" | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"itemId": 3, | ||
"name": "Product C", | ||
"quantity": 3, | ||
"price": 15 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
|
||
|
||
Json Spec: [ | ||
{ | ||
"operation": "modify-overwrite-beta", | ||
"spec": { | ||
"orders": { | ||
"*": { | ||
"customer": { | ||
"address": "=concat(@(1,address.street),' ',@(1,address.city), ' ', @(1,address.state), ' ',@(1,address.zip))" | ||
}, | ||
"itemTemp": "@(1,items)" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"operation": "modify-overwrite-beta", | ||
"spec": { | ||
"orders": { | ||
"*": { | ||
"itemTemp": { | ||
"*": { | ||
"inverseValue": "=divide(1,@(1,price))", | ||
"temp": "=divideAndRound(2, @(1,quantity), @(1,inverseValue))" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"operation": "shift", | ||
"spec": { | ||
"orders": { | ||
"*": { | ||
"*": "orders[&1].&", | ||
"itemTemp": { | ||
"*": { | ||
"temp": "orders[#4].total" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"operation": "modify-overwrite-beta", | ||
"spec": { | ||
"orders": { | ||
"*": { | ||
"total": "=doubleSum(@(1,total))" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"operation": "remove", | ||
"spec": { | ||
"orders": { | ||
"*": { | ||
"items": { | ||
"*": { | ||
"inverseValue": "", | ||
"temp": "" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
|
||
|
||
Output Json: { | ||
"orders": [ | ||
{ | ||
"orderId": 1, | ||
"orderDate": "2022-02-20T12:34:56Z", | ||
"customer": { | ||
"customerId": 1, | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"email": "[email protected]", | ||
"address": "123 Main St Anytown CA 12345" | ||
}, | ||
"items": [ | ||
{ | ||
"itemId": 1, | ||
"name": "Product A", | ||
"quantity": 2, | ||
"price": 10 | ||
}, | ||
{ | ||
"itemId": 2, | ||
"name": "Product B", | ||
"quantity": 1, | ||
"price": 20 | ||
} | ||
], | ||
"total": 40.0 | ||
}, | ||
{ | ||
"orderId": 2, | ||
"orderDate": "2022-02-21T09:12:34Z", | ||
"customer": { | ||
"customerId": 2, | ||
"firstName": "Jane", | ||
"lastName": "Smith", | ||
"email": "[email protected]", | ||
"address": "456 Oak St Somewhere NY 67890" | ||
}, | ||
"items": [ | ||
{ | ||
"itemId": 3, | ||
"name": "Product C", | ||
"quantity": 3, | ||
"price": 15 | ||
} | ||
], | ||
"total": 45.0 | ||
} | ||
] | ||
} |
This file contains 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,16 @@ | ||
## Number of Oprations 3 | ||
1. modify-overwrite-beta (3 times) | ||
2. shift (1 times) | ||
3. remove (1 times) | ||
|
||
## Explanation | ||
|
||
* In the first operation **(modify-oveerwrite-beta)** all the address get concat (joined separated by space) and a new tempItem is created in which i have stored items tempararly. | ||
|
||
* In the second operation **(modify-oveerwrite-beta)** i have calculated the inverseValue and the divide that value with quantity. For getting the product of price and quantity. | ||
|
||
* In the third operation **(shift)** I have created a list of total value of all items purchased by a customer for calculating the total price. | ||
|
||
* In fourth opration **(modify-overwrite-beta)** calculated the total price using **doubleSum** function. | ||
|
||
* At the last I have used **remove** operation to delete the unwanted fields from the json / final output.. |
This file contains 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,68 @@ | ||
Input Json | ||
|
||
{ | ||
"name": "John Smith", | ||
"age": 35, | ||
"address": { | ||
"street": "123 Main St", | ||
"city": "Anytown", | ||
"state": "CA", | ||
"zip": "12345" | ||
}, | ||
"phone_numbers": [ | ||
{ | ||
"type": "home", | ||
"number": "555-1234" | ||
}, | ||
{ | ||
"type": "work", | ||
"number": "555-5678" | ||
} | ||
] | ||
} | ||
|
||
Json Spec | ||
|
||
[ | ||
{ | ||
"operation": "modify-default-beta", | ||
"spec": { | ||
"nameList": "=split(' ', @(1,name))", | ||
"firstName": "=firstElement(@(1,nameList))", | ||
"lastName": "=lastElement(@(1,nameList))", | ||
"phone_number_count": "=size(@(1,phone_numbers))" | ||
} | ||
}, | ||
{ | ||
"operation": "remove", | ||
"spec": { | ||
"name": "", | ||
"nameList": "" | ||
} | ||
} | ||
] | ||
|
||
Output Json | ||
|
||
{ | ||
"age": 35, | ||
"address": { | ||
"street": "123 Main St", | ||
"city": "Anytown", | ||
"state": "CA", | ||
"zip": "12345" | ||
}, | ||
"phone_numbers": [ | ||
{ | ||
"type": "home", | ||
"number": "555-1234" | ||
}, | ||
{ | ||
"type": "work", | ||
"number": "555-5678" | ||
} | ||
], | ||
"firstName": "John", | ||
"lastName": "Smith", | ||
"phone_number_count": 2 | ||
} |
This file contains 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,9 @@ | ||
## Number of Operation 2 | ||
1. "modify-default-beta (1 times) | ||
2. remove (1 times) | ||
|
||
## Explanation: | ||
|
||
* First operation **(modify-default-beta)** is used split the name and then assign then separately in fname and lname keys. Ath last I have used size function to count the number of object present inside the phone_numbers. | ||
|
||
* At last **(remove)** operation is used remove the name and temp key nameList. |
This file contains 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,45 @@ | ||
Input Json | ||
|
||
{ | ||
"items": [ | ||
{ | ||
"name": "item1", | ||
"value": 10 | ||
}, | ||
{ | ||
"name": "item2", | ||
"value": 20 | ||
} | ||
] | ||
} | ||
|
||
Json Spec | ||
|
||
[ | ||
{ | ||
"operation": "shift", | ||
"spec": { | ||
"items": { | ||
"*": { | ||
"name": "items[#2].itemName", | ||
"value": "items[#2].itemValue" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
|
||
|
||
Output Json | ||
{ | ||
"items": [ | ||
{ | ||
"itemName": "item1", | ||
"itemValue": 10 | ||
}, | ||
{ | ||
"itemName": "item2", | ||
"itemValue": 20 | ||
} | ||
] | ||
} |
This file contains 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,6 @@ | ||
## Number of operations 1 | ||
1. shift (1 times) | ||
|
||
## Explanation: | ||
|
||
* In first operation **(shift)** i have rename the keys from name to itemName and from value to itemValue. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Price should have double type value, please correct in all questions.